forked from rpm-software-management/rpm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn keystore into an interface class
Add an abstract rpm::keystore class and port our existing rpmdb and fs keystores to that. The keystore code as such doesn't really change at all in here, the bigger change is the way it's initialized because it's an object instead of just an integer in the rpmts struct. As a kind of side-effect, we introduce the rpm:: namespace here. Fixes: rpm-software-management#3342
- Loading branch information
Showing
4 changed files
with
69 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,42 @@ | ||
#ifndef _KEYSTORE_H | ||
#define _KEYSTORE_H | ||
|
||
#include <string> | ||
|
||
#include <rpm/rpmtypes.h> | ||
#include <rpm/rpmutil.h> | ||
|
||
enum { | ||
KEYRING_RPMDB = 1, | ||
KEYRING_FS = 2, | ||
namespace rpm { | ||
|
||
class keystore { | ||
public: | ||
virtual rpmRC load_keys(rpmtxn txn, rpmKeyring keyring) = 0; | ||
virtual rpmRC import_key(rpmtxn txn, rpmPubkey key, rpmFlags flags = 0, int replace = 1) = 0; | ||
virtual rpmRC delete_key(rpmtxn txn, rpmPubkey key) = 0; | ||
|
||
virtual ~keystore() = default; | ||
}; | ||
|
||
RPM_GNUC_INTERNAL | ||
rpmRC rpmKeystoreLoad(rpmtxn txn, rpmKeyring keyring); | ||
class keystore_fs : public keystore { | ||
public: | ||
virtual rpmRC load_keys(rpmtxn txn, rpmKeyring keyring); | ||
virtual rpmRC import_key(rpmtxn txn, rpmPubkey key, rpmFlags flags = 0, int replace = 1); | ||
virtual rpmRC delete_key(rpmtxn txn, rpmPubkey key); | ||
|
||
RPM_GNUC_INTERNAL | ||
rpmRC rpmKeystoreImportPubkey(rpmtxn txn, rpmPubkey key, int replace = 0); | ||
private: | ||
rpmRC delete_key(rpmtxn txn, const std::string & keyid, const std::string & newname = ""); | ||
}; | ||
|
||
class keystore_rpmdb : public keystore { | ||
public: | ||
virtual rpmRC load_keys(rpmtxn txn, rpmKeyring keyring); | ||
virtual rpmRC import_key(rpmtxn txn, rpmPubkey key, rpmFlags flags = 0, int replace = 1); | ||
virtual rpmRC delete_key(rpmtxn txn, rpmPubkey key); | ||
|
||
private: | ||
rpmRC delete_key(rpmtxn txn, const std::string & keyid, unsigned int newinstance = 0); | ||
}; | ||
|
||
RPM_GNUC_INTERNAL | ||
rpmRC rpmKeystoreDeletePubkey(rpmtxn txn, rpmPubkey key); | ||
}; /* namespace */ | ||
|
||
#endif /* _KEYSTORE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters