X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb_keyd.c;h=7d3754a837693d26e610b3e2150471c9ce06aeae;hb=7fd2267eca87bd9bcfe5e66e95e2e683bda1533b;hp=33d2c21b4d15eac23e918073f2ca7399c037607e;hpb=338e91f33174edebe42d77843c0eea34f53bc53c;p=onak.git diff --git a/keydb_keyd.c b/keydb_keyd.c index 33d2c21..7d3754a 100644 --- a/keydb_keyd.c +++ b/keydb_keyd.c @@ -227,6 +227,7 @@ static int keyd_store_key(struct onak_dbctx *dbctx, struct openpgp_packet_list *list_end = NULL; struct openpgp_publickey *next = NULL; uint64_t keyid; + enum keyd_ops cmd = KEYD_CMD_STORE; if (get_keyid(publickey, &keyid) != ONAK_E_OK) { logthing(LOGTHING_ERROR, "Couldn't find key ID for key."); @@ -234,10 +235,10 @@ static int keyd_store_key(struct onak_dbctx *dbctx, } if (update) { - keyd_delete_key(dbctx, keyid, false); + cmd = KEYD_CMD_UPDATE; } - if (keyd_send_cmd(keyd_fd, KEYD_CMD_STORE)) { + if (keyd_send_cmd(keyd_fd, cmd)) { keybuf.offset = 0; keybuf.size = 8192; keybuf.buffer = malloc(keybuf.size); @@ -502,7 +503,7 @@ static void keyd_cleanupdb(struct onak_dbctx *dbctx) * this file are called in order to allow the DB to be initialized ready * for access. */ -struct onak_dbctx *keydb_keyd_init(bool readonly) +struct onak_dbctx *keydb_keyd_init(struct onak_db_config *dbcfg, bool readonly) { struct sockaddr_un sock; uint32_t cmd = KEYD_CMD_UNKNOWN; @@ -515,6 +516,7 @@ struct onak_dbctx *keydb_keyd_init(bool readonly) if (dbctx == NULL) { return NULL; } + dbctx->config = dbcfg; keyd_fd = socket(PF_UNIX, SOCK_STREAM, 0); if (keyd_fd < 0) {