17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*d67944fbSScott Rotondo * Common Development and Distribution License (the "License"). 6*d67944fbSScott Rotondo * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*d67944fbSScott Rotondo * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate * uucp file transfer program: 337c478bd9Sstevel@tonic-gate * to place a call to a remote machine, login, and 347c478bd9Sstevel@tonic-gate * copy files between the two machines. 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * Added check to limit the total number of uucicos as defined 397c478bd9Sstevel@tonic-gate * in the Limits file. 407c478bd9Sstevel@tonic-gate * 417c478bd9Sstevel@tonic-gate * Added -f flag to "force execution", ignoring the limit on the 427c478bd9Sstevel@tonic-gate * number of uucicos. This will be used when invoking uucico from 437c478bd9Sstevel@tonic-gate * Uutry. 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #include "uucp.h" 477c478bd9Sstevel@tonic-gate #include "log.h" 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #ifndef V7 507c478bd9Sstevel@tonic-gate #include <sys/mkdev.h> 517c478bd9Sstevel@tonic-gate #endif /* V7 */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #ifdef TLI 547c478bd9Sstevel@tonic-gate #include <sys/tiuser.h> 557c478bd9Sstevel@tonic-gate #endif /* TLI */ 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate jmp_buf Sjbuf; 587c478bd9Sstevel@tonic-gate extern unsigned msgtime; 597c478bd9Sstevel@tonic-gate char uuxqtarg[MAXBASENAME] = {'\0'}; 607c478bd9Sstevel@tonic-gate int uuxqtflag = 0; 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate extern int (*Setup)(), (*Teardown)(); /* defined in interface.c */ 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate #define USAGE "Usage: %s [-x NUM] [-r [0|1]] -s SYSTEM -u USERID -d SPOOL -i INTERFACE [-f]\n" 657c478bd9Sstevel@tonic-gate extern void closedem(); 667c478bd9Sstevel@tonic-gate void cleanup(), cleanTM(); 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate extern int sysaccess(), guinfo(), eaccess(), countProcs(), interface(), 697c478bd9Sstevel@tonic-gate savline(), omsg(), restline(), imsg(), callok(), gnxseq(), 707c478bd9Sstevel@tonic-gate cmtseq(), conn(), startup(), cntrl(); 717c478bd9Sstevel@tonic-gate extern void setuucp(), fixline(), gename(), ulkseq(), pfEndfile(); 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #ifdef NOSTRANGERS 747c478bd9Sstevel@tonic-gate static void checkrmt(); /* See if we want to talk to remote. */ 757c478bd9Sstevel@tonic-gate #endif /* NOSTRANGERS */ 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate extern char *Mytype; 787c478bd9Sstevel@tonic-gate 79*d67944fbSScott Rotondo static char *pskip(); 80*d67944fbSScott Rotondo 81462be471Sceastha int 827c478bd9Sstevel@tonic-gate main(argc, argv, envp) 83462be471Sceastha int argc; 847c478bd9Sstevel@tonic-gate char *argv[]; 857c478bd9Sstevel@tonic-gate char **envp; 867c478bd9Sstevel@tonic-gate { 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate extern void intrEXIT(), onintr(), timeout(); 897c478bd9Sstevel@tonic-gate extern void setservice(); 907c478bd9Sstevel@tonic-gate #ifndef ATTSVR3 917c478bd9Sstevel@tonic-gate void setTZ(); 927c478bd9Sstevel@tonic-gate #endif /* ATTSVR3 */ 937c478bd9Sstevel@tonic-gate int ret, seq, exitcode; 947c478bd9Sstevel@tonic-gate char file[NAMESIZE]; 957c478bd9Sstevel@tonic-gate char msg[BUFSIZ], *p, *q; 967c478bd9Sstevel@tonic-gate char xflag[6]; /* -xN N is single digit */ 977c478bd9Sstevel@tonic-gate char *ttyn; 987c478bd9Sstevel@tonic-gate char *iface; /* interface name */ 997c478bd9Sstevel@tonic-gate char cb[128]; 1007c478bd9Sstevel@tonic-gate time_t ts, tconv; 1017c478bd9Sstevel@tonic-gate char lockname[MAXFULLNAME]; 1027c478bd9Sstevel@tonic-gate struct limits limitval; 1037c478bd9Sstevel@tonic-gate int maxnumb; 1047c478bd9Sstevel@tonic-gate int force = 0; /* set to force execution, ignoring uucico limit */ 1057c478bd9Sstevel@tonic-gate char gradedir[2*NAMESIZE]; 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* Set locale environment variables local definitions */ 1087c478bd9Sstevel@tonic-gate (void) setlocale(LC_ALL, ""); 1097c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ 1107c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */ 1117c478bd9Sstevel@tonic-gate #endif 1127c478bd9Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN); 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate Ulimit = ulimit(1,0L); 1157c478bd9Sstevel@tonic-gate Uid = getuid(); 1167c478bd9Sstevel@tonic-gate Euid = geteuid(); /* this should be UUCPUID */ 1177c478bd9Sstevel@tonic-gate if (Uid == 0) 1187c478bd9Sstevel@tonic-gate setuid(UUCPUID); 1197c478bd9Sstevel@tonic-gate Env = envp; 1207c478bd9Sstevel@tonic-gate Role = SLAVE; 1217c478bd9Sstevel@tonic-gate strcpy(Logfile, LOGCICO); 1227c478bd9Sstevel@tonic-gate *Rmtname = NULLCHAR; 1237c478bd9Sstevel@tonic-gate Ifn = Ofn = -1; /* must be set before signal handlers */ 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate closedem(); 1267c478bd9Sstevel@tonic-gate time(&Nstat.t_qtime); 1277c478bd9Sstevel@tonic-gate tconv = Nstat.t_start = Nstat.t_qtime; 1287c478bd9Sstevel@tonic-gate strcpy(Progname, "uucico"); 1297c478bd9Sstevel@tonic-gate setservice(Progname); 1307c478bd9Sstevel@tonic-gate ret = sysaccess(EACCESS_SYSTEMS); 1317c478bd9Sstevel@tonic-gate ASSERT(ret == 0, Ct_OPEN, "Systems", ret); 1327c478bd9Sstevel@tonic-gate ret = sysaccess(EACCESS_DEVICES); 1337c478bd9Sstevel@tonic-gate ASSERT(ret == 0, Ct_OPEN, "Devices", ret); 1347c478bd9Sstevel@tonic-gate ret = sysaccess(EACCESS_DIALERS); 1357c478bd9Sstevel@tonic-gate ASSERT(ret == 0, Ct_OPEN, "Dialers", ret); 1367c478bd9Sstevel@tonic-gate Pchar = 'C'; 1377c478bd9Sstevel@tonic-gate (void) signal(SIGILL, intrEXIT); 1387c478bd9Sstevel@tonic-gate (void) signal(SIGTRAP, intrEXIT); 1397c478bd9Sstevel@tonic-gate (void) signal(SIGIOT, intrEXIT); 1407c478bd9Sstevel@tonic-gate (void) signal(SIGEMT, intrEXIT); 1417c478bd9Sstevel@tonic-gate (void) signal(SIGFPE, intrEXIT); 1427c478bd9Sstevel@tonic-gate (void) signal(SIGBUS, intrEXIT); 1437c478bd9Sstevel@tonic-gate (void) signal(SIGSEGV, intrEXIT); 1447c478bd9Sstevel@tonic-gate (void) signal(SIGSYS, intrEXIT); 1457c478bd9Sstevel@tonic-gate if (signal(SIGPIPE, SIG_IGN) != SIG_IGN) /* This for sockets */ 1467c478bd9Sstevel@tonic-gate (void) signal(SIGPIPE, intrEXIT); 1477c478bd9Sstevel@tonic-gate (void) signal(SIGINT, onintr); 1487c478bd9Sstevel@tonic-gate (void) signal(SIGHUP, onintr); 1497c478bd9Sstevel@tonic-gate (void) signal(SIGQUIT, onintr); 1507c478bd9Sstevel@tonic-gate (void) signal(SIGTERM, onintr); 1517c478bd9Sstevel@tonic-gate #ifdef SIGUSR1 1527c478bd9Sstevel@tonic-gate (void) signal(SIGUSR1, SIG_IGN); 1537c478bd9Sstevel@tonic-gate #endif 1547c478bd9Sstevel@tonic-gate #ifdef SIGUSR2 1557c478bd9Sstevel@tonic-gate (void) signal(SIGUSR2, SIG_IGN); 1567c478bd9Sstevel@tonic-gate #endif 1577c478bd9Sstevel@tonic-gate #ifdef BSD4_2 1587c478bd9Sstevel@tonic-gate (void) sigsetmask(sigblock(0) & ~(1 << (SIGALRM - 1))); 1597c478bd9Sstevel@tonic-gate #endif /*BSD4_2*/ 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate pfInit(); 1627c478bd9Sstevel@tonic-gate scInit("xfer"); 1637c478bd9Sstevel@tonic-gate ret = guinfo(Euid, User); 1647c478bd9Sstevel@tonic-gate ASSERT(ret == 0, "BAD UID ", "", ret); 1657c478bd9Sstevel@tonic-gate strncpy(Uucp, User, NAMESIZE); 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate setuucp(User); 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate *xflag = NULLCHAR; 1707c478bd9Sstevel@tonic-gate iface = "UNIX"; 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate while ((ret = getopt(argc, argv, "fd:c:r:s:x:u:i:")) != EOF) { 1737c478bd9Sstevel@tonic-gate switch (ret) { 1747c478bd9Sstevel@tonic-gate case 'd': 1757c478bd9Sstevel@tonic-gate if ( eaccess(optarg, 01) != 0 ) { 1767c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext("%s: cannot" 1777c478bd9Sstevel@tonic-gate " access spool directory %s\n"), 1787c478bd9Sstevel@tonic-gate Progname, optarg); 1797c478bd9Sstevel@tonic-gate exit(1); 1807c478bd9Sstevel@tonic-gate } 1817c478bd9Sstevel@tonic-gate Spool = optarg; 1827c478bd9Sstevel@tonic-gate break; 1837c478bd9Sstevel@tonic-gate case 'c': 1847c478bd9Sstevel@tonic-gate Mytype = optarg; 1857c478bd9Sstevel@tonic-gate break; 1867c478bd9Sstevel@tonic-gate case 'f': 1877c478bd9Sstevel@tonic-gate ++force; 1887c478bd9Sstevel@tonic-gate break; 1897c478bd9Sstevel@tonic-gate case 'r': 1907c478bd9Sstevel@tonic-gate if ( (Role = atoi(optarg)) != MASTER && Role != SLAVE ) { 1917c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext("%s: bad value" 1927c478bd9Sstevel@tonic-gate " '%s' for -r argument\n" USAGE), 1937c478bd9Sstevel@tonic-gate Progname, optarg, Progname); 1947c478bd9Sstevel@tonic-gate exit(1); 1957c478bd9Sstevel@tonic-gate } 1967c478bd9Sstevel@tonic-gate break; 1977c478bd9Sstevel@tonic-gate case 's': 1987c478bd9Sstevel@tonic-gate strncpy(Rmtname, optarg, MAXFULLNAME-1); 1997c478bd9Sstevel@tonic-gate if (versys(Rmtname)) { 2007c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 2017c478bd9Sstevel@tonic-gate gettext("%s: %s not in Systems file\n"), 2027c478bd9Sstevel@tonic-gate Progname, optarg); 2037c478bd9Sstevel@tonic-gate cleanup(101); 2047c478bd9Sstevel@tonic-gate } 2057c478bd9Sstevel@tonic-gate /* set args for possible xuuxqt call */ 2067c478bd9Sstevel@tonic-gate strcpy(uuxqtarg, Rmtname); 2077c478bd9Sstevel@tonic-gate /* if versys put a longer name in, truncate it again */ 2087c478bd9Sstevel@tonic-gate Rmtname[MAXBASENAME] = '\0'; 2097c478bd9Sstevel@tonic-gate break; 2107c478bd9Sstevel@tonic-gate case 'x': 2117c478bd9Sstevel@tonic-gate Debug = atoi(optarg); 2127c478bd9Sstevel@tonic-gate if (Debug <= 0) 2137c478bd9Sstevel@tonic-gate Debug = 1; 2147c478bd9Sstevel@tonic-gate if (Debug > 9) 2157c478bd9Sstevel@tonic-gate Debug = 9; 2167c478bd9Sstevel@tonic-gate (void) sprintf(xflag, "-x%d", Debug); 2177c478bd9Sstevel@tonic-gate break; 2187c478bd9Sstevel@tonic-gate case 'u': 2197c478bd9Sstevel@tonic-gate DEBUG(4, "Loginuser %s specified\n", optarg); 2207c478bd9Sstevel@tonic-gate strncpy(Loginuser, optarg, NAMESIZE); 2217c478bd9Sstevel@tonic-gate Loginuser[NAMESIZE - 1] = NULLCHAR; 2227c478bd9Sstevel@tonic-gate break; 2237c478bd9Sstevel@tonic-gate case 'i': 2247c478bd9Sstevel@tonic-gate /* interface type */ 2257c478bd9Sstevel@tonic-gate iface = optarg; 2267c478bd9Sstevel@tonic-gate break; 2277c478bd9Sstevel@tonic-gate default: 2287c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext(USAGE), Progname); 2297c478bd9Sstevel@tonic-gate exit(1); 2307c478bd9Sstevel@tonic-gate } 2317c478bd9Sstevel@tonic-gate } 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate if (Role == MASTER || *Loginuser == NULLCHAR) { 2347c478bd9Sstevel@tonic-gate ret = guinfo(Uid, Loginuser); 2357c478bd9Sstevel@tonic-gate ASSERT(ret == 0, "BAD LOGIN_UID ", "", ret); 2367c478bd9Sstevel@tonic-gate } 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate /* limit the total number of uucicos */ 2397c478bd9Sstevel@tonic-gate if (force) { 2407c478bd9Sstevel@tonic-gate DEBUG(4, "force flag set (ignoring uucico limit)\n%s", ""); 2417c478bd9Sstevel@tonic-gate } else if (scanlimit("uucico", &limitval) == FAIL) { 2427c478bd9Sstevel@tonic-gate DEBUG(1, "No limits for uucico in %s\n", LIMITS); 2437c478bd9Sstevel@tonic-gate } else { 2447c478bd9Sstevel@tonic-gate maxnumb = limitval.totalmax; 2457c478bd9Sstevel@tonic-gate if (maxnumb < 0) { 2467c478bd9Sstevel@tonic-gate DEBUG(4, "Non-positive limit for uucico in %s\n", LIMITS); 2477c478bd9Sstevel@tonic-gate DEBUG(1, "No limits for uucico\n%s", ""); 2487c478bd9Sstevel@tonic-gate } else { 2497c478bd9Sstevel@tonic-gate DEBUG(4, "Uucico limit %d -- ", maxnumb); 2507c478bd9Sstevel@tonic-gate (void) sprintf(lockname, "%s.", LOCKPRE); 2517c478bd9Sstevel@tonic-gate if (countProcs(lockname, (maxnumb-1)) == FALSE) { 2527c478bd9Sstevel@tonic-gate DEBUG(4, "exiting\n%s", ""); 2537c478bd9Sstevel@tonic-gate cleanup(101); 2547c478bd9Sstevel@tonic-gate } 2557c478bd9Sstevel@tonic-gate DEBUG(4, "continuing\n%s", ""); 2567c478bd9Sstevel@tonic-gate } 2577c478bd9Sstevel@tonic-gate } 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate pfStrtConn((Role == MASTER) ? 'M' : 'S'); 2607c478bd9Sstevel@tonic-gate if (Role == MASTER) { 2617c478bd9Sstevel@tonic-gate if (*Rmtname == NULLCHAR) { 2627c478bd9Sstevel@tonic-gate DEBUG(5, "No -s specified\n%s" , ""); 2637c478bd9Sstevel@tonic-gate cleanup(101); 2647c478bd9Sstevel@tonic-gate } 2657c478bd9Sstevel@tonic-gate /* get Myname - it depends on who I'm calling--Rmtname */ 2667c478bd9Sstevel@tonic-gate (void) mchFind(Rmtname); 2677c478bd9Sstevel@tonic-gate myName(Myname); 2687c478bd9Sstevel@tonic-gate if (EQUALSN(Rmtname, Myname, MAXBASENAME)) { 2697c478bd9Sstevel@tonic-gate DEBUG(5, "This system specified: -sMyname: %s, ", Myname); 2707c478bd9Sstevel@tonic-gate cleanup(101); 2717c478bd9Sstevel@tonic-gate } 2727c478bd9Sstevel@tonic-gate acInit("xfer"); 2737c478bd9Sstevel@tonic-gate } 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate ASSERT(chdir(Spool) == 0, Ct_CHDIR, Spool, errno); 2767c478bd9Sstevel@tonic-gate strcpy(Wrkdir, Spool); 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate scReqsys((Role == MASTER) ? Myname : Rmtname); /* log requestor system */ 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate if (Role == SLAVE) { 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate #ifndef ATTSVR3 2837c478bd9Sstevel@tonic-gate setTZ(); 2847c478bd9Sstevel@tonic-gate #endif /* ATTSVR3 */ 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate if (freopen(RMTDEBUG, "a", stderr) == 0) { 2877c478bd9Sstevel@tonic-gate errent(Ct_OPEN, RMTDEBUG, errno, __FILE__, __LINE__); 2887c478bd9Sstevel@tonic-gate freopen("/dev/null", "w", stderr); 2897c478bd9Sstevel@tonic-gate } 2907c478bd9Sstevel@tonic-gate if ( interface(iface) ) { 2917c478bd9Sstevel@tonic-gate (void)fprintf(stderr, 2927c478bd9Sstevel@tonic-gate "%s: invalid interface %s\n", Progname, iface); 2937c478bd9Sstevel@tonic-gate cleanup(101); 2947c478bd9Sstevel@tonic-gate } 2957c478bd9Sstevel@tonic-gate /*master setup will be called from processdev()*/ 2967c478bd9Sstevel@tonic-gate if ( (*Setup)( Role, &Ifn, &Ofn ) ) { 2977c478bd9Sstevel@tonic-gate DEBUG(5, "SLAVE Setup failed%s", ""); 2987c478bd9Sstevel@tonic-gate cleanup(101); 2997c478bd9Sstevel@tonic-gate } 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate /* 3027c478bd9Sstevel@tonic-gate * initial handshake 3037c478bd9Sstevel@tonic-gate */ 3047c478bd9Sstevel@tonic-gate (void) savline(); 3057c478bd9Sstevel@tonic-gate fixline(Ifn, 0, D_ACU); 3067c478bd9Sstevel@tonic-gate /* get MyName - use logFind to check PERMISSIONS file */ 3077c478bd9Sstevel@tonic-gate (void) logFind(Loginuser, ""); 3087c478bd9Sstevel@tonic-gate myName(Myname); 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate DEBUG(4,"cico.c: Myname - %s\n",Myname); 3117c478bd9Sstevel@tonic-gate DEBUG(4,"cico.c: Loginuser - %s\n",Loginuser); 3127c478bd9Sstevel@tonic-gate fflush(stderr); 3137c478bd9Sstevel@tonic-gate Nstat.t_scall = times(&Nstat.t_tga); 3147c478bd9Sstevel@tonic-gate (void) sprintf(msg, "here=%s", Myname); 3157c478bd9Sstevel@tonic-gate omsg('S', msg, Ofn); 3167c478bd9Sstevel@tonic-gate (void) signal(SIGALRM, timeout); 3177c478bd9Sstevel@tonic-gate (void) alarm(msgtime); /* give slow machines a second chance */ 3187c478bd9Sstevel@tonic-gate if (setjmp(Sjbuf)) { 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate /* 3217c478bd9Sstevel@tonic-gate * timed out 3227c478bd9Sstevel@tonic-gate */ 3237c478bd9Sstevel@tonic-gate (void) restline(); 3247c478bd9Sstevel@tonic-gate rmlock(CNULL); 3257c478bd9Sstevel@tonic-gate exit(0); 3267c478bd9Sstevel@tonic-gate } 3277c478bd9Sstevel@tonic-gate for (;;) { 3287c478bd9Sstevel@tonic-gate ret = imsg(msg, Ifn); 3297c478bd9Sstevel@tonic-gate if (ret != 0) { 3307c478bd9Sstevel@tonic-gate (void) alarm(0); 3317c478bd9Sstevel@tonic-gate (void) restline(); 3327c478bd9Sstevel@tonic-gate rmlock(CNULL); 3337c478bd9Sstevel@tonic-gate exit(0); 3347c478bd9Sstevel@tonic-gate } 3357c478bd9Sstevel@tonic-gate if (msg[0] == 'S') 3367c478bd9Sstevel@tonic-gate break; 3377c478bd9Sstevel@tonic-gate } 3387c478bd9Sstevel@tonic-gate Nstat.t_ecall = times(&Nstat.t_tga); 3397c478bd9Sstevel@tonic-gate (void) alarm(0); 3407c478bd9Sstevel@tonic-gate q = &msg[1]; 3417c478bd9Sstevel@tonic-gate p = pskip(q); 3427c478bd9Sstevel@tonic-gate strncpy(Rmtname, q, MAXBASENAME); 3437c478bd9Sstevel@tonic-gate Rmtname[MAXBASENAME] = '\0'; 3447c478bd9Sstevel@tonic-gate 3457c478bd9Sstevel@tonic-gate seq = 0; 3467c478bd9Sstevel@tonic-gate while (p && *p == '-') { 3477c478bd9Sstevel@tonic-gate q = pskip(p); 3487c478bd9Sstevel@tonic-gate switch(*(++p)) { 3497c478bd9Sstevel@tonic-gate case 'x': 3507c478bd9Sstevel@tonic-gate Debug = atoi(++p); 3517c478bd9Sstevel@tonic-gate if (Debug <= 0) 3527c478bd9Sstevel@tonic-gate Debug = 1; 3537c478bd9Sstevel@tonic-gate (void) sprintf(xflag, "-x%d", Debug); 3547c478bd9Sstevel@tonic-gate break; 3557c478bd9Sstevel@tonic-gate case 'Q': 3567c478bd9Sstevel@tonic-gate seq = atoi(++p); 3577c478bd9Sstevel@tonic-gate if (seq < 0) 3587c478bd9Sstevel@tonic-gate seq = 0; 3597c478bd9Sstevel@tonic-gate break; 3607c478bd9Sstevel@tonic-gate #ifdef MAXGRADE 3617c478bd9Sstevel@tonic-gate case 'v': /* version -- -vname=val or -vname */ 3627c478bd9Sstevel@tonic-gate if (strncmp(++p, "grade=", 6) == 0 && 3637c478bd9Sstevel@tonic-gate isalnum(p[6])) 3647c478bd9Sstevel@tonic-gate MaxGrade = p[6]; 3657c478bd9Sstevel@tonic-gate break; 3667c478bd9Sstevel@tonic-gate #endif /* MAXGRADE */ 3677c478bd9Sstevel@tonic-gate case 'R': 3687c478bd9Sstevel@tonic-gate Restart++; 3697c478bd9Sstevel@tonic-gate p++; 3707c478bd9Sstevel@tonic-gate break; 3717c478bd9Sstevel@tonic-gate case 'U': 3727c478bd9Sstevel@tonic-gate SizeCheck++; 3737c478bd9Sstevel@tonic-gate RemUlimit = strtol(++p, (char **) NULL,0); 3747c478bd9Sstevel@tonic-gate break; 3757c478bd9Sstevel@tonic-gate default: 3767c478bd9Sstevel@tonic-gate break; 3777c478bd9Sstevel@tonic-gate } 3787c478bd9Sstevel@tonic-gate p = q; 3797c478bd9Sstevel@tonic-gate } 3807c478bd9Sstevel@tonic-gate DEBUG(4, "sys-%s\n", Rmtname); 3817c478bd9Sstevel@tonic-gate if (strpbrk(Rmtname, Shchar) != NULL) { 3827c478bd9Sstevel@tonic-gate DEBUG(4, "Bad remote system name '%s'\n", Rmtname); 3837c478bd9Sstevel@tonic-gate logent(Rmtname, "BAD REMOTE SYSTEM NAME"); 3847c478bd9Sstevel@tonic-gate omsg('R', "Bad remote system name", Ofn); 3857c478bd9Sstevel@tonic-gate cleanup(101); 3867c478bd9Sstevel@tonic-gate } 3877c478bd9Sstevel@tonic-gate if (Restart) 3887c478bd9Sstevel@tonic-gate CDEBUG(1,"Checkpoint Restart enabled\n%s", ""); 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate #ifdef NOSTRANGERS 3917c478bd9Sstevel@tonic-gate checkrmt(); /* Do we know the remote system. */ 3927c478bd9Sstevel@tonic-gate #else 3937c478bd9Sstevel@tonic-gate (void) versys(Rmtname); /* in case the real name is longer */ 3947c478bd9Sstevel@tonic-gate #endif /* NOSTRANGERS */ 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate (void) sprintf(lockname, "%ld", (long) getpid()); 3977c478bd9Sstevel@tonic-gate if (umlock(LOCKPRE, lockname)) { 3987c478bd9Sstevel@tonic-gate omsg('R', "LCK", Ofn); 3997c478bd9Sstevel@tonic-gate cleanup(101); 4007c478bd9Sstevel@tonic-gate } 4017c478bd9Sstevel@tonic-gate 4027c478bd9Sstevel@tonic-gate /* validate login using PERMISSIONS file */ 4037c478bd9Sstevel@tonic-gate if (logFind(Loginuser, Rmtname) == FAIL) { 4047c478bd9Sstevel@tonic-gate scWrite(); /* log security violation */ 4057c478bd9Sstevel@tonic-gate Uerror = SS_BAD_LOG_MCH; 4067c478bd9Sstevel@tonic-gate logent(UERRORTEXT, "FAILED"); 4077c478bd9Sstevel@tonic-gate systat(Rmtname, SS_BAD_LOG_MCH, UERRORTEXT, 4087c478bd9Sstevel@tonic-gate Retrytime); 4097c478bd9Sstevel@tonic-gate omsg('R', "LOGIN", Ofn); 4107c478bd9Sstevel@tonic-gate cleanup(101); 4117c478bd9Sstevel@tonic-gate } 4127c478bd9Sstevel@tonic-gate 4137c478bd9Sstevel@tonic-gate ret = callBack(); 4147c478bd9Sstevel@tonic-gate DEBUG(4,"return from callcheck: %s",ret ? "TRUE" : "FALSE"); 4157c478bd9Sstevel@tonic-gate if (ret==TRUE) { 4167c478bd9Sstevel@tonic-gate (void) signal(SIGINT, SIG_IGN); 4177c478bd9Sstevel@tonic-gate (void) signal(SIGHUP, SIG_IGN); 4187c478bd9Sstevel@tonic-gate omsg('R', "CB", Ofn); 4197c478bd9Sstevel@tonic-gate logent("CALLBACK", "REQUIRED"); 4207c478bd9Sstevel@tonic-gate /* 4217c478bd9Sstevel@tonic-gate * set up for call back 4227c478bd9Sstevel@tonic-gate */ 4237c478bd9Sstevel@tonic-gate chremdir(Rmtname); 4247c478bd9Sstevel@tonic-gate (void) sprintf(file, "%s/%c", Rmtname, D_QUEUE); 4257c478bd9Sstevel@tonic-gate chremdir(file); 4267c478bd9Sstevel@tonic-gate gename(CMDPRE, Rmtname, 'C', file); 4277c478bd9Sstevel@tonic-gate (void) close(creat(file, CFILEMODE)); 4287c478bd9Sstevel@tonic-gate if (callok(Rmtname) == SS_CALLBACK_LOOP) { 4297c478bd9Sstevel@tonic-gate systat(Rmtname, SS_CALLBACK_LOOP, "CALL BACK - LOOP", Retrytime); 4307c478bd9Sstevel@tonic-gate } else { 4317c478bd9Sstevel@tonic-gate systat(Rmtname, SS_CALLBACK, "CALL BACK", Retrytime); 4327c478bd9Sstevel@tonic-gate xuucico(Rmtname); 4337c478bd9Sstevel@tonic-gate } 4347c478bd9Sstevel@tonic-gate cleanup(101); 4357c478bd9Sstevel@tonic-gate } 4367c478bd9Sstevel@tonic-gate 4377c478bd9Sstevel@tonic-gate if (callok(Rmtname) == SS_SEQBAD) { 4387c478bd9Sstevel@tonic-gate Uerror = SS_SEQBAD; 4397c478bd9Sstevel@tonic-gate logent(UERRORTEXT, "PREVIOUS"); 4407c478bd9Sstevel@tonic-gate omsg('R', "BADSEQ", Ofn); 4417c478bd9Sstevel@tonic-gate cleanup(101); 4427c478bd9Sstevel@tonic-gate } 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate if (gnxseq(Rmtname) == seq) { 4457c478bd9Sstevel@tonic-gate if (Restart) { 4467c478bd9Sstevel@tonic-gate if (SizeCheck) 4477c478bd9Sstevel@tonic-gate (void) sprintf (msg, "OK -R -U0x%lx %s", 4487c478bd9Sstevel@tonic-gate Ulimit, xflag); 4497c478bd9Sstevel@tonic-gate else 4507c478bd9Sstevel@tonic-gate (void) sprintf (msg, "OK -R %s", xflag); 4517c478bd9Sstevel@tonic-gate omsg('R', msg, Ofn); 4527c478bd9Sstevel@tonic-gate } else 4537c478bd9Sstevel@tonic-gate omsg('R', "OK", Ofn); 4547c478bd9Sstevel@tonic-gate (void) cmtseq(); 4557c478bd9Sstevel@tonic-gate } else { 4567c478bd9Sstevel@tonic-gate Uerror = SS_SEQBAD; 4577c478bd9Sstevel@tonic-gate systat(Rmtname, SS_SEQBAD, UERRORTEXT, Retrytime); 4587c478bd9Sstevel@tonic-gate logent(UERRORTEXT, "HANDSHAKE FAILED"); 4597c478bd9Sstevel@tonic-gate ulkseq(); 4607c478bd9Sstevel@tonic-gate omsg('R', "BADSEQ", Ofn); 4617c478bd9Sstevel@tonic-gate cleanup(101); 4627c478bd9Sstevel@tonic-gate } 4637c478bd9Sstevel@tonic-gate ttyn = ttyname(Ifn); 4647c478bd9Sstevel@tonic-gate if (ttyn != CNULL && *ttyn != NULLCHAR) { 4657c478bd9Sstevel@tonic-gate struct stat ttysbuf; 4667c478bd9Sstevel@tonic-gate if ( fstat(Ifn,&ttysbuf) == 0 ) 4677c478bd9Sstevel@tonic-gate Dev_mode = ttysbuf.st_mode; 4687c478bd9Sstevel@tonic-gate else 4697c478bd9Sstevel@tonic-gate Dev_mode = R_DEVICEMODE; 4707c478bd9Sstevel@tonic-gate if ( EQUALSN(ttyn,"/dev/",5) ) 4717c478bd9Sstevel@tonic-gate strcpy(Dc, ttyn+5); 4727c478bd9Sstevel@tonic-gate else 4737c478bd9Sstevel@tonic-gate strcpy(Dc, ttyn); 4747c478bd9Sstevel@tonic-gate chmod(ttyn, S_DEVICEMODE); 4757c478bd9Sstevel@tonic-gate } else 4767c478bd9Sstevel@tonic-gate strcpy(Dc, "notty"); 4777c478bd9Sstevel@tonic-gate /* set args for possible xuuxqt call */ 4787c478bd9Sstevel@tonic-gate strcpy(uuxqtarg, Rmtname); 4797c478bd9Sstevel@tonic-gate } 4807c478bd9Sstevel@tonic-gate 4817c478bd9Sstevel@tonic-gate strcpy(User, Uucp); 4827c478bd9Sstevel@tonic-gate /* 4837c478bd9Sstevel@tonic-gate * Ensure reasonable ulimit (MINULIMIT) 4847c478bd9Sstevel@tonic-gate */ 4857c478bd9Sstevel@tonic-gate 4867c478bd9Sstevel@tonic-gate #ifndef V7 4877c478bd9Sstevel@tonic-gate { 4887c478bd9Sstevel@tonic-gate long minulimit; 4897c478bd9Sstevel@tonic-gate minulimit = ulimit(1, (long) 0); 4907c478bd9Sstevel@tonic-gate ASSERT(minulimit >= MINULIMIT, "ULIMIT TOO SMALL", 4917c478bd9Sstevel@tonic-gate Loginuser, (int) minulimit); 4927c478bd9Sstevel@tonic-gate } 4937c478bd9Sstevel@tonic-gate #endif 4947c478bd9Sstevel@tonic-gate if (Role == MASTER && callok(Rmtname) != 0) { 4957c478bd9Sstevel@tonic-gate logent("SYSTEM STATUS", "CAN NOT CALL"); 4967c478bd9Sstevel@tonic-gate cleanup(101); 4977c478bd9Sstevel@tonic-gate } 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate chremdir(Rmtname); 5007c478bd9Sstevel@tonic-gate 5017c478bd9Sstevel@tonic-gate (void) strcpy(Wrkdir, RemSpool); 5027c478bd9Sstevel@tonic-gate if (Role == MASTER) { 5037c478bd9Sstevel@tonic-gate 5047c478bd9Sstevel@tonic-gate /* 5057c478bd9Sstevel@tonic-gate * master part 5067c478bd9Sstevel@tonic-gate */ 5077c478bd9Sstevel@tonic-gate (void) signal(SIGINT, SIG_IGN); 5087c478bd9Sstevel@tonic-gate (void) signal(SIGHUP, SIG_IGN); 5097c478bd9Sstevel@tonic-gate (void) signal(SIGQUIT, SIG_IGN); 5107c478bd9Sstevel@tonic-gate if (Ifn != -1 && Role == MASTER) { 5117c478bd9Sstevel@tonic-gate (void) (*Write)(Ofn, EOTMSG, strlen(EOTMSG)); 5127c478bd9Sstevel@tonic-gate (void) close(Ofn); 5137c478bd9Sstevel@tonic-gate (void) close(Ifn); 5147c478bd9Sstevel@tonic-gate Ifn = Ofn = -1; 5157c478bd9Sstevel@tonic-gate rmlock(CNULL); 5167c478bd9Sstevel@tonic-gate sleep(3); 5177c478bd9Sstevel@tonic-gate } 5187c478bd9Sstevel@tonic-gate 5197c478bd9Sstevel@tonic-gate /* 5207c478bd9Sstevel@tonic-gate * Find the highest priority job grade that has 5217c478bd9Sstevel@tonic-gate * jobs to do. This is needed to form the lock name. 5227c478bd9Sstevel@tonic-gate */ 5237c478bd9Sstevel@tonic-gate 5247c478bd9Sstevel@tonic-gate findgrade(RemSpool, JobGrade); 5257c478bd9Sstevel@tonic-gate DEBUG(4, "Job grade to process - %s\n", JobGrade); 5267c478bd9Sstevel@tonic-gate 5277c478bd9Sstevel@tonic-gate /* 5287c478bd9Sstevel@tonic-gate * Lock the job grade if there is one to process. 5297c478bd9Sstevel@tonic-gate */ 5307c478bd9Sstevel@tonic-gate 5317c478bd9Sstevel@tonic-gate if (*JobGrade != NULLCHAR) { 5327c478bd9Sstevel@tonic-gate (void) sprintf(gradedir, "%s/%s", Rmtname, JobGrade); 5337c478bd9Sstevel@tonic-gate chremdir(gradedir); 5347c478bd9Sstevel@tonic-gate 5357c478bd9Sstevel@tonic-gate (void) sprintf(lockname, "%.*s.%s", SYSNSIZE, Rmtname, JobGrade); 5367c478bd9Sstevel@tonic-gate (void) sprintf(msg, "call to %s - process job grade %s ", 5377c478bd9Sstevel@tonic-gate Rmtname, JobGrade); 5387c478bd9Sstevel@tonic-gate if (umlock(LOCKPRE, lockname) != 0) { 5397c478bd9Sstevel@tonic-gate logent(msg, "LOCKED"); 5407c478bd9Sstevel@tonic-gate CDEBUG(1, "Currently Talking With %s\n", 5417c478bd9Sstevel@tonic-gate Rmtname); 5427c478bd9Sstevel@tonic-gate cleanup(100); 5437c478bd9Sstevel@tonic-gate } 5447c478bd9Sstevel@tonic-gate } else { 5457c478bd9Sstevel@tonic-gate (void) sprintf(msg, "call to %s - no work", Rmtname); 5467c478bd9Sstevel@tonic-gate } 5477c478bd9Sstevel@tonic-gate 5487c478bd9Sstevel@tonic-gate Nstat.t_scall = times(&Nstat.t_tga); 5497c478bd9Sstevel@tonic-gate Ofn = Ifn = conn(Rmtname); 5507c478bd9Sstevel@tonic-gate Nstat.t_ecall = times(&Nstat.t_tga); 5517c478bd9Sstevel@tonic-gate if (Ofn < 0) { 5527c478bd9Sstevel@tonic-gate delock(LOCKPRE, lockname); 5537c478bd9Sstevel@tonic-gate logent(UERRORTEXT, "CONN FAILED"); 5547c478bd9Sstevel@tonic-gate systat(Rmtname, Uerror, UERRORTEXT, Retrytime); 5557c478bd9Sstevel@tonic-gate cleanup(101); 5567c478bd9Sstevel@tonic-gate } else { 5577c478bd9Sstevel@tonic-gate logent(msg, "SUCCEEDED"); 5587c478bd9Sstevel@tonic-gate ttyn = ttyname(Ifn); 5597c478bd9Sstevel@tonic-gate if (ttyn != CNULL && *ttyn != NULLCHAR) { 5607c478bd9Sstevel@tonic-gate struct stat ttysbuf; 5617c478bd9Sstevel@tonic-gate if ( fstat(Ifn,&ttysbuf) == 0 ) 5627c478bd9Sstevel@tonic-gate Dev_mode = ttysbuf.st_mode; 5637c478bd9Sstevel@tonic-gate else 5647c478bd9Sstevel@tonic-gate Dev_mode = R_DEVICEMODE; 5657c478bd9Sstevel@tonic-gate chmod(ttyn, M_DEVICEMODE); 5667c478bd9Sstevel@tonic-gate } 5677c478bd9Sstevel@tonic-gate } 5687c478bd9Sstevel@tonic-gate 5697c478bd9Sstevel@tonic-gate if (setjmp(Sjbuf)) { 5707c478bd9Sstevel@tonic-gate delock(LOCKPRE, lockname); 5717c478bd9Sstevel@tonic-gate Uerror = SS_LOGIN_FAILED; 5727c478bd9Sstevel@tonic-gate logent(Rmtname, UERRORTEXT); 5737c478bd9Sstevel@tonic-gate systat(Rmtname, SS_LOGIN_FAILED, 5747c478bd9Sstevel@tonic-gate UERRORTEXT, Retrytime); 5757c478bd9Sstevel@tonic-gate DEBUG(4, "%s - failed\n", UERRORTEXT); 5767c478bd9Sstevel@tonic-gate cleanup(101); 5777c478bd9Sstevel@tonic-gate } 5787c478bd9Sstevel@tonic-gate (void) signal(SIGALRM, timeout); 5797c478bd9Sstevel@tonic-gate /* give slow guys lots of time to thrash */ 5807c478bd9Sstevel@tonic-gate (void) alarm(2 * msgtime); 5817c478bd9Sstevel@tonic-gate for (;;) { 5827c478bd9Sstevel@tonic-gate ret = imsg(msg, Ifn); 5837c478bd9Sstevel@tonic-gate if (ret != 0) { 5847c478bd9Sstevel@tonic-gate continue; /* try again */ 5857c478bd9Sstevel@tonic-gate } 5867c478bd9Sstevel@tonic-gate if (msg[0] == 'S') 5877c478bd9Sstevel@tonic-gate break; 5887c478bd9Sstevel@tonic-gate } 5897c478bd9Sstevel@tonic-gate (void) alarm(0); 5907c478bd9Sstevel@tonic-gate if(EQUALSN("here=", &msg[1], 5)){ 5917c478bd9Sstevel@tonic-gate /* This may be a problem, we check up to MAXBASENAME 5927c478bd9Sstevel@tonic-gate * characters now. The old comment was: 5937c478bd9Sstevel@tonic-gate * this is a problem. We'd like to compare with an 5947c478bd9Sstevel@tonic-gate * untruncated Rmtname but we fear incompatability. 5957c478bd9Sstevel@tonic-gate * So we'll look at most 6 chars (at most). 5967c478bd9Sstevel@tonic-gate */ 5977c478bd9Sstevel@tonic-gate (void) pskip(&msg[6]); 5987c478bd9Sstevel@tonic-gate if (!EQUALSN(&msg[6], Rmtname, MAXBASENAME)) { 5997c478bd9Sstevel@tonic-gate delock(LOCKPRE, lockname); 6007c478bd9Sstevel@tonic-gate Uerror = SS_WRONG_MCH; 6017c478bd9Sstevel@tonic-gate logent(&msg[6], UERRORTEXT); 6027c478bd9Sstevel@tonic-gate systat(Rmtname, SS_WRONG_MCH, UERRORTEXT, 6037c478bd9Sstevel@tonic-gate Retrytime); 6047c478bd9Sstevel@tonic-gate DEBUG(4, "%s - failed\n", UERRORTEXT); 6057c478bd9Sstevel@tonic-gate cleanup(101); 6067c478bd9Sstevel@tonic-gate } 6077c478bd9Sstevel@tonic-gate } 6087c478bd9Sstevel@tonic-gate CDEBUG(1,"Login Successful: System=%s\n",&msg[6]); 6097c478bd9Sstevel@tonic-gate seq = gnxseq(Rmtname); 6107c478bd9Sstevel@tonic-gate (void) sprintf(msg, "%s -Q%d -R -U0x%lx %s", 6117c478bd9Sstevel@tonic-gate Myname, seq, Ulimit, xflag); 6127c478bd9Sstevel@tonic-gate #ifdef MAXGRADE 6137c478bd9Sstevel@tonic-gate if (MaxGrade != NULLCHAR) { 6147c478bd9Sstevel@tonic-gate p = strchr(msg, NULLCHAR); 6157c478bd9Sstevel@tonic-gate sprintf(p, " -vgrade=%c", MaxGrade); 6167c478bd9Sstevel@tonic-gate } 6177c478bd9Sstevel@tonic-gate #endif /* MAXGRADE */ 6187c478bd9Sstevel@tonic-gate omsg('S', msg, Ofn); 6197c478bd9Sstevel@tonic-gate (void) alarm(msgtime); /* give slow guys some thrash time */ 6207c478bd9Sstevel@tonic-gate for (;;) { 6217c478bd9Sstevel@tonic-gate ret = imsg(msg, Ifn); 6227c478bd9Sstevel@tonic-gate DEBUG(4, "msg-%s\n", msg); 6237c478bd9Sstevel@tonic-gate if (ret != 0) { 6247c478bd9Sstevel@tonic-gate (void) alarm(0); 6257c478bd9Sstevel@tonic-gate delock(LOCKPRE, lockname); 6267c478bd9Sstevel@tonic-gate ulkseq(); 6277c478bd9Sstevel@tonic-gate cleanup(101); 6287c478bd9Sstevel@tonic-gate } 6297c478bd9Sstevel@tonic-gate if (msg[0] == 'R') 6307c478bd9Sstevel@tonic-gate break; 6317c478bd9Sstevel@tonic-gate } 6327c478bd9Sstevel@tonic-gate (void) alarm(0); 6337c478bd9Sstevel@tonic-gate 6347c478bd9Sstevel@tonic-gate /* check for rejects from remote */ 6357c478bd9Sstevel@tonic-gate Uerror = 0; 6367c478bd9Sstevel@tonic-gate if (EQUALS(&msg[1], "LCK")) 6377c478bd9Sstevel@tonic-gate Uerror = SS_RLOCKED; 6387c478bd9Sstevel@tonic-gate else if (EQUALS(&msg[1], "LOGIN")) 6397c478bd9Sstevel@tonic-gate Uerror = SS_RLOGIN; 6407c478bd9Sstevel@tonic-gate else if (EQUALS(&msg[1], "CB")) 6417c478bd9Sstevel@tonic-gate Uerror = (callBack() ? SS_CALLBACK_LOOP : SS_CALLBACK); 6427c478bd9Sstevel@tonic-gate else if (EQUALS(&msg[1], "You are unknown to me")) 6437c478bd9Sstevel@tonic-gate Uerror = SS_RUNKNOWN; 6447c478bd9Sstevel@tonic-gate else if (EQUALS(&msg[1], "BADSEQ")) 6457c478bd9Sstevel@tonic-gate Uerror = SS_SEQBAD; 6467c478bd9Sstevel@tonic-gate else if (!EQUALSN(&msg[1], "OK", 2)) 6477c478bd9Sstevel@tonic-gate Uerror = SS_UNKNOWN_RESPONSE; 6487c478bd9Sstevel@tonic-gate if (Uerror) { 6497c478bd9Sstevel@tonic-gate delock(LOCKPRE, lockname); 6507c478bd9Sstevel@tonic-gate systat(Rmtname, Uerror, UERRORTEXT, Retrytime); 6517c478bd9Sstevel@tonic-gate logent(UERRORTEXT, "HANDSHAKE FAILED"); 6527c478bd9Sstevel@tonic-gate CDEBUG(1, "HANDSHAKE FAILED: %s\n", UERRORTEXT); 6537c478bd9Sstevel@tonic-gate ulkseq(); 6547c478bd9Sstevel@tonic-gate cleanup(101); 6557c478bd9Sstevel@tonic-gate } 6567c478bd9Sstevel@tonic-gate (void) cmtseq(); 6577c478bd9Sstevel@tonic-gate 6587c478bd9Sstevel@tonic-gate /* 6597c478bd9Sstevel@tonic-gate * See if we have any additional parameters on the OK 6607c478bd9Sstevel@tonic-gate */ 6617c478bd9Sstevel@tonic-gate 6627c478bd9Sstevel@tonic-gate if (strlen(&msg[3])) { 6637c478bd9Sstevel@tonic-gate p = pskip(&msg[3]); 6647c478bd9Sstevel@tonic-gate while (p && *p == '-') { 6657c478bd9Sstevel@tonic-gate q = pskip(p); 6667c478bd9Sstevel@tonic-gate switch(*(++p)) { 6677c478bd9Sstevel@tonic-gate case 'R': 6687c478bd9Sstevel@tonic-gate Restart++; 6697c478bd9Sstevel@tonic-gate p++; 6707c478bd9Sstevel@tonic-gate break; 6717c478bd9Sstevel@tonic-gate case 'U': 6727c478bd9Sstevel@tonic-gate SizeCheck++; 6737c478bd9Sstevel@tonic-gate RemUlimit = strtol(++p, (char **) NULL, 0); 6747c478bd9Sstevel@tonic-gate break; 6757c478bd9Sstevel@tonic-gate case 'x': 6767c478bd9Sstevel@tonic-gate if (!Debug) { 6777c478bd9Sstevel@tonic-gate Debug = atoi(++p); 6787c478bd9Sstevel@tonic-gate if (Debug <= 0) 6797c478bd9Sstevel@tonic-gate Debug = 1; 6807c478bd9Sstevel@tonic-gate } 6817c478bd9Sstevel@tonic-gate break; 6827c478bd9Sstevel@tonic-gate default: 6837c478bd9Sstevel@tonic-gate break; 6847c478bd9Sstevel@tonic-gate } 6857c478bd9Sstevel@tonic-gate p = q; 6867c478bd9Sstevel@tonic-gate } 6877c478bd9Sstevel@tonic-gate } 6887c478bd9Sstevel@tonic-gate 6897c478bd9Sstevel@tonic-gate } 6907c478bd9Sstevel@tonic-gate DEBUG(4, " Rmtname %s, ", Rmtname); 6917c478bd9Sstevel@tonic-gate DEBUG(4, " Restart %s, ", (Restart ? "YES" : "NO")); 6927c478bd9Sstevel@tonic-gate DEBUG(4, "Role %s, ", Role ? "MASTER" : "SLAVE"); 6937c478bd9Sstevel@tonic-gate DEBUG(4, "Ifn - %d, ", Ifn); 6947c478bd9Sstevel@tonic-gate DEBUG(4, "Loginuser - %s\n", Loginuser); 6957c478bd9Sstevel@tonic-gate 6967c478bd9Sstevel@tonic-gate /* alarm/setjmp added here due to experience with uucico 6977c478bd9Sstevel@tonic-gate * hanging for hours in imsg(). 6987c478bd9Sstevel@tonic-gate */ 6997c478bd9Sstevel@tonic-gate if (setjmp(Sjbuf)) { 7007c478bd9Sstevel@tonic-gate delock(LOCKPRE, lockname); 7017c478bd9Sstevel@tonic-gate logent("startup", "TIMEOUT"); 7027c478bd9Sstevel@tonic-gate DEBUG(4, "%s - timeout\n", "startup"); 7037c478bd9Sstevel@tonic-gate cleanup(101); 7047c478bd9Sstevel@tonic-gate } 7057c478bd9Sstevel@tonic-gate (void) alarm(MAXSTART); 7067c478bd9Sstevel@tonic-gate ret = startup(); 7077c478bd9Sstevel@tonic-gate (void) alarm(0); 7087c478bd9Sstevel@tonic-gate 7097c478bd9Sstevel@tonic-gate if (ret != SUCCESS) { 7107c478bd9Sstevel@tonic-gate delock(LOCKPRE, lockname); 7117c478bd9Sstevel@tonic-gate logent("startup", "FAILED"); 7127c478bd9Sstevel@tonic-gate Uerror = SS_STARTUP; 7137c478bd9Sstevel@tonic-gate CDEBUG(1, "%s\n", UERRORTEXT); 7147c478bd9Sstevel@tonic-gate systat(Rmtname, Uerror, UERRORTEXT, Retrytime); 7157c478bd9Sstevel@tonic-gate exitcode = 101; 7167c478bd9Sstevel@tonic-gate } else { 7177c478bd9Sstevel@tonic-gate pfConnected(Rmtname, Dc); 7187c478bd9Sstevel@tonic-gate acConnected(Rmtname, Dc); 7197c478bd9Sstevel@tonic-gate logent("startup", "OK"); 7207c478bd9Sstevel@tonic-gate systat(Rmtname, SS_INPROGRESS, UTEXT(SS_INPROGRESS),Retrytime); 7217c478bd9Sstevel@tonic-gate Nstat.t_sftp = times(&Nstat.t_tga); 7227c478bd9Sstevel@tonic-gate 7237c478bd9Sstevel@tonic-gate exitcode = cntrl(); 7247c478bd9Sstevel@tonic-gate Nstat.t_eftp = times(&Nstat.t_tga); 7257c478bd9Sstevel@tonic-gate DEBUG(4, "cntrl - %d\n", exitcode); 7267c478bd9Sstevel@tonic-gate (void) signal(SIGINT, SIG_IGN); 7277c478bd9Sstevel@tonic-gate (void) signal(SIGHUP, SIG_IGN); 7287c478bd9Sstevel@tonic-gate (void) signal(SIGALRM, timeout); 7297c478bd9Sstevel@tonic-gate 7307c478bd9Sstevel@tonic-gate if (exitcode == 0) { 7317c478bd9Sstevel@tonic-gate (void) time(&ts); 7327c478bd9Sstevel@tonic-gate (void) sprintf(cb, "conversation complete %s %ld", 7337c478bd9Sstevel@tonic-gate Dc, ts - tconv); 7347c478bd9Sstevel@tonic-gate logent(cb, "OK"); 7357c478bd9Sstevel@tonic-gate systat(Rmtname, SS_OK, UTEXT(SS_OK), Retrytime); 7367c478bd9Sstevel@tonic-gate 7377c478bd9Sstevel@tonic-gate } else { 7387c478bd9Sstevel@tonic-gate logent("conversation complete", "FAILED"); 7397c478bd9Sstevel@tonic-gate systat(Rmtname, SS_CONVERSATION, 7407c478bd9Sstevel@tonic-gate UTEXT(SS_CONVERSATION), Retrytime); 7417c478bd9Sstevel@tonic-gate } 7427c478bd9Sstevel@tonic-gate (void) alarm(msgtime); /* give slow guys some thrash time */ 7437c478bd9Sstevel@tonic-gate omsg('O', "OOOOO", Ofn); 7447c478bd9Sstevel@tonic-gate CDEBUG(4, "send OO %d,", ret); 7457c478bd9Sstevel@tonic-gate if (!setjmp(Sjbuf)) { 7467c478bd9Sstevel@tonic-gate for (;;) { 7477c478bd9Sstevel@tonic-gate omsg('O', "OOOOO", Ofn); 7487c478bd9Sstevel@tonic-gate ret = imsg(msg, Ifn); 7497c478bd9Sstevel@tonic-gate if (ret != 0) 7507c478bd9Sstevel@tonic-gate break; 7517c478bd9Sstevel@tonic-gate if (msg[0] == 'O') 7527c478bd9Sstevel@tonic-gate break; 7537c478bd9Sstevel@tonic-gate } 7547c478bd9Sstevel@tonic-gate } 7557c478bd9Sstevel@tonic-gate (void) alarm(0); 7567c478bd9Sstevel@tonic-gate } 7577c478bd9Sstevel@tonic-gate cleanup(exitcode); 7587c478bd9Sstevel@tonic-gate /*NOTREACHED*/ 759462be471Sceastha return (0); 7607c478bd9Sstevel@tonic-gate } 7617c478bd9Sstevel@tonic-gate 7627c478bd9Sstevel@tonic-gate /* 7637c478bd9Sstevel@tonic-gate * clean and exit with "code" status 7647c478bd9Sstevel@tonic-gate */ 7657c478bd9Sstevel@tonic-gate void 7667c478bd9Sstevel@tonic-gate cleanup(code) 767462be471Sceastha int code; 7687c478bd9Sstevel@tonic-gate { 7697c478bd9Sstevel@tonic-gate (void) signal(SIGINT, SIG_IGN); 7707c478bd9Sstevel@tonic-gate (void) signal(SIGHUP, SIG_IGN); 7717c478bd9Sstevel@tonic-gate rmlock(CNULL); 7727c478bd9Sstevel@tonic-gate closedem(); 7737c478bd9Sstevel@tonic-gate alarm(msgtime); /* Start timer in case closes hang. */ 7747c478bd9Sstevel@tonic-gate if (setjmp(Sjbuf) == 0) 7757c478bd9Sstevel@tonic-gate (*Teardown)( Role, Ifn, Ofn ); 7767c478bd9Sstevel@tonic-gate alarm(0); /* Turn off timer. */ 7777c478bd9Sstevel@tonic-gate DEBUG(4, "exit code %d\n", code); 7787c478bd9Sstevel@tonic-gate CDEBUG(1, "Conversation Complete: Status %s\n\n", 7797c478bd9Sstevel@tonic-gate code ? "FAILED" : "SUCCEEDED"); 7807c478bd9Sstevel@tonic-gate 7817c478bd9Sstevel@tonic-gate cleanTM(); 7827c478bd9Sstevel@tonic-gate if ((code == 0) && (uuxqtflag == 1)) 7837c478bd9Sstevel@tonic-gate xuuxqt(uuxqtarg); 7847c478bd9Sstevel@tonic-gate exit(code); 7857c478bd9Sstevel@tonic-gate } 7867c478bd9Sstevel@tonic-gate 7877c478bd9Sstevel@tonic-gate short TM_cnt = 0; 7887c478bd9Sstevel@tonic-gate char TM_name[MAXNAMESIZE]; 7897c478bd9Sstevel@tonic-gate 7907c478bd9Sstevel@tonic-gate void 7917c478bd9Sstevel@tonic-gate cleanTM() 7927c478bd9Sstevel@tonic-gate { 793462be471Sceastha int i; 7947c478bd9Sstevel@tonic-gate char tm_name[MAXNAMESIZE]; 7957c478bd9Sstevel@tonic-gate 7967c478bd9Sstevel@tonic-gate DEBUG(7,"TM_cnt: %d\n",TM_cnt); 7977c478bd9Sstevel@tonic-gate for(i=0; i < TM_cnt; i++) { 7987c478bd9Sstevel@tonic-gate (void) sprintf(tm_name, "%s.%3.3d", TM_name, i); 7997c478bd9Sstevel@tonic-gate DEBUG(7, "tm_name: %s\n", tm_name); 8007c478bd9Sstevel@tonic-gate unlink(tm_name); 8017c478bd9Sstevel@tonic-gate } 8027c478bd9Sstevel@tonic-gate return; 8037c478bd9Sstevel@tonic-gate } 8047c478bd9Sstevel@tonic-gate 8057c478bd9Sstevel@tonic-gate void 8067c478bd9Sstevel@tonic-gate TMname(file, pnum) 8077c478bd9Sstevel@tonic-gate char *file; 8087c478bd9Sstevel@tonic-gate pid_t pnum; 8097c478bd9Sstevel@tonic-gate { 8107c478bd9Sstevel@tonic-gate 8117c478bd9Sstevel@tonic-gate (void) sprintf(file, "%s/TM.%.5ld.%.3d", RemSpool, (long) pnum, TM_cnt); 8127c478bd9Sstevel@tonic-gate if (TM_cnt == 0) 8137c478bd9Sstevel@tonic-gate (void) sprintf(TM_name, "%s/TM.%.5ld", RemSpool, (long) pnum); 8147c478bd9Sstevel@tonic-gate DEBUG(7, "TMname(%s)\n", file); 8157c478bd9Sstevel@tonic-gate TM_cnt++; 8167c478bd9Sstevel@tonic-gate return; 8177c478bd9Sstevel@tonic-gate } 8187c478bd9Sstevel@tonic-gate 8197c478bd9Sstevel@tonic-gate /* 8207c478bd9Sstevel@tonic-gate * intrrupt - remove locks and exit 8217c478bd9Sstevel@tonic-gate */ 8227c478bd9Sstevel@tonic-gate void 8237c478bd9Sstevel@tonic-gate onintr(inter) 824462be471Sceastha int inter; 8257c478bd9Sstevel@tonic-gate { 8267c478bd9Sstevel@tonic-gate char str[30]; 8277c478bd9Sstevel@tonic-gate /* I'm putting a test for zero here because I saw it happen 8287c478bd9Sstevel@tonic-gate * and don't know how or why, but it seemed to then loop 8297c478bd9Sstevel@tonic-gate * here for ever? 8307c478bd9Sstevel@tonic-gate */ 8317c478bd9Sstevel@tonic-gate if (inter == 0) 8327c478bd9Sstevel@tonic-gate exit(99); 8337c478bd9Sstevel@tonic-gate (void) signal(inter, SIG_IGN); 8347c478bd9Sstevel@tonic-gate (void) sprintf(str, "SIGNAL %d", inter); 8357c478bd9Sstevel@tonic-gate logent(str, "CAUGHT"); 8367c478bd9Sstevel@tonic-gate pfEndfile("PARTIAL FILE"); 8377c478bd9Sstevel@tonic-gate acEnd(PARTIAL); /*stop collecting accounting log */ 8387c478bd9Sstevel@tonic-gate cleanup(inter); 8397c478bd9Sstevel@tonic-gate } 8407c478bd9Sstevel@tonic-gate 8417c478bd9Sstevel@tonic-gate void 8427c478bd9Sstevel@tonic-gate intrEXIT(inter) 8437c478bd9Sstevel@tonic-gate int inter; 8447c478bd9Sstevel@tonic-gate { 8457c478bd9Sstevel@tonic-gate char cb[20]; 8467c478bd9Sstevel@tonic-gate 8477c478bd9Sstevel@tonic-gate (void) sprintf(cb, "SIGNAL %d", inter); 8487c478bd9Sstevel@tonic-gate logent("INTREXIT", cb); 8497c478bd9Sstevel@tonic-gate (void) signal(SIGIOT, SIG_DFL); 8507c478bd9Sstevel@tonic-gate (void) signal(SIGILL, SIG_DFL); 8517c478bd9Sstevel@tonic-gate rmlock(CNULL); 8527c478bd9Sstevel@tonic-gate closedem(); 8537c478bd9Sstevel@tonic-gate (void) setuid(Uid); 8547c478bd9Sstevel@tonic-gate abort(); 8557c478bd9Sstevel@tonic-gate } 8567c478bd9Sstevel@tonic-gate 8577c478bd9Sstevel@tonic-gate /* 8587c478bd9Sstevel@tonic-gate * catch SIGALRM routine 8597c478bd9Sstevel@tonic-gate */ 8607c478bd9Sstevel@tonic-gate void 8617c478bd9Sstevel@tonic-gate timeout() 8627c478bd9Sstevel@tonic-gate { 8637c478bd9Sstevel@tonic-gate longjmp(Sjbuf, 1); 8647c478bd9Sstevel@tonic-gate } 8657c478bd9Sstevel@tonic-gate 8667c478bd9Sstevel@tonic-gate /* skip to next field */ 8677c478bd9Sstevel@tonic-gate static char * 8687c478bd9Sstevel@tonic-gate pskip(p) 869462be471Sceastha char *p; 8707c478bd9Sstevel@tonic-gate { 8717c478bd9Sstevel@tonic-gate if ((p = strchr(p, ' ')) != CNULL) 8727c478bd9Sstevel@tonic-gate do 8737c478bd9Sstevel@tonic-gate *p++ = NULLCHAR; 8747c478bd9Sstevel@tonic-gate while (*p == ' '); 8757c478bd9Sstevel@tonic-gate return(p); 8767c478bd9Sstevel@tonic-gate } 8777c478bd9Sstevel@tonic-gate 8787c478bd9Sstevel@tonic-gate void 8797c478bd9Sstevel@tonic-gate closedem() 8807c478bd9Sstevel@tonic-gate { 881462be471Sceastha int i, maxfiles; 8827c478bd9Sstevel@tonic-gate 8837c478bd9Sstevel@tonic-gate #ifdef ATTSVR3 8847c478bd9Sstevel@tonic-gate maxfiles = ulimit(4,0); 8857c478bd9Sstevel@tonic-gate #else /* !ATTSVR3 */ 8867c478bd9Sstevel@tonic-gate #ifdef BSD4_2 8877c478bd9Sstevel@tonic-gate maxfiles = getdtablesize(); 8887c478bd9Sstevel@tonic-gate #else /* BSD4_2 */ 8897c478bd9Sstevel@tonic-gate maxfiles = _NFILE; 8907c478bd9Sstevel@tonic-gate #endif /* BSD4_2 */ 8917c478bd9Sstevel@tonic-gate #endif /* ATTSVR3 */ 8927c478bd9Sstevel@tonic-gate 8937c478bd9Sstevel@tonic-gate for ( i = 3; i < maxfiles; i++ ) 8947c478bd9Sstevel@tonic-gate if ( i != Ifn && i != Ofn && i != fileno(stderr) ) 8957c478bd9Sstevel@tonic-gate (void) close(i); 8967c478bd9Sstevel@tonic-gate return; 8977c478bd9Sstevel@tonic-gate } 8987c478bd9Sstevel@tonic-gate 8997c478bd9Sstevel@tonic-gate #ifndef ATTSVR3 9007c478bd9Sstevel@tonic-gate 9017c478bd9Sstevel@tonic-gate /* 9027c478bd9Sstevel@tonic-gate * setTZ() 9037c478bd9Sstevel@tonic-gate * 9047c478bd9Sstevel@tonic-gate * if login "shell" is uucico (i.e., Role == SLAVE), must set 9057c478bd9Sstevel@tonic-gate * timezone env variable TZ. otherwise will default to EST. 9067c478bd9Sstevel@tonic-gate */ 9077c478bd9Sstevel@tonic-gate 9087c478bd9Sstevel@tonic-gate #define LINELEN 81 9097c478bd9Sstevel@tonic-gate 9107c478bd9Sstevel@tonic-gate void 9117c478bd9Sstevel@tonic-gate setTZ() 9127c478bd9Sstevel@tonic-gate { 9137c478bd9Sstevel@tonic-gate static char buf[LINELEN], *bp; 9147c478bd9Sstevel@tonic-gate extern char *fgets(); 9157c478bd9Sstevel@tonic-gate FILE *tzfp; 9167c478bd9Sstevel@tonic-gate extern FILE *fopen(); 917462be471Sceastha int i; 9187c478bd9Sstevel@tonic-gate extern int fclose(), strncmp(); 9197c478bd9Sstevel@tonic-gate 9207c478bd9Sstevel@tonic-gate if ( (tzfp = fopen("/etc/TIMEZONE","r")) == (FILE *)NULL ) 9217c478bd9Sstevel@tonic-gate return; 9227c478bd9Sstevel@tonic-gate while ( (bp = fgets(buf,LINELEN,tzfp)) != (char *)NULL ) { 9237c478bd9Sstevel@tonic-gate while ( isspace(*bp) ) 9247c478bd9Sstevel@tonic-gate ++bp; 9257c478bd9Sstevel@tonic-gate if ( strncmp(bp, "TZ=", 3) == 0 ) { 9267c478bd9Sstevel@tonic-gate for ( i = strlen(bp) - 1; i > 0 && isspace(*(bp+i)); --i ) 9277c478bd9Sstevel@tonic-gate *(bp+i) = '\0'; 9287c478bd9Sstevel@tonic-gate putenv(bp); 9297c478bd9Sstevel@tonic-gate (void)fclose(tzfp); 9307c478bd9Sstevel@tonic-gate return; 9317c478bd9Sstevel@tonic-gate } 9327c478bd9Sstevel@tonic-gate } 9337c478bd9Sstevel@tonic-gate (void)fclose(tzfp); 9347c478bd9Sstevel@tonic-gate return; 9357c478bd9Sstevel@tonic-gate } 9367c478bd9Sstevel@tonic-gate #endif /* ATTSVR3 */ 9377c478bd9Sstevel@tonic-gate 9387c478bd9Sstevel@tonic-gate #ifdef NOSTRANGERS 9397c478bd9Sstevel@tonic-gate /* 9407c478bd9Sstevel@tonic-gate * Function: checkrmt 9417c478bd9Sstevel@tonic-gate * 9427c478bd9Sstevel@tonic-gate * If NOSTRANGERS is defined, see if the remote system is in our systems 9437c478bd9Sstevel@tonic-gate * file. If it is not, execute NOSTRANGERS and then reject the call. 9447c478bd9Sstevel@tonic-gate */ 9457c478bd9Sstevel@tonic-gate 9467c478bd9Sstevel@tonic-gate static void 9477c478bd9Sstevel@tonic-gate checkrmt () 9487c478bd9Sstevel@tonic-gate 9497c478bd9Sstevel@tonic-gate { 9507c478bd9Sstevel@tonic-gate char ** eVarPtr; /* Pointer to environment variable. */ 9517c478bd9Sstevel@tonic-gate char msgbuf[BUFSIZ]; /* Place to build messages. */ 9527c478bd9Sstevel@tonic-gate pid_t procid; /* ID of Nostranger process. */ 9537c478bd9Sstevel@tonic-gate static char * safePath = PATH; 9547c478bd9Sstevel@tonic-gate int status; /* Exit status of child. */ 9557c478bd9Sstevel@tonic-gate pid_t waitrv; /* Return value from wait system call. */ 9567c478bd9Sstevel@tonic-gate 9577c478bd9Sstevel@tonic-gate /* here's the place to look the remote system up in the Systems file. 9587c478bd9Sstevel@tonic-gate * If the command NOSTRANGERS is executable and 9597c478bd9Sstevel@tonic-gate * If they're not in my file then hang up */ 9607c478bd9Sstevel@tonic-gate 9617c478bd9Sstevel@tonic-gate if (versys(Rmtname) && (access(NOSTRANGERS, 1) == 0)) { 9627c478bd9Sstevel@tonic-gate sprintf(msgbuf, "Invoking %s for %%s\n", NOSTRANGERS); 9637c478bd9Sstevel@tonic-gate DEBUG(4, msgbuf, Rmtname); 9647c478bd9Sstevel@tonic-gate 9657c478bd9Sstevel@tonic-gate /* 9667c478bd9Sstevel@tonic-gate * Ignore hangup in case remote goes away before we can 9677c478bd9Sstevel@tonic-gate * finish logging. 9687c478bd9Sstevel@tonic-gate */ 9697c478bd9Sstevel@tonic-gate 9707c478bd9Sstevel@tonic-gate (void) signal(SIGHUP, SIG_IGN); 9717c478bd9Sstevel@tonic-gate omsg('R', "You are unknown to me", Ofn); 9727c478bd9Sstevel@tonic-gate scWrite(); /* log unknown remote system */ 9737c478bd9Sstevel@tonic-gate procid = fork(); 9747c478bd9Sstevel@tonic-gate if ( procid == 0 ) { 9757c478bd9Sstevel@tonic-gate /* 9767c478bd9Sstevel@tonic-gate * Before execing the no strangers program, there is 9777c478bd9Sstevel@tonic-gate * a security aspect to consider. If NOSTRANGERS is 9787c478bd9Sstevel@tonic-gate * not a full path name, then the PATH environment 9797c478bd9Sstevel@tonic-gate * variable will provide places to look for the file. 9807c478bd9Sstevel@tonic-gate * To be safe, we will set the PATH environment 9817c478bd9Sstevel@tonic-gate * variable before we do the exec. 9827c478bd9Sstevel@tonic-gate */ 9837c478bd9Sstevel@tonic-gate 9847c478bd9Sstevel@tonic-gate /* Find PATH in current environment and change it. */ 9857c478bd9Sstevel@tonic-gate 9867c478bd9Sstevel@tonic-gate for (eVarPtr = Env; *eVarPtr != CNULL; eVarPtr++) { 9877c478bd9Sstevel@tonic-gate if (PREFIX("PATH=", *eVarPtr)) 9887c478bd9Sstevel@tonic-gate *eVarPtr = safePath; 9897c478bd9Sstevel@tonic-gate } 9907c478bd9Sstevel@tonic-gate execlp( NOSTRANGERS, "stranger", Rmtname, (char *) 0); 9917c478bd9Sstevel@tonic-gate sprintf(msgbuf, "Execlp of %s failed with errno=%%d\n", 9927c478bd9Sstevel@tonic-gate NOSTRANGERS); 9937c478bd9Sstevel@tonic-gate DEBUG(4, msgbuf, errno); 9947c478bd9Sstevel@tonic-gate perror(gettext("cico.c: execlp NOSTRANGERS failed")); 9957c478bd9Sstevel@tonic-gate cleanup(errno); 9967c478bd9Sstevel@tonic-gate } else if (procid < 0) { 9977c478bd9Sstevel@tonic-gate perror(gettext("cico.c: execlp NOSTRANGERS failed")); 9987c478bd9Sstevel@tonic-gate cleanup(errno); 9997c478bd9Sstevel@tonic-gate } else { 10007c478bd9Sstevel@tonic-gate while ((waitrv = wait(&status)) != procid) 10017c478bd9Sstevel@tonic-gate if (waitrv == -1 && errno != EINTR) 10027c478bd9Sstevel@tonic-gate cleanup(errno); 10037c478bd9Sstevel@tonic-gate sprintf(msgbuf, "%s exit status was %%#x\n", 10047c478bd9Sstevel@tonic-gate NOSTRANGERS); 10057c478bd9Sstevel@tonic-gate DEBUG(4, msgbuf, status); 10067c478bd9Sstevel@tonic-gate } 10077c478bd9Sstevel@tonic-gate cleanup(101); 10087c478bd9Sstevel@tonic-gate } 10097c478bd9Sstevel@tonic-gate } 10107c478bd9Sstevel@tonic-gate #endif /* NOSTRANGERS */ 1011