4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2014 Garrett D'Amore
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
30 /* All Rights Reserved */
35 * uucp file transfer program:
36 * to place a call to a remote machine, login, and
37 * copy files between the two machines.
41 * Added check to limit the total number of uucicos as defined
44 * Added -f flag to "force execution", ignoring the limit on the
45 * number of uucicos. This will be used when invoking uucico from
53 #include <sys/mkdev.h>
57 #include <sys/tiuser.h>
61 extern unsigned msgtime
;
62 char uuxqtarg
[MAXBASENAME
] = {'\0'};
65 extern int (*Setup
)(), (*Teardown
)(); /* defined in interface.c */
67 #define USAGE "Usage: %s [-x NUM] [-r [0|1]] -s SYSTEM -u USERID -d SPOOL -i INTERFACE [-f]\n"
68 extern void closedem();
69 void cleanup(), cleanTM();
71 extern int sysaccess(), guinfo(), eaccess(), countProcs(), interface(),
72 savline(), omsg(), restline(), imsg(), callok(), gnxseq(),
73 cmtseq(), conn(), startup(), cntrl();
74 extern void setuucp(), fixline(), gename(), ulkseq(), pfEndfile();
77 static void checkrmt(); /* See if we want to talk to remote. */
78 #endif /* NOSTRANGERS */
85 main(argc
, argv
, envp
)
91 extern void intrEXIT(), onintr(), timeout();
92 extern void setservice();
96 int ret
, seq
, exitcode
;
98 char msg
[BUFSIZ
], *p
, *q
;
99 char xflag
[6]; /* -xN N is single digit */
101 char *iface
; /* interface name */
104 char lockname
[MAXFULLNAME
];
105 struct limits limitval
;
107 int force
= 0; /* set to force execution, ignoring uucico limit */
108 char gradedir
[2*NAMESIZE
];
110 /* Set locale environment variables local definitions */
111 (void) setlocale(LC_ALL
, "");
112 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
113 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */
115 (void) textdomain(TEXT_DOMAIN
);
117 Ulimit
= ulimit(1,0L);
119 Euid
= geteuid(); /* this should be UUCPUID */
124 strcpy(Logfile
, LOGCICO
);
126 Ifn
= Ofn
= -1; /* must be set before signal handlers */
129 time(&Nstat
.t_qtime
);
130 tconv
= Nstat
.t_start
= Nstat
.t_qtime
;
131 strcpy(Progname
, "uucico");
132 setservice(Progname
);
133 ret
= sysaccess(EACCESS_SYSTEMS
);
134 ASSERT(ret
== 0, Ct_OPEN
, "Systems", ret
);
135 ret
= sysaccess(EACCESS_DEVICES
);
136 ASSERT(ret
== 0, Ct_OPEN
, "Devices", ret
);
137 ret
= sysaccess(EACCESS_DIALERS
);
138 ASSERT(ret
== 0, Ct_OPEN
, "Dialers", ret
);
140 (void) signal(SIGILL
, intrEXIT
);
141 (void) signal(SIGTRAP
, intrEXIT
);
142 (void) signal(SIGIOT
, intrEXIT
);
143 (void) signal(SIGEMT
, intrEXIT
);
144 (void) signal(SIGFPE
, intrEXIT
);
145 (void) signal(SIGBUS
, intrEXIT
);
146 (void) signal(SIGSEGV
, intrEXIT
);
147 (void) signal(SIGSYS
, intrEXIT
);
148 if (signal(SIGPIPE
, SIG_IGN
) != SIG_IGN
) /* This for sockets */
149 (void) signal(SIGPIPE
, intrEXIT
);
150 (void) signal(SIGINT
, onintr
);
151 (void) signal(SIGHUP
, onintr
);
152 (void) signal(SIGQUIT
, onintr
);
153 (void) signal(SIGTERM
, onintr
);
155 (void) signal(SIGUSR1
, SIG_IGN
);
158 (void) signal(SIGUSR2
, SIG_IGN
);
161 (void) sigsetmask(sigblock(0) & ~(1 << (SIGALRM
- 1)));
166 ret
= guinfo(Euid
, User
);
167 ASSERT(ret
== 0, "BAD UID ", "", ret
);
168 strncpy(Uucp
, User
, NAMESIZE
);
175 while ((ret
= getopt(argc
, argv
, "fd:c:r:s:x:u:i:")) != EOF
) {
178 if ( eaccess(optarg
, 01) != 0 ) {
179 (void) fprintf(stderr
, gettext("%s: cannot"
180 " access spool directory %s\n"),
193 if ( (Role
= atoi(optarg
)) != MASTER
&& Role
!= SLAVE
) {
194 (void) fprintf(stderr
, gettext("%s: bad value"
195 " '%s' for -r argument\n" USAGE
),
196 Progname
, optarg
, Progname
);
201 strncpy(Rmtname
, optarg
, MAXFULLNAME
-1);
202 if (versys(Rmtname
)) {
203 (void) fprintf(stderr
,
204 gettext("%s: %s not in Systems file\n"),
208 /* set args for possible xuuxqt call */
209 strcpy(uuxqtarg
, Rmtname
);
210 /* if versys put a longer name in, truncate it again */
211 Rmtname
[MAXBASENAME
] = '\0';
214 Debug
= atoi(optarg
);
219 (void) sprintf(xflag
, "-x%d", Debug
);
222 DEBUG(4, "Loginuser %s specified\n", optarg
);
223 strncpy(Loginuser
, optarg
, NAMESIZE
);
224 Loginuser
[NAMESIZE
- 1] = NULLCHAR
;
231 (void) fprintf(stderr
, gettext(USAGE
), Progname
);
236 if (Role
== MASTER
|| *Loginuser
== NULLCHAR
) {
237 ret
= guinfo(Uid
, Loginuser
);
238 ASSERT(ret
== 0, "BAD LOGIN_UID ", "", ret
);
241 /* limit the total number of uucicos */
243 DEBUG(4, "force flag set (ignoring uucico limit)\n%s", "");
244 } else if (scanlimit("uucico", &limitval
) == FAIL
) {
245 DEBUG(1, "No limits for uucico in %s\n", LIMITS
);
247 maxnumb
= limitval
.totalmax
;
249 DEBUG(4, "Non-positive limit for uucico in %s\n", LIMITS
);
250 DEBUG(1, "No limits for uucico\n%s", "");
252 DEBUG(4, "Uucico limit %d -- ", maxnumb
);
253 (void) sprintf(lockname
, "%s.", LOCKPRE
);
254 if (countProcs(lockname
, (maxnumb
-1)) == FALSE
) {
255 DEBUG(4, "exiting\n%s", "");
258 DEBUG(4, "continuing\n%s", "");
262 pfStrtConn((Role
== MASTER
) ? 'M' : 'S');
263 if (Role
== MASTER
) {
264 if (*Rmtname
== NULLCHAR
) {
265 DEBUG(5, "No -s specified\n%s" , "");
268 /* get Myname - it depends on who I'm calling--Rmtname */
269 (void) mchFind(Rmtname
);
271 if (EQUALSN(Rmtname
, Myname
, MAXBASENAME
)) {
272 DEBUG(5, "This system specified: -sMyname: %s, ", Myname
);
278 ASSERT(chdir(Spool
) == 0, Ct_CHDIR
, Spool
, errno
);
279 strcpy(Wrkdir
, Spool
);
281 scReqsys((Role
== MASTER
) ? Myname
: Rmtname
); /* log requestor system */
289 if (freopen(RMTDEBUG
, "a", stderr
) == 0) {
290 errent(Ct_OPEN
, RMTDEBUG
, errno
, __FILE__
, __LINE__
);
291 freopen("/dev/null", "w", stderr
);
293 if ( interface(iface
) ) {
294 (void)fprintf(stderr
,
295 "%s: invalid interface %s\n", Progname
, iface
);
298 /*master setup will be called from processdev()*/
299 if ( (*Setup
)( Role
, &Ifn
, &Ofn
) ) {
300 DEBUG(5, "SLAVE Setup failed%s", "");
308 fixline(Ifn
, 0, D_ACU
);
309 /* get MyName - use logFind to check PERMISSIONS file */
310 (void) logFind(Loginuser
, "");
313 DEBUG(4,"cico.c: Myname - %s\n",Myname
);
314 DEBUG(4,"cico.c: Loginuser - %s\n",Loginuser
);
316 Nstat
.t_scall
= times(&Nstat
.t_tga
);
317 (void) sprintf(msg
, "here=%s", Myname
);
319 (void) signal(SIGALRM
, timeout
);
320 (void) alarm(msgtime
); /* give slow machines a second chance */
331 ret
= imsg(msg
, Ifn
);
341 Nstat
.t_ecall
= times(&Nstat
.t_tga
);
345 strncpy(Rmtname
, q
, MAXBASENAME
);
346 Rmtname
[MAXBASENAME
] = '\0';
349 while (p
&& *p
== '-') {
356 (void) sprintf(xflag
, "-x%d", Debug
);
364 case 'v': /* version -- -vname=val or -vname */
365 if (strncmp(++p
, "grade=", 6) == 0 &&
369 #endif /* MAXGRADE */
376 RemUlimit
= strtol(++p
, (char **) NULL
,0);
383 DEBUG(4, "sys-%s\n", Rmtname
);
384 if (strpbrk(Rmtname
, Shchar
) != NULL
) {
385 DEBUG(4, "Bad remote system name '%s'\n", Rmtname
);
386 logent(Rmtname
, "BAD REMOTE SYSTEM NAME");
387 omsg('R', "Bad remote system name", Ofn
);
391 CDEBUG(1,"Checkpoint Restart enabled\n%s", "");
394 checkrmt(); /* Do we know the remote system. */
396 (void) versys(Rmtname
); /* in case the real name is longer */
397 #endif /* NOSTRANGERS */
399 (void) sprintf(lockname
, "%ld", (long) getpid());
400 if (umlock(LOCKPRE
, lockname
)) {
401 omsg('R', "LCK", Ofn
);
405 /* validate login using PERMISSIONS file */
406 if (logFind(Loginuser
, Rmtname
) == FAIL
) {
407 scWrite(); /* log security violation */
408 Uerror
= SS_BAD_LOG_MCH
;
409 logent(UERRORTEXT
, "FAILED");
410 systat(Rmtname
, SS_BAD_LOG_MCH
, UERRORTEXT
,
412 omsg('R', "LOGIN", Ofn
);
417 DEBUG(4,"return from callcheck: %s",ret
? "TRUE" : "FALSE");
419 (void) signal(SIGINT
, SIG_IGN
);
420 (void) signal(SIGHUP
, SIG_IGN
);
421 omsg('R', "CB", Ofn
);
422 logent("CALLBACK", "REQUIRED");
424 * set up for call back
427 (void) sprintf(file
, "%s/%c", Rmtname
, D_QUEUE
);
429 gename(CMDPRE
, Rmtname
, 'C', file
);
430 (void) close(creat(file
, CFILEMODE
));
431 if (callok(Rmtname
) == SS_CALLBACK_LOOP
) {
432 systat(Rmtname
, SS_CALLBACK_LOOP
, "CALL BACK - LOOP", Retrytime
);
434 systat(Rmtname
, SS_CALLBACK
, "CALL BACK", Retrytime
);
440 if (callok(Rmtname
) == SS_SEQBAD
) {
442 logent(UERRORTEXT
, "PREVIOUS");
443 omsg('R', "BADSEQ", Ofn
);
447 if (gnxseq(Rmtname
) == seq
) {
450 (void) sprintf (msg
, "OK -R -U0x%lx %s",
453 (void) sprintf (msg
, "OK -R %s", xflag
);
456 omsg('R', "OK", Ofn
);
460 systat(Rmtname
, SS_SEQBAD
, UERRORTEXT
, Retrytime
);
461 logent(UERRORTEXT
, "HANDSHAKE FAILED");
463 omsg('R', "BADSEQ", Ofn
);
467 if (ttyn
!= CNULL
&& *ttyn
!= NULLCHAR
) {
469 if ( fstat(Ifn
,&ttysbuf
) == 0 )
470 Dev_mode
= ttysbuf
.st_mode
;
472 Dev_mode
= R_DEVICEMODE
;
473 if ( EQUALSN(ttyn
,"/dev/",5) )
477 chmod(ttyn
, S_DEVICEMODE
);
480 /* set args for possible xuuxqt call */
481 strcpy(uuxqtarg
, Rmtname
);
486 * Ensure reasonable ulimit (MINULIMIT)
492 minulimit
= ulimit(1, (long) 0);
493 ASSERT(minulimit
>= MINULIMIT
, "ULIMIT TOO SMALL",
494 Loginuser
, (int) minulimit
);
497 if (Role
== MASTER
&& callok(Rmtname
) != 0) {
498 logent("SYSTEM STATUS", "CAN NOT CALL");
504 (void) strcpy(Wrkdir
, RemSpool
);
505 if (Role
== MASTER
) {
510 (void) signal(SIGINT
, SIG_IGN
);
511 (void) signal(SIGHUP
, SIG_IGN
);
512 (void) signal(SIGQUIT
, SIG_IGN
);
513 if (Ifn
!= -1 && Role
== MASTER
) {
514 (void) (*Write
)(Ofn
, EOTMSG
, strlen(EOTMSG
));
523 * Find the highest priority job grade that has
524 * jobs to do. This is needed to form the lock name.
527 findgrade(RemSpool
, JobGrade
);
528 DEBUG(4, "Job grade to process - %s\n", JobGrade
);
531 * Lock the job grade if there is one to process.
534 if (*JobGrade
!= NULLCHAR
) {
535 (void) sprintf(gradedir
, "%s/%s", Rmtname
, JobGrade
);
538 (void) sprintf(lockname
, "%.*s.%s", SYSNSIZE
, Rmtname
, JobGrade
);
539 (void) sprintf(msg
, "call to %s - process job grade %s ",
541 if (umlock(LOCKPRE
, lockname
) != 0) {
542 logent(msg
, "LOCKED");
543 CDEBUG(1, "Currently Talking With %s\n",
548 (void) sprintf(msg
, "call to %s - no work", Rmtname
);
551 Nstat
.t_scall
= times(&Nstat
.t_tga
);
552 Ofn
= Ifn
= conn(Rmtname
);
553 Nstat
.t_ecall
= times(&Nstat
.t_tga
);
555 delock(LOCKPRE
, lockname
);
556 logent(UERRORTEXT
, "CONN FAILED");
557 systat(Rmtname
, Uerror
, UERRORTEXT
, Retrytime
);
560 logent(msg
, "SUCCEEDED");
562 if (ttyn
!= CNULL
&& *ttyn
!= NULLCHAR
) {
564 if ( fstat(Ifn
,&ttysbuf
) == 0 )
565 Dev_mode
= ttysbuf
.st_mode
;
567 Dev_mode
= R_DEVICEMODE
;
568 chmod(ttyn
, M_DEVICEMODE
);
573 delock(LOCKPRE
, lockname
);
574 Uerror
= SS_LOGIN_FAILED
;
575 logent(Rmtname
, UERRORTEXT
);
576 systat(Rmtname
, SS_LOGIN_FAILED
,
577 UERRORTEXT
, Retrytime
);
578 DEBUG(4, "%s - failed\n", UERRORTEXT
);
581 (void) signal(SIGALRM
, timeout
);
582 /* give slow guys lots of time to thrash */
583 (void) alarm(2 * msgtime
);
585 ret
= imsg(msg
, Ifn
);
587 continue; /* try again */
593 if(EQUALSN("here=", &msg
[1], 5)){
594 /* This may be a problem, we check up to MAXBASENAME
595 * characters now. The old comment was:
596 * this is a problem. We'd like to compare with an
597 * untruncated Rmtname but we fear incompatability.
598 * So we'll look at most 6 chars (at most).
600 (void) pskip(&msg
[6]);
601 if (!EQUALSN(&msg
[6], Rmtname
, MAXBASENAME
)) {
602 delock(LOCKPRE
, lockname
);
603 Uerror
= SS_WRONG_MCH
;
604 logent(&msg
[6], UERRORTEXT
);
605 systat(Rmtname
, SS_WRONG_MCH
, UERRORTEXT
,
607 DEBUG(4, "%s - failed\n", UERRORTEXT
);
611 CDEBUG(1,"Login Successful: System=%s\n",&msg
[6]);
612 seq
= gnxseq(Rmtname
);
613 (void) sprintf(msg
, "%s -Q%d -R -U0x%lx %s",
614 Myname
, seq
, Ulimit
, xflag
);
616 if (MaxGrade
!= NULLCHAR
) {
617 p
= strchr(msg
, NULLCHAR
);
618 sprintf(p
, " -vgrade=%c", MaxGrade
);
620 #endif /* MAXGRADE */
622 (void) alarm(msgtime
); /* give slow guys some thrash time */
624 ret
= imsg(msg
, Ifn
);
625 DEBUG(4, "msg-%s\n", msg
);
628 delock(LOCKPRE
, lockname
);
637 /* check for rejects from remote */
639 if (EQUALS(&msg
[1], "LCK"))
641 else if (EQUALS(&msg
[1], "LOGIN"))
643 else if (EQUALS(&msg
[1], "CB"))
644 Uerror
= (callBack() ? SS_CALLBACK_LOOP
: SS_CALLBACK
);
645 else if (EQUALS(&msg
[1], "You are unknown to me"))
646 Uerror
= SS_RUNKNOWN
;
647 else if (EQUALS(&msg
[1], "BADSEQ"))
649 else if (!EQUALSN(&msg
[1], "OK", 2))
650 Uerror
= SS_UNKNOWN_RESPONSE
;
652 delock(LOCKPRE
, lockname
);
653 systat(Rmtname
, Uerror
, UERRORTEXT
, Retrytime
);
654 logent(UERRORTEXT
, "HANDSHAKE FAILED");
655 CDEBUG(1, "HANDSHAKE FAILED: %s\n", UERRORTEXT
);
662 * See if we have any additional parameters on the OK
665 if (strlen(&msg
[3])) {
667 while (p
&& *p
== '-') {
676 RemUlimit
= strtol(++p
, (char **) NULL
, 0);
693 DEBUG(4, " Rmtname %s, ", Rmtname
);
694 DEBUG(4, " Restart %s, ", (Restart
? "YES" : "NO"));
695 DEBUG(4, "Role %s, ", Role
? "MASTER" : "SLAVE");
696 DEBUG(4, "Ifn - %d, ", Ifn
);
697 DEBUG(4, "Loginuser - %s\n", Loginuser
);
699 /* alarm/setjmp added here due to experience with uucico
700 * hanging for hours in imsg().
703 delock(LOCKPRE
, lockname
);
704 logent("startup", "TIMEOUT");
705 DEBUG(4, "%s - timeout\n", "startup");
708 (void) alarm(MAXSTART
);
712 if (ret
!= SUCCESS
) {
713 delock(LOCKPRE
, lockname
);
714 logent("startup", "FAILED");
716 CDEBUG(1, "%s\n", UERRORTEXT
);
717 systat(Rmtname
, Uerror
, UERRORTEXT
, Retrytime
);
720 pfConnected(Rmtname
, Dc
);
721 acConnected(Rmtname
, Dc
);
722 logent("startup", "OK");
723 systat(Rmtname
, SS_INPROGRESS
, UTEXT(SS_INPROGRESS
),Retrytime
);
724 Nstat
.t_sftp
= times(&Nstat
.t_tga
);
727 Nstat
.t_eftp
= times(&Nstat
.t_tga
);
728 DEBUG(4, "cntrl - %d\n", exitcode
);
729 (void) signal(SIGINT
, SIG_IGN
);
730 (void) signal(SIGHUP
, SIG_IGN
);
731 (void) signal(SIGALRM
, timeout
);
735 (void) sprintf(cb
, "conversation complete %s %ld",
738 systat(Rmtname
, SS_OK
, UTEXT(SS_OK
), Retrytime
);
741 logent("conversation complete", "FAILED");
742 systat(Rmtname
, SS_CONVERSATION
,
743 UTEXT(SS_CONVERSATION
), Retrytime
);
745 (void) alarm(msgtime
); /* give slow guys some thrash time */
746 omsg('O', "OOOOO", Ofn
);
747 CDEBUG(4, "send OO %d,", ret
);
748 if (!setjmp(Sjbuf
)) {
750 omsg('O', "OOOOO", Ofn
);
751 ret
= imsg(msg
, Ifn
);
766 * clean and exit with "code" status
772 (void) signal(SIGINT
, SIG_IGN
);
773 (void) signal(SIGHUP
, SIG_IGN
);
776 alarm(msgtime
); /* Start timer in case closes hang. */
777 if (setjmp(Sjbuf
) == 0)
778 (*Teardown
)( Role
, Ifn
, Ofn
);
779 alarm(0); /* Turn off timer. */
780 DEBUG(4, "exit code %d\n", code
);
781 CDEBUG(1, "Conversation Complete: Status %s\n\n",
782 code
? "FAILED" : "SUCCEEDED");
785 if ((code
== 0) && (uuxqtflag
== 1))
791 char TM_name
[MAXNAMESIZE
];
797 char tm_name
[MAXNAMESIZE
];
799 DEBUG(7,"TM_cnt: %d\n",TM_cnt
);
800 for(i
=0; i
< TM_cnt
; i
++) {
801 (void) sprintf(tm_name
, "%s.%3.3d", TM_name
, i
);
802 DEBUG(7, "tm_name: %s\n", tm_name
);
814 (void) sprintf(file
, "%s/TM.%.5ld.%.3d", RemSpool
, (long) pnum
, TM_cnt
);
816 (void) sprintf(TM_name
, "%s/TM.%.5ld", RemSpool
, (long) pnum
);
817 DEBUG(7, "TMname(%s)\n", file
);
823 * intrrupt - remove locks and exit
830 /* I'm putting a test for zero here because I saw it happen
831 * and don't know how or why, but it seemed to then loop
836 (void) signal(inter
, SIG_IGN
);
837 (void) sprintf(str
, "SIGNAL %d", inter
);
838 logent(str
, "CAUGHT");
839 pfEndfile("PARTIAL FILE");
840 acEnd(PARTIAL
); /*stop collecting accounting log */
850 (void) sprintf(cb
, "SIGNAL %d", inter
);
851 logent("INTREXIT", cb
);
852 (void) signal(SIGIOT
, SIG_DFL
);
853 (void) signal(SIGILL
, SIG_DFL
);
861 * catch SIGALRM routine
869 /* skip to next field */
874 if ((p
= strchr(p
, ' ')) != CNULL
)
887 maxfiles
= ulimit(4,0);
890 maxfiles
= getdtablesize();
896 for ( i
= 3; i
< maxfiles
; i
++ )
897 if ( i
!= Ifn
&& i
!= Ofn
&& i
!= fileno(stderr
) )
907 * if login "shell" is uucico (i.e., Role == SLAVE), must set
908 * timezone env variable TZ. otherwise will default to EST.
916 static char buf
[LINELEN
], *bp
;
917 extern char *fgets();
919 extern FILE *fopen();
921 extern int fclose(), strncmp();
923 if ( (tzfp
= fopen("/etc/default/init","r")) == NULL
)
925 while ( (bp
= fgets(buf
,LINELEN
,tzfp
)) != NULL
) {
926 while ( isspace(*bp
) )
928 if ( strncmp(bp
, "TZ=", 3) == 0 ) {
929 for ( i
= strlen(bp
) - 1; i
> 0 && isspace(*(bp
+i
)); --i
)
945 * If NOSTRANGERS is defined, see if the remote system is in our systems
946 * file. If it is not, execute NOSTRANGERS and then reject the call.
953 char ** eVarPtr
; /* Pointer to environment variable. */
954 char msgbuf
[BUFSIZ
]; /* Place to build messages. */
955 pid_t procid
; /* ID of Nostranger process. */
956 static char * safePath
= PATH
;
957 int status
; /* Exit status of child. */
958 pid_t waitrv
; /* Return value from wait system call. */
960 /* here's the place to look the remote system up in the Systems file.
961 * If the command NOSTRANGERS is executable and
962 * If they're not in my file then hang up */
964 if (versys(Rmtname
) && (access(NOSTRANGERS
, 1) == 0)) {
965 sprintf(msgbuf
, "Invoking %s for %%s\n", NOSTRANGERS
);
966 DEBUG(4, msgbuf
, Rmtname
);
969 * Ignore hangup in case remote goes away before we can
973 (void) signal(SIGHUP
, SIG_IGN
);
974 omsg('R', "You are unknown to me", Ofn
);
975 scWrite(); /* log unknown remote system */
979 * Before execing the no strangers program, there is
980 * a security aspect to consider. If NOSTRANGERS is
981 * not a full path name, then the PATH environment
982 * variable will provide places to look for the file.
983 * To be safe, we will set the PATH environment
984 * variable before we do the exec.
987 /* Find PATH in current environment and change it. */
989 for (eVarPtr
= Env
; *eVarPtr
!= CNULL
; eVarPtr
++) {
990 if (PREFIX("PATH=", *eVarPtr
))
993 execlp( NOSTRANGERS
, "stranger", Rmtname
, (char *) 0);
994 sprintf(msgbuf
, "Execlp of %s failed with errno=%%d\n",
996 DEBUG(4, msgbuf
, errno
);
997 perror(gettext("cico.c: execlp NOSTRANGERS failed"));
999 } else if (procid
< 0) {
1000 perror(gettext("cico.c: execlp NOSTRANGERS failed"));
1003 while ((waitrv
= wait(&status
)) != procid
)
1004 if (waitrv
== -1 && errno
!= EINTR
)
1006 sprintf(msgbuf
, "%s exit status was %%#x\n",
1008 DEBUG(4, msgbuf
, status
);
1013 #endif /* NOSTRANGERS */