Skip to content

Commit

Permalink
Having no keys imported is not an error
Browse files Browse the repository at this point in the history
...any more than "ls" in an empty directory is.

"Backport" of d666883

Resolves: 3556
Co-authored-by: Florian Festi <[email protected]>
  • Loading branch information
pmatilai and ffesti committed Feb 6, 2025
1 parent b332378 commit c924b24
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
5 changes: 2 additions & 3 deletions tests/rpmdb.at
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@ RPMTEST_CHECK([
runroot rpmkeys --delete 1964c5fc
runroot rpmkeys --list
],
[1],
[package gpg-pubkey is not installed
],
[0],
[],
[])
RPMTEST_CLEANUP

Expand Down
33 changes: 33 additions & 0 deletions tests/rpmsigdig.at
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,39 @@ runroot rpmkeys -Kv /data/RPMS/hello-2.0-1.x86_64.rpm /data/RPMS/hello-1.0-1.i38
[])
RPMTEST_CLEANUP

AT_SETUP([rpmkeys key update and delete (rpmdb)])
AT_KEYWORDS([rpmkeys signature])
RPMDB_INIT
# currently the default but make it explicit
# root's .rpmmacros used to keep this build prefix independent
echo "%_keyring rpmdb" >> "${RPMTEST}"/root/.rpmmacros
runroot rpmkeys --import /data/keys/rpm.org-rsa-2048-test.pub

RPMTEST_CHECK([
runroot rpmkeys --delete abcd gimmekey 1111aaaa2222bbbb
],
[3],
[],
[error: package gpg-pubkey-abcd is not installed
error: package gpg-pubkey-gimmekey is not installed
error: package gpg-pubkey-1111aaaa2222bbbb is not installed
])

RPMTEST_CHECK([
runroot rpmkeys --delete 1964c5fc
],
[0],
[],
[])

RPMTEST_CHECK([
runroot rpmkeys --list
],
[0],
[],
[])
RPMTEST_CLEANUP

# ------------------------------
# Test rpmkeys write errors
AT_SETUP([[rpmkeys -K no space left on stdout]])
Expand Down
3 changes: 2 additions & 1 deletion tools/rpmkeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ int main(int argc, char *argv[])
case MODE_LISTKEY:
{
ARGV_t query = NULL;
QVA_t qva = &rpmQVKArgs;
if (args != NULL) {
query = gpgkeyargs(args);
} else {
qva->qva_source |= RPMQV_ALL;
argvAdd(&query, "gpg-pubkey");
}
QVA_t qva = &rpmQVKArgs;
rstrcat(&qva->qva_queryFormat, "%{version}-%{release}: %{summary}\n");
ec = rpmcliQuery(ts, &rpmQVKArgs, (ARGV_const_t) query);
query = argvFree(query);
Expand Down

0 comments on commit c924b24

Please sign in to comment.