diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-08-03 20:21:27 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-13 12:59:29 +0200 |
commit | 0b6d55cae9b8adc507fbea95d1b2874729a77386 (patch) | |
tree | 633c78b6d05847dfda3ce42fa386a2fdc388bc06 /src | |
parent | b25ba6cf673036e46cbaec77d3c7859ed83d3ca8 (diff) | |
download | systemd-0b6d55cae9b8adc507fbea95d1b2874729a77386.tar.gz systemd-0b6d55cae9b8adc507fbea95d1b2874729a77386.tar.bz2 systemd-0b6d55cae9b8adc507fbea95d1b2874729a77386.zip |
logind: improve logging in manager_connect_console()
let's make sure we log about every failure
Also, complain about systems where /dev/tty0 exists but
/sys/class/tty/tty0/active does not. Such systems (usually container
environments) are pretty broken as they mount something that is not a VC
to /dev/tty0 and they really shouldn't.
Systems should either have a VC or not, but not badly fake one by
mounting things wildly.
This just adds a warning message, as before we'll simply turn off VC
handling in this case.
Diffstat (limited to 'src')
-rw-r--r-- | src/login/logind.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/login/logind.c b/src/login/logind.c index e7f3a99b97..189af504e3 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -789,28 +789,28 @@ static int manager_connect_console(Manager *m) { assert(m); assert(m->console_active_fd < 0); - /* On certain architectures (S390 and Xen, and containers), - /dev/tty0 does not exist, so don't fail if we can't open - it. */ + /* On certain systems (such as S390, Xen, and containers) /dev/tty0 does not exist (as there is no VC), so + * don't fail if we can't open it. */ + if (access("/dev/tty0", F_OK) < 0) return 0; m->console_active_fd = open("/sys/class/tty/tty0/active", O_RDONLY|O_NOCTTY|O_CLOEXEC); if (m->console_active_fd < 0) { - /* On some systems the device node /dev/tty0 may exist - * even though /sys/class/tty/tty0 does not. */ - if (errno == ENOENT) + /* On some systems /dev/tty0 may exist even though /sys/class/tty/tty0 does not. These are broken, but + * common. Let's complain but continue anyway. */ + if (errno == ENOENT) { + log_warning_errno(errno, "System has /dev/tty0 but not /sys/class/tty/tty0/active which is broken, ignoring: %m"); return 0; + } return log_error_errno(errno, "Failed to open /sys/class/tty/tty0/active: %m"); } r = sd_event_add_io(m->event, &m->console_active_event_source, m->console_active_fd, 0, manager_dispatch_console, m); - if (r < 0) { - log_error("Failed to watch foreground console"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to watch foreground console: %m"); /* * SIGRTMIN is used as global VT-release signal, SIGRTMIN + 1 is used @@ -829,7 +829,7 @@ static int manager_connect_console(Manager *m) { r = sd_event_add_signal(m->event, NULL, SIGRTMIN, manager_vt_switch, m); if (r < 0) - return r; + return log_error_errno(r, "Failed to subscribe to signal: %m"); return 0; } |