From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JOBy6-0001xm-QM for mharc-grub-devel@gnu.org; Sun, 10 Feb 2008 08:11:38 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JOBy5-0001wM-69 for grub-devel@gnu.org; Sun, 10 Feb 2008 08:11:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JOBy0-0001uv-Ef for grub-devel@gnu.org; Sun, 10 Feb 2008 08:11:36 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JOBy0-0001ul-9l for grub-devel@gnu.org; Sun, 10 Feb 2008 08:11:32 -0500 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JOBxz-00075c-RU for grub-devel@gnu.org; Sun, 10 Feb 2008 08:11:32 -0500 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JOBxv-0002v7-TS for grub-devel@gnu.org; Sun, 10 Feb 2008 14:11:31 +0100 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1JOBwC-00011P-4a for grub-devel@gnu.org; Sun, 10 Feb 2008 14:09:40 +0100 Date: Sun, 10 Feb 2008 14:09:40 +0100 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080210130940.GA3879@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7AUc2qLy4jB3hD7Z" Content-Disposition: inline Content-Transfer-Encoding: 8bit Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH] implement menu_lock X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Feb 2008 13:11:37 -0000 --7AUc2qLy4jB3hD7Z Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 I know my rights; I want my phone call! What use is a phone call… if you are unable to speak? (as seen on /.) --7AUc2qLy4jB3hD7Z Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="menu_lock.diff" 2008-02-10 Robert Millan * 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); +} --7AUc2qLy4jB3hD7Z--