diff options
author | Colin Guthrie <colin@mageia.org> | 2011-10-21 01:28:48 +0100 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2011-10-21 10:10:39 +0100 |
commit | be75c98a06d569fbaa2d86f92676af961795d094 (patch) | |
tree | e2ce8ce7ffb97af34164634a3fbd8630dc7463e8 /src | |
parent | 4688ea25c9a5a87e48f89fc91a3c93a7c8c95b4a (diff) | |
download | initscripts-be75c98a06d569fbaa2d86f92676af961795d094.tar initscripts-be75c98a06d569fbaa2d86f92676af961795d094.tar.gz initscripts-be75c98a06d569fbaa2d86f92676af961795d094.tar.bz2 initscripts-be75c98a06d569fbaa2d86f92676af961795d094.tar.xz initscripts-be75c98a06d569fbaa2d86f92676af961795d094.zip |
Add the mdkconf patch
Diffstat (limited to 'src')
-rw-r--r-- | src/console_check.c | 1 | ||||
-rw-r--r-- | src/console_init.c | 102 | ||||
-rw-r--r-- | src/usernetctl.8 | 4 |
3 files changed, 100 insertions, 7 deletions
diff --git a/src/console_check.c b/src/console_check.c index 8584f78e..5ae8a13a 100644 --- a/src/console_check.c +++ b/src/console_check.c @@ -25,6 +25,7 @@ #include <sys/ioctl.h> +#include <linux/types.h> #include <linux/serial.h> #include <linux/serial_core.h> diff --git a/src/console_init.c b/src/console_init.c index 22083a86..494959a1 100644 --- a/src/console_init.c +++ b/src/console_init.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <string.h> #include <sys/ioctl.h> #include <sys/stat.h> @@ -35,6 +36,9 @@ static char *font = NULL; static char *acm = NULL; static char *unimap = NULL; static char *keymap = NULL; +static char *unikeytable = NULL; +static char *backspace = NULL; +static char *grp_toggle = NULL; static int linux_console(int fd) { unsigned char twelve = 12; @@ -62,25 +66,60 @@ static int configured_as_utf8() { return 0; } -static int read_keymap() { +static int read_keymap(int utf8) { shvarFile *keyboard = NULL; char *tmp; struct stat sb; + if (!stat("/etc/sysconfig/console/default.kmap",&sb)) { keymap = "/etc/sysconfig/console/default.kmap"; - return 0; } if ((keyboard = svNewFile("/etc/sysconfig/keyboard")) == NULL) return 0; + tmp = svGetValue(keyboard, "BACKSPACE"); + if (tmp) + backspace = tmp; + + tmp = svGetValue(keyboard, "GRP_TOGGLE"); + if (tmp) + grp_toggle = tmp; + + if (keymap) + return 0; + tmp = svGetValue(keyboard, "KEYMAP"); if (tmp) keymap = tmp; + + tmp = svGetValue(keyboard, "UNIKEYTABLE"); + if (tmp) + unikeytable = tmp; + tmp = svGetValue(keyboard, "KEYTABLE"); if (tmp) { if (keymap) free(keymap); + keymap = NULL; + if (utf8) { + if (g_str_has_suffix (tmp, "uni") || strstr(tmp,".uni.")) + unikeytable = tmp; + else { + char * substring; + if ((substring = strstr(tmp, ".map"))) { + GString *new_string; + new_string = g_string_new_len (tmp, strlen(tmp)+4); + new_string = g_string_insert_len(new_string, substring-tmp,".uni",4); + unikeytable = g_string_free (new_string, FALSE); + } + else { + free (unikeytable); + asprintf (&unikeytable, "%s.uni", tmp); + } + } + + } asprintf(&keymap, "%s.map", tmp); } return 0; @@ -126,13 +165,20 @@ static void set_terminal(int fd, int utf8) { static void set_keymap(int fd, int utf8) { int pid; + int status; if ((pid = fork()) == 0) { - char *args[] = { "loadkeys", "-q", NULL, NULL, NULL }; + char *args[] = { "/bin/loadkeys", "-q", NULL, NULL, NULL }; dup2(fd, 0); dup2(fd, 1); if (utf8) { + if (unikeytable) { + args[2] = unikeytable; + if (g_spawn_sync (NULL, args, NULL, G_SPAWN_CHILD_INHERITS_STDIN , NULL, NULL, NULL, NULL, NULL, NULL)) + exit(0); + } + args[2] = "-u"; args[3] = keymap; } else { @@ -141,11 +187,49 @@ static void set_keymap(int fd, int utf8) { execv("/bin/loadkeys", args); exit(1); } + waitpid(pid, &status, 0); +} + +static void set_backspace(int fd) { + int pid; + int status; + + if ((pid = fork()) == 0) { + char *args[] = { "/bin/loadkeys", "-q", NULL, NULL }; + dup2(fd, 0); + dup2(fd, 1); + + if (backspace && g_ascii_strcasecmp (backspace, "BackSpace")) { + args[2] = "backspace"; + } else { + args[2] = "delete"; + } + execv("/bin/loadkeys", args); + exit(1); + } + waitpid(pid, &status, 0); +} + +static void set_grp_toggle(int fd) { + int pid; + int status; + + if ((pid = fork()) == 0) { + char *args[] = { "/bin/loadkeys", "-q", NULL, NULL }; + dup2(fd, 0); + dup2(fd, 1); + + args[2] = grp_toggle; + execv("/bin/loadkeys", args); + exit(1); + } + waitpid(pid, &status, 0); } int main(int argc, char **argv) { char *device; int dev; + struct stat sb; if (argc < 2) { printf("usage: console_init <device>\n"); @@ -160,9 +244,13 @@ int main(int argc, char **argv) { set_keyboard(dev, utf8); set_terminal(dev, utf8); set_font(device); - read_keymap(); - if (keymap) + read_keymap(utf8); + if (keymap || unikeytable) set_keymap(dev,utf8); - } - return 0; + set_backspace(dev); + if (grp_toggle) + set_grp_toggle(dev); + } + /* check if /usr is mounted */ + return stat("/usr/bin",&sb) != 0; } diff --git a/src/usernetctl.8 b/src/usernetctl.8 index 2fb84da1..ebf86e1a 100644 --- a/src/usernetctl.8 +++ b/src/usernetctl.8 @@ -34,6 +34,10 @@ Attempt to bring the interface up or down. .TP report Report on whether users can bring the interface up or down. + +.SH FILES +.IR /etc/sysconfig/network-scripts/ifcfg-* + .SH NOTES Alternate device configurations may inherit the default configuration's permissions. |