]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
utmp-wtmp: fix error in case isatty() fails
authorLennart Poettering <lennart@poettering.net>
Tue, 22 Nov 2022 11:56:38 +0000 (12:56 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 Nov 2022 12:10:29 +0000 (13:10 +0100)
src/shared/utmp-wtmp.c

index d2c8473c60f1dc8acc183d07664f40b2799166b5..20add0e81b0f0faf7724251a360e18cc76a34180 100644 (file)
@@ -292,8 +292,10 @@ static int write_to_terminal(const char *tty, const char *message) {
         assert(message);
 
         fd = open(tty, O_WRONLY|O_NONBLOCK|O_NOCTTY|O_CLOEXEC);
-        if (fd < 0 || !isatty(fd))
+        if (fd < 0)
                 return -errno;
+        if (!isatty(fd))
+                return -ENOTTY;
 
         p = message;
         left = strlen(message);