version 1.1.4.4, 2002/03/08 17:04:43 |
version 1.2, 2001/07/18 21:10:43 |
|
|
*ttyfd = open(name, O_RDWR | O_NOCTTY); |
*ttyfd = open(name, O_RDWR | O_NOCTTY); |
if (*ttyfd < 0) { |
if (*ttyfd < 0) { |
error("Could not open pty slave side %.100s: %.100s", |
error("Could not open pty slave side %.100s: %.100s", |
name, strerror(errno)); |
name, strerror(errno)); |
close(*ptyfd); |
close(*ptyfd); |
return 0; |
return 0; |
} |
} |
|
|
fd = open(_PATH_TTY, O_WRONLY); |
fd = open(_PATH_TTY, O_WRONLY); |
if (fd < 0) |
if (fd < 0) |
error("open /dev/tty failed - could not set controlling tty: %.100s", |
error("open /dev/tty failed - could not set controlling tty: %.100s", |
strerror(errno)); |
strerror(errno)); |
else { |
else { |
close(fd); |
close(fd); |
} |
} |
|
|
|
|
void |
void |
pty_change_window_size(int ptyfd, int row, int col, |
pty_change_window_size(int ptyfd, int row, int col, |
int xpixel, int ypixel) |
int xpixel, int ypixel) |
{ |
{ |
struct winsize w; |
struct winsize w; |
w.ws_row = row; |
w.ws_row = row; |
|
|
|
|
/* |
/* |
* Change owner and mode of the tty as required. |
* 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)) |
if (stat(ttyname, &st)) |
fatal("stat(%.100s) failed: %.100s", ttyname, |
fatal("stat(%.100s) failed: %.100s", ttyname, |
|
|
|
|
if (st.st_uid != pw->pw_uid || st.st_gid != gid) { |
if (st.st_uid != pw->pw_uid || st.st_gid != gid) { |
if (chown(ttyname, pw->pw_uid, gid) < 0) { |
if (chown(ttyname, pw->pw_uid, gid) < 0) { |
if (errno == EROFS && |
if (errno == EROFS && |
(st.st_uid == pw->pw_uid || st.st_uid == 0)) |
(st.st_uid == pw->pw_uid || st.st_uid == 0)) |
error("chown(%.100s, %d, %d) failed: %.100s", |
error("chown(%.100s, %d, %d) failed: %.100s", |
ttyname, pw->pw_uid, gid, |
ttyname, pw->pw_uid, gid, |
strerror(errno)); |
strerror(errno)); |
else |
else |
fatal("chown(%.100s, %d, %d) failed: %.100s", |
fatal("chown(%.100s, %d, %d) failed: %.100s", |
ttyname, pw->pw_uid, gid, |
ttyname, pw->pw_uid, gid, |
strerror(errno)); |
strerror(errno)); |
} |
} |
} |
} |
|
|
|
|
if (errno == EROFS && |
if (errno == EROFS && |
(st.st_mode & (S_IRGRP | S_IROTH)) == 0) |
(st.st_mode & (S_IRGRP | S_IROTH)) == 0) |
error("chmod(%.100s, 0%o) failed: %.100s", |
error("chmod(%.100s, 0%o) failed: %.100s", |
ttyname, mode, strerror(errno)); |
ttyname, mode, strerror(errno)); |
else |
else |
fatal("chmod(%.100s, 0%o) failed: %.100s", |
fatal("chmod(%.100s, 0%o) failed: %.100s", |
ttyname, mode, strerror(errno)); |
ttyname, mode, strerror(errno)); |
} |
} |
} |
} |
} |
} |