From 913ace4529a624e616068bde610831fc3cf2ac58 Mon Sep 17 00:00:00 2001 From: Evan Goode Date: Wed, 20 Sep 2023 18:02:44 +0000 Subject: [PATCH] Add back hardcoded self-protection of `dnf` Now that obsoletion of protected packages is allowed (https://github.com/rpm-software-management/libdnf/pull/1610), it's best to hardcode the protection of dnf here instead of using the file in /etc/dnf/protected.d. This way, DNF 4 cannot uninstall itself, but DNF 5 can uninstall DNF 4, and likewise (given a similar change in DNF 5), DNF 5 cannot uninstall itself, but DNF 4 can uninstall DNF 5. Related: https://bugzilla.redhat.com/show_bug.cgi?id=2221905 Related: https://bugzilla.redhat.com/show_bug.cgi?id=2221907 = changelog = msg: Allow dnf to be removed by DNF 5 type: enhancement --- libdnf/conf/ConfigMain.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdnf/conf/ConfigMain.cpp b/libdnf/conf/ConfigMain.cpp index 9c71d7802..40ae7b8fc 100644 --- a/libdnf/conf/ConfigMain.cpp +++ b/libdnf/conf/ConfigMain.cpp @@ -313,8 +313,9 @@ class ConfigMain::Impl { } }; - OptionStringList protected_packages{resolveGlobs("glob:/etc/yum/protected.d/*.conf " \ - "glob:/etc/dnf/protected.d/*.conf")}; + OptionStringList protected_packages{resolveGlobs("dnf " \ + "glob:/etc/yum/protected.d/*.conf " \ + "glob:/etc/dnf/protected.d/*.conf")}; OptionString username{""}; OptionString password{""}; OptionBool gpgcheck{false};