]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
lock support (not tested)
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 12 Sep 2010 14:11:41 +0000 (16:11 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 12 Sep 2010 14:11:41 +0000 (16:11 +0200)
grub-core/lib/legacy_parse.c
grub-core/normal/auth.c
grub-core/normal/main.c
include/grub/normal.h

index 3f28544b3fdf70c8ae93f1484bc30761556b87df..868eab4ab3578b89ed523623f9862a00d4173f3e 100644 (file)
@@ -146,7 +146,8 @@ struct legacy_command legacy_commands[] =
      " \"netbsd\", \"freebsd\", \"openbsd\", \"linux\", \"biglinux\" and"
      " \"multiboot\". The option --no-mem-option tells GRUB not to pass a"
      " Linux's mem option automatically."},
-    /* FIXME: lock is unsupported. */
+    {"lock", "if ! authenticate legacy; then return; fi", NULL, 0, 0, {}, 0,
+     0, "Break a command execution unless the user is authenticated."},
     {"makeactive", "parttool \"$root\" boot+\n", NULL, 0, 0, {}, 0, 0,
      "Set the active partition on the root disk to GRUB's root device."
      " This command is limited to _primary_ PC partitions on a hard disk."},
@@ -435,12 +436,6 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
       return NULL;
     }
 
-  if (grub_strncmp ("lock", cmdname, ptr - cmdname) == 0
-      && ptr - cmdname == sizeof ("lock") - 1)
-    {
-      /* FIXME */
-    }
-
   for (cmdnum = 0; cmdnum < ARRAY_SIZE (legacy_commands); cmdnum++)
     if (grub_strncmp (legacy_commands[cmdnum].name, cmdname, ptr - cmdname) == 0
        && legacy_commands[cmdnum].name[ptr - cmdname] == 0)
index bf1efbfdd904dc1d6345d4d7f0ed62bceeb191cd..e5216da8c3fc1d1abdc016ca73aa2743a5b17866 100644 (file)
@@ -248,3 +248,27 @@ grub_auth_check_authentication (const char *userlist)
 
   return GRUB_ACCESS_DENIED;
 }
+
+static grub_err_t
+grub_cmd_authenticate (struct grub_command *cmd __attribute__ ((unused)),
+                      int argc, char **args)
+{
+  return grub_auth_check_authentication ((argc >= 1) ? args[0] : "");
+}
+
+static grub_command_t cmd;
+
+void
+grub_normal_auth_init (void)
+{
+  cmd = grub_register_command ("authenticate",
+                              grub_cmd_authenticate,
+                              N_("[USERLIST]"), N_("Authenticate users"));
+
+}
+
+void
+grub_normal_auth_fini (void)
+{
+  grub_unregister_command (cmd);
+}
index c7e83fba02bcae5184f69c71c810d950d117648e..f2e5eaf51a6834b1562f0a3a17ca15f65079364e 100644 (file)
@@ -477,6 +477,7 @@ GRUB_MOD_INIT(normal)
   /* Previously many modules depended on gzio. Be nice to user and load it.  */
   grub_dl_load ("gzio");
 
+  grub_normal_auth_init ();
   grub_context_init ();
   grub_script_init ();
   grub_menu_init ();
@@ -520,6 +521,7 @@ GRUB_MOD_FINI(normal)
   grub_context_fini ();
   grub_script_fini ();
   grub_menu_fini ();
+  grub_normal_auth_fini ();
 
   grub_xputs = grub_xputs_saved;
 
index 417560d9f48056b44f1e248bc49c6bf73ebf39b0..72912e524b68c6837ff11cbb456f96baebf16a4f 100644 (file)
@@ -123,4 +123,7 @@ grub_normal_add_menu_entry (int argc, const char **args, char **classes,
 grub_err_t
 grub_normal_set_password (const char *user, const char *password);
 
+void grub_normal_auth_init (void);
+void grub_normal_auth_fini (void);
+
 #endif /* ! GRUB_NORMAL_HEADER */