]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: fix stdin conversion to tty name
authorKarel Zak <kzak@redhat.com>
Mon, 24 Feb 2025 12:37:04 +0000 (13:37 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 24 Feb 2025 12:37:04 +0000 (13:37 +0100)
Addresses: https://github.com/util-linux/util-linux/issues/3304
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.c

index aa859c27b30b97693bf05be8e0a432a955a7aa09..0dfe52c900db817ec1a9144e49c6ac2262ed2e84 100644 (file)
@@ -928,11 +928,15 @@ static void parse_args(int argc, char **argv, struct options *op)
 
        /* resolve the tty path in case it was provided as stdin */
        if (strcmp(op->tty, "-") == 0) {
+               int fd;
+               const char *name = op->tty;
+
                op->tty_is_stdin = 1;
-               int fd = get_terminal_name(NULL, &op->tty, NULL);
-               if (fd < 0) {
+               fd = get_terminal_name(NULL, &name, NULL);
+               if (fd >= 0)
+                       op->tty = name; /* set real device name */
+               else
                        log_warn(_("could not get terminal name: %d"), fd);
-               }
        }
 
        /* On virtual console remember the line which is used for */