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

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