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