Script screws up after rlogind dies..
Smith
ks at pur-ee.UUCP
Sat Dec 15 12:18:24 AEST 1984
Description:
Often, rlogin daemons terminate abnormally and fail to reset
the modes on the psuedo tty. The next rlogin daemon can
fix this since it runs as root, but script runs as the
individual user and has no recourse. When script can't
open the tty, it merely says "Permission denied" and exits.
It should just skip over that pty and try the next...
Repeat-By:
% chmod 622 /dev/ttyp0
- or -
% kill -9 rlogindpid
% script
Permission denied
Fix:
Just don't use a tty that you can't read and write:
RCS file: RCS/script.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -c -r1.1 -r1.3
*** /tmp/,RCSt1007377 Fri Dec 14 21:10:58 1984
--- /tmp/,RCSt2007377 Fri Dec 14 21:11:02 1984
***************
*** 12,17
#include <sys/ioctl.h>
#include <sgtty.h>
#include <sys/time.h>
char *getenv();
char *ctime();
--- 12,18 -----
#include <sys/ioctl.h>
#include <sgtty.h>
#include <sys/time.h>
+ #include <sys/file.h>
char *getenv();
char *ctime();
***************
*** 191,196
line[strlen("/dev/ptyp")] = "0123456789abcdef"[i];
master = open(line, 2);
if (master >= 0) {
ioctl(0, TIOCGETP, (char *)&b);
ioctl(0, TIOCGETC, (char *)&tc);
ioctl(0, TIOCGETD, (char *)&l);
--- 192,201 -----
line[strlen("/dev/ptyp")] = "0123456789abcdef"[i];
master = open(line, 2);
if (master >= 0) {
+ if (!checkslave()) {
+ close(master);
+ continue;
+ }
ioctl(0, TIOCGETP, (char *)&b);
ioctl(0, TIOCGETC, (char *)&tc);
ioctl(0, TIOCGETD, (char *)&l);
***************
*** 202,207
}
fprintf(stderr, "Out of pty's\n");
fail();
}
getslave()
--- 207,223 -----
}
fprintf(stderr, "Out of pty's\n");
fail();
+ }
+
+ checkslave()
+ {
+ line[strlen("/dev/")] = 't';
+ if (access(line, R_OK|W_OK) < 0) {
+ line[strlen("/dev/")] = 'p';
+ return 0;
+ }
+ line[strlen("/dev/")] = 'p';
+ return 1;
}
getslave()
More information about the Comp.unix.wizards
mailing list