SHA256
1
0
forked from pool/systemd

- Update compose_table patch to use two separate loadkeys call,

compose table overflows otherwise (spotted by Werner Fink).

OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=185
This commit is contained in:
Frederic Crozat 2011-08-26 14:11:36 +00:00 committed by Git OBS Bridge
parent 0c58c0f7e5
commit 57b136d57b
2 changed files with 80 additions and 49 deletions

View File

@ -1,14 +1,14 @@
From e183dbe195058ef921c4bd9760dc3631b425dd92 Mon Sep 17 00:00:00 2001 From 07f0fb4424105c0e90e2add79efe48109b6c9fd1 Mon Sep 17 00:00:00 2001
From: Frederic Crozat <fcrozat@suse.com> From: Frederic Crozat <fcrozat@suse.com>
Date: Thu, 18 Aug 2011 18:28:01 +0200 Date: Thu, 18 Aug 2011 18:28:01 +0200
Subject: [PATCH] handle disable_caplock and compose_table and kbd_rate Subject: [PATCH] handle disable_caplock and compose_table and kbd_rate
--- ---
src/vconsole-setup.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/vconsole-setup.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 90 insertions(+), 3 deletions(-) 1 files changed, 121 insertions(+), 3 deletions(-)
diff --git a/src/vconsole-setup.c b/src/vconsole-setup.c diff --git a/src/vconsole-setup.c b/src/vconsole-setup.c
index 4347a20..28dc1d9 100644 index 4347a20..af558ef 100644
--- a/src/vconsole-setup.c --- a/src/vconsole-setup.c
+++ b/src/vconsole-setup.c +++ b/src/vconsole-setup.c
@@ -39,6 +39,7 @@ @@ -39,6 +39,7 @@
@ -25,52 +25,79 @@ index 4347a20..28dc1d9 100644
-static int load_keymap(const char *vc, const char *map, const char *map_toggle, bool utf8, pid_t *_pid) { -static int load_keymap(const char *vc, const char *map, const char *map_toggle, bool utf8, pid_t *_pid) {
- const char *args[8]; - const char *args[8];
+static int load_keymap(const char *vc, const char *map, const char *map_toggle, bool utf8, bool disable_capslock, const char *compose_table, pid_t *_pid) { +static int load_keymap(const char *vc, const char *map, const char *map_toggle, bool utf8, bool disable_capslock, pid_t *_pid) {
+ const char *args[1024]; + const char *args[9];
int i = 0; int i = 0;
pid_t pid; pid_t pid;
@@ -98,6 +99,35 @@ static int load_keymap(const char *vc, const char *map, const char *map_toggle, @@ -98,6 +99,8 @@ static int load_keymap(const char *vc, const char *map, const char *map_toggle,
args[i++] = map; args[i++] = map;
if (map_toggle) if (map_toggle)
args[i++] = map_toggle; args[i++] = map_toggle;
+ if (disable_capslock) + if (disable_capslock)
+ args[i++] = "disable.capslock"; + args[i++] = "disable.capslock";
+ if (compose_table) {
+ char **strv_compose_table = NULL;
+
+ 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;
+ args[i++] = arg;
+
+ }
+ }
+ strv_free(strv_compose_table);
+ }
args[i++] = NULL; args[i++] = NULL;
if ((pid = fork()) < 0) { if ((pid = fork()) < 0) {
@@ -149,6 +179,42 @@ static int load_font(const char *vc, const char *font, const char *map, const ch @@ -149,6 +152,96 @@ static int load_font(const char *vc, const char *font, const char *map, const ch
return 0; return 0;
} }
+#ifdef TARGET_SUSE +#ifdef TARGET_SUSE
+static int load_compose_table(const char *vc, const char *compose_table, pid_t *_pid) {
+ const char *args[1024];
+ int i = 0;
+ pid_t pid;
+ char **strv_compose_table = NULL;
+
+ 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;
+ args[i++] = 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;
+ return 0;
+}
+
+static int set_kbd_rate(const char *vc, const char *kbd_rate, const char *kbd_delay, pid_t *_pid) { +static int set_kbd_rate(const char *vc, const char *kbd_rate, const char *kbd_delay, pid_t *_pid) {
+ const char *args[7]; + const char *args[7];
+ int i = 0; + int i = 0;
@ -109,14 +136,7 @@ index 4347a20..28dc1d9 100644
int main(int argc, char **argv) { int main(int argc, char **argv) {
const char *vc; const char *vc;
char *vc_keymap = NULL; char *vc_keymap = NULL;
@@ -156,14 +222,22 @@ int main(int argc, char **argv) { @@ -162,8 +255,16 @@ int main(int argc, char **argv) {
char *vc_font = NULL;
char *vc_font_map = NULL;
char *vc_font_unimap = NULL;
+ char *vc_compose_table = NULL;
#ifdef TARGET_GENTOO
char *vc_unicode = NULL;
#endif
#ifdef TARGET_MANDRIVA #ifdef TARGET_MANDRIVA
char *vc_keytable = NULL; char *vc_keytable = NULL;
#endif #endif
@ -124,7 +144,8 @@ index 4347a20..28dc1d9 100644
+ char *vc_kbd_delay = NULL; + char *vc_kbd_delay = NULL;
+ char *vc_kbd_rate = NULL; + char *vc_kbd_rate = NULL;
+ char *vc_kbd_disable_caps_lock = NULL; + char *vc_kbd_disable_caps_lock = NULL;
+ pid_t kbd_rate_pid = 0; + char *vc_compose_table = NULL;
+ pid_t kbd_rate_pid = 0, compose_table_pid = 0;
+#endif +#endif
int fd = -1; int fd = -1;
bool utf8; bool utf8;
@ -132,7 +153,7 @@ index 4347a20..28dc1d9 100644
int r = EXIT_FAILURE; int r = EXIT_FAILURE;
pid_t font_pid = 0, keymap_pid = 0; pid_t font_pid = 0, keymap_pid = 0;
@@ -268,6 +342,10 @@ int main(int argc, char **argv) { @@ -268,6 +369,10 @@ int main(int argc, char **argv) {
#elif defined(TARGET_SUSE) #elif defined(TARGET_SUSE)
if ((r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE, if ((r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
"KEYTABLE", &vc_keymap, "KEYTABLE", &vc_keymap,
@ -143,7 +164,7 @@ index 4347a20..28dc1d9 100644
NULL)) < 0) { NULL)) < 0) {
if (r != -ENOENT) if (r != -ENOENT)
@@ -283,6 +361,7 @@ int main(int argc, char **argv) { @@ -283,6 +388,7 @@ int main(int argc, char **argv) {
if (r != -ENOENT) if (r != -ENOENT)
log_warning("Failed to read /etc/sysconfig/console: %s", strerror(-r)); log_warning("Failed to read /etc/sysconfig/console: %s", strerror(-r));
} }
@ -151,23 +172,27 @@ index 4347a20..28dc1d9 100644
#elif defined(TARGET_ARCH) #elif defined(TARGET_ARCH)
if ((r = parse_env_file("/etc/rc.conf", NEWLINE, if ((r = parse_env_file("/etc/rc.conf", NEWLINE,
@@ -439,7 +518,10 @@ int main(int argc, char **argv) { @@ -439,7 +545,11 @@ int main(int argc, char **argv) {
if (!utf8) if (!utf8)
disable_utf8(fd); disable_utf8(fd);
- if (load_keymap(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid) >= 0 && - if (load_keymap(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid) >= 0 &&
+ if (load_keymap(vc, vc_keymap, vc_keymap_toggle, utf8, disable_capslock, vc_compose_table, &keymap_pid) >= 0 && + if (load_keymap(vc, vc_keymap, vc_keymap_toggle, utf8, disable_capslock, &keymap_pid) >= 0 &&
+#ifdef TARGET_SUSE +#ifdef TARGET_SUSE
+ 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 && + set_kbd_rate(vc, vc_kbd_rate, vc_kbd_delay, &kbd_rate_pid) >= 0 &&
+#endif +#endif
load_font(vc, vc_font, vc_font_map, vc_font_unimap, &font_pid) >= 0) load_font(vc, vc_font, vc_font_map, vc_font_unimap, &font_pid) >= 0)
r = EXIT_SUCCESS; r = EXIT_SUCCESS;
@@ -447,6 +529,11 @@ finish: @@ -447,6 +557,14 @@ finish:
if (keymap_pid > 0) if (keymap_pid > 0)
wait_for_terminate_and_warn(KBD_LOADKEYS, keymap_pid); wait_for_terminate_and_warn(KBD_LOADKEYS, keymap_pid);
+#ifdef TARGET_SUSE +#ifdef TARGET_SUSE
+ if (compose_table_pid > 0)
+ wait_for_terminate_and_warn(KBD_LOADKEYS, compose_table_pid);
+
+ if (kbd_rate_pid > 0) + if (kbd_rate_pid > 0)
+ wait_for_terminate_and_warn("/bin/kbdrate", kbd_rate_pid); + wait_for_terminate_and_warn("/bin/kbdrate", kbd_rate_pid);
+#endif +#endif

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Aug 26 14:10:30 UTC 2011 - fcrozat@suse.com
- Update compose_table patch to use two separate loadkeys call,
compose table overflows otherwise (spotted by Werner Fink).
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Aug 24 13:02:12 UTC 2011 - fcrozat@novell.com Wed Aug 24 13:02:12 UTC 2011 - fcrozat@novell.com