BSD 4_3_Reno release
[unix-history] / usr / src / usr.sbin / sliplogin / sliplogin.c
index b93b34a..42afaf3 100644 (file)
@@ -1,22 +1,46 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement:  ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)sliplogin.c 1.3     MS/ACF  89/04/18";
-#endif
+char copyright[] =
+"@(#) Copyright (c) 1990 The Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)sliplogin.c        5.3 (Berkeley) 7/1/90";
+#endif /* not lint */
 
 /*
  * sliplogin.c
  * [MUST BE RUN SUID, SLOPEN DOES A SUSER()!]
  *
  * This program initializes its own tty port to be an async TCP/IP interface.
 
 /*
  * sliplogin.c
  * [MUST BE RUN SUID, SLOPEN DOES A SUSER()!]
  *
  * This program initializes its own tty port to be an async TCP/IP interface.
- * It merely sets up the SLIP module all by its lonesome on the STREAMS stack,
- * initializes the network interface, and pauses forever waiting for hangup.
+ * It sets the line discipline to slip, invokes a shell script to initialize
+ * the network interface, then pauses forever waiting for hangup.
  *
  * It is a remote descendant of several similar programs with incestuous ties:
  * - Kirk Smith's slipconf, modified by Richard Johnsson @ DEC WRL.
  * - slattach, probably by Rick Adams but touched by countless hordes.
  * - the original sliplogin for 4.2bsd, Doug Kingston the mover behind it.
  *
  * It is a remote descendant of several similar programs with incestuous ties:
  * - Kirk Smith's slipconf, modified by Richard Johnsson @ DEC WRL.
  * - slattach, probably by Rick Adams but touched by countless hordes.
  * - the original sliplogin for 4.2bsd, Doug Kingston the mover behind it.
- * - a simple slattach-like program used to test the STREAMS SLIP code.
  *
  *
- * There are three basic forms of usage:
+ * There are two forms of usage:
  *
  * "sliplogin"
  * Invoked simply as "sliplogin" and a realuid != 0, the program looks up
  *
  * "sliplogin"
  * Invoked simply as "sliplogin" and a realuid != 0, the program looks up
@@ -27,122 +51,183 @@ static char *sccsid = "@(#)sliplogin.c    1.3     MS/ACF  89/04/18";
  * "sliplogin IPhost1 </dev/ttyb"
  * Invoked by root with a username, the name is looked up in the
  * /etc/hosts.slip file and if found fd0 is configured as in case 1.
  * "sliplogin IPhost1 </dev/ttyb"
  * Invoked by root with a username, the name is looked up in the
  * /etc/hosts.slip file and if found fd0 is configured as in case 1.
- *
- * "sliplogin 192.100.1.1 192.100.1.2 255.255.255.0 < /dev/ttyb"
- * Finally, if invoked with a remote addr, local addr, and optionally
- * a net mask, the line on fd0 is setup as specified if the user is root.
- *
- * Doug Kingston 8810??                - logging + first pass at adding I_STR ioctl's
- * Rayan Zachariassen 881011   - version for SunOS STREAMS SLIP
  */
 
  */
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/socket.h>
-#include <sys/termios.h>
 #include <sys/ioctl.h>
 #include <sys/ioctl.h>
+#include <sys/signal.h>
 #include <sys/file.h>
 #include <sys/syslog.h>
 #include <sys/file.h>
 #include <sys/syslog.h>
+#include <netdb.h>
 
 
+#if defined(BSD4_4)
+#define TERMIOS
+#endif
+#ifdef TERMIOS
+#include <sys/termios.h>
+#include <ttyent.h>
+#endif
 #include <netinet/in.h>
 #include <net/if.h>
 #include <netinet/in.h>
 #include <net/if.h>
-#include <net/if_slvar.h>      /* XXX */
+#include <net/if_slvar.h>
 
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
 
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
-#include <netdb.h>
-
-#include <signal.h>
-#include <strings.h>
-#include <pwd.h>
-#include <ttyent.h>
-
-#define        SLIPIFNAME      "sl"
-
-#define ADDR   1
-#define MASK   2
+#include <string.h>
+#include "pathnames.h"
 
 
-#define        DCD_CHECK_INTERVAL 5    /* if > 0, time between automatic DCD checks */
-#define        DCD_SETTLING_TIME 1     /* time between DCD change and status check */
+int    unit;
+int    slip_mode;
+int    speed;
+char   loginargs[BUFSIZ];
+char   loginfile[BUFSIZ];
+char   logoutfile[BUFSIZ];
+char   loginname[BUFSIZ];
 
 
-int gotalarm = 0;
-int timeleft = DCD_CHECK_INTERVAL;
+struct slip_modes {
+       char    *sm_name;
+       int     sm_value;
+}       modes[] = {
+       "normal",       0,              
+       "compress",     SC_COMPRESS,   
+       "noicmp",       SC_NOICMP,
+       "autocomp",     SC_AUTOCOMP
+};
 
 void
 
 void
-alarm_handler()
+findid(name)
+       char *name;
 {
 {
-       /*if (timeleft > DCD_SETTLING_TIME)
-               (void) alarm(timeleft-DCD_SETTLING_TIME);
-       else */
-               (void) alarm(DCD_CHECK_INTERVAL);
-       gotalarm = 1;
-       timeleft = 0;
-}
+       FILE *fp;
+       static char slopt[5][16];
+       static char laddr[16];
+       static char raddr[16];
+       static char mask[16];
+       char user[16];
+       int i, j, n;
 
 
-#if    defined(SIGDCD) && SIGDCD > 0
-void
-dcd_handler()
-{
-#if    DCD_SETTLING_TIME > 0
-       timeleft = alarm(DCD_SETTLING_TIME);
-#else
-       gotalarm = 1;
-#endif /* DCD_SETTLING_TIME */
-}
-#endif
+       (void)strcpy(loginname, name);
+       if ((fp = fopen(_PATH_ACCESS, "r")) == NULL) {
+               (void)fprintf(stderr, "sliplogin: %s: %s\n",
+                   _PATH_ACCESS, strerror(errno));
+               syslog(LOG_ERR, "%s: %m\n", _PATH_ACCESS);
+               exit(1);
+       }
+       while (fgets(loginargs, sizeof(loginargs) - 1, fp)) {
+               if (ferror(fp))
+                       break;
+               n = sscanf(loginargs, "%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s\n",
+                        user, laddr, raddr, mask, slopt[0], slopt[1], 
+                       slopt[2], slopt[3], slopt[4]);
+               if (user[0] == '#' || isspace(user[0]))
+                       continue;
+               if (strcmp(user, name) != 0)
+                       continue;
 
 
-/* Use TIOCMGET to test if DCD is low on the port of the passed descriptor */
+               slip_mode = 0;
+               for (i = 0; i < n - 4; i++) {
+                       for (j = 0; j < sizeof(modes)/sizeof(struct slip_modes);
+                               j++) {
+                               if (strcmp(modes[j].sm_name, slopt[i]) == 0) {
+                                       slip_mode |= modes[j].sm_value;
+                                       break;
+                               }
+                       }
+               }
 
 
-int
-lowdcd(fd)
-       int fd;
-{
-       int mbits;
+               /*
+                * we've found the guy we're looking for -- see if
+                * there's a login file we can use.  First check for
+                * one specific to this host.  If none found, try for
+                * a generic one.
+                */
+               (void)sprintf(loginfile, "%s.%s", _PATH_LOGIN, name);
+               if (access(loginfile, R_OK|X_OK)) {
+                       (void)strcpy(loginfile, _PATH_LOGIN);
+                       (void)strcpy(logoutfile, _PATH_LOGOUT);
+                       if (access(loginfile, R_OK|X_OK)) {
+                               fputs("access denied - no login file\n",
+                                     stderr);
+                               syslog(LOG_ERR,
+                                      "access denied for %s - no %s\n",
+                                      name, _PATH_LOGIN);
+                               exit(5);
+                       }
+               } else
+                       (void)sprintf(logoutfile, "%s.%s", _PATH_LOGOUT, name);
 
 
-       if (ioctl(fd, TIOCMGET, (caddr_t)&mbits) < 0)
-               return 1;       /* port is dead, we die */
-       return !(mbits & TIOCM_CAR);
+               (void) fclose(fp);
+               return;
+       }
+       (void)fprintf(stderr, "SLIP access denied for %s\n", name);
+       syslog(LOG_ERR, "SLIP access denied for %s\n", name);
+       exit(4);
+       /* NOTREACHED */
 }
 
 }
 
-/* Use TIOCMGET to test if DTR is low on the port of the passed descriptor */
-
-int
-lowdtr(fd)
-       int fd;
+char *
+sigstr(s)
+       int s;
 {
 {
-       int mbits;
-
-       if (ioctl(fd, TIOCMGET, (caddr_t)&mbits) < 0)
-               return 1;       /* port is dead, we die */
-       return ((mbits & TIOCM_DTR) == TIOCM_DTR);
+       static char buf[32];
+
+       switch (s) {
+       case SIGHUP:    return("HUP");
+       case SIGINT:    return("INT");
+       case SIGQUIT:   return("QUIT");
+       case SIGILL:    return("ILL");
+       case SIGTRAP:   return("TRAP");
+       case SIGIOT:    return("IOT");
+       case SIGEMT:    return("EMT");
+       case SIGFPE:    return("FPE");
+       case SIGKILL:   return("KILL");
+       case SIGBUS:    return("BUS");
+       case SIGSEGV:   return("SEGV");
+       case SIGSYS:    return("SYS");
+       case SIGPIPE:   return("PIPE");
+       case SIGALRM:   return("ALRM");
+       case SIGTERM:   return("TERM");
+       case SIGURG:    return("URG");
+       case SIGSTOP:   return("STOP");
+       case SIGTSTP:   return("TSTP");
+       case SIGCONT:   return("CONT");
+       case SIGCHLD:   return("CHLD");
+       case SIGTTIN:   return("TTIN");
+       case SIGTTOU:   return("TTOU");
+       case SIGIO:     return("IO");
+       case SIGXCPU:   return("XCPU");
+       case SIGXFSZ:   return("XFSZ");
+       case SIGVTALRM: return("VTALRM");
+       case SIGPROF:   return("PROF");
+       case SIGWINCH:  return("WINCH");
+#ifdef SIGLOST
+       case SIGLOST:   return("LOST");
+#endif
+       case SIGUSR1:   return("USR1");
+       case SIGUSR2:   return("USR2");
+       }
+       (void)sprintf(buf, "sig %d", s);
+       return(buf);
 }
 
 }
 
-char   *Accessfile = "/etc/hosts.slip";
-
-extern char *malloc(), *ttyname();
-extern struct passwd *getpwuid();
-
-char   *dstaddr, *localaddr, *netmask;
-int    slip_mode, unit;
-
-struct slip_modes {
-       char    *sm_name;
-       int     sm_value;
-}       modes[] = {
-       "normal",       0,              /* slip "standard" ala Rick Adams */
-       "compress",     SC_COMPRESS,    /* Van Jacobsen's tcp header comp. */
-       "noicmp",       SC_NOICMP,      /* Sam's(?) ICMP suppression */
-} ;
-
-/*
- * If we are uncerimoniously dumped, bitch
- */
-void
-hup_handler()
+int
+hup_handler(s)
+       int s;
 {
 {
-syslog(LOG_NOTICE, "connection closed: process aborted %s%d: remote %s\n",
-               SLIPIFNAME, unit, dstaddr);
-       exit(1) ;
+       if (access(logoutfile, R_OK|X_OK) == 0) {
+               char logincmd[2*BUFSIZ+32];
+
+               (void)sprintf(logincmd, "%s %d %d %s", logoutfile, unit, speed,
+                             loginargs);
+               (void)system(logincmd);
+       }
+       (void)close(0);
+       syslog(LOG_INFO, "closed %s slip unit %d (%s)\n", loginname, unit,
+              sigstr(s));
+       exit(1);
+       /* NOTREACHED */
 }
 
 main(argc, argv)
 }
 
 main(argc, argv)
@@ -150,63 +235,88 @@ main(argc, argv)
        char *argv[];
 {
        int     fd, s, ldisc, odisc;
        char *argv[];
 {
        int     fd, s, ldisc, odisc;
+       char *name;
+#ifdef TERMIOS
        struct  termios tios, otios;
        struct  termios tios, otios;
-       struct  ifreq ifr;
+#else
+       struct  sgttyb tty, otty;
+#endif
+       char logincmd[2*BUFSIZ+32];
+       extern uid_t getuid();
 
 
+       if ((name = strrchr(argv[0], '/')) == NULL)
+               name = argv[0];
        s = getdtablesize();
        for (fd = 3 ; fd < s ; fd++)
        s = getdtablesize();
        for (fd = 3 ; fd < s ; fd++)
-               close(fd);
-       openlog("sliplogin", LOG_PID, LOG_DAEMON);
-       if (getuid() == 0) {
-               if (argc <= 1) {
-                       fprintf(stderr, "Usage: %s loginname\n", argv[0]);
-                       fprintf(stderr, "   or: %s dstaddr localaddr [mask]\n",
-                                       argv[0]);
+               (void) close(fd);
+       openlog(name, LOG_PID, LOG_DAEMON);
+       if (argc > 1) {
+               if (argc > 2) {
+                       (void)fprintf(stderr, "Usage: %s loginname\n", argv[0]);
                        exit(1);
                        exit(1);
-               } else if (argc == 2) {
-                       findid(argv[1]);
-                       fprintf(stderr, "local %s remote %s mask %s\n",
-                               localaddr, dstaddr, netmask);
-               } if (argc > 2) {
-                       if (argc < 3 || argc > 4) {
-                               fprintf(stderr,
-                                       "Usage: %s dstaddr localaddr [mask]\n",
-                                       argv[0]);
-                               exit(1);
-                       }
-                       dstaddr = argv[1];
-                       localaddr = argv[2];
-                       if (argc == 4)
-                               netmask = argv[3];
-                       else
-                               netmask = "default";
                }
                }
-       } else
-               findid((char *)0);
-       /* ensure that the slip line is our controlling terminal */
-       if ((fd = open("/dev/tty", O_RDONLY, 0)) >= 0) {
-               (void) ioctl(fd, TIOCNOTTY, 0);
-               (void) close(fd);
-               fd = open(ttyname(0), O_RDWR, 0);
-               if (fd >= 0)
+               findid(argv[1]);
+
+               /*
+                * Disassociate from current controlling terminal, if any,
+                * and ensure that the slip line is our controlling terminal.
+                */
+#ifdef TERMIOS
+               (void) setsid();
+               (void) ioctl(0, TIOCSCTTY, (caddr_t)0);
+#else
+               if ((fd = open("/dev/tty", O_RDONLY, 0)) >= 0) {
+                       extern char *ttyname();
+
+                       (void) ioctl(fd, TIOCNOTTY, (caddr_t)0);
                        (void) close(fd);
                        (void) close(fd);
+                       /* open slip tty again to acquire as controlling tty? */
+                       fd = open(ttyname(0), O_RDWR, 0);
+                       if (fd >= 0)
+                               (void) close(fd);
+               }
                (void) setpgrp(0, getpid());
                (void) setpgrp(0, getpid());
+#endif
+       } else {
+               extern char *getenv();
+
+               if ((name = getenv("USER")) == NULL) {
+                       (void) fprintf(stderr, "access denied - no username\n");
+                       syslog(LOG_ERR, "access denied - no username\n");
+                       exit(1);
+               }
+               findid(name);
        }
        }
-       fchmod(0, 0600);
+       (void) fchmod(0, 0600);
+       (void) fprintf(stderr, "starting slip login for %s\n", loginname);
+#ifdef TERMIOS
        /* set up the line parameters */
        /* set up the line parameters */
-       if (ioctl(0, TCGETA, (caddr_t)&tios) < 0) {
-               syslog(LOG_ERR, "ioctl (TCGETA): %m");
+       if (ioctl(0, TIOCGETA, (caddr_t)&tios) < 0) {
+               syslog(LOG_ERR, "ioctl (TIOCGETA): %m");
                exit(1);
        }
                exit(1);
        }
-       otios = tios ;
-       tios.c_cflag &= 0xf;    /* only save the speed */
-       tios.c_cflag |= CS8|CREAD|HUPCL;
+       otios = tios;
+       tios.c_cflag = CS8|CREAD|HUPCL;
        tios.c_iflag = IGNBRK;
        tios.c_oflag = tios.c_lflag = 0;
        tios.c_iflag = IGNBRK;
        tios.c_oflag = tios.c_lflag = 0;
-       if (ioctl(0, TCSETA, (caddr_t)&tios) < 0) {
-               syslog(LOG_ERR, "ioctl (TCSETA) (1): %m");
+       if (ioctl(0, TIOCSETA, (caddr_t)&tios) < 0) {
+               syslog(LOG_ERR, "ioctl (TIOCSETA) (1): %m");
                exit(1);
        }
                exit(1);
        }
+#else
+       /* set up the line parameters */
+       if (ioctl(0, TIOCGETP, (caddr_t)&tty) < 0) {
+               syslog(LOG_ERR, "ioctl (TIOCGETP): %m");
+               exit(1);
+       }
+       otty = tty;
+       speed = tty.sg_ispeed;
+       tty.sg_flags = RAW | ANYP;
+       if (ioctl(0, TIOCSETP, (caddr_t)&tty) < 0) {
+               syslog(LOG_ERR, "ioctl (TIOCSETP): %m");
+               exit(1);
+       }
+#endif
        /* find out what ldisc we started with */
        if (ioctl(0, TIOCGETD, (caddr_t)&odisc) < 0) {
                syslog(LOG_ERR, "ioctl(TIOCGETD) (1): %m");
        /* find out what ldisc we started with */
        if (ioctl(0, TIOCGETD, (caddr_t)&odisc) < 0) {
                syslog(LOG_ERR, "ioctl(TIOCGETD) (1): %m");
@@ -214,7 +324,7 @@ main(argc, argv)
        }
        ldisc = SLIPDISC;
        if (ioctl(0, TIOCSETD, (caddr_t)&ldisc) < 0) {
        }
        ldisc = SLIPDISC;
        if (ioctl(0, TIOCSETD, (caddr_t)&ldisc) < 0) {
-               syslog(LOG_ERR, "ioctl(TIOCSETD) (1): %m");
+               syslog(LOG_ERR, "ioctl(TIOCSETD): %m");
                exit(1);
        }
        /* find out what unit number we were assigned */
                exit(1);
        }
        /* find out what unit number we were assigned */
@@ -222,191 +332,40 @@ main(argc, argv)
                syslog(LOG_ERR, "ioctl (TIOCGETD) (2): %m");
                exit(1);
        }
                syslog(LOG_ERR, "ioctl (TIOCGETD) (2): %m");
                exit(1);
        }
-       syslog(LOG_NOTICE, "attaching %s%d: local %s remote %s mask %s\n",
-               SLIPIFNAME, unit, localaddr, dstaddr, netmask);
-#ifdef notdef
-       /* set the local and remote interface addresses */
-       s = socket(AF_INET, SOCK_DGRAM, 0);
-       if (getuid() != 0 || argc == 4) {
-               (void) sprintf(ifr.ifr_name, "%s%d", SLIPIFNAME, unit);
-               in_getaddr(netmask, &ifr.ifr_addr, MASK);
-               if (ioctl(s, SIOCSIFNETMASK, (caddr_t)&ifr) < 0) {
-                       syslog(LOG_ERR, "ioctl (SIOCSIFNETMASK): %m");
+       (void) signal(SIGHUP, hup_handler);
+       (void) signal(SIGTERM, hup_handler);
+
+       syslog(LOG_INFO, "attaching slip unit %d for %s\n", unit, loginname);
+       (void)sprintf(logincmd, "%s %d %d %s", loginfile, unit, speed,
+                     loginargs);
+       /*
+        * aim stdout and errout at /dev/null so logincmd output won't
+        * babble into the slip tty line.
+        */
+       (void)close(1);
+       if ((fd = open("/dev/null", O_WRONLY, 0)) != 1) {
+               if (fd < 0) {
+                       syslog(LOG_ERR, "open /dev/null: %m");
                        exit(1);
                }
                        exit(1);
                }
+               (void)dup2(fd, 1);
+               (void)close(fd);
        }
        }
-       (void) sprintf(ifr.ifr_name, "%s%d", SLIPIFNAME, unit);
-       in_getaddr(dstaddr, &ifr.ifr_addr, ADDR);
-       if (ioctl(s, SIOCSIFDSTADDR, (caddr_t)&ifr) < 0) {
-               syslog(LOG_ERR, "ioctl (SIOCSIFDSTADDR): %m");
-               exit(1);
-       }
-       (void) sprintf(ifr.ifr_name, "%s%d", SLIPIFNAME, unit);
-       in_getaddr(localaddr, &ifr.ifr_addr, ADDR);
-       /* this has the side-effect of marking the interface up */
-       if (ioctl(s, SIOCSIFADDR, (caddr_t)&ifr) < 0) {
-               syslog(LOG_ERR, "ioctl (SIOCSIFADDR): %m");
-               exit(1);
-       }
-#else
-       /* XXX -- give up for now and just invoke ifconfig XXX */
-       { char cmd[256];
-         sprintf(cmd, "/sbin/ifconfig %s%d inet %s %s netmask %s",
-             SLIPIFNAME, unit, localaddr, dstaddr, netmask);
-         system(cmd);
+       (void)dup2(1,2);
+       if (s = system(logincmd)) {
+               syslog(LOG_ERR, "%s login failed: exit status %d from %s",
+                      loginname, s, loginfile);
+               (void) ioctl(0, TIOCSETD, (caddr_t)&odisc);
+               exit(6);
        }
        if (ioctl(0, SLIOCSFLAGS, (caddr_t)&slip_mode) < 0) {
                syslog(LOG_ERR, "ioctl (SLIOCSFLAGS): %m");
                exit(1);
        }
        }
        if (ioctl(0, SLIOCSFLAGS, (caddr_t)&slip_mode) < 0) {
                syslog(LOG_ERR, "ioctl (SLIOCSFLAGS): %m");
                exit(1);
        }
-#endif
-
-       /* set up signal handlers */
-#if    defined(SIGDCD) && SIGDCD > 0
-       (void) signal(SIGDCD, dcd_handler);
-#endif
-       (void) sigblock(sigmask(SIGALRM));
-       (void) signal(SIGALRM, alarm_handler);
-       /* a SIGHUP will kill us */
-       (void) signal(SIGHUP, hup_handler);
-       (void) signal(SIGTERM, hup_handler);
-
-       /* timeleft = 60 * 60 * 24 * 365 ; (void) alarm(timeleft); */
-       (void) alarm(DCD_CHECK_INTERVAL);
 
        /* twiddle thumbs until we get a signal */
 
        /* twiddle thumbs until we get a signal */
-       while (1) {
+       while (1)
                sigpause(0);
                sigpause(0);
-               (void) sigblock(sigmask(SIGALRM));
-               if (gotalarm && lowdcd(0))
-                       break;
-               if (gotalarm && lowdtr(0))
-                       break;
-               gotalarm = 0;
-       }
-
-       if (lowdcd(0))
-               syslog(LOG_NOTICE,
-                       "connection closed: loss of carrier %s%d: remote %s\n",
-                       SLIPIFNAME, unit, dstaddr);
-       else if (lowdtr(0))
-               syslog(LOG_NOTICE,
-                       "connection closed by foreign host %s%d: remote %s\n",
-                       SLIPIFNAME, unit, dstaddr);
-
-       if (ioctl(0, TIOCSETD, (caddr_t)&odisc) < 0) {
-               syslog(LOG_ERR, "ioctl(TIOCSETD) (2): %m");
-               exit(1);
-       }
-       if (ioctl(0, TCSETA, (caddr_t)&otios) < 0) {
-               syslog(LOG_ERR, "ioctl (TCSETA) (2): %m");
-               exit(1);
-       }
-       exit(0);
-}
-
-findid(name)
-       char *name;
-{
-       char buf[BUFSIZ];
-       static char mode[16];
-       static char laddr[16];
-       static char raddr[16];
-       static char mask[16];
-       char user[16];
-       FILE *fp;
-       struct passwd *pw;
-       int n;
-
-       if (name == NULL && (pw = getpwuid(getuid())) == NULL) {
-               fprintf(stderr, "Your UID (%d) is unknown\n", getuid());
-               syslog(LOG_ERR, "UID (%d) is unknown\n", getuid());
-               exit(1);
-       } else if (name == NULL)
-               name = pw->pw_name;
-       if ((fp = fopen(Accessfile, "r")) == NULL) {
-               perror(Accessfile);
-               syslog(LOG_ERR, "%s: %m\n", Accessfile);
-               exit(3);
-       }
-       while (fgets(buf, sizeof(buf) - 1, fp)) {
-               if (ferror(fp))
-                       break;
-               n = sscanf(buf, "%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s%*[ \t]%15s\n",
-                       user, mode, laddr, raddr, mask);
-               if (user[0] == '#' || n != 5)
-                       continue;
-               if (strcmp(user, name) == 0) {
-                       char *p,*q; int val, i, domore;
 
 
-                       p = q = mode;   val = 0;
-               loop:
-                       while (isalnum(*p)) p++;
-                       if(ispunct(*p) || *p == '\0') {
-                               if(ispunct(*p)) domore = 1; else domore = 0;
-                               *p++ = '\0' ; 
-                               for (i = 0; i <
-                                       sizeof(modes)/sizeof(struct slip_modes)
-                                        ; i++) {
-                                       if (strcmp(modes[i].sm_name, q) == 0) {
-                                               val |= modes[i].sm_value ;
-                                               break;
-                                       } ;
-}
-                               q = p;
-                               if(domore)goto loop;
-                       }
-
-                       slip_mode = val ;
-                       localaddr = laddr;
-                       dstaddr = raddr;
-                       netmask = mask;
-                       fclose(fp);
-                       return 0;
-               }
-               if (feof(fp))
-                       break;
-       }
-       fputs("SLIP access denied\n", stderr);
-       syslog(LOG_ERR, "SLIP access denied for %s\n", name);
-       exit(4);
-}
-
-in_getaddr(s, saddr, which)
-       char *s;
-       struct sockaddr *saddr;
-       int which;
-{
-       register struct sockaddr_in *sin = (struct sockaddr_in *)saddr;
-       struct hostent *hp;
-       struct netent *np;
-       int val;
-       extern struct in_addr inet_makeaddr();
-       bzero((caddr_t)saddr, sizeof *saddr);
-       if (which == ADDR) {
-               sin->sin_len = sizeof (*sin);
-               sin->sin_family = AF_INET;
-       } else
-               sin->sin_len = 8;
-       val = inet_addr(s);
-       if (val != -1) {
-               sin->sin_addr.s_addr = val;
-               return;
-       }
-       hp = gethostbyname(s);
-       if (hp) {
-               sin->sin_family = hp->h_addrtype;
-               bcopy(hp->h_addr, (char *)&sin->sin_addr, hp->h_length);
-               return;
-       }
-       np = getnetbyname(s);
-       if (np) {
-               sin->sin_family = np->n_addrtype;
-               sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY);
-               return;
-       }
-       fprintf(stderr, "sliplogin: %s: bad value\n", s);
-       syslog(LOG_ERR, "%s: bad value\n", s);
-       exit(1);
+       /* NOTREACHED */
 }
 }