]> the.earth.li Git - onak.git/blobdiff - keydb_hkp.c
Add cleankey.o to CORE_OBJS
[onak.git] / keydb_hkp.c
index 8bb8c02bd2e3a5b5ccc504ecd36d856ad12899bb..6707ae6974f0cb34f4c1007615b29b0ada503082 100644 (file)
@@ -34,6 +34,7 @@
 #include "version.h"
 
 struct onak_hkp_dbctx {
+       struct onak_db_config *config; /* Our DB config info */
        CURL *curl;
        char hkpbase[1024];
 };
@@ -163,7 +164,7 @@ static int hkp_fetch_key_id(struct onak_dbctx *dbctx,
  *     hkp_fetch_key_fp - Given a fingerprint fetch the key from HKP server.
  */
 static int hkp_fetch_key_fp(struct onak_dbctx *dbctx,
-               uint8_t *fp, size_t fpsize,
+               struct openpgp_fingerprint *fingerprint,
                struct openpgp_publickey **publickey,
                bool intrans)
 {
@@ -171,19 +172,19 @@ static int hkp_fetch_key_fp(struct onak_dbctx *dbctx,
        char keyurl[1024];
        int i, ofs;
 
-       if (fpsize > MAX_FINGERPRINT_LEN) {
+       if (fingerprint->length > MAX_FINGERPRINT_LEN) {
                return 0;
        }
 
        ofs = snprintf(keyurl, sizeof(keyurl),
                        "%s/lookup?op=get&search=0x", privctx->hkpbase);
 
-       if ((ofs + fpsize * 2 + 1)> sizeof(keyurl)) {
+       if ((ofs + fingerprint->length * 2 + 1)> sizeof(keyurl)) {
                return 0;
        }
 
-       for (i = 0; i < fpsize; i++) {
-               ofs += sprintf(&keyurl[ofs], "%02X", fp[i]);
+       for (i = 0; i < fingerprint->length; i++) {
+               ofs += sprintf(&keyurl[ofs], "%02X", fingerprint->fp[i]);
        }
 
        return (hkp_fetch_key_url(dbctx, keyurl, publickey, intrans));
@@ -346,7 +347,7 @@ static void hkp_cleanupdb(struct onak_dbctx *dbctx)
  *
  *     We initialize CURL here.
  */
-struct onak_dbctx *keydb_hkp_init(bool readonly)
+struct onak_dbctx *keydb_hkp_init(struct onak_db_config *dbcfg, bool readonly)
 {
        struct onak_dbctx *dbctx;
        struct onak_hkp_dbctx *privctx;
@@ -357,6 +358,7 @@ struct onak_dbctx *keydb_hkp_init(bool readonly)
                return NULL;
        }
 
+       dbctx->config = dbcfg;
        dbctx->priv = privctx = malloc(sizeof(*privctx));
        dbctx->cleanupdb                = hkp_cleanupdb;
        dbctx->starttrans               = hkp_starttrans;
@@ -373,7 +375,7 @@ struct onak_dbctx *keydb_hkp_init(bool readonly)
        dbctx->getfullkeyid             = generic_getfullkeyid;
        dbctx->iterate_keys             = hkp_iterate_keys;
 
-       if (!hkp_parse_url(privctx, config.db_dir)) {
+       if (!hkp_parse_url(privctx, dbcfg->location)) {
                exit(EXIT_FAILURE);
        }
        curl_global_init(CURL_GLOBAL_DEFAULT);