SHA256
1
0
forked from pool/systemd
systemd/handle-disable_caplock-and-compose_table-and-kbd_rate.patch

232 lines
7.6 KiB
Diff
Raw Normal View History

From: Frederic Crozat <fcrozat@suse.com>
Date: Fri, 19 Aug 2011 15:29:49 +0000
Subject: handle disable_caplock and compose_table and kbd_rate
(bnc#746595)
---
src/vconsole/vconsole-setup.c | 156 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 153 insertions(+), 3 deletions(-)
--- systemd-206_git201308300826.orig/src/vconsole/vconsole-setup.c
+++ systemd-206_git201308300826/src/vconsole/vconsole-setup.c
@@ -40,6 +40,7 @@
#include "macro.h"
#include "virt.h"
#include "fileio.h"
+#include "strv.h"
static bool is_vconsole(int fd) {
unsigned char data[1];
@@ -99,8 +100,8 @@ static int enable_utf8(int fd) {
return r;
}
-static int keymap_load(const char *vc, const char *map, const char *map_toggle, bool utf8, pid_t *_pid) {
- const char *args[8];
+static int keymap_load(const char *vc, const char *map, const char *map_toggle, bool utf8, bool disable_capslock, pid_t *_pid) {
+ const char *args[9];
int i = 0;
pid_t pid;
Accepting request 184036 from home:elvigia:branches:Base:System - version 206 , highlights: * Unit files now understand the new %v specifier which resolves to the kernel version string as returned by "uname-r". * "journalctl -b" may now be used to look for boot output of a specific boot. Try "journalctl -b -1" * Creation of "dead" device nodes has been moved from udev into kmod and tmpfiles. * The udev "keymap" data files and tools to apply keyboard specific mappings of scan to key codes, and force-release scan code lists have been entirely replaced by a udev "keyboard" builtin and a hwdb data file. - remove patches now in upstream - systemd now requires libkmod >=14 and cryptsetup >= 1.6.0 - systemd now require the kmod tool in addition to the library. - version 206 , highlights: * Unit files now understand the new %v specifier which resolves to the kernel version string as returned by "uname-r". * "journalctl -b" may now be used to look for boot output of a specific boot. Try "journalctl -b -1" * Creation of "dead" device nodes has been moved from udev into kmod and tmpfiles. * The udev "keymap" data files and tools to apply keyboard specific mappings of scan to key codes, and force-release scan code lists have been entirely replaced by a udev "keyboard" builtin and a hwdb data file. - remove patches now in upstream - systemd now requires libkmod >=14 and cryptsetup >= 1.6.0 - systemd now require the kmod tool in addition to the library. (forwarded request 184035 from elvigia) OBS-URL: https://build.opensuse.org/request/show/184036 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=416
2013-07-23 11:21:21 +02:00
@@ -119,6 +120,8 @@ static int keymap_load(const char *vc, c
args[i++] = map;
if (map_toggle)
args[i++] = map_toggle;
+ if (disable_capslock)
+ args[i++] = "disable.capslock";
args[i++] = NULL;
pid = fork();
Accepting request 184036 from home:elvigia:branches:Base:System - version 206 , highlights: * Unit files now understand the new %v specifier which resolves to the kernel version string as returned by "uname-r". * "journalctl -b" may now be used to look for boot output of a specific boot. Try "journalctl -b -1" * Creation of "dead" device nodes has been moved from udev into kmod and tmpfiles. * The udev "keymap" data files and tools to apply keyboard specific mappings of scan to key codes, and force-release scan code lists have been entirely replaced by a udev "keyboard" builtin and a hwdb data file. - remove patches now in upstream - systemd now requires libkmod >=14 and cryptsetup >= 1.6.0 - systemd now require the kmod tool in addition to the library. - version 206 , highlights: * Unit files now understand the new %v specifier which resolves to the kernel version string as returned by "uname-r". * "journalctl -b" may now be used to look for boot output of a specific boot. Try "journalctl -b -1" * Creation of "dead" device nodes has been moved from udev into kmod and tmpfiles. * The udev "keymap" data files and tools to apply keyboard specific mappings of scan to key codes, and force-release scan code lists have been entirely replaced by a udev "keyboard" builtin and a hwdb data file. - remove patches now in upstream - systemd now requires libkmod >=14 and cryptsetup >= 1.6.0 - systemd now require the kmod tool in addition to the library. (forwarded request 184035 from elvigia) OBS-URL: https://build.opensuse.org/request/show/184036 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=416
2013-07-23 11:21:21 +02:00
@@ -212,6 +215,101 @@ static void font_copy_to_all_vcs(int fd)
}
}
+#ifdef HAVE_SYSV_COMPAT
+static int load_compose_table(const char *vc, const char *compose_table, pid_t *_pid) {
+ const char *args[1024];
Accepting request 96123 from home:fcrozat:systemd - Remove storage-after-cryptsetup.service, add storage-after-cryptsetup.patch instead to prevent dependency cycle (bnc#722539). - Add delay-fsck-cryptsetup-after-md-lvm-dmraid.patch: ensure fsck/cryptsetup is run after lvm/md/dmraid have landed (bnc#724912). - Add cron-tty-pam.patch: Fix cron filling logs (bnc#731358). - Add do_not_warn_pidfile.patch: Fix PID warning in logs (bnc#732912). - Add mount-swap-log.patch: Ensure swap and mount output is redirected to default log target (rhb#750032). - Add color-on-boot.patch: ensure colored status are displayed at boot time. - Update modules_on_boot.patch to fix bnc#732041. - Replace private_tmp_crash.patch with log_on_close.patch, better upstream fix for bnc#699829 and fix bnc#731719. - Update vconsole patch to fix memleaks and crash (bnc#734527). - Add handle-racy-daemon.patch: fix warnings with sendmail (bnc#732912). - Add new-lsb-headers.patch: support PIDFile: and X-Systemd-RemainAfterExit: header in initscript (bnc#727771). - Update bootsplash services to not start if vga= is missing from cmdline (bnc#727771) - Add lock-opensuse.patch: disable /var/lock/{subsys,lockdev} and change default permissions on /var/lock (bnc#733523). - Add garbage_collect_units: ensure error units are correctly garbage collected (rhb#680122). - Add crypt-loop-file.patch: add support for crypt file loop (bnc#730496). OBS-URL: https://build.opensuse.org/request/show/96123 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=228
2011-12-09 15:44:59 +01:00
+ int i = 0, j = 0;
+ pid_t pid;
+ char **strv_compose_table = NULL;
Accepting request 96123 from home:fcrozat:systemd - Remove storage-after-cryptsetup.service, add storage-after-cryptsetup.patch instead to prevent dependency cycle (bnc#722539). - Add delay-fsck-cryptsetup-after-md-lvm-dmraid.patch: ensure fsck/cryptsetup is run after lvm/md/dmraid have landed (bnc#724912). - Add cron-tty-pam.patch: Fix cron filling logs (bnc#731358). - Add do_not_warn_pidfile.patch: Fix PID warning in logs (bnc#732912). - Add mount-swap-log.patch: Ensure swap and mount output is redirected to default log target (rhb#750032). - Add color-on-boot.patch: ensure colored status are displayed at boot time. - Update modules_on_boot.patch to fix bnc#732041. - Replace private_tmp_crash.patch with log_on_close.patch, better upstream fix for bnc#699829 and fix bnc#731719. - Update vconsole patch to fix memleaks and crash (bnc#734527). - Add handle-racy-daemon.patch: fix warnings with sendmail (bnc#732912). - Add new-lsb-headers.patch: support PIDFile: and X-Systemd-RemainAfterExit: header in initscript (bnc#727771). - Update bootsplash services to not start if vga= is missing from cmdline (bnc#727771) - Add lock-opensuse.patch: disable /var/lock/{subsys,lockdev} and change default permissions on /var/lock (bnc#733523). - Add garbage_collect_units: ensure error units are correctly garbage collected (rhb#680122). - Add crypt-loop-file.patch: add support for crypt file loop (bnc#730496). OBS-URL: https://build.opensuse.org/request/show/96123 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=228
2011-12-09 15:44:59 +01:00
+ char *to_free[1024];
+
+ if (isempty(compose_table)) {
+ /* An empty map means no compose table*/
+ *_pid = 0;
+ return 0;
+ }
+
+ args[i++] = KBD_LOADKEYS;
+ args[i++] = "-q";
+ args[i++] = "-C";
+ args[i++] = vc;
+
+ strv_compose_table = strv_split(compose_table, WHITESPACE);
+ if (strv_compose_table) {
+ bool compose_loaded = false;
+ bool compose_clear = false;
+ char **name;
+ char *arg;
+
+ STRV_FOREACH (name, strv_compose_table) {
+ if (streq(*name,"-c") || streq(*name,"clear")) {
+ compose_clear = true;
+ continue;
+ }
+ if (!compose_loaded) {
+ if (compose_clear)
+ args[i++] = "-c";
+ }
+ asprintf(&arg, "compose.%s",*name);
+ compose_loaded = true;
Accepting request 96123 from home:fcrozat:systemd - Remove storage-after-cryptsetup.service, add storage-after-cryptsetup.patch instead to prevent dependency cycle (bnc#722539). - Add delay-fsck-cryptsetup-after-md-lvm-dmraid.patch: ensure fsck/cryptsetup is run after lvm/md/dmraid have landed (bnc#724912). - Add cron-tty-pam.patch: Fix cron filling logs (bnc#731358). - Add do_not_warn_pidfile.patch: Fix PID warning in logs (bnc#732912). - Add mount-swap-log.patch: Ensure swap and mount output is redirected to default log target (rhb#750032). - Add color-on-boot.patch: ensure colored status are displayed at boot time. - Update modules_on_boot.patch to fix bnc#732041. - Replace private_tmp_crash.patch with log_on_close.patch, better upstream fix for bnc#699829 and fix bnc#731719. - Update vconsole patch to fix memleaks and crash (bnc#734527). - Add handle-racy-daemon.patch: fix warnings with sendmail (bnc#732912). - Add new-lsb-headers.patch: support PIDFile: and X-Systemd-RemainAfterExit: header in initscript (bnc#727771). - Update bootsplash services to not start if vga= is missing from cmdline (bnc#727771) - Add lock-opensuse.patch: disable /var/lock/{subsys,lockdev} and change default permissions on /var/lock (bnc#733523). - Add garbage_collect_units: ensure error units are correctly garbage collected (rhb#680122). - Add crypt-loop-file.patch: add support for crypt file loop (bnc#730496). OBS-URL: https://build.opensuse.org/request/show/96123 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=228
2011-12-09 15:44:59 +01:00
+ args[i++] = to_free[j++] = arg;
+
+ }
+ strv_free(strv_compose_table);
+ }
+ args[i++] = NULL;
+
+ if ((pid = fork()) < 0) {
+ log_error("Failed to fork: %m");
+ return -errno;
+ } else if (pid == 0) {
+ execv(args[0], (char **) args);
+ _exit(EXIT_FAILURE);
+ }
+
+ *_pid = pid;
Accepting request 96123 from home:fcrozat:systemd - Remove storage-after-cryptsetup.service, add storage-after-cryptsetup.patch instead to prevent dependency cycle (bnc#722539). - Add delay-fsck-cryptsetup-after-md-lvm-dmraid.patch: ensure fsck/cryptsetup is run after lvm/md/dmraid have landed (bnc#724912). - Add cron-tty-pam.patch: Fix cron filling logs (bnc#731358). - Add do_not_warn_pidfile.patch: Fix PID warning in logs (bnc#732912). - Add mount-swap-log.patch: Ensure swap and mount output is redirected to default log target (rhb#750032). - Add color-on-boot.patch: ensure colored status are displayed at boot time. - Update modules_on_boot.patch to fix bnc#732041. - Replace private_tmp_crash.patch with log_on_close.patch, better upstream fix for bnc#699829 and fix bnc#731719. - Update vconsole patch to fix memleaks and crash (bnc#734527). - Add handle-racy-daemon.patch: fix warnings with sendmail (bnc#732912). - Add new-lsb-headers.patch: support PIDFile: and X-Systemd-RemainAfterExit: header in initscript (bnc#727771). - Update bootsplash services to not start if vga= is missing from cmdline (bnc#727771) - Add lock-opensuse.patch: disable /var/lock/{subsys,lockdev} and change default permissions on /var/lock (bnc#733523). - Add garbage_collect_units: ensure error units are correctly garbage collected (rhb#680122). - Add crypt-loop-file.patch: add support for crypt file loop (bnc#730496). OBS-URL: https://build.opensuse.org/request/show/96123 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=228
2011-12-09 15:44:59 +01:00
+
+ for (i=0 ; i < j ; i++)
+ free (to_free[i]);
+
+ return 0;
+}
+#endif
+
+static int set_kbd_rate(const char *vc, const char *kbd_rate, const char *kbd_delay, pid_t *_pid) {
+ const char *args[7];
+ int i = 0;
+ pid_t pid;
+
+ if (isempty(kbd_rate) && isempty(kbd_delay)) {
+ *_pid = 0;
+ return 0;
+ }
+
+ args[i++] = "/bin/kbdrate";
+ if (!isempty(kbd_rate)) {
+ args[i++] = "-r";
+ args[i++] = kbd_rate;
+ }
+ if (!isempty(kbd_delay)) {
+ args[i++] = "-d";
+ args[i++] = kbd_delay;
+ }
+ args[i++] = "-s";
+ args[i++] = NULL;
+
+ if ((pid = fork()) < 0) {
+ log_error("Failed to fork: %m");
+ return -errno;
+ } else if (pid == 0) {
+ execv(args[0], (char **) args);
+ _exit(EXIT_FAILURE);
+ }
+
+ *_pid = pid;
+ return 0;
+}
+
int main(int argc, char **argv) {
const char *vc;
char *vc_keymap = NULL;
2013-04-19 22:31:17 +02:00
@@ -219,8 +317,16 @@ int main(int argc, char **argv) {
char *vc_font = NULL;
char *vc_font_map = NULL;
char *vc_font_unimap = NULL;
+#ifdef HAVE_SYSV_COMPAT
+ char *vc_kbd_delay = NULL;
+ char *vc_kbd_rate = NULL;
+ char *vc_kbd_disable_caps_lock = NULL;
+ char *vc_compose_table = NULL;
+ pid_t kbd_rate_pid = 0, compose_table_pid = 0;
+#endif
int fd = -1;
bool utf8;
+ bool disable_capslock = false;
pid_t font_pid = 0, keymap_pid = 0;
bool font_copy = false;
int r = EXIT_FAILURE;
2013-04-19 22:31:17 +02:00
@@ -276,13 +382,43 @@ int main(int argc, char **argv) {
log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
}
+ if (r <= 0) {
+#ifdef HAVE_SYSV_COMPAT
+ r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
+ "KEYTABLE", &vc_keymap,
+ "KBD_DELAY", &vc_kbd_delay,
+ "KBD_RATE", &vc_kbd_rate,
+ "KBD_DISABLE_CAPS_LOCK", &vc_kbd_disable_caps_lock,
+ "COMPOSETABLE", &vc_compose_table,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/keyboard: %s", strerror(-r));
+
+ r = parse_env_file("/etc/sysconfig/console", NEWLINE,
+ "CONSOLE_FONT", &vc_font,
+ "CONSOLE_SCREENMAP", &vc_font_map,
+ "CONSOLE_UNICODEMAP", &vc_font_unimap,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/console: %s", strerror(-r));
+
+ disable_capslock = vc_kbd_disable_caps_lock && strcasecmp(vc_kbd_disable_caps_lock, "YES") == 0;
+
+#endif
+ }
+
if (utf8)
enable_utf8(fd);
else
disable_utf8(fd);
r = EXIT_FAILURE;
- if (keymap_load(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid) >= 0 &&
+
+ if (keymap_load(vc, vc_keymap, vc_keymap_toggle, utf8, disable_capslock, &keymap_pid) >= 0 &&
+#ifdef HAVE_SYSV_COMPAT
+ load_compose_table(vc, vc_compose_table, &compose_table_pid) >= 0 &&
+ set_kbd_rate(vc, vc_kbd_rate, vc_kbd_delay, &kbd_rate_pid) >= 0 &&
+#endif
font_load(vc, vc_font, vc_font_map, vc_font_unimap, &font_pid) >= 0)
r = EXIT_SUCCESS;
2013-04-19 22:31:17 +02:00
@@ -290,6 +426,14 @@ finish:
if (keymap_pid > 0)
wait_for_terminate_and_warn(KBD_LOADKEYS, keymap_pid);
+#ifdef HAVE_SYSV_COMPAT
+ if (compose_table_pid > 0)
+ wait_for_terminate_and_warn(KBD_LOADKEYS, compose_table_pid);
+
+ if (kbd_rate_pid > 0)
+ wait_for_terminate_and_warn("/bin/kbdrate", kbd_rate_pid);
+#endif
+
if (font_pid > 0) {
wait_for_terminate_and_warn(KBD_SETFONT, font_pid);
if (font_copy)
2013-04-19 22:31:17 +02:00
@@ -300,6 +444,12 @@ finish:
Accepting request 96123 from home:fcrozat:systemd - Remove storage-after-cryptsetup.service, add storage-after-cryptsetup.patch instead to prevent dependency cycle (bnc#722539). - Add delay-fsck-cryptsetup-after-md-lvm-dmraid.patch: ensure fsck/cryptsetup is run after lvm/md/dmraid have landed (bnc#724912). - Add cron-tty-pam.patch: Fix cron filling logs (bnc#731358). - Add do_not_warn_pidfile.patch: Fix PID warning in logs (bnc#732912). - Add mount-swap-log.patch: Ensure swap and mount output is redirected to default log target (rhb#750032). - Add color-on-boot.patch: ensure colored status are displayed at boot time. - Update modules_on_boot.patch to fix bnc#732041. - Replace private_tmp_crash.patch with log_on_close.patch, better upstream fix for bnc#699829 and fix bnc#731719. - Update vconsole patch to fix memleaks and crash (bnc#734527). - Add handle-racy-daemon.patch: fix warnings with sendmail (bnc#732912). - Add new-lsb-headers.patch: support PIDFile: and X-Systemd-RemainAfterExit: header in initscript (bnc#727771). - Update bootsplash services to not start if vga= is missing from cmdline (bnc#727771) - Add lock-opensuse.patch: disable /var/lock/{subsys,lockdev} and change default permissions on /var/lock (bnc#733523). - Add garbage_collect_units: ensure error units are correctly garbage collected (rhb#680122). - Add crypt-loop-file.patch: add support for crypt file loop (bnc#730496). OBS-URL: https://build.opensuse.org/request/show/96123 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=228
2011-12-09 15:44:59 +01:00
free(vc_font);
free(vc_font_map);
free(vc_font_unimap);
+#ifdef HAVE_SYSV_COMPAT
Accepting request 96123 from home:fcrozat:systemd - Remove storage-after-cryptsetup.service, add storage-after-cryptsetup.patch instead to prevent dependency cycle (bnc#722539). - Add delay-fsck-cryptsetup-after-md-lvm-dmraid.patch: ensure fsck/cryptsetup is run after lvm/md/dmraid have landed (bnc#724912). - Add cron-tty-pam.patch: Fix cron filling logs (bnc#731358). - Add do_not_warn_pidfile.patch: Fix PID warning in logs (bnc#732912). - Add mount-swap-log.patch: Ensure swap and mount output is redirected to default log target (rhb#750032). - Add color-on-boot.patch: ensure colored status are displayed at boot time. - Update modules_on_boot.patch to fix bnc#732041. - Replace private_tmp_crash.patch with log_on_close.patch, better upstream fix for bnc#699829 and fix bnc#731719. - Update vconsole patch to fix memleaks and crash (bnc#734527). - Add handle-racy-daemon.patch: fix warnings with sendmail (bnc#732912). - Add new-lsb-headers.patch: support PIDFile: and X-Systemd-RemainAfterExit: header in initscript (bnc#727771). - Update bootsplash services to not start if vga= is missing from cmdline (bnc#727771) - Add lock-opensuse.patch: disable /var/lock/{subsys,lockdev} and change default permissions on /var/lock (bnc#733523). - Add garbage_collect_units: ensure error units are correctly garbage collected (rhb#680122). - Add crypt-loop-file.patch: add support for crypt file loop (bnc#730496). OBS-URL: https://build.opensuse.org/request/show/96123 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=228
2011-12-09 15:44:59 +01:00
+ free(vc_kbd_delay);
+ free(vc_kbd_rate);
+ free(vc_kbd_disable_caps_lock);
+ free(vc_compose_table);
+#endif
if (fd >= 0)
close_nointr_nofail(fd);