diff --git a/docs/man/rpmkeys.8.md b/docs/man/rpmkeys.8.md index 9d4105939f..37277a9fe8 100644 --- a/docs/man/rpmkeys.8.md +++ b/docs/man/rpmkeys.8.md @@ -23,6 +23,10 @@ The general forms of rpm digital signature commands are **rpmkeys** {**-K\|\--checksig**} *PACKAGE\_FILE \...* +**rpmkeys** **\--list-keys** + +**rpmkeys** **\--delete-key** *KEYHASH \...* + The **\--checksig** option checks all the digests and signatures contained in *PACKAGE\_FILE* to ensure the integrity and origin of the package. Note that signatures are now verified whenever a package is @@ -37,13 +41,21 @@ example, all currently imported public keys can be displayed by: **rpm -q gpg-pubkey** -Details about a specific public key, when imported, can be displayed by +A more convenient way to display them is + +**rpmkeys** **\--list-keys** + +More details about a specific public key, when imported, can be displayed by querying. Here\'s information about the Red Hat GPG/DSA key: **rpm -qi gpg-pubkey-db42a60e** Finally, public keys can be erased after importing just like packages. -Here\'s how to remove the Red Hat GPG/DSA key +Here\'s how to remove the Red Hat GPG/DSA key: + +**rpmkeys** **\--delete-key db42a60e** + +Or alternatively: **rpm -e gpg-pubkey-db42a60e** diff --git a/tools/rpmkeys.c b/tools/rpmkeys.c index afaffe5013..0a0da35292 100644 --- a/tools/rpmkeys.c +++ b/tools/rpmkeys.c @@ -2,6 +2,7 @@ #include #include +#include #include "cliutils.h" #include "debug.h" @@ -22,12 +23,10 @@ static struct poptOption keyOptsTable[] = { N_("import an armored public key"), NULL }, { "test", '\0', POPT_ARG_NONE, &test, 0, N_("don't import, but tell if it would work or not"), NULL }, -#if 0 { "delete-key", '\0', (POPT_ARG_VAL|POPT_ARGFLAG_OR), &mode, MODE_DELKEY, N_("list keys from RPM keyring"), NULL }, { "list-keys", '\0', (POPT_ARG_VAL|POPT_ARGFLAG_OR), &mode, MODE_LISTKEY, N_("list keys from RPM keyring"), NULL }, -#endif POPT_TABLEEND }; @@ -73,9 +72,30 @@ int main(int argc, char *argv[]) rpmtsSetFlags(ts, (rpmtsFlags(ts)|RPMTRANS_FLAG_TEST)); ec = rpmcliImportPubkeys(ts, args); break; - /* XXX TODO: actually implement these... */ case MODE_DELKEY: + struct rpmInstallArguments_s * ia = &rpmIArgs; + ARGV_t gpgargs = argvNew(); + for (char * const * arg = args; *arg; arg++) { + if (strncmp(*arg, "gpg-pubkey-", 11)) { + char * gpgarg = rpmExpand("gpg-pubkey-", *arg, NULL); + argvAdd(&gpgargs, gpgarg); + free(gpgarg); + } else { + argvAdd(&gpgargs, *arg); + } + } + ec = rpmErase(ts, ia, gpgargs); + argvFree(gpgargs); + break; case MODE_LISTKEY: + if (args != NULL) { + argerror(_("--list-keys does not take any arguments")); + } + ARGV_t query = argvSplitString("gpg-pubkey", " ", ARGV_NONE); + QVA_t qva = &rpmQVKArgs; + rstrcat(&qva->qva_queryFormat, "%{version}-%{release}: %{summary}\n"); + ec = rpmcliQuery(ts, &rpmQVKArgs, (ARGV_const_t) query); + query = argvFree(query); break; default: argerror(_("only one major mode may be specified"));