Skip to content

Commit 771c409

Browse files
jrohelppisar
authored andcommitted
config: Convert 'protected_packages' to an append option
This change is necessary because the list of protected packages started being distributed across configuration files within a drop-in directory. This led to a situation where a subsequent configuration file containing `protected_packages` would overwrite any earlier settings. This issue was previously encountered and resolved in **libdnf5** approximately two years ago by changing `protected_packages` to an append option. The same proven solution is implemented here to ensure correct merging and prevent unexpected overwrites of earlier configurations. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2400488
1 parent f92daf8 commit 771c409

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

libdnf/conf/ConfigMain.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,11 @@ ConfigMain::Impl::Impl(Config & owner)
514514
owner.optBinds().add("proxy_username", proxy_username);
515515
owner.optBinds().add("proxy_password", proxy_password);
516516
owner.optBinds().add("proxy_auth_method", proxy_auth_method);
517+
517518
owner.optBinds().add("protected_packages", protected_packages,
518519
[&](Option::Priority priority, const std::string & value){
519-
if (priority >= protected_packages.getPriority())
520-
protected_packages.set(priority, resolveGlobs(value));
521-
}, nullptr, false
520+
optionTListAppend(protected_packages, priority, resolveGlobs(value));
521+
}, nullptr, true
522522
);
523523

524524
owner.optBinds().add("username", username);

libdnf/conf/ConfigRepo.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ ConfigRepo::Impl::Impl(Config & owner, ConfigMain & mainConfig)
145145
owner.optBinds().add("proxy_auth_method", proxy_auth_method);
146146
owner.optBinds().add("username", username);
147147
owner.optBinds().add("password", password);
148-
owner.optBinds().add("protected_packages", protected_packages);
148+
149+
owner.optBinds().add("protected_packages", protected_packages,
150+
[&](Option::Priority priority, const std::string & value){
151+
optionTListAppend(protected_packages, priority, value);
152+
}, nullptr, true
153+
);
154+
149155
owner.optBinds().add("gpgcheck", gpgcheck);
150156
owner.optBinds().add("repo_gpgcheck", repo_gpgcheck);
151157
owner.optBinds().add("enablegroups", enablegroups);

0 commit comments

Comments
 (0)