Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change gpgcheck option to pkg_gpgcheck but stay compatible #1766

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dnf5/commands/offline/offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void OfflineExecuteCommand::pre_configure() {
// Disable gpgcheck entirely, since GPG integrity will have already been
// checked when the transaction was prepared and serialized. This way, we
// don't need to keep track of which packages need to be gpgchecked.
ctx.get_base().get_config().get_gpgcheck_option().set(false);
ctx.get_base().get_config().get_pkg_gpgcheck_option().set(false);
}

void OfflineExecuteCommand::configure() {
Expand Down
3 changes: 2 additions & 1 deletion dnf5/commands/repo/repo_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class RepoInfoWrapper : public libdnf5::cli::output::IRepoInfo {
return repo->get_config().get_skip_if_unavailable_option().get_value();
}
std::vector<std::string> get_gpgkey() const override { return repo->get_config().get_gpgkey_option().get_value(); }
bool get_gpgcheck() const override { return repo->get_config().get_gpgcheck_option().get_value(); }
bool get_gpgcheck() const override { return repo->get_config().get_pkg_gpgcheck_option().get_value(); }
bool get_pkg_gpgcheck() const override { return repo->get_config().get_pkg_gpgcheck_option().get_value(); }
bool get_repo_gpgcheck() const override { return repo->get_config().get_repo_gpgcheck_option().get_value(); }
std::string get_repo_file_path() const override { return repo->get_repo_file_path(); }
std::string get_revision() const override { return repo->get_revision(); }
Expand Down
4 changes: 2 additions & 2 deletions dnf5/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,10 @@ void RootCommand::set_argument_parser() {
[[maybe_unused]] ArgumentParser::NamedArg * arg,
[[maybe_unused]] const char * option,
[[maybe_unused]] const char * value) {
ctx.get_base().get_config().get_gpgcheck_option().set(libdnf5::Option::Priority::COMMANDLINE, 0);
ctx.get_base().get_config().get_pkg_gpgcheck_option().set(libdnf5::Option::Priority::COMMANDLINE, 0);
ctx.get_base().get_config().get_repo_gpgcheck_option().set(libdnf5::Option::Priority::COMMANDLINE, 0);
// Store to vector. Use it later when repositories configuration will be loaded.
ctx.get_setopts().emplace_back("*.gpgcheck", "0");
ctx.get_setopts().emplace_back("*.pkg_gpgcheck", "0");
ctx.get_setopts().emplace_back("*.repo_gpgcheck", "0");
return true;
});
Expand Down
2 changes: 1 addition & 1 deletion dnf5daemon-client/commands/repolist/repolist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void RepolistCommand::run() {
"includepkgs",
"skip_if_unavailable",
"gpgkey",
"gpgcheck",
"pkg_gpgcheck",
"repo_gpgcheck",
"repofile",
"revision",
Expand Down
3 changes: 2 additions & 1 deletion dnf5daemon-client/wrappers/dbus_repo_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class DbusRepoWrapper : public libdnf5::cli::output::IRepoInfo {
std::vector<std::string> get_includepkgs() const { return rawdata.at("includepkgs"); }
bool get_skip_if_unavailable() const { return rawdata.at("skip_if_unavailable"); }
std::vector<std::string> get_gpgkey() const { return rawdata.at("gpgkey"); }
bool get_gpgcheck() const { return rawdata.at("gpgcheck"); }
bool get_gpgcheck() const { return rawdata.at("pkg_gpgcheck"); }
bool get_pkg_gpgcheck() const { return rawdata.at("pkg_gpgcheck"); }
bool get_repo_gpgcheck() const { return rawdata.at("repo_gpgcheck"); }
std::string get_repo_file_path() const { return rawdata.at("repofile"); }
std::string get_revision() const { return rawdata.at("revision"); }
Expand Down
9 changes: 5 additions & 4 deletions dnf5daemon-server/services/repo/repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum class RepoAttribute {
skip_if_unavailable,

gpgkey,
gpgcheck,
pkg_gpgcheck,
jan-kolarik marked this conversation as resolved.
Show resolved Hide resolved
repo_gpgcheck,

proxy,
Expand Down Expand Up @@ -106,7 +106,8 @@ const static std::map<std::string, RepoAttribute> repo_attributes{
{"skip_if_unavailable", RepoAttribute::skip_if_unavailable},

{"gpgkey", RepoAttribute::gpgkey},
{"gpgcheck", RepoAttribute::gpgcheck},
{"gpgcheck", RepoAttribute::pkg_gpgcheck},
{"pkg_gpgcheck", RepoAttribute::pkg_gpgcheck},
{"repo_gpgcheck", RepoAttribute::repo_gpgcheck},

{"proxy", RepoAttribute::proxy},
Expand Down Expand Up @@ -183,8 +184,8 @@ dnfdaemon::KeyValueMap repo_to_map(
case RepoAttribute::gpgkey:
dbus_repo.emplace(attr, libdnf_repo->get_config().get_gpgkey_option().get_value());
break;
case RepoAttribute::gpgcheck:
dbus_repo.emplace(attr, libdnf_repo->get_config().get_gpgcheck_option().get_value());
case RepoAttribute::pkg_gpgcheck:
dbus_repo.emplace(attr, libdnf_repo->get_config().get_pkg_gpgcheck_option().get_value());
break;
case RepoAttribute::repo_gpgcheck:
dbus_repo.emplace(attr, libdnf_repo->get_config().get_repo_gpgcheck_option().get_value());
Expand Down
5 changes: 4 additions & 1 deletion doc/dnf5.conf.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,10 @@ configuration.

Default: ``False``.

.. _pkg_gpgcheck_options-label:
.. _gpgcheck_options-label:

``gpgcheck``
``pkg_gpgcheck``
:ref:`boolean <boolean-label>`

Whether to perform GPG signature check on packages found in this repository.
Expand All @@ -985,6 +986,8 @@ configuration.
Doesn't apply for packages passed directly as arguments, as they are not in any repository,
see :ref:`localpkg_gpgcheck <localpkg_gpgcheck_options-label>`.

Due to compatibility `gpgcheck` option is supported as well but `pkg_gpgcheck` is preferred.

.. _includepkgs_options-label:

``includepkgs``
Expand Down
8 changes: 4 additions & 4 deletions doc/dnf5_plugins/config-manager.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ Examples
``dnf5 config-manager setopt repo1.proxy=http://proxy.example.com:3128/ repo2.proxy=http://proxy.example.com:3128/``
Sets override for ``proxy`` option in repositories with repository IDs ``repo1`` and ``repo2``.

``dnf5 config-manager setopt '*-debuginfo.gpgcheck=0'``
Sets override for the ``gpgcheck`` option in all repositories whose repository ID ends with ``-debuginfo``.
``dnf5 config-manager setopt '*-debuginfo.pkg_gpgcheck=0'``
Sets override for the ``pkg_gpgcheck`` option in all repositories whose repository ID ends with ``-debuginfo``.

``dnf5 config-manager unsetopt '*-debuginfo.gpgcheck'``
Remove override for the ``gpgcheck`` option in all repositories whose repository ID ends with ``-debuginfo``.
``dnf5 config-manager unsetopt '*-debuginfo.pkg_gpgcheck'``
Remove override for the ``pkg_gpgcheck`` option in all repositories whose repository ID ends with ``-debuginfo``.

``dnf5 config-manager setopt keepcache=1 log_size=10M``
Enables the ``keepcache`` main option and sets the maximum size of logger files to 10 mebibytes (10 * 1024 * 1024 bytes).
Expand Down
2 changes: 2 additions & 0 deletions include/libdnf5-cli/output/interfaces/repo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class IRepoInfo {
virtual std::vector<std::string> get_includepkgs() const = 0;
virtual bool get_skip_if_unavailable() const = 0;
virtual std::vector<std::string> get_gpgkey() const = 0;
virtual bool get_pkg_gpgcheck() const = 0;
/// @deprecated It is going to be removed, use get_pkg_gpgcheck()
virtual bool get_gpgcheck() const = 0;
virtual bool get_repo_gpgcheck() const = 0;
virtual std::string get_repo_file_path() const = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/libdnf5/base/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class LIBDNF_API Transaction {

/// @brief Check signatures of packages in the resolved transaction.
///
/// @return True if all packages have correct signatures or checking is turned off with `gpgcheck` option,
/// @return True if all packages have correct signatures or checking is turned off with `pkg_gpgcheck` option,
/// otherwise false. More info about occurred problems can be retrieved using the `get_gpg_signature_problems`
/// method.
bool check_gpg_signatures();
Expand Down
4 changes: 4 additions & 0 deletions include/libdnf5/conf/config_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,12 @@ class LIBDNF_API ConfigMain : public Config {
const OptionString & get_username_option() const;
OptionString & get_password_option();
const OptionString & get_password_option() const;
/// @deprecated It is going to be removed, use get_pkg_gpgcheck_option()
jan-kolarik marked this conversation as resolved.
Show resolved Hide resolved
OptionBool & get_gpgcheck_option();
/// @deprecated It is going to be removed, use get_pkg_gpgcheck_option()
const OptionBool & get_gpgcheck_option() const;
OptionBool & get_pkg_gpgcheck_option();
const OptionBool & get_pkg_gpgcheck_option() const;
OptionBool & get_repo_gpgcheck_option();
const OptionBool & get_repo_gpgcheck_option() const;
OptionBool & get_enabled_option();
Expand Down
4 changes: 4 additions & 0 deletions include/libdnf5/repo/config_repo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ class LIBDNF_API ConfigRepo : public Config {
const OptionChild<OptionString> & get_password_option() const;
OptionChild<OptionStringAppendList> & get_protected_packages_option();
const OptionChild<OptionStringAppendList> & get_protected_packages_option() const;
/// @deprecated It is going to be removed, use get_pkg_gpgcheck_option()
OptionChild<OptionBool> & get_gpgcheck_option();
/// @deprecated It is going to be removed, use get_pkg_gpgcheck_option()
const OptionChild<OptionBool> & get_gpgcheck_option() const;
OptionChild<OptionBool> & get_pkg_gpgcheck_option();
const OptionChild<OptionBool> & get_pkg_gpgcheck_option() const;
OptionChild<OptionBool> & get_repo_gpgcheck_option();
const OptionChild<OptionBool> & get_repo_gpgcheck_option() const;
OptionChild<OptionBool> & get_enablegroups_option();
Expand Down
4 changes: 2 additions & 2 deletions libdnf5-cli/output/repo_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void RepoInfo::Impl::add_repo(IRepoInfo & repo) {
}

add_line("Verify repodata", fmt::format("{}", repo.get_repo_gpgcheck()), nullptr, group_gpg);
add_line("Verify packages", fmt::format("{}", repo.get_gpgcheck()), nullptr, group_gpg);
add_line("Verify packages", fmt::format("{}", repo.get_pkg_gpgcheck()), nullptr, group_gpg);

// TODO(jkolarik): Verbose is not implemented and not used yet
// if (verbose) {
Expand Down Expand Up @@ -252,7 +252,7 @@ void print_repoinfo_json([[maybe_unused]] const std::vector<std::unique_ptr<IRep
json_object_object_add(json_repo, "gpg_key", json_gpg_keys);

json_object_object_add(json_repo, "repo_gpgcheck", json_object_new_boolean(repo->get_repo_gpgcheck()));
json_object_object_add(json_repo, "gpgcheck", json_object_new_boolean(repo->get_gpgcheck()));
json_object_object_add(json_repo, "pkg_gpgcheck", json_object_new_boolean(repo->get_pkg_gpgcheck()));
jan-kolarik marked this conversation as resolved.
Show resolved Hide resolved
json_object_object_add(json_repo, "available_pkgs", json_object_new_uint64(repo->get_available_pkgs()));
json_object_object_add(json_repo, "pkgs", json_object_new_uint64(repo->get_pkgs()));
json_object_object_add(json_repo, "size", json_object_new_uint64(repo->get_size()));
Expand Down
17 changes: 13 additions & 4 deletions libdnf5/conf/config_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class ConfigMain::Impl {
OptionStringAppendList protected_packages{std::vector<std::string>{"dnf5", "glob:/etc/dnf/protected.d/*.conf"}};
OptionString username{""};
OptionString password{""};
OptionBool gpgcheck{false};
OptionBool pkg_gpgcheck{false};
OptionBool repo_gpgcheck{false};
OptionBool enabled{true};
OptionBool enablegroups{true};
Expand Down Expand Up @@ -435,7 +435,9 @@ ConfigMain::Impl::Impl(Config & owner) : owner(owner) {
owner.opt_binds().add("protected_packages", protected_packages);
owner.opt_binds().add("username", username);
owner.opt_binds().add("password", password);
owner.opt_binds().add("gpgcheck", gpgcheck);
owner.opt_binds().add("pkg_gpgcheck", pkg_gpgcheck);
// Compatiblity alias for pkg_gpgcheck
owner.opt_binds().add("gpgcheck", pkg_gpgcheck);
owner.opt_binds().add("repo_gpgcheck", repo_gpgcheck);
owner.opt_binds().add("enabled", enabled);
owner.opt_binds().add("enablegroups", enablegroups);
Expand Down Expand Up @@ -1140,10 +1142,17 @@ const OptionString & ConfigMain::get_password_option() const {
}

OptionBool & ConfigMain::get_gpgcheck_option() {
return p_impl->gpgcheck;
return p_impl->pkg_gpgcheck;
}
const OptionBool & ConfigMain::get_gpgcheck_option() const {
return p_impl->gpgcheck;
return p_impl->pkg_gpgcheck;
}

OptionBool & ConfigMain::get_pkg_gpgcheck_option() {
return p_impl->pkg_gpgcheck;
}
const OptionBool & ConfigMain::get_pkg_gpgcheck_option() const {
return p_impl->pkg_gpgcheck;
}

OptionBool & ConfigMain::get_repo_gpgcheck_option() {
Expand Down
17 changes: 13 additions & 4 deletions libdnf5/repo/config_repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ConfigRepo::Impl {
OptionChild<OptionString> username{main_config.get_username_option()};
OptionChild<OptionString> password{main_config.get_password_option()};
OptionChild<OptionStringAppendList> protected_packages{main_config.get_protected_packages_option()};
OptionChild<OptionBool> gpgcheck{main_config.get_gpgcheck_option()};
OptionChild<OptionBool> pkg_gpgcheck{main_config.get_pkg_gpgcheck_option()};
OptionChild<OptionBool> repo_gpgcheck{main_config.get_repo_gpgcheck_option()};
OptionChild<OptionBool> enablegroups{main_config.get_enablegroups_option()};
OptionChild<OptionNumber<std::uint32_t>> retries{main_config.get_retries_option()};
Expand Down Expand Up @@ -143,7 +143,9 @@ ConfigRepo::Impl::Impl(Config & owner, ConfigMain & main_config, const std::stri
owner.opt_binds().add("username", username);
owner.opt_binds().add("password", password);
owner.opt_binds().add("protected_packages", protected_packages);
owner.opt_binds().add("gpgcheck", gpgcheck);
owner.opt_binds().add("pkg_gpgcheck", pkg_gpgcheck);
// Compatibility alias for pkg_gpgcheck
owner.opt_binds().add("gpgcheck", pkg_gpgcheck);
owner.opt_binds().add("repo_gpgcheck", repo_gpgcheck);
owner.opt_binds().add("enablegroups", enablegroups);
owner.opt_binds().add("retries", retries);
Expand Down Expand Up @@ -322,10 +324,17 @@ const OptionChild<OptionStringAppendList> & ConfigRepo::get_protected_packages_o
}

OptionChild<OptionBool> & ConfigRepo::get_gpgcheck_option() {
return p_impl->gpgcheck;
return p_impl->pkg_gpgcheck;
}
const OptionChild<OptionBool> & ConfigRepo::get_gpgcheck_option() const {
return p_impl->gpgcheck;
return p_impl->pkg_gpgcheck;
}

OptionChild<OptionBool> & ConfigRepo::get_pkg_gpgcheck_option() {
return p_impl->pkg_gpgcheck;
}
const OptionChild<OptionBool> & ConfigRepo::get_pkg_gpgcheck_option() const {
return p_impl->pkg_gpgcheck;
}

OptionChild<OptionBool> & ConfigRepo::get_repo_gpgcheck_option() {
Expand Down
2 changes: 1 addition & 1 deletion libdnf5/rpm/rpm_signature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ RpmSignature::CheckResult RpmSignature::check_package_signature(const rpm::Packa
}
} else {
auto & repo_config = repo->get_config();
if (!repo_config.get_gpgcheck_option().get_value()) {
if (!repo_config.get_pkg_gpgcheck_option().get_value()) {
return CheckResult::SKIPPED;
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/libdnf5/base/test_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void BaseTransactionTest::test_check_gpg_signatures_no_gpgcheck() {
void BaseTransactionTest::test_check_gpg_signatures_fail() {
add_repo_repomd("repomd-repo1");

base.get_config().get_gpgcheck_option().set(true);
base.get_config().get_pkg_gpgcheck_option().set(true);
jan-kolarik marked this conversation as resolved.
Show resolved Hide resolved

libdnf5::Goal goal(base);
goal.add_rpm_install("pkg");
Expand Down
11 changes: 11 additions & 0 deletions test/libdnf5/conf/test_conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ void ConfTest::test_config_repo() {
std::vector<std::string> baseurl = {"http://example.com/value123", "http://example.com/456"};
CPPUNIT_ASSERT_EQUAL(baseurl, config_repo.get_baseurl_option().get_value());
}

void ConfTest::test_config_pkg_gpgcheck() {
// Ensure both pkg_gpgcheck and gpgcheck point to the same underlying OptionBool object

// For ConfigMain
CPPUNIT_ASSERT_EQUAL(&config.get_pkg_gpgcheck_option(), &config.get_gpgcheck_option());

// For ConfigRepo
repo::ConfigRepo config_repo(config, "test-repo");
CPPUNIT_ASSERT_EQUAL(&config_repo.get_pkg_gpgcheck_option(), &config_repo.get_gpgcheck_option());
}
2 changes: 2 additions & 0 deletions test/libdnf5/conf/test_conf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ class ConfTest : public TestCaseFixture {
CPPUNIT_TEST_SUITE(ConfTest);
CPPUNIT_TEST(test_config_main);
CPPUNIT_TEST(test_config_repo);
CPPUNIT_TEST(test_config_pkg_gpgcheck);
CPPUNIT_TEST_SUITE_END();

public:
void setUp() override;

void test_config_main();
void test_config_repo();
void test_config_pkg_gpgcheck();

std::unique_ptr<libdnf5::Base> base;
libdnf5::LogRouter logger;
Expand Down
2 changes: 2 additions & 0 deletions test/python3/libdnf5/base/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def test_check_gpg_signatures_no_gpgcheck(self):
transaction.get_gpg_signature_problems())

def test_check_gpg_signatures_fail(self):
# Both options need to be available
self.base.get_config().gpgcheck = True
self.base.get_config().pkg_gpgcheck = True

goal = libdnf5.base.Goal(self.base)
goal.add_rpm_install("pkg")
Expand Down
Loading