X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb_keyd.c;h=cd1a2819d98eefc04b53a060d718e7c1fc58ab19;hb=b3c67e7383ef6ece55dcf6fbfa9587f5d0a14546;hp=fec6ebbc6afd3dc8751eb97ea4ea158d113db726;hpb=ce50ec7c87838b4c5444d8846caa372c8e82fa0d;p=onak.git
diff --git a/keydb_keyd.c b/keydb_keyd.c
index fec6ebb..cd1a281 100644
--- a/keydb_keyd.c
+++ b/keydb_keyd.c
@@ -13,12 +13,13 @@
* more details.
*
* You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program. If not, see .
*/
#include
#include
+#include
+#include
#include
#include
#include
@@ -34,6 +35,7 @@
#include "keystructs.h"
#include "log.h"
#include "mem.h"
+#include "onak.h"
#include "onak-conf.h"
#include "parsekey.h"
@@ -227,6 +229,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 +237,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 +505,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 +518,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) {
@@ -527,7 +531,7 @@ struct onak_dbctx *keydb_keyd_init(bool readonly)
sock.sun_family = AF_UNIX;
snprintf(sock.sun_path, sizeof(sock.sun_path) - 1, "%s/%s",
- config.db_dir,
+ config.sock_dir,
KEYD_SOCKET);
if (connect(keyd_fd, (struct sockaddr *) &sock, sizeof(sock)) < 0) {
logthing(LOGTHING_CRITICAL,