Skip to content

Commit

Permalink
Move keystore type detection back to rpmts side
Browse files Browse the repository at this point in the history
Commit 364d284 moved a little too
much to the keystore side, revert the part that moved keyring
type detection back to the rpmts level.

No functional changes, needed for the next steps.
  • Loading branch information
pmatilai committed Oct 28, 2024
1 parent 781bf3b commit 0abf554
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
24 changes: 0 additions & 24 deletions lib/keystore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@

using std::string;

enum {
KEYRING_RPMDB = 1,
KEYRING_FS = 2,
};

static int makePubkeyHeader(rpmts ts, rpmPubkey key, Header * hdrp);

static int rpmtsLoadKeyringFromFiles(rpmts ts, rpmKeyring keyring)
Expand Down Expand Up @@ -410,28 +405,9 @@ rpmRC rpmKeystoreDeletePubkey(rpmtxn txn, rpmPubkey key)
return rc;
}

static int getKeyringType(void)
{
int kt = KEYRING_RPMDB;
char *krtype = rpmExpand("%{?_keyring}", NULL);

if (rstreq(krtype, "fs")) {
kt = KEYRING_FS;
} else if (*krtype && !rstreq(krtype, "rpmdb")) {
/* Fall back to using rpmdb if unknown, for now at least */
rpmlog(RPMLOG_WARNING,
_("unknown keyring type: %s, using rpmdb\n"), krtype);
}
free(krtype);

return kt;
}

int rpmKeystoreLoad(rpmts ts, rpmKeyring keyring)
{
int nkeys = 0;
if (!ts->keyringtype)
ts->keyringtype = getKeyringType();
if (ts->keyringtype == KEYRING_FS) {
nkeys = rpmtsLoadKeyringFromFiles(ts, keyring);
} else {
Expand Down
5 changes: 5 additions & 0 deletions lib/keystore.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
#include <rpm/rpmtypes.h>
#include <rpm/rpmutil.h>

enum {
KEYRING_RPMDB = 1,
KEYRING_FS = 2,
};

RPM_GNUC_INTERNAL
int rpmKeystoreLoad(rpmts ts, rpmKeyring keyring);

Expand Down
19 changes: 19 additions & 0 deletions lib/rpmts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,30 @@ int rpmtsSetKeyring(rpmts ts, rpmKeyring keyring)
return 0;
}

static int getKeyringType(void)
{
int kt = KEYRING_RPMDB;
char *krtype = rpmExpand("%{?_keyring}", NULL);

if (rstreq(krtype, "fs")) {
kt = KEYRING_FS;
} else if (*krtype && !rstreq(krtype, "rpmdb")) {
/* Fall back to using rpmdb if unknown, for now at least */
rpmlog(RPMLOG_WARNING,
_("unknown keyring type: %s, using rpmdb\n"), krtype);
}
free(krtype);

return kt;
}

static void loadKeyring(rpmts ts)
{
/* Never load the keyring if signature checking is disabled */
if ((rpmtsVSFlags(ts) & RPMVSF_MASK_NOSIGNATURES) !=
RPMVSF_MASK_NOSIGNATURES) {
if (!ts->keyringtype)
ts->keyringtype = getKeyringType();
ts->keyring = rpmKeyringNew();
rpmKeystoreLoad(ts, ts->keyring);
}
Expand Down

0 comments on commit 0abf554

Please sign in to comment.