]> granicus.if.org Git - sudo/commitdiff
When trying to determine the tty name, check parent's stderr in
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 10 Apr 2012 17:49:49 +0000 (13:49 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 10 Apr 2012 17:49:49 +0000 (13:49 -0400)
addition to its stdin and stdout.

src/ttyname.c

index 6178ddb83c9605a8ec3b894ba82087e77f237af4..a45ab19dad8d60e3f02318a072942db519d37c0b 100644 (file)
@@ -163,7 +163,7 @@ get_process_ttyname(void)
        (tty = ttyname(STDERR_FILENO)) == NULL) {
        /* No tty for child, check the parent via /proc. */
        ppid = getppid();
-       for (i = STDIN_FILENO; i < STDERR_FILENO && tty == NULL; i++) {
+       for (i = STDIN_FILENO; i <= STDERR_FILENO && tty == NULL; i++) {
            snprintf(path, sizeof(path), "/proc/%d/fd/%d", (int)ppid, i);
            fd = open(path, O_RDONLY|O_NOCTTY|O_NONBLOCK, 0);
            if (fd != -1) {