From: Zbigniew Jędrzejewski-Szmek Date: Tue, 14 May 2024 18:00:48 +0000 (+0200) Subject: core,vconsole-setup: treat locking failure as non-fatal X-Git-Tag: v256-rc2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e9bdbb6bbcd4725171ca1fd0bb4fff83e5338acf;p=thirdparty%2Fsystemd.git core,vconsole-setup: treat locking failure as non-fatal Locking of the tty device and then /dev/console was added to synchronize vconsole-setup with other writers to the console. But it turns out that often the locking doesn't work and we carved out various cases where we ignore failure: - lack of permissions (in the user manager) - missing device node It turns out that there's at least one more failure mode: we get -EIO when the console is (mis-)configured to point to an invalid device. E.g. in rhbug#2273069 the reporter has a VM in Proxmox without a virtual console configured and has 'console=tty console=ttyS0' on the kernel cmdline. I couldn't reproduce this under libvirt, but failure with EIO has been reported by at least four users in #30501. Note that in systemd-vconsole-setup we report this is a hard failure, while in the manager, we only do a debug line. So it's possible that the failure also occured there, causing the rest of the setup of the tty to be skipped without further notice. Ignore the locking failure, since there's just too many ways it can fail. If we proceed without a lock, we're back to the situation before we started locking, which wasn't too bad. OTOH, skipping setup of the console is problematic for users, and it seems better to try to do the setup without locking. Fixes https://github.com/systemd/systemd/issues/30501, https://bugzilla.redhat.com/show_bug.cgi?id=2273069. --- diff --git a/src/core/execute.c b/src/core/execute.c index 09b0c7a6332..513e95e09d7 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -162,11 +162,11 @@ void exec_context_tty_reset(const ExecContext *context, const ExecParameters *p) * that will be closed automatically, and operate on it for convenience. */ 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"); + log_debug_errno(lock_fd, "No privileges to lock /dev/console, proceeding without lock: %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"); + log_debug_errno(lock_fd, "Device /dev/console does not exist, proceeding without lock: %m"); else if (lock_fd < 0) - return (void) log_debug_errno(lock_fd, "Failed to lock /dev/console: %m"); + log_warning_errno(lock_fd, "Failed to lock /dev/console, proceeding without lock: %m"); if (context->tty_vhangup) (void) terminal_vhangup_fd(fd); diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c index e0b1621461f..ba742dda69e 100644 --- a/src/vconsole/vconsole-setup.c +++ b/src/vconsole/vconsole-setup.c @@ -650,9 +650,9 @@ static int run(int argc, char **argv) { * performed for services with TTYVHangup=yes. */ lock_fd = lock_dev_console(); if (ERRNO_IS_NEG_DEVICE_ABSENT(lock_fd)) - log_debug_errno(lock_fd, "Device /dev/console does not exist, proceeding without locking it: %m"); + log_debug_errno(lock_fd, "Device /dev/console does not exist, proceeding without lock: %m"); else if (lock_fd < 0) - return log_error_errno(lock_fd, "Failed to lock /dev/console: %m"); + log_warning_errno(lock_fd, "Failed to lock /dev/console, proceeding without lock: %m"); (void) toggle_utf8_vc(vc, fd, utf8);