Skip to content

Commit 6e51bf2

Browse files
m-blahainknos
authored andcommitted
dnfdaemon: Explicitly specify allowed config overrides
Limit main config options overrides for dnfdaemon session only to those explicitely allowed.
1 parent 03b2bb1 commit 6e51bf2

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

dnf5daemon-server/session.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,34 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
3737
#include <iostream>
3838
#include <string>
3939

40+
static const std::unordered_set<std::string> ALLOWED_MAIN_CONF_OVERRIDES = {
41+
"allow_downgrade",
42+
"allow_vendor_change",
43+
"best",
44+
"clean_requirements_on_remove",
45+
"disable_excludes",
46+
"exclude_from_weak",
47+
"exclude_from_weak_autodetect",
48+
"excludepkgs",
49+
"ignorearch",
50+
"includepkgs",
51+
"installonly_limit",
52+
"installonlypkgs",
53+
"install_weak_deps",
54+
"keepcache",
55+
"module_obsoletes",
56+
"module_platform_id",
57+
"module_stream_switch",
58+
"multilib_policy",
59+
"obsoletes",
60+
"optional_metadata_types",
61+
"protect_running_kernel",
62+
"reposdir",
63+
"skip_broken",
64+
"skip_if_unavailable",
65+
"skip_unavailable",
66+
"strict",
67+
};
4068

4169
Session::Session(
4270
std::vector<std::unique_ptr<libdnf5::Logger>> && loggers,
@@ -65,7 +93,12 @@ Session::Session(
6593
auto value = opt.second;
6694
auto bind = opt_binds.find(key);
6795
if (bind != opt_binds.end()) {
68-
bind->second.new_string(libdnf5::Option::Priority::RUNTIME, value);
96+
if (ALLOWED_MAIN_CONF_OVERRIDES.find(key) != ALLOWED_MAIN_CONF_OVERRIDES.end()) {
97+
bind->second.new_string(libdnf5::Option::Priority::RUNTIME, value);
98+
} else {
99+
base->get_logger()->warning("Config option {} not allowed.", key);
100+
continue;
101+
}
69102
} else {
70103
base->get_logger()->warning("Unknown config option: {}", key);
71104
}

0 commit comments

Comments
 (0)