--- TEShell.C.ori Mon Dec 21 01:16:00 1998 +++ TEShell.C Sun Dec 27 17:18:35 1998 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include "../../config.h" @@ -88,6 +89,7 @@ emit done(status); } + int Shell::run(QStrList & args, const char* term) { pid_t comm_pid = fork(); @@ -109,7 +111,7 @@ // Don't know why, but his is vital for SIGHUP to find the child. // Could be, we get rid of the controling terminal by this. - for (int i = 0; i < getdtablesize(); i++) if (i != tt) close(i); + for (int i = 0; i < getdtablesize(); i++) if (i != tt && i != fd) close(i); dup2(tt,fileno(stdin)); dup2(tt,fileno(stdout)); @@ -133,6 +135,11 @@ setpgid(0,0); // is not noticeable with all close(open(dev, O_WRONLY, 0)); // clients (bash,vi). Because bash setpgid(0,0); // heals this, use '-e' to test it. + + int flag = 1; + if (ioctl(fd,TIOCSPTLCK,&flag)) // prohibit opening tty from now on + perror("cannot set secure"); + close(fd); // drop privileges setuid(getuid()); setgid(getgid()); @@ -186,6 +193,7 @@ } if (ptyfd < 0) { fprintf(stderr,"Can't open a pseudo teletype\n"); exit(1); } fcntl(ptyfd,F_SETFL,O_NDELAY); +printf("using: %s <-> %s\n",ptynam,ttynam); return ptyfd; }