89 lines
2.3 KiB
Diff
89 lines
2.3 KiB
Diff
From 0f61c017f2d0c8a11b12abec774aa94d45ec8116 Mon Sep 17 00:00:00 2001
|
|
From: Daniil Leonov <dleonov@cloudlinux.com>
|
|
Date: Tue, 9 Feb 2021 15:17:59 +0300
|
|
Subject: [PATCH] Add GPG subkeys support.
|
|
|
|
---
|
|
src/daemon/rpm.c | 46 ++++++++++++++++++++++++++++++++++++++--------
|
|
1 file changed, 38 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/daemon/rpm.c b/src/daemon/rpm.c
|
|
index af9a7be..c28c047 100644
|
|
--- a/src/daemon/rpm.c
|
|
+++ b/src/daemon/rpm.c
|
|
@@ -24,6 +24,19 @@
|
|
#include <rpm/rpmcli.h>
|
|
#include <rpm/rpmdb.h>
|
|
#include <rpm/rpmpgp.h>
|
|
+#include <rpm/rpmkeyring.h>
|
|
+
|
|
+struct rpmPubkey_s {
|
|
+ uint8_t *pkt;
|
|
+ size_t pktlen;
|
|
+ pgpKeyID_t keyid;
|
|
+ pgpDigParams pgpkey;
|
|
+ int nrefs;
|
|
+ pthread_rwlock_t lock;
|
|
+};
|
|
+
|
|
+typedef struct rpmPubkey_s * rpmPubkey;
|
|
+
|
|
#endif
|
|
|
|
/**
|
|
@@ -93,8 +106,13 @@ void rpm_destroy()
|
|
void rpm_load_gpgkey(const char* filename)
|
|
{
|
|
#ifdef HAVE_LIBRPM
|
|
+ rpmPubkey pubkey = NULL;
|
|
+ rpmPubkey *subkeys = NULL;
|
|
+ char *fingerprint = NULL;
|
|
+ int subkeysCount = 0;
|
|
uint8_t *pkt = NULL;
|
|
- size_t pklen;
|
|
+ size_t pklen = 0;
|
|
+
|
|
if (pgpReadPkts(filename, &pkt, &pklen) != PGPARMOR_PUBKEY)
|
|
{
|
|
free(pkt);
|
|
@@ -102,17 +120,29 @@ void rpm_load_gpgkey(const char* filename)
|
|
return;
|
|
}
|
|
|
|
- uint8_t keyID[8];
|
|
-#if 0
|
|
- if (pgpPubkeyFingerprint(pkt, pklen, keyID) == 0)
|
|
-#else
|
|
- if (pgpPubkeyKeyID(pkt, pklen, keyID) == 0)
|
|
-#endif
|
|
+ pubkey = rpmPubkeyNew(pkt, pklen);
|
|
+ if (pubkey != NULL)
|
|
{
|
|
- char *fingerprint = pgpHexStr(keyID, sizeof(keyID));
|
|
+ fingerprint = pgpHexStr(pubkey->keyid, sizeof(pubkey->keyid));
|
|
if (fingerprint != NULL)
|
|
list_fingerprints = g_list_append(list_fingerprints, fingerprint);
|
|
+
|
|
+ subkeys = rpmGetSubkeys(pubkey, &subkeysCount);
|
|
+ for (int i = 0; i < subkeysCount; i++)
|
|
+ {
|
|
+ rpmPubkey subkey = subkeys[i];
|
|
+ if (subkey != NULL)
|
|
+ {
|
|
+ fingerprint = pgpHexStr(subkey->keyid, sizeof(subkey->keyid));
|
|
+ if (fingerprint != NULL)
|
|
+ list_fingerprints = g_list_append(list_fingerprints, fingerprint);
|
|
+ }
|
|
+ rpmPubkeyFree(subkey);
|
|
+ }
|
|
+ free(subkeys);
|
|
}
|
|
+
|
|
+ rpmPubkeyFree(pubkey);
|
|
free(pkt);
|
|
#else
|
|
return;
|
|
--
|
|
2.25.1
|
|
|