]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: fix odd check for chardev/tty
authorKarel Zak <kzak@redhat.com>
Tue, 13 May 2014 10:28:48 +0000 (12:28 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 13 May 2014 10:28:48 +0000 (12:28 +0200)
References: https://bugzilla.redhat.com/show_bug.cgi?id=1069902
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.c

index a70683617a6f907332d747043847b9a1ed37e143..5163550fbd4bc8b1383e2d47e7338d06a00968d5 100644 (file)
@@ -975,12 +975,12 @@ static void open_tty(char *tty, struct termios *tp, struct options *op)
                        log_err(_("/dev/%s: cannot open as standard input: %m"), tty);
 
                /* Sanity checks... */
-               if (!isatty(fd))
-                       log_err(_("/dev/%s: not a character device"), tty);
                if (fstat(fd, &st) < 0)
                        log_err("%s: %m", buf);
                if ((st.st_mode & S_IFMT) != S_IFCHR)
                        log_err(_("/dev/%s: not a character device"), tty);
+               if (!isatty(fd))
+                       log_err(_("/dev/%s: not a tty"), tty);
 
                if (((tid = tcgetsid(fd)) < 0) || (pid != tid)) {
                        if (ioctl(fd, TIOCSCTTY, 1) == -1)