pty library
authorMarc Teitelbaum <marc@ucbvax.Berkeley.EDU>
Fri, 29 Jun 1990 13:38:05 +0000 (05:38 -0800)
committerMarc Teitelbaum <marc@ucbvax.Berkeley.EDU>
Fri, 29 Jun 1990 13:38:05 +0000 (05:38 -0800)
SCCS-vsn: libexec/telnetd/telnetd.c 5.46
SCCS-vsn: libexec/telnetd/sys_term.c 5.9

usr/src/libexec/telnetd/sys_term.c
usr/src/libexec/telnetd/telnetd.c

index 3379831..145ca2d 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)sys_term.c 5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)sys_term.c 5.9 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -1021,21 +1021,19 @@ char *host;
        /*
         * set up standard paths before forking to login
         */
        /*
         * set up standard paths before forking to login
         */
-#ifndef        NO_SETSID
-       if (setsid() < 0)
-               fatalperror(net, "setsid");
-#endif
-
-#ifdef TIOCSCTTY
-       if (ioctl(t, TIOCSCTTY, (char *)0) < 0)
-               fatalperror(net, "ioctl(sctty)");
-#endif
-       (void) close(net);
-       (void) close(pty);
+#if BSD > 43
+       if (login_tty(t) == -1)
+               fatalperror(net, "login_tty");
+#else
        (void) dup2(t, 0);
        (void) dup2(t, 1);
        (void) dup2(t, 2);
        (void) close(t);
        (void) dup2(t, 0);
        (void) dup2(t, 1);
        (void) dup2(t, 2);
        (void) close(t);
+#endif
+       if (net > 2)
+               (void) close(net);
+       if (pty > 2)
+               (void) close(pty);
        /*
         * -h : pass on name of host.
         *              WARNING:  -h is accepted by login if and only if
        /*
         * -h : pass on name of host.
         *              WARNING:  -h is accepted by login if and only if
index 2df6780..b6a70d5 100644 (file)
@@ -12,7 +12,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)telnetd.c  5.45 (Berkeley) %G%";
+static char sccsid[] = "@(#)telnetd.c  5.46 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -449,7 +449,14 @@ doit(who)
        char *host, *inet_ntoa();
        int t;
        struct hostent *hp;
        char *host, *inet_ntoa();
        int t;
        struct hostent *hp;
+#if BSD > 43
+       extern char *line;
 
 
+       if (openpty(&pty, &t, line, NULL, NULL) == -1)
+               fatal(net, "All network ports in use");
+       init_termbuf();
+#else
+       
        /*
         * Find an available pty to use.
         */
        /*
         * Find an available pty to use.
         */
@@ -458,6 +465,7 @@ doit(who)
                fatal(net, "All network ports in use");
 
        t = getptyslave();
                fatal(net, "All network ports in use");
 
        t = getptyslave();
+#endif
 
        /* get name of connected client */
        hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr),
 
        /* get name of connected client */
        hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr),