Blame SOURCES/0249-Make-the-menu-entry-users-option-argument-to-be-opti.patch

d9d99f
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
d9d99f
From: Javier Martinez Canillas <javierm@redhat.com>
d9d99f
Date: Mon, 26 Nov 2018 10:06:42 +0100
d9d99f
Subject: [PATCH] Make the menu entry users option argument to be optional
d9d99f
d9d99f
The --users option is used to restrict the access to specific menu entries
d9d99f
only to a set of users. But the option requires an argument to either be a
d9d99f
constant or a variable that has been set. So for example the following:
d9d99f
d9d99f
  menuentry "May be run by superusers or users in $users" --users $users {
d9d99f
  	    linux /vmlinuz
d9d99f
  }
d9d99f
d9d99f
Would fail if $users is not defined and grub would discard the menu entry.
d9d99f
Instead, allow the --users option to have an optional argument and ignore
d9d99f
the option if the argument was not set.
d9d99f
d9d99f
Related: rhbz#1652434
d9d99f
d9d99f
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
d9d99f
---
d9d99f
 grub-core/commands/menuentry.c | 4 ++--
d9d99f
 1 file changed, 2 insertions(+), 2 deletions(-)
d9d99f
d9d99f
diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c
b71686
index 8d242b018..7004e08ce 100644
d9d99f
--- a/grub-core/commands/menuentry.c
d9d99f
+++ b/grub-core/commands/menuentry.c
d9d99f
@@ -29,7 +29,7 @@ static const struct grub_arg_option options[] =
d9d99f
   {
d9d99f
     {"class", 1, GRUB_ARG_OPTION_REPEATABLE,
d9d99f
      N_("Menu entry type."), N_("STRING"), ARG_TYPE_STRING},
d9d99f
-    {"users", 2, 0,
d9d99f
+    {"users", 2, GRUB_ARG_OPTION_OPTIONAL,
d9d99f
      N_("List of users allowed to boot this entry."), N_("USERNAME[,USERNAME]"),
d9d99f
      ARG_TYPE_STRING},
d9d99f
     {"hotkey", 3, 0,
d9d99f
@@ -280,7 +280,7 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args)
d9d99f
   if (! ctxt->state[3].set && ! ctxt->script)
d9d99f
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "no menuentry definition");
d9d99f
 
d9d99f
-  if (ctxt->state[1].set)
d9d99f
+  if (ctxt->state[1].set && ctxt->state[1].arg)
d9d99f
     users = ctxt->state[1].arg;
d9d99f
   else if (ctxt->state[5].set)
d9d99f
     users = NULL;