]> git.sommitrealweird.co.uk Git - onak.git/blobdiff - keydb.c
Add Debian init.d file for keyd
[onak.git] / keydb.c
diff --git a/keydb.c b/keydb.c
index 0039057093898bc067f5c3149ae9a0ec352559a9..4dc9332ad3690bbee67c1dfa6b7f39ada55f7910 100644 (file)
--- a/keydb.c
+++ b/keydb.c
@@ -105,16 +105,24 @@ struct ll *generic_cached_getkeysigs(uint64_t keyid)
        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;
        }
 
-       key = createandaddtohash(keyid);
+       key = findinhash(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) {
@@ -177,7 +185,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,
-                       "Fetching key 0x%llX, result: %d",
+                       "Fetching key 0x%" PRIX64 ", result: %d",
                        get_keyid(curkey),
                        config.dbbackend->fetch_key(get_keyid(curkey), &oldkey,
                                        intrans));