|
|
b12df0 |
From 9e9c6cbbdd60f4538cee041ffe3f9cd831c5de17 Mon Sep 17 00:00:00 2001
|
|
|
b12df0 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
b12df0 |
Date: Fri, 3 Aug 2018 20:21:27 +0200
|
|
|
b12df0 |
Subject: [PATCH] logind: improve logging in manager_connect_console()
|
|
|
b12df0 |
|
|
|
b12df0 |
let's make sure we log about every failure
|
|
|
b12df0 |
|
|
|
b12df0 |
Also, complain about systems where /dev/tty0 exists but
|
|
|
b12df0 |
/sys/class/tty/tty0/active does not. Such systems (usually container
|
|
|
b12df0 |
environments) are pretty broken as they mount something that is not a VC
|
|
|
b12df0 |
to /dev/tty0 and they really shouldn't.
|
|
|
b12df0 |
|
|
|
b12df0 |
Systems should either have a VC or not, but not badly fake one by
|
|
|
b12df0 |
mounting things wildly.
|
|
|
b12df0 |
|
|
|
b12df0 |
This just adds a warning message, as before we'll simply turn off VC
|
|
|
b12df0 |
handling in this case.
|
|
|
b12df0 |
|
|
|
b12df0 |
(cherry picked from commit 0b6d55cae9b8adc507fbea95d1b2874729a77386)
|
|
|
b12df0 |
|
|
|
b12df0 |
Related: #1642460
|
|
|
b12df0 |
---
|
|
|
b12df0 |
src/login/logind.c | 22 +++++++++++-----------
|
|
|
b12df0 |
1 file changed, 11 insertions(+), 11 deletions(-)
|
|
|
b12df0 |
|
|
|
b12df0 |
diff --git a/src/login/logind.c b/src/login/logind.c
|
|
|
b12df0 |
index 52fcee933c..1b366cd55f 100644
|
|
|
b12df0 |
--- a/src/login/logind.c
|
|
|
b12df0 |
+++ b/src/login/logind.c
|
|
|
b12df0 |
@@ -815,28 +815,28 @@ static int manager_connect_console(Manager *m) {
|
|
|
b12df0 |
assert(m);
|
|
|
b12df0 |
assert(m->console_active_fd < 0);
|
|
|
b12df0 |
|
|
|
b12df0 |
- /* On certain architectures (S390 and Xen, and containers),
|
|
|
b12df0 |
- /dev/tty0 does not exist, so don't fail if we can't open
|
|
|
b12df0 |
- it. */
|
|
|
b12df0 |
+ /* On certain systems (such as S390, Xen, and containers) /dev/tty0 does not exist (as there is no VC), so
|
|
|
b12df0 |
+ * don't fail if we can't open it. */
|
|
|
b12df0 |
+
|
|
|
b12df0 |
if (access("/dev/tty0", F_OK) < 0)
|
|
|
b12df0 |
return 0;
|
|
|
b12df0 |
|
|
|
b12df0 |
m->console_active_fd = open("/sys/class/tty/tty0/active", O_RDONLY|O_NOCTTY|O_CLOEXEC);
|
|
|
b12df0 |
if (m->console_active_fd < 0) {
|
|
|
b12df0 |
|
|
|
b12df0 |
- /* On some systems the device node /dev/tty0 may exist
|
|
|
b12df0 |
- * even though /sys/class/tty/tty0 does not. */
|
|
|
b12df0 |
- if (errno == ENOENT)
|
|
|
b12df0 |
+ /* On some systems /dev/tty0 may exist even though /sys/class/tty/tty0 does not. These are broken, but
|
|
|
b12df0 |
+ * common. Let's complain but continue anyway. */
|
|
|
b12df0 |
+ if (errno == ENOENT) {
|
|
|
b12df0 |
+ log_warning_errno(errno, "System has /dev/tty0 but not /sys/class/tty/tty0/active which is broken, ignoring: %m");
|
|
|
b12df0 |
return 0;
|
|
|
b12df0 |
+ }
|
|
|
b12df0 |
|
|
|
b12df0 |
return log_error_errno(errno, "Failed to open /sys/class/tty/tty0/active: %m");
|
|
|
b12df0 |
}
|
|
|
b12df0 |
|
|
|
b12df0 |
r = sd_event_add_io(m->event, &m->console_active_event_source, m->console_active_fd, 0, manager_dispatch_console, m);
|
|
|
b12df0 |
- if (r < 0) {
|
|
|
b12df0 |
- log_error("Failed to watch foreground console");
|
|
|
b12df0 |
- return r;
|
|
|
b12df0 |
- }
|
|
|
b12df0 |
+ if (r < 0)
|
|
|
b12df0 |
+ return log_error_errno(r, "Failed to watch foreground console: %m");
|
|
|
b12df0 |
|
|
|
b12df0 |
/*
|
|
|
b12df0 |
* SIGRTMIN is used as global VT-release signal, SIGRTMIN + 1 is used
|
|
|
b12df0 |
@@ -855,7 +855,7 @@ static int manager_connect_console(Manager *m) {
|
|
|
b12df0 |
|
|
|
b12df0 |
r = sd_event_add_signal(m->event, NULL, SIGRTMIN, manager_vt_switch, m);
|
|
|
b12df0 |
if (r < 0)
|
|
|
b12df0 |
- return r;
|
|
|
b12df0 |
+ return log_error_errno(r, "Failed to subscribe to signal: %m");
|
|
|
b12df0 |
|
|
|
b12df0 |
return 0;
|
|
|
b12df0 |
}
|