From 40d9a19936bce579734822948005bf4ca00313d5 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Mon, 7 Oct 2024 20:40:32 +0200 Subject: [PATCH] rpmkeys --verbose --list Give more detailed information about the public keys. No 100% sure of using --verbose is the right call here. May be we should add --info to the cli. Does not list sub keys yet. --- tests/rpmdb.at | 16 ++++++++++++++++ tools/rpmkeys.cc | 27 ++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/tests/rpmdb.at b/tests/rpmdb.at index 545c6d6e7b..06c29afd8d 100644 --- a/tests/rpmdb.at +++ b/tests/rpmdb.at @@ -130,6 +130,22 @@ runroot rpmkeys --list 4344591e1964c5fc ], []) +RPMTEST_CHECK([ +runroot rpmkeys -v --list 4344591e1964c5fc +], +[0], +[Public key +Issuer: rpm.org RSA testkey +Fingerprint: 771b18d3d7baa28734333c424344591e1964c5fc +Key ID: 4344591e1964c5fc +Creation Time: Thu Apr 6 12:48:24 2017 +Version: V4 +Key algorithm: RSA +Hash algorithm: SHA256 + +], +[]) + RPMTEST_CHECK([ runroot rpmkeys --list XXX diff --git a/tools/rpmkeys.cc b/tools/rpmkeys.cc index 839e31ae32..43adee425b 100644 --- a/tools/rpmkeys.cc +++ b/tools/rpmkeys.cc @@ -113,6 +113,28 @@ static int printKey(rpmPubkey key, void * data) return 0; } +static int printKeyLong(rpmPubkey key, void * data) +{ + char * fp = rpmPubkeyFingerprintAsHex(key); + char * keyid = rpmPubkeyKeyIDAsHex(key); + pgpDigParams params = rpmPubkeyPgpDigParams(key); + const time_t unixtime = pgpDigParamsCreationTime(params); + rpmlog(RPMLOG_NOTICE, "Public key\n"); + rpmlog(RPMLOG_NOTICE, "Issuer: %s\n", pgpDigParamsUserID(params)); + rpmlog(RPMLOG_NOTICE, "Fingerprint: %s\n", fp); + rpmlog(RPMLOG_NOTICE, "Key ID: %s\n", keyid); + rpmlog(RPMLOG_NOTICE, "Creation Time: %s", asctime(gmtime(&unixtime))); + rpmlog(RPMLOG_NOTICE, "Version: V%i\n", pgpDigParamsVersion(params)); + rpmlog(RPMLOG_NOTICE, "Key algorithm: %s\n", pgpValString(PGPVAL_PUBKEYALGO, pgpDigParamsAlgo(params, PGPVAL_PUBKEYALGO))); + + rpmlog(RPMLOG_NOTICE, "Hash algorithm: %s\n", pgpValString(PGPVAL_HASHALGO, pgpDigParamsAlgo(params, PGPVAL_HASHALGO))); + rpmlog(RPMLOG_NOTICE, "\n"); + free(fp); + free(keyid); + return 0; + +} + int main(int argc, char *argv[]) { int ec = EXIT_FAILURE; @@ -156,7 +178,10 @@ int main(int argc, char *argv[]) } case MODE_LISTKEY: { - ec = matchingKeys(keyring, args, NULL, printKey); + if (rpmIsVerbose()) + ec = matchingKeys(keyring, args, NULL, printKeyLong); + else + ec = matchingKeys(keyring, args, NULL, printKey); break; } default: