Implement menu_lock. This is a variable that locks the menu when set. It can be used by users to lock the menu, although there's no way to authenticate users for unlocking it, yet (but the procedure would be independant from this interface).
-- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)
2008-02-10 Robert Millan <[EMAIL PROTECTED]> * normal/misc.c (grub_normal_env_getint): New function. Generic method to obtain the integer value of an environment variable whose string represents an integer. * normal/menu.c (print_message): When `menu_lock' environment variable is set to 1, tell user that editor and command-line are locked instead of the hotkeys to access them. (run_menu): When `menu_lock' environment variable is set to 1, disallow access to editor or command-line. (grub_menu_run): When processing an entry, say that we're "Processing" it rather than "Booting" it, since user might setup entries to set or unset menu_lock without booting an OS. diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/normal/menu.c ./normal/menu.c --- ../grub2/normal/menu.c 2008-02-09 12:23:50.000000000 +0100 +++ ./normal/menu.c 2008-02-09 22:17:38.000000000 +0100 @@ -91,8 +91,15 @@ print_message (int nested, int edit) Use the %C and %C keys to select which entry is highlighted.\n", (grub_uint32_t) GRUB_TERM_DISP_UP, (grub_uint32_t) GRUB_TERM_DISP_DOWN); grub_printf ("\ - Press enter to boot the selected OS, \'e\' to edit the\n\ + Press enter to boot the selected OS"); + + if (grub_normal_env_getint ("menu_lock") == 1) + grub_printf ( ". Access to command\n\ + editor or command-line is currently locked."); + else + grub_printf ( ", \'e\' to edit the\n\ commands before booting or \'c\' for a command-line."); + if (nested) grub_printf ("\n\ ESC to return previous menu."); @@ -457,15 +464,21 @@ run_menu (grub_menu_t menu, int nested) break; case 'c': + if (grub_normal_env_getint ("menu_lock") == 1) + break; + grub_cmdline_run (1); goto refresh; case 'e': - { + if (grub_normal_env_getint ("menu_lock") == 1) + break; + + { grub_menu_entry_t e = get_entry (menu, first + offset); if (e) grub_menu_entry_run (e); - } + } goto refresh; default: @@ -511,7 +524,7 @@ grub_menu_run (grub_menu_t menu, int nes grub_cls (); grub_setcursor (1); - grub_printf (" Booting \'%s\'\n\n", e->title); + grub_printf (" Processing \'%s\'\n\n", e->title); run_menu_entry (e); diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/normal/misc.c ./normal/misc.c --- ../grub2/normal/misc.c 2007-10-15 12:59:38.000000000 +0200 +++ ./normal/misc.c 2008-02-09 21:32:39.000000000 +0100 @@ -73,3 +73,12 @@ grub_normal_print_device_info (const cha grub_printf ("\n"); return grub_errno; } + +int +grub_normal_env_getint (char *name) +{ + char *value = grub_env_get (name); + if (! value) + return -1; + return grub_strtoul (value, 0, 10); +}
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel