/* ARGSUSED */ void variable(int cc) { char buf[256]; if (prompt("[set] ", buf, sizeof (buf))) return; vlex(buf); if (vtable[BEAUTIFY].v_access&CHANGED) { vtable[BEAUTIFY].v_access &= ~CHANGED; (void) kill(pid, SIGSYS); } if (vtable[SCRIPT].v_access&CHANGED) { vtable[SCRIPT].v_access &= ~CHANGED; setscript(); /* * So that "set record=blah script" doesn't * cause two transactions to occur. */ if (vtable[RECORD].v_access&CHANGED) vtable[RECORD].v_access &= ~CHANGED; } if (vtable[RECORD].v_access&CHANGED) { vtable[RECORD].v_access &= ~CHANGED; if (boolean(value(SCRIPT))) setscript(); } if (vtable[TAND].v_access&CHANGED) { vtable[TAND].v_access &= ~CHANGED; if (boolean(value(TAND))) tandem("on"); else tandem("off"); } if (vtable[LECHO].v_access&CHANGED) { vtable[LECHO].v_access &= ~CHANGED; boolean(value(HALFDUPLEX)) = boolean(value(LECHO)); } if (vtable[PARITY].v_access&CHANGED) { vtable[PARITY].v_access &= ~CHANGED; setparity(NULL); } if (vtable[BAUDRATE].v_access&CHANGED) { vtable[BAUDRATE].v_access &= ~CHANGED; ttysetup(speed(number(value(BAUDRATE)))); } if (vtable[HARDWAREFLOW].v_access & CHANGED) { vtable[HARDWAREFLOW].v_access &= ~CHANGED; if (boolean(value(HARDWAREFLOW))) hardwareflow("on"); else hardwareflow("off"); } }
/* * Botch the interface to look like cu's */ void cumain(int argc, char *argv[]) { int i; static char sbuf[12]; if (argc < 2) { printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n"); exit(8); } CU = DV = NULL; BR = DEFBR; for (; argc > 1; argv++, argc--) { if (argv[1][0] != '-') PN = argv[1]; else switch (argv[1][1]) { case 't': HW = 1, DU = -1; --argc; continue; case 'a': CU = argv[2]; ++argv; --argc; break; case 's': if (argc < 3 || speed(atoi(argv[2])) == 0) { fprintf(stderr, "cu: unsupported speed %s\n", argv[2]); exit(3); } BR = atoi(argv[2]); ++argv; --argc; break; case 'l': DV = argv[2]; ++argv; --argc; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (CU) CU[strlen(CU)-1] = argv[1][1]; if (DV) DV[strlen(DV)-1] = argv[1][1]; break; default: printf("Bad flag %s", argv[1]); break; } } signal(SIGINT, cleanup); signal(SIGQUIT, cleanup); signal(SIGHUP, cleanup); signal(SIGTERM, cleanup); /* * The "cu" host name is used to define the * attributes of the generic dialer. */ (void)snprintf(sbuf, sizeof(sbuf), "cu%ld", BR); if ((i = hunt(sbuf)) == 0) { printf("all ports busy\n"); exit(3); } if (i == -1) { printf("link down\n"); (void)uu_unlock(uucplock); exit(3); } setbuf(stdout, NULL); loginit(); user_uid(); vinit(); setparity("none"); boolean(value(VERBOSE)) = 0; if (HW) ttysetup(speed(BR)); if (connect()) { printf("Connect failed\n"); daemon_uid(); (void)uu_unlock(uucplock); exit(1); } if (!HW) ttysetup(speed(BR)); exit(0); }
int main(int argc, char *argv[]) { char *System = NULL; int c, i; char *p; const char *q; char sbuf[12]; int cmdlineBR; int fcarg; setprogname(argv[0]); gid = getgid(); egid = getegid(); uid = getuid(); euid = geteuid(); if (strcmp(getprogname(), "cu") == 0) { cumode = 1; cumain(argc, argv); goto cucommon; } if (argc > 4) tipusage(); if (!isatty(0)) errx(EXIT_FAILURE, "must be interactive"); cmdlineBR = 0; while((c = getopt(argc, argv, "v0123456789")) != -1) { switch(c) { case 'v': vflag++; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': cmdlineBR = cmdlineBR * 10 + (c - '0'); BR = cmdlineBR; break; default: warnx("%s, unknown option", argv[1]); break; } } argc -= optind; argv += optind; if (argc != 1) tipusage(); else System = argv[0]; if (System == NULL) goto notnumber; if (isalpha((unsigned char)*System)) goto notnumber; /* * System name is really a phone number... * Copy the number then stomp on the original (in case the number * is private, we don't want 'ps' or 'w' to find it). */ if (strlen(System) > sizeof PNbuf - 1) { errx(1, "phone number too long (max = %d bytes)", (int)sizeof(PNbuf) - 1); } (void)strlcpy(PNbuf, System, sizeof(PNbuf)); for (p = System; *p; p++) *p = '\0'; PN = PNbuf; (void)snprintf(sbuf, sizeof sbuf, "tip%d", (int)BR); System = sbuf; notnumber: (void)signal(SIGINT, cleanup); (void)signal(SIGQUIT, cleanup); (void)signal(SIGHUP, cleanup); (void)signal(SIGTERM, cleanup); if ((i = hunt(System)) == 0) { errx(3, "all ports busy"); } if (i == -1) { errx(3, "link down"); } setbuf(stdout, NULL); /* * Kludge, their's no easy way to get the initialization * in the right order, so force it here */ if ((PH = getenv("PHONES")) == NULL) PH = path_phones; vinit(); /* init variables */ setparity("none"); /* set the parity table */ /* * Hardwired connections require the * line speed set before they make any transmissions * (this is particularly true of things like a DF03-AC) */ if (HW) { if (ttysetup((speed_t)number(value(BAUDRATE))) != 0) { errx(3, "bad baud rate %d", (int)number(value(BAUDRATE))); } } if ((q = tip_connect()) != NULL) { errx(1, "\07%s\n[EOT]", q); } if (!HW) { if (ttysetup((speed_t)number(value(BAUDRATE))) != 0) { errx(3, "bad baud rate %d", (int)number(value(BAUDRATE))); } } cucommon: /* * From here down the code is shared with * the "cu" version of tip. */ /* * Direct connections with no carrier require using O_NONBLOCK on * open, but we don't want to keep O_NONBLOCK after open because it * will cause busy waits. */ if (DC && ((fcarg = fcntl(FD, F_GETFL, 0)) < 0 || fcntl(FD, F_SETFL, fcarg & ~O_NONBLOCK) < 0)) { err(1, "can't clear O_NONBLOCK"); } (void)tcgetattr(0, &defterm); term = defterm; term.c_lflag &= ~(ICANON|IEXTEN|ECHO); term.c_iflag &= ~(INPCK|ICRNL); term.c_oflag &= ~OPOST; term.c_cc[VMIN] = 1; term.c_cc[VTIME] = 0; defchars = term; term.c_cc[VINTR] = term.c_cc[VQUIT] = term.c_cc[VSUSP] = term.c_cc[VDSUSP] = term.c_cc[VDISCARD] = term.c_cc[VLNEXT] = _POSIX_VDISABLE; raw(); (void)pipe(attndes); (void)pipe(fildes); (void)pipe(repdes); (void)signal(SIGALRM, alrmtimeout); /* * Everything's set up now: * connection established (hardwired or dialup) * line conditioned (baud rate, mode, etc.) * internal data structures (variables) * so, fork one process for local side and one for remote. */ (void)printf("%s", cumode ? "Connected\r\n" : "\07connected\r\n"); switch (pid = fork()) { default: tipin(); break; case 0: tipout(); break; case -1: err(1, "can't fork"); } /*NOTREACHED*/ exit(0); /* XXX: pacify gcc */ }
static int unidialer_dialer(char *num, char *acu) { char *cp; char dial_string [80]; #if ACULOG char line [80]; #endif #ifdef DEBUG dumpmodemparms (modem_name); #endif if (lock_baud) { int i; if ((i = speed(number(value(BAUDRATE)))) == 0) return 0; ttysetup (i); } if (boolean(value(VERBOSE))) printf("Using \"%s\"\n", acu); acu_hupcl (); /* * Get in synch. */ if (!unidialersync()) { badsynch: printf("tip: can't synchronize with %s\n", modem_name); #if ACULOG logent(value(HOST), num, modem_name, "can't synch up"); #endif return (0); } unidialer_modem_cmd (FD, echo_off_command); /* turn off echoing */ sleep(1); #ifdef DEBUG if (boolean(value(VERBOSE))) unidialer_verbose_read(); #endif acu_flush (); /* flush any clutter */ unidialer_modem_cmd (FD, init_string); if (!unidialer_get_okay (reset_delay)) goto badsynch; fflush (stdout); for (cp = num; *cp; cp++) if (*cp == '=') *cp = ','; (void) sprintf (dial_string, dial_command, num); unidialer_modem_cmd (FD, dial_string); connected = unidialer_connect (); if (connected && hw_flow_control) { acu_hw_flow_control (hw_flow_control); } #if ACULOG if (timeout) { sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, modem_name, line); } #endif if (timeout) unidialer_disconnect (); return (connected); }
int main(int argc, char *argv[]) { char *system = NOSTR; int i; char *p; char sbuf[15]; gid = getgid(); egid = getegid(); uid = getuid(); euid = geteuid(); if (equal(sname(argv[0]), "cu")) { cumode = 1; cumain(argc, argv); goto cucommon; } if (argc > 4) { (void) fprintf(stderr, "usage: tip [-v] [-speed] [system-name]\n"); return (1); } if (!isatty(0)) { (void) fprintf(stderr, "tip: must be interactive\n"); return (1); } for (; argc > 1; argv++, argc--) { if (argv[1][0] != '-') system = argv[1]; else switch (argv[1][1]) { case 'v': vflag++; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': BR = atoi(&argv[1][1]); break; default: (void) fprintf(stderr, "tip: %s, unknown option\n", argv[1]); break; } } (void) setlocale(LC_CTYPE, ""); if (system == NOSTR) goto notnumber; for (p = system; *p; p++) if (isalpha(*p)) goto notnumber; /* * System name is really a phone number... * Copy the number then stomp on the original (in case the number * is private, we don't want 'ps' or 'w' to find it). */ if (strlen(system) > sizeof (PNbuf) - 1) { (void) fprintf(stderr, "tip: phone number too long (max = %d bytes)\n", sizeof (PNbuf) - 1); return (1); } (void) strncpy(PNbuf, system, sizeof (PNbuf) - 1); for (p = system; *p; p++) *p = '\0'; PN = PNbuf; (void) snprintf(sbuf, sizeof (sbuf), "tip%d", BR); system = sbuf; notnumber: (void) signal(SIGINT, (sig_handler_t)cleanup); (void) signal(SIGQUIT, (sig_handler_t)cleanup); (void) signal(SIGHUP, (sig_handler_t)cleanup); (void) signal(SIGTERM, (sig_handler_t)cleanup); if ((i = hunt(system)) == 0) { (void) printf("all ports busy\n"); return (3); } if (i == -1) { (void) printf("link down\n"); delock(uucplock); return (3); } setbuf(stdout, NULL); loginit(); /* * Now that we have the logfile and the ACU open * return to the real uid and gid. These things will * be closed on exit. The saved-setuid uid and gid * allows us to get the original setuid permissions back * for removing the uucp lock. */ userperm(); /* * Kludge, there's no easy way to get the initialization * in the right order, so force it here. * Do the open here, before we change back to real uid. * We will check whether the open succeeded later, when * (and if) we actually go to use the file. */ if ((PH = getenv("PHONES")) == NOSTR) { myperm(); PH = "/etc/phones"; } phfd = fopen(PH, "r"); userperm(); vinit(); /* init variables */ setparity("none"); /* set the parity table */ if ((i = speed(number(value(BAUDRATE)))) == NULL) { (void) printf("tip: bad baud rate %d\n", number(value(BAUDRATE))); myperm(); delock(uucplock); return (3); } /* * Hardwired connections require the * line speed set before they make any transmissions * (this is particularly true of things like a DF03-AC) */ if (HW) ttysetup(i); if (p = connect()) { (void) printf("\07%s\n[EOT]\n", p); myperm(); delock(uucplock); return (1); } /* * Always setup the tty again here in case hardware flow * control was selected, which can only be set after the * connection is made, or in case this is not a hardwired * modem (rare these days) that likewise can only be setup * after the connection is made. */ ttysetup(i); cucommon: /* * From here down the code is shared with * the "cu" version of tip. */ (void) ioctl(0, TCGETS, (char *)&defarg); arg = defarg; /* turn off input processing */ arg.c_lflag &= ~(ICANON|ISIG|ECHO|IEXTEN); arg.c_cc[VMIN] = 1; arg.c_cc[VTIME] = 0; arg.c_iflag &= ~(INPCK|IXON|IXOFF|ICRNL); arg.c_oflag = 0; /* turn off all output processing */ /* handle tandem mode in case was set in remote file */ if (boolean(value(TAND))) tandem("on"); else tandem("off"); raw(); (void) pipe(fildes); (void) pipe(repdes); (void) signal(SIGALRM, (sig_handler_t)timeout); /* * Everything's set up now: * connection established (hardwired or dialup) * line conditioned (baud rate, mode, etc.) * internal data structures (variables) * so, fork one process for local side and one for remote. */ if (CM != NOSTR) { (void) sleep(2); /* let line settle */ parwrite(FD, (unsigned char *)CM, strlen(CM)); } (void) printf(cumode ? "Connected\r\n" : "\07connected\r\n"); (void) signal(SIGCHLD, (sig_handler_t)deadkid); if (pid = fork()) tipin(); else tipout(); /*NOTREACHED*/ }
int multitech_dialer (char *num, char *acu) { char *cp; #if ACULOG char line [80]; #endif if (lock_baud) { int i; if ((i = speed(number(value(BAUDRATE)))) == 0) return 0; ttysetup (i); } if (boolean(value(VERBOSE))) printf("Using \"%s\"\n", acu); acu_hupcl (); /* * Get in synch. */ if (!multitechsync()) { badsynch: printf("can't synchronize with multitech\n"); #if ACULOG logent(value(HOST), num, "multitech", "can't synch up"); #endif return (0); } acu_nap (intercommand_delay); multitech_write_str (FD, echo_off_command); /* turn off echoing */ sleep(1); #ifdef DEBUG if (boolean(value(VERBOSE))) multitech_verbose_read(); #endif acu_flush (); acu_nap (intercommand_delay); multitech_write_str (FD, init_string); if (!multitech_swallow ("\r\nOK\r\n")) goto badsynch; fflush (stdout); acu_nap (intercommand_delay); multitech_write_str (FD, dial_command); for (cp = num; *cp; cp++) if (*cp == '=') *cp = ','; multitech_write_str (FD, num); multitech_write_str (FD, "\r"); connected = multitech_connect(); #if ACULOG if (timeout) { sprintf(line, "%d second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "multitech", line); } #endif if (timeout) multitech_disconnect (); return (connected); }
int main(int argc, char *argv[]) { char *sys = NOSTR, sbuf[12], *p; int i; /* XXX preserve previous braindamaged behavior */ setboolean(value(DC), TRUE); gid = getgid(); egid = getegid(); uid = getuid(); euid = geteuid(); if (equal(__progname, "cu")) { cumode = 1; cumain(argc, argv); goto cucommon; } if (argc > 4) { fprintf(stderr, "usage: tip [-v] [-speed] [system-name]\n"); exit(1); } if (!isatty(0)) { fprintf(stderr, "%s: must be interactive\n", __progname); exit(1); } for (; argc > 1; argv++, argc--) { if (argv[1][0] != '-') sys = argv[1]; else switch (argv[1][1]) { case 'v': vflag++; break; case 'n': noesc++; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': BR = atoi(&argv[1][1]); break; default: fprintf(stderr, "%s: %s, unknown option\n", __progname, argv[1]); break; } } if (sys == NOSTR) goto notnumber; if (isalpha(*sys)) goto notnumber; /* * System name is really a phone number... * Copy the number then stomp on the original (in case the number * is private, we don't want 'ps' or 'w' to find it). */ if (strlen(sys) > sizeof PNbuf - 1) { fprintf(stderr, "%s: phone number too long (max = %d bytes)\n", __progname, (int)sizeof(PNbuf) - 1); exit(1); } strlcpy(PNbuf, sys, sizeof PNbuf - 1); for (p = sys; *p; p++) *p = '\0'; PN = PNbuf; (void)snprintf(sbuf, sizeof(sbuf), "tip%ld", BR); sys = sbuf; notnumber: (void)signal(SIGINT, cleanup); (void)signal(SIGQUIT, cleanup); (void)signal(SIGHUP, cleanup); (void)signal(SIGTERM, cleanup); (void)signal(SIGCHLD, SIG_DFL); if ((i = hunt(sys)) == 0) { printf("all ports busy\n"); exit(3); } if (i == -1) { printf("link down\n"); (void)uu_unlock(uucplock); exit(3); } setbuf(stdout, NULL); loginit(); /* * Now that we have the logfile and the ACU open * return to the real uid and gid. These things will * be closed on exit. Swap real and effective uid's * so we can get the original permissions back * for removing the uucp lock. */ user_uid(); /* * Kludge, their's no easy way to get the initialization * in the right order, so force it here */ if ((PH = getenv("PHONES")) == NOSTR) PH = _PATH_PHONES; vinit(); /* init variables */ setparity("none"); /* set the parity table */ /* * Hardwired connections require the * line speed set before they make any transmissions * (this is particularly true of things like a DF03-AC) */ if (HW && ttysetup(number(value(BAUDRATE)))) { fprintf(stderr, "%s: bad baud rate %ld\n", __progname, number(value(BAUDRATE))); daemon_uid(); (void)uu_unlock(uucplock); exit(3); } if ((p = con())) { printf("\07%s\n[EOT]\n", p); daemon_uid(); (void)uu_unlock(uucplock); exit(1); } if (!HW && ttysetup(number(value(BAUDRATE)))) { fprintf(stderr, "%s: bad baud rate %ld\n", __progname, number(value(BAUDRATE))); daemon_uid(); (void)uu_unlock(uucplock); exit(3); } cucommon: /* * From here down the code is shared with * the "cu" version of tip. */ i = fcntl(FD, F_GETFL); if (i == -1) { perror("fcntl"); cleanup(0); } i = fcntl(FD, F_SETFL, i & ~O_NONBLOCK); if (i == -1) { perror("fcntl"); cleanup(0); } tcgetattr(0, &defterm); gotdefterm = 1; term = defterm; term.c_lflag &= ~(ICANON|IEXTEN|ECHO); term.c_iflag &= ~(INPCK|ICRNL); term.c_oflag &= ~OPOST; term.c_cc[VMIN] = 1; term.c_cc[VTIME] = 0; defchars = term; term.c_cc[VINTR] = term.c_cc[VQUIT] = term.c_cc[VSUSP] = term.c_cc[VDSUSP] = term.c_cc[VDISCARD] = term.c_cc[VLNEXT] = _POSIX_VDISABLE; raw(); pipe(fildes); pipe(repdes); (void)signal(SIGALRM, timeout); if (value(LINEDISC) != TTYDISC) { int ld = (int)(intptr_t)value(LINEDISC); ioctl(FD, TIOCSETD, &ld); } /* * Everything's set up now: * connection established (hardwired or dialup) * line conditioned (baud rate, mode, etc.) * internal data structures (variables) * so, fork one process for local side and one for remote. */ printf(cumode ? "Connected\r\n" : "\07connected\r\n"); tipin_pid = getpid(); if ((tipout_pid = fork())) tipin(); else tipout(); /*NOTREACHED*/ exit(0); }
/* * Botch the interface to look like cu's */ void cumain(int argc, char *argv[]) { int ch, i, parity; long l; char *cp; static char sbuf[12]; if (argc < 2) cuusage(); CU = DV = NOSTR; BR = DEFBR; parity = 0; /* none */ /* * We want to accept -# as a speed. It's easiest to look through * the arguments, replace -# with -s#, and let getopt() handle it. */ for (i = 1; i < argc; i++) { if (argv[i][0] == '-' && argv[i][1] >= '0' && argv[i][1] <= '9') { asprintf(&cp, "-s%s", argv[i] + 1); if (cp == NULL) { fprintf(stderr, "%s: cannot convert -# to -s#\n", __progname); exit(3); } argv[i] = cp; } } while ((ch = getopt(argc, argv, "a:l:s:htoe")) != -1) { switch (ch) { case 'a': CU = optarg; break; case 'l': if (DV != NULL) { fprintf(stderr, "%s: cannot specificy multiple -l options\n", __progname); exit(3); } if (strchr(optarg, '/')) DV = optarg; else asprintf(&DV, "/dev/%s", optarg); break; case 's': l = strtol(optarg, &cp, 10); if (*cp != '\0' || l < 0 || l >= INT_MAX) { fprintf(stderr, "%s: unsupported speed %s\n", __progname, optarg); exit(3); } BR = (int)l; break; case 'h': setboolean(value(LECHO), TRUE); HD = TRUE; break; case 't': HW = 1, DU = -1; break; case 'o': if (parity != 0) parity = 0; /* -e -o */ else parity = 1; /* odd */ break; case 'e': if (parity != 0) parity = 0; /* -o -e */ else parity = -1; /* even */ break; default: cuusage(); break; } } argc -= optind; argv += optind; switch (argc) { case 1: PN = argv[0]; break; case 0: break; default: cuusage(); break; } signal(SIGINT, cleanup); signal(SIGQUIT, cleanup); signal(SIGHUP, cleanup); signal(SIGTERM, cleanup); signal(SIGCHLD, SIG_DFL); /* * The "cu" host name is used to define the * attributes of the generic dialer. */ (void)snprintf(sbuf, sizeof(sbuf), "cu%ld", BR); if ((i = hunt(sbuf)) == 0) { printf("all ports busy\n"); exit(3); } if (i == -1) { printf("link down\n"); (void)uu_unlock(uucplock); exit(3); } setbuf(stdout, NULL); loginit(); user_uid(); vinit(); switch (parity) { case -1: setparity("even"); break; case 1: setparity("odd"); break; default: setparity("none"); break; } setboolean(value(VERBOSE), FALSE); if (HW && ttysetup(BR)) { fprintf(stderr, "%s: unsupported speed %ld\n", __progname, BR); daemon_uid(); (void)uu_unlock(uucplock); exit(3); } if (con()) { printf("Connect failed\n"); daemon_uid(); (void)uu_unlock(uucplock); exit(1); } if (!HW && ttysetup(BR)) { fprintf(stderr, "%s: unsupported speed %ld\n", __progname, BR); daemon_uid(); (void)uu_unlock(uucplock); exit(3); } }
int main(int argc, char *argv[]) { char *system = NULL; int i; char *p; char sbuf[12]; gid = getgid(); egid = getegid(); uid = getuid(); euid = geteuid(); #if INCLUDE_CU_INTERFACE if (equal(sname(argv[0]), "cu")) { cumode = 1; cumain(argc, argv); goto cucommon; } #endif /* INCLUDE_CU_INTERFACE */ if (argc > 4) usage(); if (!isatty(0)) errx(1, "must be interactive"); for (; argc > 1; argv++, argc--) { if (argv[1][0] != '-') system = argv[1]; else switch (argv[1][1]) { case 'v': vflag++; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': BR = atoi(&argv[1][1]); break; default: warnx("%s, unknown option", argv[1]); break; } } if (system == NULL) goto notnumber; if (isalpha(*system)) goto notnumber; /* * System name is really a phone number... * Copy the number then stomp on the original (in case the number * is private, we don't want 'ps' or 'w' to find it). */ if (strlen(system) > sizeof(PNbuf) - 1) errx(1, "phone number too long (max = %zd bytes)", sizeof PNbuf - 1); strncpy(PNbuf, system, sizeof(PNbuf) - 1); for (p = system; *p; p++) *p = '\0'; PN = PNbuf; (void)snprintf(sbuf, sizeof(sbuf), "tip%ld", BR); system = sbuf; notnumber: (void)signal(SIGINT, cleanup); (void)signal(SIGQUIT, cleanup); (void)signal(SIGHUP, cleanup); (void)signal(SIGTERM, cleanup); (void)signal(SIGUSR1, tipdone); if ((i = hunt(system)) == 0) { printf("all ports busy\n"); exit(3); } if (i == -1) { printf("link down\n"); (void)uu_unlock(uucplock); exit(3); } setbuf(stdout, NULL); loginit(); /* * Kludge, their's no easy way to get the initialization * in the right order, so force it here */ if ((PH = getenv("PHONES")) == NULL) PH = _PATH_PHONES; vinit(); /* init variables */ setparity("even"); /* set the parity table */ if ((i = speed(number(value(BAUDRATE)))) == 0) { printf("tip: bad baud rate %d\n", number(value(BAUDRATE))); (void)uu_unlock(uucplock); exit(3); } /* * Now that we have the logfile and the ACU open * return to the real uid and gid. These things will * be closed on exit. Swap real and effective uid's * so we can get the original permissions back * for removing the uucp lock. */ user_uid(); /* * Hardwired connections require the * line speed set before they make any transmissions * (this is particularly true of things like a DF03-AC) */ if (HW) ttysetup(i); if ((p = connect())) { printf("\07%s\n[EOT]\n", p); daemon_uid(); (void)uu_unlock(uucplock); exit(1); } if (!HW) ttysetup(i); cucommon: /* * From here down the code is shared with * the "cu" version of tip. */ #if HAVE_TERMIOS tcgetattr (0, &otermios); ctermios = otermios; #ifndef _POSIX_SOURCE ctermios.c_iflag = (IMAXBEL|IXANY|ISTRIP|IXON|BRKINT); ctermios.c_lflag = (PENDIN|IEXTEN|ISIG|ECHOCTL|ECHOE|ECHOKE); #else ctermios.c_iflag = (ISTRIP|IXON|BRKINT); ctermios.c_lflag = (PENDIN|IEXTEN|ISIG|ECHOE); #endif ctermios.c_cflag = (CLOCAL|HUPCL|CREAD|CS8); ctermios.c_cc[VINTR] = ctermios.c_cc[VQUIT] = -1; ctermios.c_cc[VSUSP] = ctermios.c_cc[VDSUSP] = ctermios.c_cc[VDISCARD] = ctermios.c_cc[VLNEXT] = -1; #else /* HAVE_TERMIOS */ ioctl(0, TIOCGETP, (char *)&defarg); ioctl(0, TIOCGETC, (char *)&defchars); ioctl(0, TIOCGLTC, (char *)&deflchars); ioctl(0, TIOCGETD, (char *)&odisc); arg = defarg; arg.sg_flags = ANYP | CBREAK; tchars = defchars; tchars.t_intrc = tchars.t_quitc = -1; ltchars = deflchars; ltchars.t_suspc = ltchars.t_dsuspc = ltchars.t_flushc = ltchars.t_lnextc = -1; #endif /* HAVE_TERMIOS */ raw(); pipe(fildes); pipe(repdes); (void)signal(SIGALRM, timeoutfunc); /* * Everything's set up now: * connection established (hardwired or dialup) * line conditioned (baud rate, mode, etc.) * internal data structures (variables) * so, fork one process for local side and one for remote. */ printf(cumode ? "Connected\r\n" : "\07connected\r\n"); if (LI != NULL && tiplink (LI, 0) != 0) { tipabort ("login failed"); } if ((pid = fork())) tipin(); else tipout(); /*NOTREACHED*/ }