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