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]>
Reviewed-by: Avnish Chouhan <[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 efc6ec5f2..ad3088475 100644
--- a/util/grub-editenv.c
+++ b/util/grub-editenv.c
@@ -476,18 +476,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 != NULL)
+       grub_envblk_delete (envblk_fs, argv[0]);
+
       argc--;
       argv++;
     }
 
   write_envblk (name, envblk);
   grub_envblk_close (envblk);
+
+  if (envblk_fs != NULL)
+    {
+      fs_envblk->ops->write (envblk_fs);
+      grub_envblk_close (envblk_fs);
+    }
 }
 
 static bool
-- 
2.51.0


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

Reply via email to