26
29
Xerror("try again");
30
* Should make reads of tty fail, writes succeed.
34
* I don't know what the right thing to do here is,
35
* so this is all experimentally determined.
36
* If we just dup /dev/null onto 0, then running
37
* ssh foo & will reopen /dev/tty, try to read a password,
38
* get a signal, and repeat, in a tight loop, forever.
39
* Arguably this is a bug in ssh (it behaves the same
40
* way under bash as under rc) but I'm fixing it here
41
* anyway. If we dissociate the process from the tty,
42
* then it won't be able to open /dev/tty ever again.
43
* The SIG_IGN on SIGTTOU makes writing the tty
44
* (via fd 1 or 2, for example) succeed even though
45
* our pgrp is not the terminal's controlling pgrp.
32
signal(SIGTTIN, SIG_IGN);
33
signal(SIGTTOU, SIG_IGN);
35
pushredir(ROPEN, null, 0);
47
if((tty = open("/dev/tty", OREAD)) >= 0){
49
* Should make reads of tty fail, writes succeed.
51
signal(SIGTTIN, SIG_IGN);
52
signal(SIGTTOU, SIG_IGN);
53
ioctl(tty, TIOCNOTTY);
57
pushredir(ROPEN, null, 0);
36
60
start(runq->code, runq->pc+1, runq->local);
41
66
runq->pc = runq->code[runq->pc].i;
42
67
inttoascii(npid, pid);
62
87
Xerror("try again");
65
91
start(p->code, pc+2, runq->local);
68
94
pushredir(ROPEN, pfd[PWR], lfd);
71
98
start(p->code, p->code[pc].i, runq->local);
73
100
pushredir(ROPEN, pfd[PRD], rfd);
160
189
sidefd = pfd[PRD];
161
190
mainfd = pfd[PWR];
192
switch(pid = fork()){
165
194
Xerror("try again");
168
198
start(p->code, pc+2, runq->local);
170
200
pushredir(ROPEN, sidefd, p->code[pc].i==READ?1:0);
175
206
pushredir(ROPEN, mainfd, mainfd); /* isn't this a noop? */
176
207
strcpy(name, Fdprefix);