All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] implement menu_lock
Date: Sun, 10 Feb 2008 14:09:40 +0100	[thread overview]
Message-ID: <20080210130940.GA3879@thorin> (raw)

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]


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 /.)

[-- Attachment #2: menu_lock.diff --]
[-- Type: text/x-diff, Size: 2859 bytes --]

2008-02-10  Robert Millan  <rmh@aybabtu.com>

	* 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);
+}

             reply	other threads:[~2008-02-10 13:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-10 13:09 Robert Millan [this message]
2008-02-10 13:11 ` [PATCH] implement menu_lock Robert Millan
2008-02-10 20:13 ` Yoshinori K. Okuji
2008-02-10 20:59   ` Robert Millan
2008-02-10 21:08     ` Robert Millan
2008-02-12  7:41     ` Yoshinori K. Okuji
2009-03-08 13:50       ` phcoder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080210130940.GA3879@thorin \
    --to=rmh@aybabtu.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.