|
| 1 | +From bdc6e9895af1bf9759d56314f2018d7fb1ca0abf Mon Sep 17 00:00:00 2001 |
| 2 | +From: AllSpark < [email protected]> |
| 3 | +Date: Mon, 18 Aug 2025 07:25:14 +0000 |
| 4 | +Subject: [PATCH] dnfdaemon: Explicitly specify allowed config overrides |
| 5 | + |
| 6 | +Signed-off-by: Azure Linux Security Servicing Account < [email protected]> |
| 7 | +Upstream-reference: AI Backport of https://github.com/rpm-software-management/dnf5/commit/6e51bf2f0d585ab661806076c1e428c6482ddf86.patch |
| 8 | +--- |
| 9 | + dnf5daemon-server/session.cpp | 38 ++++++++++++++++++++++++++++++++++- |
| 10 | + 1 file changed, 37 insertions(+), 1 deletion(-) |
| 11 | + |
| 12 | +diff --git a/dnf5daemon-server/session.cpp b/dnf5daemon-server/session.cpp |
| 13 | +index 8e86723..fd50514 100644 |
| 14 | +--- a/dnf5daemon-server/session.cpp |
| 15 | ++++ b/dnf5daemon-server/session.cpp |
| 16 | +@@ -34,6 +34,37 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>. |
| 17 | + #include <chrono> |
| 18 | + #include <iostream> |
| 19 | + #include <string> |
| 20 | ++#include <unordered_set> |
| 21 | ++ |
| 22 | ++static const std::unordered_set<std::string> ALLOWED_MAIN_CONF_OVERRIDES = { |
| 23 | ++ "allow_downgrade", |
| 24 | ++ "allow_vendor_change", |
| 25 | ++ "best", |
| 26 | ++ "clean_requirements_on_remove", |
| 27 | ++ "disable_excludes", |
| 28 | ++ "exclude_from_weak", |
| 29 | ++ "exclude_from_weak_autodetect", |
| 30 | ++ "excludepkgs", |
| 31 | ++ "ignorearch", |
| 32 | ++ "includepkgs", |
| 33 | ++ "installonly_limit", |
| 34 | ++ "installonlypkgs", |
| 35 | ++ "install_weak_deps", |
| 36 | ++ "keepcache", |
| 37 | ++ "module_obsoletes", |
| 38 | ++ "module_platform_id", |
| 39 | ++ "module_stream_switch", |
| 40 | ++ "multilib_policy", |
| 41 | ++ "obsoletes", |
| 42 | ++ "optional_metadata_types", |
| 43 | ++ "protect_running_kernel", |
| 44 | ++ "reposdir", |
| 45 | ++ "skip_broken", |
| 46 | ++ "skip_if_unavailable", |
| 47 | ++ "skip_unavailable", |
| 48 | ++ "strict", |
| 49 | ++}; |
| 50 | ++ |
| 51 | + |
| 52 | + |
| 53 | + Session::Session( |
| 54 | +@@ -63,7 +94,12 @@ Session::Session( |
| 55 | + auto value = opt.second; |
| 56 | + auto bind = opt_binds.find(key); |
| 57 | + if (bind != opt_binds.end()) { |
| 58 | +- bind->second.new_string(libdnf::Option::Priority::RUNTIME, value); |
| 59 | ++ if (ALLOWED_MAIN_CONF_OVERRIDES.find(key) != ALLOWED_MAIN_CONF_OVERRIDES.end()) { |
| 60 | ++ bind->second.new_string(libdnf::Option::Priority::RUNTIME, value); |
| 61 | ++ } else { |
| 62 | ++ base->get_logger()->warning("Config option {} not allowed.", key); |
| 63 | ++ continue; |
| 64 | ++ } |
| 65 | + } else { |
| 66 | + base->get_logger()->warning("Unknown config option: {}", key); |
| 67 | + } |
| 68 | +-- |
| 69 | +2.45.4 |
| 70 | + |
0 commit comments