|
Zbigniew Jędrzejewski-Szmek |
d743bb |
From d80b4dbf2c0d91ad54c2c0a0296096293ed59b39 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
Date: Wed, 24 May 2017 23:25:44 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
Subject: [PATCH] vconsole-setup: skip setting fonts when setfont returns
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
EX_OSERR
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
MIME-Version: 1.0
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
Content-Type: text/plain; charset=UTF-8
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
Content-Transfer-Encoding: 8bit
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
On a machine without a VGA console, /dev/tty{0,1,…} exist, so
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
systemd-vconsole-setup is started, but all setfont operations fail.
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
setfont has a bunch of return codes for different failure modes. It uses
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
EX_OSERR when the communication with the kernel using ioctls fails. This isn't
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
too specific, but at least it's only used this general class of errors. Let's
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
swallow the error in this case to avoid systemd-vconsole-setup.service failing
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
on cloud vms.
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
On a machine from https://bugzilla.redhat.com/show_bug.cgi?id=1272686#c4:
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
$ build/systemd-vconsole-setup
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
setfont: putfont: 512,8x16: failed: -1
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
putfont: PIO_FONT: Invalid argument
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
/usr/bin/setfont failed with error code 71.
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
Setting fonts failed with a "system error", ignoring.
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
$ SYSTEMD_LOG_LEVEL=debug build/systemd-vconsole-setup
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
Found container virtualization none.
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
Sysfs UTF-8 flag enabled
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
UTF-8 kbdmode enabled on /dev/tty0
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
Executing "/usr/bin/setfont -C /dev/tty0 eurlatgr"...
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
setfont: putfont: 512,8x16: failed: -1
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
putfont: PIO_FONT: Invalid argument
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
/usr/bin/setfont failed with error code 71.
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
Executing "/usr/bin/loadkeys -q -C /dev/tty0 -u us"...
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
/usr/bin/loadkeys succeeded.
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
Setting fonts failed with a "system error", ignoring.
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
$ lspci | grep -i vga
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
$ ls /dev/tty?
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
/dev/tty0 /dev/tty2 /dev/tty4 /dev/tty6 /dev/tty8
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
/dev/tty1 /dev/tty3 /dev/tty5 /dev/tty7 /dev/tty9
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
If we have a better test for /dev/tty? being connected to something that has a
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
font, we could avoid running setfont at all… ATM, I'm not aware of a simple
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
test like that.
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
(cherry picked from commit 93c9a9d235e2304500c490b4868534385f925c76)
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
---
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
src/vconsole/vconsole-setup.c | 19 ++++++++++++-------
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
1 file changed, 12 insertions(+), 7 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
index 2401077be5..dc63bb530c 100644
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
--- a/src/vconsole/vconsole-setup.c
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+++ b/src/vconsole/vconsole-setup.c
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
@@ -28,6 +28,7 @@
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
#include <stdio.h>
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
#include <stdlib.h>
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
#include <sys/ioctl.h>
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+#include <sysexits.h>
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
#include <termios.h>
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
#include <unistd.h>
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
@@ -336,8 +337,8 @@ int main(int argc, char **argv) {
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
*vc_keymap = NULL, *vc_keymap_toggle = NULL,
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
*vc_font = NULL, *vc_font_map = NULL, *vc_font_unimap = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
_cleanup_close_ int fd = -1;
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
- bool utf8, font_copy = false, font_ok, keyboard_ok;
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
- int r = EXIT_FAILURE;
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+ bool utf8, font_copy = false, keyboard_ok;
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+ int r;
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
log_set_target(LOG_TARGET_AUTO);
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
log_parse_environment();
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
@@ -382,7 +383,6 @@ int main(int argc, char **argv) {
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
"FONT_MAP", &vc_font_map,
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
"FONT_UNIMAP", &vc_font_unimap,
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
-
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
if (r < 0 && r != -ENOENT)
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
log_warning_errno(r, "Failed to read /etc/vconsole.conf: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
@@ -399,22 +399,27 @@ int main(int argc, char **argv) {
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
"vconsole.font.map", &vc_font_map,
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
"vconsole.font.unimap", &vc_font_unimap,
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
-
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
if (r < 0 && r != -ENOENT)
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
log_warning_errno(r, "Failed to read /proc/cmdline: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
}
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
toggle_utf8_sysfs(utf8);
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
toggle_utf8(vc, fd, utf8);
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
- font_ok = font_load_and_wait(vc, vc_font, vc_font_map, vc_font_unimap) == 0;
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+ r = font_load_and_wait(vc, vc_font, vc_font_map, vc_font_unimap);
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
keyboard_ok = keyboard_load_and_wait(vc, vc_keymap, vc_keymap_toggle, utf8) == 0;
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
if (font_copy) {
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
- if (font_ok)
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+ if (r == 0)
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
setup_remaining_vcs(fd, utf8);
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+ else if (r == EX_OSERR)
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+ /* setfont returns EX_OSERR when ioctl(KDFONTOP/PIO_FONTX/PIO_FONTX) fails.
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+ * This might mean various things, but in particular lack of a graphical
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+ * console. Let's be generous and not treat this as an error. */
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+ log_notice("Setting fonts failed with a \"system error\", ignoring.");
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
else
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
log_warning("Setting source virtual console failed, ignoring remaining ones");
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
}
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
- return font_ok && keyboard_ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
+ return IN_SET(r, 0, EX_OSERR) && keyboard_ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
Zbigniew Jędrzejewski-Szmek |
d743bb |
}
|