Mon 04 Jul 2011 03:01:38 PM UTC, original submission:
sulogin can be given an optional TTY argument on the command line. According to the manual page:
"sulogin will be connected to the current terminal, or to the optional device that can be specified on the command line (typically /dev/console)."
However the TTY argument only replaces file descriptors 0, 1 and 2 if certain conditions are met:
534 pid = getpid();
535 pgrp = getpgid(0);
536 ppgrp = getpgid(getppid());
537 ttypgrp = tcgetpgrp(fd);
538
539 if (pgrp != ttypgrp && ppgrp != ttypgrp) {
...
// Replace fd 0, 1, 2
...
566 } ...
If (pgrp != ttypgrp && ppgrp != ttypgrp) evaluates to FALSE then the TTY argument will not replace file descriptors 0, 1 and 2.
That is exactly what happens on my system, where pgrp=673, ppgrp=0, and ttypgrp=673. Consequently file descriptors 0, 1 and 2 remain connected to /dev/null instead of being replaced by the TTY argument (/dev/tty1 in my case), and sulogin quietly fails.
Surely if an optional TTY argument is provided then it should replace file descriptors 0, 1 and 2 unconditionally.
|