From: Ian Jackson Date: Sat, 7 Dec 2019 14:13:24 +0000 (+0000) Subject: privcache: Break out uncached_load_file X-Git-Tag: v0.6.0~45 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b9b111d4ea26e6f5c5110a25ef763b5930465f43;p=secnet.git privcache: Break out uncached_load_file We are going to want to reuse this to make a new entrypoint. Signed-off-by: Ian Jackson --- diff --git a/privcache.c b/privcache.c index ba756ff..298626f 100644 --- a/privcache.c +++ b/privcache.c @@ -37,19 +37,19 @@ struct privcache { struct hash_if *defhash; }; +static struct sigprivkey_if *uncached_load_file( + const struct sigscheme_info *scheme, + const char *path, + struct buffer_if *databuf, + struct hash_if *defhash, + struct log_if *log); + static struct sigprivkey_if *uncached_get(struct privcache *st, const struct sigkeyid *id, struct log_if *log) { - bool_t ok=False; - FILE *f=0; - sprintf(st->path.write_here, SIGKEYID_PR_FMT, SIGKEYID_PR_VAL(id)); const char *path=st->path.buffer; - struct hash_if *defhash=st->defhash; - struct buffer_if *databuf=&st->databuf; - - struct sigprivkey_if *sigpriv=0; const struct sigscheme_info *scheme; for (scheme=sigschemes; scheme->name; @@ -59,9 +59,27 @@ static struct sigprivkey_if *uncached_get(struct privcache *st, slilog(log,M_ERR,"private key file %s not loaded (unknown algid)", path); - goto out; + return 0; found: + return uncached_load_file(scheme, + path, + &st->databuf, + st->defhash, + log); +} + +static struct sigprivkey_if *uncached_load_file( + const struct sigscheme_info *scheme, + const char *path, + struct buffer_if *databuf, + struct hash_if *defhash, + struct log_if *log) +{ + bool_t ok=False; + FILE *f=0; + struct sigprivkey_if *sigpriv=0; + f = fopen(path,"rb"); if (!f) { if (errno == ENOENT) {