|
| 1 | +From 6e51bf2f0d585ab661806076c1e428c6482ddf86 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Marek Blaha <mblaha@redhat.com> |
| 3 | +Date: Tue, 23 Jan 2024 10:08:51 +0100 |
| 4 | +Subject: [PATCH] dnfdaemon: Explicitly specify allowed config overrides |
| 5 | + |
| 6 | +Limit main config options overrides for dnfdaemon session only to |
| 7 | +those explicitely allowed. |
| 8 | +--- |
| 9 | + dnf5daemon-server/session.cpp | 35 ++++++++++++++++++++++++++++++++++- |
| 10 | + 1 file changed, 34 insertions(+), 1 deletion(-) |
| 11 | + |
| 12 | +diff --git a/dnf5daemon-server/session.cpp b/dnf5daemon-server/session.cpp |
| 13 | +index b5f2415b4..5322ddc08 100644 |
| 14 | +--- a/dnf5daemon-server/session.cpp |
| 15 | ++++ b/dnf5daemon-server/session.cpp |
| 16 | +@@ -37,6 +37,34 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>. |
| 17 | + #include <iostream> |
| 18 | + #include <string> |
| 19 | + |
| 20 | ++static const std::unordered_set<std::string> ALLOWED_MAIN_CONF_OVERRIDES = { |
| 21 | ++ "allow_downgrade", |
| 22 | ++ "allow_vendor_change", |
| 23 | ++ "best", |
| 24 | ++ "clean_requirements_on_remove", |
| 25 | ++ "disable_excludes", |
| 26 | ++ "exclude_from_weak", |
| 27 | ++ "exclude_from_weak_autodetect", |
| 28 | ++ "excludepkgs", |
| 29 | ++ "ignorearch", |
| 30 | ++ "includepkgs", |
| 31 | ++ "installonly_limit", |
| 32 | ++ "installonlypkgs", |
| 33 | ++ "install_weak_deps", |
| 34 | ++ "keepcache", |
| 35 | ++ "module_obsoletes", |
| 36 | ++ "module_platform_id", |
| 37 | ++ "module_stream_switch", |
| 38 | ++ "multilib_policy", |
| 39 | ++ "obsoletes", |
| 40 | ++ "optional_metadata_types", |
| 41 | ++ "protect_running_kernel", |
| 42 | ++ "reposdir", |
| 43 | ++ "skip_broken", |
| 44 | ++ "skip_if_unavailable", |
| 45 | ++ "skip_unavailable", |
| 46 | ++ "strict", |
| 47 | ++}; |
| 48 | + |
| 49 | + Session::Session( |
| 50 | + std::vector<std::unique_ptr<libdnf5::Logger>> && loggers, |
| 51 | +@@ -65,7 +93,12 @@ Session::Session( |
| 52 | + auto value = opt.second; |
| 53 | + auto bind = opt_binds.find(key); |
| 54 | + if (bind != opt_binds.end()) { |
| 55 | +- bind->second.new_string(libdnf5::Option::Priority::RUNTIME, value); |
| 56 | ++ if (ALLOWED_MAIN_CONF_OVERRIDES.find(key) != ALLOWED_MAIN_CONF_OVERRIDES.end()) { |
| 57 | ++ bind->second.new_string(libdnf5::Option::Priority::RUNTIME, value); |
| 58 | ++ } else { |
| 59 | ++ base->get_logger()->warning("Config option {} not allowed.", key); |
| 60 | ++ continue; |
| 61 | ++ } |
| 62 | + } else { |
| 63 | + base->get_logger()->warning("Unknown config option: {}", key); |
| 64 | + } |
0 commit comments