From 2a5ae102fe5771abb56759e4d6a10b9e32e6fa7d Mon Sep 17 00:00:00 2001 From: okuji Date: Sat, 14 Oct 2000 08:09:43 +0000 Subject: [PATCH] reset key mappings, when the user specifies no argument to setkey. --- ChangeLog | 8 ++++++++ stage2/builtins.c | 20 ++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f31774639..aad64adb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2000-10-14 OKUJI Yoshinori + + * stage2/builtins.c (setkey_func): If TO_KEY is NULL (i.e. the + user specifies no argument), clear BIOS_KEY_MAP and + ASCII_KEY_MAP. + If TO_KEY is non-NULL but FROM_KEY is NULL, set ERRNUM to + ERR_BAD_ARGUMENT and return one. + 2000-10-13 OKUJI Yoshinori * docs/grub.texi: Added an entry for the new chapter "Security", diff --git a/stage2/builtins.c b/stage2/builtins.c index 5eee56dfa..5bfa2db93 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -3212,6 +3212,21 @@ setkey_func (char *arg, int flags) to_key = arg; from_key = skip_to (0, to_key); + + if (! to_key) + { + /* If the user specifies no argument, reset the key mappings. */ + bios_key_map[0] = 0; + ascii_key_map[0] = 0; + + return 0; + } + else if (! from_key) + { + /* The user must specify two arguments or zero argument. */ + errnum = ERR_BAD_ARGUMENT; + return 1; + } nul_terminate (to_key); nul_terminate (from_key); @@ -3301,7 +3316,7 @@ static struct builtin builtin_setkey = "setkey", setkey_func, BUILTIN_CMDLINE | BUILTIN_MENU, - "setkey TO_KEY FROM_KEY", + "setkey [TO_KEY FROM_KEY]", "Change the keyboard map. The key FROM_KEY is mapped to the key TO_KEY." " A key must be an alphabet, a digit, or one of these: escape, exclam," " at, numbersign, dollar, percent, caret, ampersand, asterisk, parenleft," @@ -3309,7 +3324,8 @@ static struct builtin builtin_setkey = " braceleft, bracketright, braceright, enter, control, semicolon, colon," " quote, doublequote, backquote, tilde, shift, backslash, bar, comma," " less, period, greater, slash, question, alt, space, capslock, FX (X" - " is a digit), and delete." + " is a digit), and delete. If no argument is specified, reset key" + " mappings." };