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