From 3f239a85d556bd35fc969758fe395b9a88cbc040 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Fri, 20 Sep 2024 13:58:04 +0200 Subject: [PATCH] Add Key Fingerprints to rpmsinfoMsg() --- lib/rpmvs.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/rpmvs.c b/lib/rpmvs.c index 997b613176..2faf27ddbd 100644 --- a/lib/rpmvs.c +++ b/lib/rpmvs.c @@ -306,13 +306,30 @@ const char *rpmsinfoDescr(struct rpmsinfo_s *sinfo) char *rpmsinfoMsg(struct rpmsinfo_s *sinfo) { char *msg = NULL; + char *fphex = NULL; + char *fpmsg = NULL; + if (sinfo->rc == RPMRC_OK && sinfo->key) { + uint8_t *fp; + size_t fplen; + if (!rpmPubkeyFingerPrint(sinfo->key, &fp, &fplen)) { + fphex = rpmhex(fp, fplen); + free(fp); + } + } + if (fphex) + rasprintf(&fpmsg, _(", Key Fingerprint: %s"), fphex); + else + rstrcat(&fpmsg, ""); + if (sinfo->msg) { - rasprintf(&msg, "%s: %s (%s)", - rpmsinfoDescr(sinfo), rpmSigString(sinfo->rc), sinfo->msg); + rasprintf(&msg, "%s: %s%s (%s)", + rpmsinfoDescr(sinfo), rpmSigString(sinfo->rc), fpmsg, sinfo->msg); } else { - rasprintf(&msg, "%s: %s", - rpmsinfoDescr(sinfo), rpmSigString(sinfo->rc)); + rasprintf(&msg, "%s: %s%s", + rpmsinfoDescr(sinfo), rpmSigString(sinfo->rc), fpmsg); } + free(fphex); + free(fpmsg); return msg; }