This patch updates unset_variables so that removals are also applied to
the external environment block when it is present. The code opens the
external block, deletes the same named keys there, and then writes the
external block back using fs_envblk_write. The file based envblk is
still updated and written as before.

Signed-off-by: Michael Chang <[email protected]>
Reviewed-by: Neal Gompa <[email protected]>
---
 util/grub-editenv.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/util/grub-editenv.c b/util/grub-editenv.c
index ca3787c98..b2aac8e1f 100644
--- a/util/grub-editenv.c
+++ b/util/grub-editenv.c
@@ -473,18 +473,32 @@ static void
 unset_variables (const char *name, int argc, char *argv[])
 {
   grub_envblk_t envblk;
+  grub_envblk_t envblk_fs = NULL;
 
   envblk = open_envblk_file (name);
+
+  if (fs_envblk != NULL)
+    envblk_fs = fs_envblk->ops->open (envblk);
+
   while (argc)
     {
       grub_envblk_delete (envblk, argv[0]);
 
+      if (envblk_fs)
+       grub_envblk_delete (envblk_fs, argv[0]);
+
       argc--;
       argv++;
     }
 
   write_envblk (name, envblk);
   grub_envblk_close (envblk);
+
+  if (envblk_fs)
+    {
+      fs_envblk->ops->write (envblk_fs);
+      grub_envblk_close (envblk_fs);
+    }
 }
 
 static int
-- 
2.50.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to