Fix the other su bug reintroduced two commits ago, namely
$ su % kill -STOP $$ where su is executing (t)csh. csh's job handling is a little more special than that of (a)sh, bash and even zsh and blows up a little more spectacularly. This modification restores the original mucking about with the tty pgrp, but is careful to only do it when su (or su's child) is the foreground process. While I'm here, fix a STDERR_FILENO spelling as suggested by bde.
This commit is contained in:
parent
ff3ced1270
commit
cd17a1f7ba
@ -156,7 +156,7 @@ main(int argc, char *argv[])
|
||||
char * const *b;
|
||||
} np;
|
||||
uid_t ruid;
|
||||
pid_t child_pid, pid;
|
||||
pid_t child_pid, child_pgrp, pid;
|
||||
int asme, ch, asthem, fastlogin, prio, i, retcode,
|
||||
statusp, setmaclabel;
|
||||
u_int setwhat;
|
||||
@ -392,17 +392,30 @@ main(int argc, char *argv[])
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sigaction(SIGTTOU, &sa, NULL);
|
||||
close(fds[0]);
|
||||
setpgid(child_pid, child_pid);
|
||||
if (tcgetpgrp(STDERR_FILENO) == getpgrp())
|
||||
tcsetpgrp(STDERR_FILENO, child_pid);
|
||||
close(fds[1]);
|
||||
sigaction(SIGPIPE, &sa_pipe, NULL);
|
||||
while ((pid = waitpid(child_pid, &statusp, WUNTRACED)) != -1) {
|
||||
if (WIFSTOPPED(statusp)) {
|
||||
child_pgrp = getpgid(child_pid);
|
||||
if (tcgetpgrp(STDERR_FILENO) == child_pgrp)
|
||||
tcsetpgrp(STDERR_FILENO, getpgrp());
|
||||
kill(getpid(), SIGSTOP);
|
||||
if (tcgetpgrp(STDERR_FILENO) == getpgrp()) {
|
||||
child_pgrp = getpgid(child_pid);
|
||||
tcsetpgrp(STDERR_FILENO, child_pgrp);
|
||||
}
|
||||
kill(child_pid, SIGCONT);
|
||||
statusp = 1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
child_pgrp = getpgid(child_pid);
|
||||
if (tcgetpgrp(STDERR_FILENO) == child_pgrp)
|
||||
tcsetpgrp(STDERR_FILENO, getpgrp());
|
||||
if (pid == -1)
|
||||
err(1, "waitpid");
|
||||
PAM_END();
|
||||
|
Loading…
x
Reference in New Issue
Block a user