X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/4b8483ae278577a3adc8d84da81d77019704466f..e02c731dfbb288c736f2cd09a9b6df0507c59ddd:/keydb_file.c?ds=sidebyside diff --git a/keydb_file.c b/keydb_file.c index e5cf087..1d9b081 100644 --- a/keydb_file.c +++ b/keydb_file.c @@ -20,10 +20,9 @@ #include "keystructs.h" #include "ll.h" #include "mem.h" +#include "onak-conf.h" #include "parsekey.h" -#define DBDIR "/home/noodles/onak-0.0.1/db" - /** * keydb_fetchchar - Fetches a char from a file. */ @@ -35,9 +34,9 @@ static int keydb_fetchchar(void *fd, size_t count, unsigned char *c) /** * keydb_putchar - Puts a char to a file. */ -static int keydb_putchar(void *fd, unsigned char c) +static int keydb_putchar(void *fd, size_t count, unsigned char *c) { - return !(write( *(int *) fd, &c, sizeof(c))); + return !(write( *(int *) fd, c, count)); } /** @@ -75,7 +74,8 @@ int fetch_key(uint64_t keyid, struct openpgp_publickey **publickey) char keyfile[1024]; int fd = -1; - snprintf(keyfile, 1023, "%s/0x%llX", DBDIR, keyid & 0xFFFFFFFF); + snprintf(keyfile, 1023, "%s/0x%llX", config.file_dbpath, + keyid & 0xFFFFFFFF); fd = open(keyfile, O_RDONLY); // | O_SHLOCK); if (fd > -1) { @@ -104,7 +104,7 @@ int store_key(struct openpgp_publickey *publickey) char keyfile[1024]; int fd = -1; - snprintf(keyfile, 1023, "%s/0x%llX", DBDIR, + snprintf(keyfile, 1023, "%s/0x%llX", config.file_dbpath, get_keyid(publickey) & 0xFFFFFFFF); fd = open(keyfile, O_WRONLY | O_CREAT, 0664); // | O_EXLOCK); @@ -132,7 +132,7 @@ int delete_key(uint64_t keyid) { char keyfile[1024]; - snprintf(keyfile, 1023, "%s/0x%llX", DBDIR, + snprintf(keyfile, 1023, "%s/0x%llX", config.file_dbpath, keyid & 0xFFFFFFFF); return unlink(keyfile); @@ -141,4 +141,7 @@ int delete_key(uint64_t keyid) /* * Include the basic keydb routines. */ +#define NEED_KEYID2UID 1 +#define NEED_GETKEYSIGS 1 +#define NEED_GETFULLKEYID 1 #include "keydb.c"