diff --git a/lib/keystore.cc b/lib/keystore.cc index 7516ce4a37..55fcd62345 100644 --- a/lib/keystore.cc +++ b/lib/keystore.cc @@ -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) @@ -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 { diff --git a/lib/keystore.hh b/lib/keystore.hh index 625989d5aa..fc0f7b5bfa 100644 --- a/lib/keystore.hh +++ b/lib/keystore.hh @@ -3,6 +3,11 @@ #include #include +enum { + KEYRING_RPMDB = 1, + KEYRING_FS = 2, +}; + RPM_GNUC_INTERNAL int rpmKeystoreLoad(rpmts ts, rpmKeyring keyring); diff --git a/lib/rpmts.cc b/lib/rpmts.cc index ebaa354e09..1e856115fd 100644 --- a/lib/rpmts.cc +++ b/lib/rpmts.cc @@ -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); }