]> andersk Git - gssapi-openssh.git/blobdiff - openssh/sshpty.c
The man2html from jbasney on pkilab2 works whereas the standard one doesn't.
[gssapi-openssh.git] / openssh / sshpty.c
index 4747ceaf4d097f48961fcfa127335846f30de4bd..e1e60314109f14da39bab97c4db3d36b240b9b9a 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: sshpty.c,v 1.10 2003/06/12 07:57:38 markus Exp $");
+RCSID("$OpenBSD: sshpty.c,v 1.3 2001/07/22 21:32:27 markus Exp $");
 
 #ifdef HAVE_UTIL_H
 # include <util.h>
@@ -101,12 +101,12 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
                error("/dev/ptmx: %.100s", strerror(errno));
                return 0;
        }
-       old_signal = signal(SIGCHLD, SIG_DFL);
+       old_signal = mysignal(SIGCHLD, SIG_DFL);
        if (grantpt(ptm) < 0) {
                error("grantpt: %.100s", strerror(errno));
                return 0;
        }
-       signal(SIGCHLD, old_signal);
+       mysignal(SIGCHLD, old_signal);
        if (unlockpt(ptm) < 0) {
                error("unlockpt: %.100s", strerror(errno));
                return 0;
@@ -156,16 +156,16 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
        *ttyfd = open(name, O_RDWR | O_NOCTTY);
        if (*ttyfd < 0) {
                error("Could not open pty slave side %.100s: %.100s",
-                   name, strerror(errno));
+                     name, strerror(errno));
                close(*ptyfd);
                return 0;
        }
        return 1;
 #else /* HAVE_DEV_PTS_AND_PTC */
-#ifdef _UNICOS
+#ifdef _CRAY
        char buf[64];
-       int i;
-       int highpty;
+       int i;
+       int highpty;
 
 #ifdef _SC_CRAY_NPTY
        highpty = sysconf(_SC_CRAY_NPTY);
@@ -199,7 +199,6 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
        const char *ptyminors = "0123456789abcdef";
        int num_minors = strlen(ptyminors);
        int num_ptys = strlen(ptymajors) * num_minors;
-       struct termios tio;
 
        for (i = 0; i < num_ptys; i++) {
                snprintf(buf, sizeof buf, "/dev/pty%c%c", ptymajors[i / num_minors],
@@ -224,19 +223,6 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
                        close(*ptyfd);
                        return 0;
                }
-               /* set tty modes to a sane state for broken clients */
-               if (tcgetattr(*ptyfd, &tio) < 0)
-                       logit("Getting tty modes for pty failed: %.100s", strerror(errno));
-               else {
-                       tio.c_lflag |= (ECHO | ISIG | ICANON);
-                       tio.c_oflag |= (OPOST | ONLCR);
-                       tio.c_iflag |= ICRNL;
-
-                       /* Set the new modes for the terminal. */
-                       if (tcsetattr(*ptyfd, TCSANOW, &tio) < 0)
-                               logit("Setting tty modes for pty failed: %.100s", strerror(errno));
-               }
-
                return 1;
        }
        return 0;
@@ -258,7 +244,7 @@ pty_release(const char *ttyname)
                error("chmod %.100s 0666 failed: %.100s", ttyname, strerror(errno));
 }
 
-/* Makes the tty the process's controlling tty and sets it to sane modes. */
+/* Makes the tty the processes controlling tty and sets it to sane modes. */
 
 void
 pty_make_controlling_tty(int *ttyfd, const char *ttyname)
@@ -268,15 +254,15 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
        void *old;
 #endif /* USE_VHANGUP */
 
-#ifdef _UNICOS
+#ifdef _CRAY
        if (setsid() < 0)
                error("setsid: %.100s", strerror(errno));
 
        fd = open(ttyname, O_RDWR|O_NOCTTY);
        if (fd != -1) {
-               signal(SIGHUP, SIG_IGN);
+               mysignal(SIGHUP, SIG_IGN);
                ioctl(fd, TCVHUP, (char *)NULL);
-               signal(SIGHUP, SIG_DFL);
+               mysignal(SIGHUP, SIG_DFL);
                setpgid(0, 0);
                close(fd);
        } else {
@@ -289,8 +275,8 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
        if (fd < 0)
                error("%.100s: %.100s", ttyname, strerror(errno));
        close(*ttyfd);
-       *ttyfd = fd;
-#else /* _UNICOS */
+               *ttyfd = fd;
+#else /* _CRAY */
 
        /* First disconnect from the old controlling tty. */
 #ifdef TIOCNOTTY
@@ -323,9 +309,9 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
                error("SETPGRP %s",strerror(errno));
 #endif /* HAVE_NEWS4 */
 #ifdef USE_VHANGUP
-       old = signal(SIGHUP, SIG_IGN);
+       old = mysignal(SIGHUP, SIG_IGN);
        vhangup();
-       signal(SIGHUP, old);
+       mysignal(SIGHUP, old);
 #endif /* USE_VHANGUP */
        fd = open(ttyname, O_RDWR);
        if (fd < 0) {
@@ -342,20 +328,20 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
        fd = open(_PATH_TTY, O_WRONLY);
        if (fd < 0)
                error("open /dev/tty failed - could not set controlling tty: %.100s",
-                   strerror(errno));
-       else 
+                     strerror(errno));
+       else {
                close(fd);
-#endif /* _UNICOS */
+       }
+#endif /* _CRAY */
 }
 
 /* Changes the window size associated with the pty. */
 
 void
 pty_change_window_size(int ptyfd, int row, int col,
-       int xpixel, int ypixel)
+                      int xpixel, int ypixel)
 {
        struct winsize w;
-
        w.ws_row = row;
        w.ws_col = col;
        w.ws_xpixel = xpixel;
@@ -392,15 +378,15 @@ pty_setowner(struct passwd *pw, const char *ttyname)
 
        if (st.st_uid != pw->pw_uid || st.st_gid != gid) {
                if (chown(ttyname, pw->pw_uid, gid) < 0) {
-                       if (errno == EROFS &&
-                           (st.st_uid == pw->pw_uid || st.st_uid == 0))
-                               debug("chown(%.100s, %u, %u) failed: %.100s",
-                                   ttyname, (u_int)pw->pw_uid, (u_int)gid,
-                                   strerror(errno));
+                       if (errno == EROFS && 
+                          (st.st_uid == pw->pw_uid || st.st_uid == 0))
+                               error("chown(%.100s, %d, %d) failed: %.100s",
+                                     ttyname, pw->pw_uid, gid,
+                                     strerror(errno));
                        else
-                               fatal("chown(%.100s, %u, %u) failed: %.100s",
-                                   ttyname, (u_int)pw->pw_uid, (u_int)gid,
-                                   strerror(errno));
+                               fatal("chown(%.100s, %d, %d) failed: %.100s",
+                                     ttyname, pw->pw_uid, gid,
+                                     strerror(errno));
                }
        }
 
@@ -408,11 +394,11 @@ pty_setowner(struct passwd *pw, const char *ttyname)
                if (chmod(ttyname, mode) < 0) {
                        if (errno == EROFS &&
                            (st.st_mode & (S_IRGRP | S_IROTH)) == 0)
-                               debug("chmod(%.100s, 0%o) failed: %.100s",
-                                   ttyname, (u_int)mode, strerror(errno));
+                               error("chmod(%.100s, 0%o) failed: %.100s",
+                                     ttyname, mode, strerror(errno));
                        else
                                fatal("chmod(%.100s, 0%o) failed: %.100s",
-                                   ttyname, (u_int)mode, strerror(errno));
+                                     ttyname, mode, strerror(errno));
                }
        }
 }
This page took 0.042352 seconds and 4 git commands to generate.