X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb%2Fkeydb_fs.c;h=565cfe840fd2d65f424752314343b9f09f064e62;hb=e82fd57b92d94287f728e37a3e17aaab11b722b8;hp=f7c865ee6b897cfb7995a35b5828dca1e7a63d12;hpb=3a9aaa4369f8078b801cddd2353db5730d2388c8;p=onak.git diff --git a/keydb/keydb_fs.c b/keydb/keydb_fs.c index f7c865e..565cfe8 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; }