15
15
#include < rpm/rpmts.h>
16
16
#include < rpm/rpmtypes.h>
17
17
18
- #include " keystore.hh"
19
18
#include " rpmts_internal.hh"
20
19
21
20
#include " debug.h"
22
21
23
22
using std::string;
23
+ using namespace rpm ;
24
24
25
25
static int makePubkeyHeader (rpmts ts, rpmPubkey key, Header * hdrp);
26
26
27
- static rpmRC rpmtsLoadKeyringFromFiles (rpmtxn txn, rpmKeyring keyring)
27
+ rpmRC keystore_fs::load_keys (rpmtxn txn, rpmKeyring keyring)
28
28
{
29
29
ARGV_t files = NULL ;
30
30
/* XXX TODO: deal with chroot path issues */
@@ -55,7 +55,7 @@ static rpmRC rpmtsLoadKeyringFromFiles(rpmtxn txn, rpmKeyring keyring)
55
55
return RPMRC_OK;
56
56
}
57
57
58
- static rpmRC rpmtsDeleteFSKey (rpmtxn txn, const string & keyid, const string & newname = " " )
58
+ rpmRC keystore_fs::delete_key (rpmtxn txn, const string & keyid, const string & newname)
59
59
{
60
60
rpmRC rc = RPMRC_NOTFOUND;
61
61
string keyglob = " gpg-pubkey-" + keyid + " *.key" ;
@@ -74,12 +74,12 @@ static rpmRC rpmtsDeleteFSKey(rpmtxn txn, const string & keyid, const string & n
74
74
return rc;
75
75
}
76
76
77
- static rpmRC rpmtsDeleteFSKey (rpmtxn txn, rpmPubkey key)
77
+ rpmRC keystore_fs::delete_key (rpmtxn txn, rpmPubkey key)
78
78
{
79
- return rpmtsDeleteFSKey (txn, rpmPubkeyFingerprintAsHex (key));
79
+ return delete_key (txn, rpmPubkeyFingerprintAsHex (key));
80
80
}
81
81
82
- static rpmRC rpmtsImportFSKey (rpmtxn txn, rpmPubkey key, rpmFlags flags, int replace)
82
+ rpmRC keystore_fs::import_key (rpmtxn txn, rpmPubkey key, rpmFlags flags, int replace)
83
83
{
84
84
rpmRC rc = RPMRC_FAIL;
85
85
const char *fp = rpmPubkeyFingerprintAsHex (key);
@@ -117,9 +117,9 @@ static rpmRC rpmtsImportFSKey(rpmtxn txn, rpmPubkey key, rpmFlags flags, int rep
117
117
118
118
if (!rc && replace) {
119
119
/* find and delete the old pubkey entry */
120
- if (rpmtsDeleteFSKey (txn, fp, keyfmt) == RPMRC_NOTFOUND) {
120
+ if (delete_key (txn, fp, keyfmt) == RPMRC_NOTFOUND) {
121
121
/* make sure an old, short keyid version gets removed */
122
- rpmtsDeleteFSKey (txn, fp+32 , keyfmt);
122
+ delete_key (txn, fp+32 , keyfmt);
123
123
}
124
124
}
125
125
@@ -131,7 +131,7 @@ static rpmRC rpmtsImportFSKey(rpmtxn txn, rpmPubkey key, rpmFlags flags, int rep
131
131
return rc;
132
132
}
133
133
134
- static rpmRC rpmtsLoadKeyringFromDB (rpmtxn txn, rpmKeyring keyring)
134
+ rpmRC keystore_rpmdb::load_keys (rpmtxn txn, rpmKeyring keyring)
135
135
{
136
136
Header h;
137
137
rpmdbMatchIterator mi;
@@ -170,7 +170,7 @@ static rpmRC rpmtsLoadKeyringFromDB(rpmtxn txn, rpmKeyring keyring)
170
170
return RPMRC_OK;
171
171
}
172
172
173
- static rpmRC rpmtsDeleteDBKey (rpmtxn txn, const string & keyid, unsigned int newinstance = 0 )
173
+ rpmRC keystore_rpmdb::delete_key (rpmtxn txn, const string & keyid, unsigned int newinstance)
174
174
{
175
175
rpmts ts = rpmtxnTs (txn);
176
176
if (rpmtsOpenDB (ts, (O_RDWR|O_CREAT)))
@@ -194,12 +194,12 @@ static rpmRC rpmtsDeleteDBKey(rpmtxn txn, const string & keyid, unsigned int new
194
194
return rc;
195
195
}
196
196
197
- static rpmRC rpmtsDeleteDBKey (rpmtxn txn, rpmPubkey key)
197
+ rpmRC keystore_rpmdb::delete_key (rpmtxn txn, rpmPubkey key)
198
198
{
199
- return rpmtsDeleteDBKey (txn, rpmPubkeyFingerprintAsHex (key));
199
+ return delete_key (txn, rpmPubkeyFingerprintAsHex (key));
200
200
}
201
201
202
- static rpmRC rpmtsImportDBKey (rpmtxn txn, rpmPubkey key, rpmFlags flags, int replace)
202
+ rpmRC keystore_rpmdb::import_key (rpmtxn txn, rpmPubkey key, rpmFlags flags, int replace)
203
203
{
204
204
Header h = NULL ;
205
205
rpmRC rc = RPMRC_FAIL;
@@ -213,9 +213,9 @@ static rpmRC rpmtsImportDBKey(rpmtxn txn, rpmPubkey key, rpmFlags flags, int rep
213
213
/* find and delete the old pubkey entry */
214
214
unsigned int newinstance = headerGetInstance (h);
215
215
char *keyid = headerFormat (h, " %{version}" , NULL );
216
- if (rpmtsDeleteDBKey (txn, keyid, newinstance) == RPMRC_NOTFOUND) {
216
+ if (delete_key (txn, keyid, newinstance) == RPMRC_NOTFOUND) {
217
217
/* make sure an old, short keyid version gets removed */
218
- rpmtsDeleteDBKey (txn, keyid+32 , newinstance);
218
+ delete_key (txn, keyid+32 , newinstance);
219
219
}
220
220
free (keyid);
221
221
}
@@ -372,44 +372,3 @@ static int makePubkeyHeader(rpmts ts, rpmPubkey key, Header * hdrp)
372
372
373
373
return rc;
374
374
}
375
-
376
- rpmRC rpmKeystoreImportPubkey (rpmtxn txn, rpmPubkey key, int replace)
377
- {
378
- rpmRC rc = RPMRC_FAIL;
379
- rpmts ts = rpmtxnTs (txn);
380
-
381
- /* Add header to database. */
382
- if (!(rpmtsFlags (ts) & RPMTRANS_FLAG_TEST)) {
383
- if (ts->keyringtype == KEYRING_FS)
384
- rc = rpmtsImportFSKey (txn, key, 0 , replace);
385
- else
386
- rc = rpmtsImportDBKey (txn, key, 0 , replace);
387
- } else {
388
- rc = RPMRC_OK;
389
- }
390
- return rc;
391
- }
392
-
393
- rpmRC rpmKeystoreDeletePubkey (rpmtxn txn, rpmPubkey key)
394
- {
395
- rpmRC rc = RPMRC_FAIL;
396
- rpmts ts = rpmtxnTs (txn);
397
- if (ts->keyringtype == KEYRING_FS)
398
- rc = rpmtsDeleteFSKey (txn, key);
399
- else
400
- rc = rpmtsDeleteDBKey (txn, key);
401
- return rc;
402
- }
403
-
404
- rpmRC rpmKeystoreLoad (rpmtxn txn, rpmKeyring keyring)
405
- {
406
- rpmRC rc = RPMRC_FAIL;
407
- rpmts ts = rpmtxnTs (txn);
408
- if (ts->keyringtype == KEYRING_FS) {
409
- rc = rpmtsLoadKeyringFromFiles (txn, keyring);
410
- } else {
411
- rc = rpmtsLoadKeyringFromDB (txn, keyring);
412
- }
413
- return rc;
414
- }
415
-
0 commit comments