mirror of
https://github.com/systemd/systemd.git
synced 2026-08-05 07:30:30 +00:00
Merge pull request #31269 from poettering/vconsole-enodev
vconsole/pid1: handle ENODEV on /dev/console somewhat graceful
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ int lock_dev_console(void) {
|
||||
|
||||
r = lock_generic(fd, LOCK_BSD, LOCK_EX);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to lock /dev/console: %m");
|
||||
return r;
|
||||
|
||||
return TAKE_FD(fd);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user