2010-09-16 00:36:41 +02:00
|
|
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
|
|
|
|
|
|
|
/***
|
|
|
|
This file is part of systemd.
|
|
|
|
|
|
|
|
Copyright 2010 Kay Sievers
|
|
|
|
|
|
|
|
systemd is free software; you can redistribute it and/or modify it
|
2012-04-12 00:20:58 +02:00
|
|
|
under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
2010-09-16 00:36:41 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
systemd is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2012-04-12 00:20:58 +02:00
|
|
|
Lesser General Public License for more details.
|
2010-09-16 00:36:41 +02:00
|
|
|
|
2012-04-12 00:20:58 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2010-09-16 00:36:41 +02:00
|
|
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
***/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <linux/kd.h>
|
2015-10-24 22:58:24 +02:00
|
|
|
#include <linux/tiocl.h>
|
2013-01-15 02:25:56 +01:00
|
|
|
#include <linux/vt.h>
|
2015-10-24 22:58:24 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <unistd.h>
|
2010-09-16 00:36:41 +02:00
|
|
|
|
2015-10-25 13:14:12 +01:00
|
|
|
#include "fd-util.h"
|
2013-02-14 12:26:13 +01:00
|
|
|
#include "fileio.h"
|
2015-10-25 14:08:25 +01:00
|
|
|
#include "io-util.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "log.h"
|
2015-04-10 19:10:00 +02:00
|
|
|
#include "process-util.h"
|
2015-05-31 23:55:55 +02:00
|
|
|
#include "signal-util.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "string-util.h"
|
|
|
|
#include "terminal-util.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "virt.h"
|
2010-09-16 00:36:41 +02:00
|
|
|
|
2010-09-21 03:16:28 +02:00
|
|
|
static bool is_vconsole(int fd) {
|
2010-09-16 00:36:41 +02:00
|
|
|
unsigned char data[1];
|
|
|
|
|
|
|
|
data[0] = TIOCL_GETFGCONSOLE;
|
|
|
|
return ioctl(fd, TIOCLINUX, data) >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int disable_utf8(int fd) {
|
|
|
|
int r = 0, k;
|
|
|
|
|
|
|
|
if (ioctl(fd, KDSKBMODE, K_XLATE) < 0)
|
|
|
|
r = -errno;
|
|
|
|
|
2014-12-02 02:43:19 +01:00
|
|
|
k = loop_write(fd, "\033%@", 3, false);
|
|
|
|
if (k < 0)
|
|
|
|
r = k;
|
2010-09-16 00:36:41 +02:00
|
|
|
|
2015-07-07 01:27:20 +02:00
|
|
|
k = write_string_file("/sys/module/vt/parameters/default_utf8", "0", 0);
|
2012-05-03 15:10:09 +02:00
|
|
|
if (k < 0)
|
2010-09-16 00:36:41 +02:00
|
|
|
r = k;
|
|
|
|
|
|
|
|
if (r < 0)
|
2014-11-28 13:19:16 +01:00
|
|
|
log_warning_errno(r, "Failed to disable UTF-8: %m");
|
2010-09-16 00:36:41 +02:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2012-06-10 20:37:14 +02:00
|
|
|
static int enable_utf8(int fd) {
|
|
|
|
int r = 0, k;
|
2013-02-09 02:40:57 +01:00
|
|
|
long current = 0;
|
|
|
|
|
|
|
|
if (ioctl(fd, KDGKBMODE, ¤t) < 0 || current == K_XLATE) {
|
|
|
|
/*
|
|
|
|
* Change the current keyboard to unicode, unless it
|
|
|
|
* is currently in raw or off mode anyway. We
|
|
|
|
* shouldn't interfere with X11's processing of the
|
|
|
|
* key events.
|
|
|
|
*
|
|
|
|
* http://lists.freedesktop.org/archives/systemd-devel/2013-February/008573.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (ioctl(fd, KDSKBMODE, K_UNICODE) < 0)
|
|
|
|
r = -errno;
|
|
|
|
}
|
2012-06-10 20:37:14 +02:00
|
|
|
|
2014-12-02 02:43:19 +01:00
|
|
|
k = loop_write(fd, "\033%G", 3, false);
|
|
|
|
if (k < 0)
|
|
|
|
r = k;
|
2012-06-10 20:37:14 +02:00
|
|
|
|
2015-07-07 01:27:20 +02:00
|
|
|
k = write_string_file("/sys/module/vt/parameters/default_utf8", "1", 0);
|
2012-06-10 20:37:14 +02:00
|
|
|
if (k < 0)
|
|
|
|
r = k;
|
|
|
|
|
|
|
|
if (r < 0)
|
2014-11-28 13:19:16 +01:00
|
|
|
log_warning_errno(r, "Failed to enable UTF-8: %m");
|
2012-06-10 20:37:14 +02:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2015-04-09 13:10:11 +02:00
|
|
|
static int keyboard_load_and_wait(const char *vc, const char *map, const char *map_toggle, bool utf8) {
|
2010-11-06 17:11:03 +01:00
|
|
|
const char *args[8];
|
2015-04-09 13:10:11 +02:00
|
|
|
int i = 0, r;
|
2010-09-16 00:36:41 +02:00
|
|
|
pid_t pid;
|
|
|
|
|
vconsole-setup: check error of child process
If we don't check the error of the child process, systemd-vconsole-setup
would exit with 0 even if it could not really setup the console.
For a simple test, move loadkeys elsewhere and execute
systemd-vconsole-setup:
[root@localhost ~]# strace -f -e execve /usr/lib/systemd/systemd-vconsole-setup
execve("/usr/lib/systemd/systemd-vconsole-setup", ["/usr/lib/systemd/systemd-vconsol"...], [/* 15 vars */]) = 0
Process 171 attached
[pid 171] execve("/usr/bin/loadkeys", ["/usr/bin/loadkeys", "-q", "-C", "/dev/tty0", "br-abnt2"], [/* 15 vars */]) = -1 ENOENT (No such file or directory)
[pid 171] +++ exited with 1 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=171, si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
+++ exited with 0 +++
Note that loadkeys returned 1 while systemd-vconsole-setup return 0.
Since the font and keyboard setup are already serialized, refactor the
code a little bit so the functions do the wait by themselves. One change
in behavior in this patch is that we don't return early, but we do try
to setup the keyboard even if the font load failed.
2015-03-13 18:47:28 +01:00
|
|
|
/* An empty map means kernel map */
|
|
|
|
if (isempty(map))
|
2015-04-09 13:10:11 +02:00
|
|
|
return 1;
|
2011-04-20 04:30:08 +02:00
|
|
|
|
2010-09-21 00:07:09 +02:00
|
|
|
args[i++] = KBD_LOADKEYS;
|
2010-09-16 00:36:41 +02:00
|
|
|
args[i++] = "-q";
|
|
|
|
args[i++] = "-C";
|
|
|
|
args[i++] = vc;
|
|
|
|
if (utf8)
|
|
|
|
args[i++] = "-u";
|
|
|
|
args[i++] = map;
|
2010-11-06 17:11:03 +01:00
|
|
|
if (map_toggle)
|
|
|
|
args[i++] = map_toggle;
|
2010-09-16 00:36:41 +02:00
|
|
|
args[i++] = NULL;
|
|
|
|
|
2012-05-03 15:10:09 +02:00
|
|
|
pid = fork();
|
2015-04-09 13:10:11 +02:00
|
|
|
if (pid < 0)
|
|
|
|
return log_error_errno(errno, "Failed to fork: %m");
|
|
|
|
else if (pid == 0) {
|
2015-05-31 23:55:55 +02:00
|
|
|
|
|
|
|
(void) reset_all_signal_handlers();
|
|
|
|
(void) reset_signal_mask();
|
|
|
|
|
2010-09-16 00:36:41 +02:00
|
|
|
execv(args[0], (char **) args);
|
|
|
|
_exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2015-04-09 13:10:11 +02:00
|
|
|
r = wait_for_terminate_and_warn(KBD_LOADKEYS, pid, true);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return r == 0;
|
2010-09-16 00:36:41 +02:00
|
|
|
}
|
|
|
|
|
2015-04-09 13:10:11 +02:00
|
|
|
static int font_load_and_wait(const char *vc, const char *font, const char *map, const char *unimap) {
|
2010-09-16 00:36:41 +02:00
|
|
|
const char *args[9];
|
2015-04-09 13:10:11 +02:00
|
|
|
int i = 0, r;
|
2010-09-16 00:36:41 +02:00
|
|
|
pid_t pid;
|
|
|
|
|
vconsole-setup: check error of child process
If we don't check the error of the child process, systemd-vconsole-setup
would exit with 0 even if it could not really setup the console.
For a simple test, move loadkeys elsewhere and execute
systemd-vconsole-setup:
[root@localhost ~]# strace -f -e execve /usr/lib/systemd/systemd-vconsole-setup
execve("/usr/lib/systemd/systemd-vconsole-setup", ["/usr/lib/systemd/systemd-vconsol"...], [/* 15 vars */]) = 0
Process 171 attached
[pid 171] execve("/usr/bin/loadkeys", ["/usr/bin/loadkeys", "-q", "-C", "/dev/tty0", "br-abnt2"], [/* 15 vars */]) = -1 ENOENT (No such file or directory)
[pid 171] +++ exited with 1 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=171, si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
+++ exited with 0 +++
Note that loadkeys returned 1 while systemd-vconsole-setup return 0.
Since the font and keyboard setup are already serialized, refactor the
code a little bit so the functions do the wait by themselves. One change
in behavior in this patch is that we don't return early, but we do try
to setup the keyboard even if the font load failed.
2015-03-13 18:47:28 +01:00
|
|
|
/* An empty font means kernel font */
|
|
|
|
if (isempty(font))
|
2015-04-09 13:10:11 +02:00
|
|
|
return 1;
|
2011-04-20 04:30:08 +02:00
|
|
|
|
2010-09-21 00:07:09 +02:00
|
|
|
args[i++] = KBD_SETFONT;
|
2010-09-16 00:36:41 +02:00
|
|
|
args[i++] = "-C";
|
|
|
|
args[i++] = vc;
|
|
|
|
args[i++] = font;
|
2010-09-28 23:41:09 +02:00
|
|
|
if (map) {
|
2010-09-16 00:36:41 +02:00
|
|
|
args[i++] = "-m";
|
|
|
|
args[i++] = map;
|
|
|
|
}
|
2010-09-28 23:41:09 +02:00
|
|
|
if (unimap) {
|
2010-09-16 00:36:41 +02:00
|
|
|
args[i++] = "-u";
|
|
|
|
args[i++] = unimap;
|
|
|
|
}
|
|
|
|
args[i++] = NULL;
|
|
|
|
|
2012-05-03 15:10:09 +02:00
|
|
|
pid = fork();
|
2015-04-09 13:10:11 +02:00
|
|
|
if (pid < 0)
|
|
|
|
return log_error_errno(errno, "Failed to fork: %m");
|
|
|
|
else if (pid == 0) {
|
2015-05-31 23:55:55 +02:00
|
|
|
|
|
|
|
(void) reset_all_signal_handlers();
|
|
|
|
(void) reset_signal_mask();
|
|
|
|
|
2010-09-16 00:36:41 +02:00
|
|
|
execv(args[0], (char **) args);
|
|
|
|
_exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2015-04-09 13:10:11 +02:00
|
|
|
r = wait_for_terminate_and_warn(KBD_SETFONT, pid, true);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return r == 0;
|
2010-09-16 00:36:41 +02:00
|
|
|
}
|
|
|
|
|
2013-01-15 15:57:12 +01:00
|
|
|
/*
|
|
|
|
* A newly allocated VT uses the font from the active VT. Here
|
|
|
|
* we update all possibly already allocated VTs with the configured
|
|
|
|
* font. It also allows to restart systemd-vconsole-setup.service,
|
|
|
|
* to apply a new font to all VTs.
|
|
|
|
*/
|
|
|
|
static void font_copy_to_all_vcs(int fd) {
|
2013-03-25 00:59:00 +01:00
|
|
|
struct vt_stat vcs = {};
|
2014-06-23 18:23:48 +02:00
|
|
|
unsigned char map8[E_TABSZ];
|
|
|
|
unsigned short map16[E_TABSZ];
|
|
|
|
struct unimapdesc unimapd;
|
|
|
|
struct unipair unipairs[USHRT_MAX];
|
2013-03-25 00:59:00 +01:00
|
|
|
int i, r;
|
2013-01-15 02:25:56 +01:00
|
|
|
|
2013-01-15 15:57:12 +01:00
|
|
|
/* get active, and 16 bit mask of used VT numbers */
|
|
|
|
r = ioctl(fd, VT_GETSTATE, &vcs);
|
2015-04-09 13:12:55 +02:00
|
|
|
if (r < 0) {
|
|
|
|
log_debug_errno(errno, "VT_GETSTATE failed, ignoring: %m");
|
2013-01-15 02:25:56 +01:00
|
|
|
return;
|
2015-04-09 13:12:55 +02:00
|
|
|
}
|
2013-01-15 02:25:56 +01:00
|
|
|
|
2013-01-15 15:57:12 +01:00
|
|
|
for (i = 1; i <= 15; i++) {
|
2015-04-09 13:12:55 +02:00
|
|
|
char vcname[strlen("/dev/vcs") + DECIMAL_STR_MAX(int)];
|
2013-04-18 09:11:22 +02:00
|
|
|
_cleanup_close_ int vcfd = -1;
|
2013-03-25 00:59:00 +01:00
|
|
|
struct console_font_op cfo = {};
|
2013-01-15 02:25:56 +01:00
|
|
|
|
2013-01-15 15:57:12 +01:00
|
|
|
if (i == vcs.v_active)
|
2013-01-15 02:25:56 +01:00
|
|
|
continue;
|
|
|
|
|
2013-01-15 20:32:57 +01:00
|
|
|
/* skip non-allocated ttys */
|
|
|
|
snprintf(vcname, sizeof(vcname), "/dev/vcs%i", i);
|
|
|
|
if (access(vcname, F_OK) < 0)
|
2013-01-15 02:25:56 +01:00
|
|
|
continue;
|
|
|
|
|
2013-01-15 20:32:57 +01:00
|
|
|
snprintf(vcname, sizeof(vcname), "/dev/tty%i", i);
|
2013-01-15 15:57:12 +01:00
|
|
|
vcfd = open_terminal(vcname, O_RDWR|O_CLOEXEC);
|
|
|
|
if (vcfd < 0)
|
2013-01-15 02:25:56 +01:00
|
|
|
continue;
|
|
|
|
|
2013-01-15 15:57:12 +01:00
|
|
|
/* copy font from active VT, where the font was uploaded to */
|
2013-01-15 02:25:56 +01:00
|
|
|
cfo.op = KD_FONT_OP_COPY;
|
2013-01-15 15:57:12 +01:00
|
|
|
cfo.height = vcs.v_active-1; /* tty1 == index 0 */
|
2014-09-30 21:14:58 +02:00
|
|
|
(void) ioctl(vcfd, KDFONTOP, &cfo);
|
2014-06-23 18:23:48 +02:00
|
|
|
|
|
|
|
/* copy map of 8bit chars */
|
|
|
|
if (ioctl(fd, GIO_SCRNMAP, map8) >= 0)
|
2015-04-09 13:12:55 +02:00
|
|
|
(void) ioctl(vcfd, PIO_SCRNMAP, map8);
|
2014-06-23 18:23:48 +02:00
|
|
|
|
|
|
|
/* copy map of 8bit chars -> 16bit Unicode values */
|
|
|
|
if (ioctl(fd, GIO_UNISCRNMAP, map16) >= 0)
|
2015-04-09 13:12:55 +02:00
|
|
|
(void) ioctl(vcfd, PIO_UNISCRNMAP, map16);
|
2014-06-23 18:23:48 +02:00
|
|
|
|
|
|
|
/* copy unicode translation table */
|
|
|
|
/* unimapd is a ushort count and a pointer to an
|
|
|
|
array of struct unipair { ushort, ushort } */
|
|
|
|
unimapd.entries = unipairs;
|
|
|
|
unimapd.entry_ct = USHRT_MAX;
|
|
|
|
if (ioctl(fd, GIO_UNIMAP, &unimapd) >= 0) {
|
|
|
|
struct unimapinit adv = { 0, 0, 0 };
|
|
|
|
|
2014-09-30 21:14:58 +02:00
|
|
|
(void) ioctl(vcfd, PIO_UNIMAPCLR, &adv);
|
|
|
|
(void) ioctl(vcfd, PIO_UNIMAP, &unimapd);
|
2014-06-23 18:23:48 +02:00
|
|
|
}
|
2013-01-15 02:25:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-16 00:36:41 +02:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
const char *vc;
|
2014-07-02 04:20:11 +02:00
|
|
|
_cleanup_free_ char
|
|
|
|
*vc_keymap = NULL, *vc_keymap_toggle = NULL,
|
|
|
|
*vc_font = NULL, *vc_font_map = NULL, *vc_font_unimap = NULL;
|
|
|
|
_cleanup_close_ int fd = -1;
|
2015-04-09 13:12:55 +02:00
|
|
|
bool utf8, font_copy = false, font_ok, keyboard_ok;
|
2013-01-15 02:25:56 +01:00
|
|
|
int r = EXIT_FAILURE;
|
2010-09-16 00:36:41 +02:00
|
|
|
|
2011-04-20 04:30:08 +02:00
|
|
|
log_set_target(LOG_TARGET_AUTO);
|
2010-09-16 00:36:41 +02:00
|
|
|
log_parse_environment();
|
|
|
|
log_open();
|
|
|
|
|
2011-08-01 20:52:18 +02:00
|
|
|
umask(0022);
|
|
|
|
|
2010-09-16 00:36:41 +02:00
|
|
|
if (argv[1])
|
|
|
|
vc = argv[1];
|
2013-01-15 02:25:56 +01:00
|
|
|
else {
|
2013-01-15 15:57:12 +01:00
|
|
|
vc = "/dev/tty0";
|
|
|
|
font_copy = true;
|
2013-01-15 02:25:56 +01:00
|
|
|
}
|
2010-09-16 00:36:41 +02:00
|
|
|
|
2012-05-03 15:10:09 +02:00
|
|
|
fd = open_terminal(vc, O_RDWR|O_CLOEXEC);
|
|
|
|
if (fd < 0) {
|
2014-11-28 19:29:59 +01:00
|
|
|
log_error_errno(errno, "Failed to open %s: %m", vc);
|
2014-07-02 04:20:11 +02:00
|
|
|
return EXIT_FAILURE;
|
2010-09-16 00:36:41 +02:00
|
|
|
}
|
|
|
|
|
2010-09-21 03:16:28 +02:00
|
|
|
if (!is_vconsole(fd)) {
|
2010-09-16 00:36:41 +02:00
|
|
|
log_error("Device %s is not a virtual console.", vc);
|
2014-07-02 04:20:11 +02:00
|
|
|
return EXIT_FAILURE;
|
2010-09-16 00:36:41 +02:00
|
|
|
}
|
|
|
|
|
2010-09-21 03:16:28 +02:00
|
|
|
utf8 = is_locale_utf8();
|
2010-09-16 00:36:41 +02:00
|
|
|
|
2013-04-05 13:32:34 +02:00
|
|
|
r = parse_env_file("/etc/vconsole.conf", NEWLINE,
|
|
|
|
"KEYMAP", &vc_keymap,
|
|
|
|
"KEYMAP_TOGGLE", &vc_keymap_toggle,
|
|
|
|
"FONT", &vc_font,
|
|
|
|
"FONT_MAP", &vc_font_map,
|
|
|
|
"FONT_UNIMAP", &vc_font_unimap,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (r < 0 && r != -ENOENT)
|
2014-11-28 13:19:16 +01:00
|
|
|
log_warning_errno(r, "Failed to read /etc/vconsole.conf: %m");
|
2013-04-05 13:32:34 +02:00
|
|
|
|
|
|
|
/* Let the kernel command line override /etc/vconsole.conf */
|
2015-09-07 13:42:47 +02:00
|
|
|
if (detect_container() <= 0) {
|
2012-05-03 15:10:09 +02:00
|
|
|
r = parse_env_file("/proc/cmdline", WHITESPACE,
|
|
|
|
"vconsole.keymap", &vc_keymap,
|
|
|
|
"vconsole.keymap.toggle", &vc_keymap_toggle,
|
|
|
|
"vconsole.font", &vc_font,
|
|
|
|
"vconsole.font.map", &vc_font_map,
|
|
|
|
"vconsole.font.unimap", &vc_font_unimap,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (r < 0 && r != -ENOENT)
|
2014-11-28 13:19:16 +01:00
|
|
|
log_warning_errno(r, "Failed to read /proc/cmdline: %m");
|
2012-05-03 15:10:09 +02:00
|
|
|
}
|
2010-09-16 01:58:16 +02:00
|
|
|
|
2012-06-10 20:37:14 +02:00
|
|
|
if (utf8)
|
2015-04-09 13:12:55 +02:00
|
|
|
(void) enable_utf8(fd);
|
2012-06-10 20:37:14 +02:00
|
|
|
else
|
2015-04-09 13:12:55 +02:00
|
|
|
(void) disable_utf8(fd);
|
2010-09-21 03:16:28 +02:00
|
|
|
|
2015-04-09 13:10:11 +02:00
|
|
|
font_ok = font_load_and_wait(vc, vc_font, vc_font_map, vc_font_unimap) > 0;
|
|
|
|
keyboard_ok = keyboard_load_and_wait(vc, vc_keymap, vc_keymap_toggle, utf8) > 0;
|
2010-09-16 00:36:41 +02:00
|
|
|
|
vconsole-setup: check error of child process
If we don't check the error of the child process, systemd-vconsole-setup
would exit with 0 even if it could not really setup the console.
For a simple test, move loadkeys elsewhere and execute
systemd-vconsole-setup:
[root@localhost ~]# strace -f -e execve /usr/lib/systemd/systemd-vconsole-setup
execve("/usr/lib/systemd/systemd-vconsole-setup", ["/usr/lib/systemd/systemd-vconsol"...], [/* 15 vars */]) = 0
Process 171 attached
[pid 171] execve("/usr/bin/loadkeys", ["/usr/bin/loadkeys", "-q", "-C", "/dev/tty0", "br-abnt2"], [/* 15 vars */]) = -1 ENOENT (No such file or directory)
[pid 171] +++ exited with 1 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=171, si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
+++ exited with 0 +++
Note that loadkeys returned 1 while systemd-vconsole-setup return 0.
Since the font and keyboard setup are already serialized, refactor the
code a little bit so the functions do the wait by themselves. One change
in behavior in this patch is that we don't return early, but we do try
to setup the keyboard even if the font load failed.
2015-03-13 18:47:28 +01:00
|
|
|
/* Only copy the font when we executed setfont successfully */
|
|
|
|
if (font_copy && font_ok)
|
2015-04-09 13:12:55 +02:00
|
|
|
(void) font_copy_to_all_vcs(fd);
|
2010-09-16 00:36:41 +02:00
|
|
|
|
vconsole-setup: check error of child process
If we don't check the error of the child process, systemd-vconsole-setup
would exit with 0 even if it could not really setup the console.
For a simple test, move loadkeys elsewhere and execute
systemd-vconsole-setup:
[root@localhost ~]# strace -f -e execve /usr/lib/systemd/systemd-vconsole-setup
execve("/usr/lib/systemd/systemd-vconsole-setup", ["/usr/lib/systemd/systemd-vconsol"...], [/* 15 vars */]) = 0
Process 171 attached
[pid 171] execve("/usr/bin/loadkeys", ["/usr/bin/loadkeys", "-q", "-C", "/dev/tty0", "br-abnt2"], [/* 15 vars */]) = -1 ENOENT (No such file or directory)
[pid 171] +++ exited with 1 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=171, si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
+++ exited with 0 +++
Note that loadkeys returned 1 while systemd-vconsole-setup return 0.
Since the font and keyboard setup are already serialized, refactor the
code a little bit so the functions do the wait by themselves. One change
in behavior in this patch is that we don't return early, but we do try
to setup the keyboard even if the font load failed.
2015-03-13 18:47:28 +01:00
|
|
|
return font_ok && keyboard_ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
2010-09-16 00:36:41 +02:00
|
|
|
}
|