]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1,vconsole-setup: gracefully handle if /dev/vconsole is not accessible due to... 31269/head
authorLennart Poettering <lennart@poettering.net>
Fri, 9 Feb 2024 11:55:27 +0000 (12:55 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 9 Feb 2024 13:19:20 +0000 (14:19 +0100)
I think this is generally the right thing to do and is just an extension
of the existing ENOENT check.

Prompted by: #31257

src/core/execute.c
src/vconsole/vconsole-setup.c

index b91513c5da8fef63798b0b9a8eb8c97e472a3b6b..fb3e9b79cbeef1c6d08ed5a69be519b38c1b6443 100644 (file)
@@ -163,6 +163,8 @@ void exec_context_tty_reset(const ExecContext *context, const ExecParameters *p)
         lock_fd = lock_dev_console();
         if (ERRNO_IS_NEG_PRIVILEGE(lock_fd))
                 log_debug_errno(lock_fd, "No privileges to lock /dev/console, proceeding without: %m");
+        else if (ERRNO_IS_NEG_DEVICE_ABSENT(lock_fd))
+                log_debug_errno(lock_fd, "Device /dev/console does not exist, proceeding without locking it: %m");
         else if (lock_fd < 0)
                 return (void) log_debug_errno(lock_fd, "Failed to lock /dev/console: %m");
 
index 83e43b16ff98532661593e299da407075013c522..554d00e5b75922068c1b46f537db1d2339827b41 100644 (file)
@@ -624,14 +624,10 @@ static int run(int argc, char **argv) {
         /* Take lock around the remaining operation to avoid being interrupted by a tty reset operation
          * performed for services with TTYVHangup=yes. */
         lock_fd = lock_dev_console();
-        if (lock_fd < 0) {
-                log_full_errno(lock_fd == -ENOENT ? LOG_DEBUG : LOG_ERR,
-                               lock_fd,
-                               "Failed to lock /dev/console%s: %m",
-                               lock_fd == -ENOENT ? ", ignoring" : "");
-                if (lock_fd != -ENOENT)
-                        return lock_fd;
-        }
+        if (ERRNO_IS_NEG_DEVICE_ABSENT(lock_fd))
+                log_debug_errno(lock_fd, "Device /dev/console does not exist, proceeding without locking it: %m");
+        else if (lock_fd < 0)
+                return log_error_errno(lock_fd, "Failed to lock /dev/console: %m");
 
         (void) toggle_utf8_sysfs(utf8);
         (void) toggle_utf8_vc(vc, fd, utf8);