From 1c7dbce83b2f63f1db6b2a48a83fe58306094e51 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Dec 2019 14:13:24 +0000 Subject: [PATCH] privcache: Break out uncached_load_file We are going to want to reuse this to make a new entrypoint. Signed-off-by: Ian Jackson --- privcache.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) 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) { -- 2.30.2