Blame 0004-boom.bootloader-do-not-allow-deletion-of-read-only-b.patch

804b00f
From 31f95734f0d6f90f256754377207f5373ff9015c Mon Sep 17 00:00:00 2001
804b00f
From: "Bryn M. Reeves" <bmr@redhat.com>
804b00f
Date: Tue, 14 Jun 2022 07:54:29 -0400
804b00f
Subject: [PATCH 4/5] boom.bootloader: do not allow deletion of read-only boot
804b00f
 entries
804b00f
804b00f
Currently when attempting to delete an entry that has been marked
804b00f
read-only boom generates a misleading error message:
804b00f
804b00f
  # boom delete 7fce1e5
804b00f
  Entry does not exist: /boot/loader/entries/619c4d9f1efa4cf7bd76f149f12138a0-7fce1e5-5.14.0-108.el9.x86_64.conf
804b00f
804b00f
Boom should not attempt to delete entries that are marked read-only;
804b00f
these are either system provided entries, or entries that have been
804b00f
modified outside of boom's control. Reject attempts to delete these
804b00f
with an error that indicates the reason they cannot be removed:
804b00f
804b00f
  # boom delete f6f8df5
804b00f
  Cannot delete read-only boot entry: /boot/loader/entries/68f613d8774e41e792fad28212cfedae-4.18.0-348.el8.x86_64.conf
804b00f
804b00f
Resolves: #10
804b00f
804b00f
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
804b00f
(cherry picked from commit 42f66737e1d7dec432cd7fc330f87304a585c308)
804b00f
---
804b00f
 boom/bootloader.py | 4 ++++
804b00f
 1 file changed, 4 insertions(+)
804b00f
804b00f
diff --git a/boom/bootloader.py b/boom/bootloader.py
804b00f
index bbf7fd5..a81ea84 100644
804b00f
--- a/boom/bootloader.py
804b00f
+++ b/boom/bootloader.py
804b00f
@@ -2445,6 +2445,10 @@ class BootEntry(object):
804b00f
             :raises: ``OsError`` if an error occurs removing the file or
804b00f
                      ``ValueError`` if the entry does not exist.
804b00f
         """
804b00f
+        if self.read_only:
804b00f
+            raise ValueError("Cannot delete read-only boot "
804b00f
+                             "entry: %s" % self._last_path)
804b00f
+
804b00f
         if not path_exists(self._entry_path):
804b00f
             raise ValueError("Entry does not exist: %s" % self._entry_path)
804b00f
         try:
804b00f
-- 
804b00f
2.34.3
804b00f