X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb%2Fkeydb_fs.c;h=921c97834da28f292d72cfcc1128ffb2f3c7e840;hb=HEAD;hp=f7c865ee6b897cfb7995a35b5828dca1e7a63d12;hpb=a2979c20e1ab2d52e3a961ac7dad45fee9d6345a;p=onak.git diff --git a/keydb/keydb_fs.c b/keydb/keydb_fs.c index f7c865e..921c978 100644 --- a/keydb/keydb_fs.c +++ b/keydb/keydb_fs.c @@ -32,6 +32,7 @@ #include "charfuncs.h" #include "decodekey.h" +#include "key-store.h" #include "keydb.h" #include "keyid.h" #include "keystructs.h" @@ -258,8 +259,9 @@ static int fs_fetch_key_id(struct onak_dbctx *dbctx, bool intrans) { static char buffer[PATH_MAX]; - int ret = 0, fd; + int ret = 0; struct openpgp_packet_list *packets = NULL; + onak_status_t res; if (!intrans) fs_starttrans(dbctx); @@ -268,20 +270,20 @@ static int fs_fetch_key_id(struct onak_dbctx *dbctx, keyid = fs_getfullkeyid(dbctx, keyid); keypath(buffer, sizeof(buffer), keyid, dbctx->config->location); - fd = open(buffer, O_RDONLY); - if (fd == -1 && errno == ENOENT) { + res = onak_read_openpgp_file(buffer, + &packets); + if (res == ONAK_E_NOT_FOUND) { subkeypath(buffer, sizeof(buffer), keyid, dbctx->config->location); - fd = open(buffer, O_RDONLY); + res = onak_read_openpgp_file(buffer, + &packets); } - if (fd != -1) { + if (res == ONAK_E_OK) { /* File is present, load it in... */ - read_openpgp_stream(file_fetchchar, &fd, &packets, 0); parse_keys(packets, publickey); free_packet_list(packets); packets = NULL; - close(fd); ret = 1; } @@ -593,16 +595,16 @@ static int fs_fetch_key_skshash(struct onak_dbctx *dbctx, struct openpgp_publickey **publickey) { static char buffer[PATH_MAX]; - int ret = 0, fd; + int ret = 0; struct openpgp_packet_list *packets = NULL; + onak_status_t res; skshashpath(buffer, sizeof(buffer), hash, dbctx->config->location); - if ((fd = open(buffer, O_RDONLY)) != -1) { - read_openpgp_stream(file_fetchchar, &fd, &packets, 0); + res = onak_read_openpgp_file(buffer, &packets); + if (res == ONAK_E_OK) { parse_keys(packets, publickey); free_packet_list(packets); packets = NULL; - close(fd); ret = 1; } @@ -620,9 +622,10 @@ static int fs_fetch_key_skshash(struct onak_dbctx *dbctx, * * Returns the number of keys we iterated over. */ -static int fs_iterate_keys(struct onak_dbctx *dbctx, - void (*iterfunc)(void *ctx, - struct openpgp_publickey *key), void *ctx) +static int fs_iterate_keys(__unused struct onak_dbctx *dbctx, + __unused void (*iterfunc)(void *ctx, + struct openpgp_publickey *key), + __unused void *ctx) { return 0; }