projects
/
onak.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Define OpenPGP constants and use them rather than magic numbers
[onak.git]
/
keydb.c
diff --git
a/keydb.c
b/keydb.c
index 339450bda290f1d0c99166836dbb6f86800696c1..2abfa02bae51ae8a9d8d7b3f587844b66c4b29ca 100644
(file)
--- a/
keydb.c
+++ b/
keydb.c
@@
-23,6
+23,7
@@
#include "keystructs.h"
#include "mem.h"
#include "merge.h"
#include "keystructs.h"
#include "mem.h"
#include "merge.h"
+#include "openpgp.h"
#include "parsekey.h"
#include "sendsync.h"
#include "parsekey.h"
#include "sendsync.h"
@@
-42,7
+43,7
@@
char *generic_keyid2uid(uint64_t keyid)
publickey != NULL) {
curuid = publickey->uids;
while (curuid != NULL && buf[0] == 0) {
publickey != NULL) {
curuid = publickey->uids;
while (curuid != NULL && buf[0] == 0) {
- if (curuid->packet->tag ==
13
) {
+ if (curuid->packet->tag ==
OPENPGP_PACKET_UID
) {
snprintf(buf, 1023, "%.*s",
(int) curuid->packet->length,
curuid->packet->data);
snprintf(buf, 1023, "%.*s",
(int) curuid->packet->length,
curuid->packet->data);
@@
-105,16
+106,24
@@
struct ll *generic_cached_getkeysigs(uint64_t keyid)
struct stats_key *key = NULL;
struct stats_key *signedkey = NULL;
struct ll *cursig = NULL;
struct stats_key *key = NULL;
struct stats_key *signedkey = NULL;
struct ll *cursig = NULL;
+ struct ll *sigs = NULL;
bool revoked = false;
if (keyid == 0) {
return NULL;
}
bool revoked = false;
if (keyid == 0) {
return NULL;
}
- key =
createandaddto
hash(keyid);
+ key =
findin
hash(keyid);
- if (key->gotsigs == false) {
- key->sigs = config.dbbackend->getkeysigs(key->keyid, &revoked);
+ if (key == NULL || key->gotsigs == false) {
+ sigs = config.dbbackend->getkeysigs(keyid, &revoked);
+ if (sigs == NULL) {
+ return NULL;
+ }
+ if (key == NULL) {
+ key = createandaddtohash(keyid);
+ }
+ key->sigs = sigs;
key->revoked = revoked;
for (cursig = key->sigs; cursig != NULL;
cursig = cursig->next) {
key->revoked = revoked;
for (cursig = key->sigs; cursig != NULL;
cursig = cursig->next) {
@@
-177,7
+186,7
@@
int generic_update_keys(struct openpgp_publickey **keys, bool sendsync)
for (curkey = *keys; curkey != NULL; curkey = curkey->next) {
intrans = config.dbbackend->starttrans();
logthing(LOGTHING_INFO,
for (curkey = *keys; curkey != NULL; curkey = curkey->next) {
intrans = config.dbbackend->starttrans();
logthing(LOGTHING_INFO,
- "Fetching key 0x%
llX
, result: %d",
+ "Fetching key 0x%
" PRIX64 "
, result: %d",
get_keyid(curkey),
config.dbbackend->fetch_key(get_keyid(curkey), &oldkey,
intrans));
get_keyid(curkey),
config.dbbackend->fetch_key(get_keyid(curkey), &oldkey,
intrans));
@@
-205,7
+214,8
@@
int generic_update_keys(struct openpgp_publickey **keys, bool sendsync)
prev = curkey;
logthing(LOGTHING_INFO,
"Merged key; storing updated key.");
prev = curkey;
logthing(LOGTHING_INFO,
"Merged key; storing updated key.");
- store_key(oldkey, intrans, true);
+ config.dbbackend->store_key(oldkey, intrans,
+ true);
}
free_publickey(oldkey);
oldkey = NULL;
}
free_publickey(oldkey);
oldkey = NULL;