summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/sshpty.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2002-03-18 09:55:03 +0000
committerdes <des@FreeBSD.org>2002-03-18 09:55:03 +0000
commit2fc4a488978a03338ecc65403597582c77dabeea (patch)
tree068818e7abaca45008ac24af9fb4de22815cc0eb /crypto/openssh/sshpty.c
parent8acd87ac472a182ef2d717212f2c0faba81143a5 (diff)
downloadFreeBSD-src-2fc4a488978a03338ecc65403597582c77dabeea.zip
FreeBSD-src-2fc4a488978a03338ecc65403597582c77dabeea.tar.gz
Vendor import of OpenSSH 3.1
Diffstat (limited to 'crypto/openssh/sshpty.c')
-rw-r--r--crypto/openssh/sshpty.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/crypto/openssh/sshpty.c b/crypto/openssh/sshpty.c
index d0f2554..b21d3cc 100644
--- a/crypto/openssh/sshpty.c
+++ b/crypto/openssh/sshpty.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshpty.c,v 1.1 2001/03/04 01:46:30 djm Exp $");
+RCSID("$OpenBSD: sshpty.c,v 1.4 2001/12/19 07:18:56 deraadt Exp $");
#include <util.h>
#include "sshpty.h"
@@ -131,7 +131,7 @@ 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;
}
@@ -224,7 +224,7 @@ 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));
+ strerror(errno));
else {
close(fd);
}
@@ -234,7 +234,7 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
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;
@@ -264,7 +264,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,
@@ -272,14 +273,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)
+ 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));
+ ttyname, pw->pw_uid, gid,
+ strerror(errno));
else
fatal("chown(%.100s, %d, %d) failed: %.100s",
- ttyname, pw->pw_uid, gid,
- strerror(errno));
+ ttyname, pw->pw_uid, gid,
+ strerror(errno));
}
}
@@ -288,10 +290,10 @@ pty_setowner(struct passwd *pw, const char *ttyname)
if (errno == EROFS &&
(st.st_mode & (S_IRGRP | S_IROTH)) == 0)
error("chmod(%.100s, 0%o) failed: %.100s",
- ttyname, mode, strerror(errno));
+ ttyname, mode, strerror(errno));
else
fatal("chmod(%.100s, 0%o) failed: %.100s",
- ttyname, mode, strerror(errno));
+ ttyname, mode, strerror(errno));
}
}
}
OpenPOWER on IntegriCloud