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

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