]> andersk Git - openssh.git/blobdiff - sshpty.c
- jakob@cvs.openbsd.org 2001/08/02 16:14:05
[openssh.git] / sshpty.c
index aca6f027cb978e4842941d1ab9701a07c7388d18..71e16b79e1bde7d40d3ae7ab88289d4e87ad6262 100644 (file)
--- a/sshpty.c
+++ b/sshpty.c
@@ -12,7 +12,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: pty.c,v 1.22 2001/02/08 19:30:52 itojun Exp $");
+RCSID("$OpenBSD: sshpty.c,v 1.3 2001/07/22 21:32:27 markus Exp $");
 
 #ifdef HAVE_UTIL_H
 # include <util.h>
@@ -20,6 +20,7 @@ RCSID("$OpenBSD: pty.c,v 1.22 2001/02/08 19:30:52 itojun Exp $");
 
 #include "sshpty.h"
 #include "log.h"
+#include "misc.h"
 
 /* Pty allocated with _getpty gets broken if we do I_PUSH:es to it. */
 #if defined(HAVE__GETPTY) || defined(HAVE_OPENPTY)
@@ -93,16 +94,19 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
         */
        int ptm;
        char *pts;
+       mysig_t old_signal;
 
        ptm = open("/dev/ptmx", O_RDWR | O_NOCTTY);
        if (ptm < 0) {
                error("/dev/ptmx: %.100s", strerror(errno));
                return 0;
        }
+       old_signal = mysignal(SIGCHLD, SIG_DFL);
        if (grantpt(ptm) < 0) {
                error("grantpt: %.100s", strerror(errno));
                return 0;
        }
+       mysignal(SIGCHLD, old_signal);
        if (unlockpt(ptm) < 0) {
                error("unlockpt: %.100s", strerror(errno));
                return 0;
@@ -309,7 +313,8 @@ pty_setowner(struct passwd *pw, const char *ttyname)
 
        /*
         * Change owner and mode of the tty as required.
-        * Warn but continue if filesystem is read-only and the uids match.
+        * Warn but continue if filesystem is read-only and the uids match/
+        * tty is owned by root.
         */
        if (stat(ttyname, &st))
                fatal("stat(%.100s) failed: %.100s", ttyname,
@@ -317,7 +322,8 @@ 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)
+                       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));
This page took 0.059843 seconds and 4 git commands to generate.