vconsole: permit configuration of vconsole settings via credentials

This commit is contained in:
Lennart Poettering
2023-01-05 18:24:21 +01:00
parent bc0b2d377f
commit ea575e176a
9 changed files with 210 additions and 4 deletions
+15 -3
View File
@@ -19,6 +19,7 @@
#include <unistd.h>
#include "alloc-util.h"
#include "creds-util.h"
#include "env-file.h"
#include "errno-util.h"
#include "fd-util.h"
@@ -434,6 +435,17 @@ int main(int argc, char **argv) {
utf8 = is_locale_utf8();
/* Load data from credentials (lowest priority) */
r = read_credential_strings_many(
"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);
if (r < 0 && r != -ENXIO)
log_warning_errno(r, "Failed to import credentials, ignoring: %m");
/* Load data from configuration file (middle priority) */
r = parse_env_file(NULL, "/etc/vconsole.conf",
"KEYMAP", &vc_keymap,
"KEYMAP_TOGGLE", &vc_keymap_toggle,
@@ -441,9 +453,9 @@ int main(int argc, char **argv) {
"FONT_MAP", &vc_font_map,
"FONT_UNIMAP", &vc_font_unimap);
if (r < 0 && r != -ENOENT)
log_warning_errno(r, "Failed to read /etc/vconsole.conf: %m");
log_warning_errno(r, "Failed to read /etc/vconsole.conf, ignoring: %m");
/* Let the kernel command line override /etc/vconsole.conf */
/* Let the kernel command line override /etc/vconsole.conf (highest priority) */
r = proc_cmdline_get_key_many(
PROC_CMDLINE_STRIP_RD_PREFIX,
"vconsole.keymap", &vc_keymap,
@@ -456,7 +468,7 @@ int main(int argc, char **argv) {
"vconsole.font.map", &vc_font_map,
"vconsole.font.unimap", &vc_font_unimap);
if (r < 0 && r != -ENOENT)
log_warning_errno(r, "Failed to read /proc/cmdline: %m");
log_warning_errno(r, "Failed to read /proc/cmdline, ignoring: %m");
(void) toggle_utf8_sysfs(utf8);
(void) toggle_utf8_vc(vc, fd, utf8);