summaryrefslogtreecommitdiffstats
path: root/apps/apps.c
diff options
context:
space:
mode:
authorViktor Dukhovni <openssl-users@dukhovni.org>2018-03-05 14:40:02 -0500
committerViktor Dukhovni <openssl-users@dukhovni.org>2018-03-07 11:03:01 -0500
commitc7d5ea2670c2f2ce855b099a14ca2c218661ad3f (patch)
tree425e06b49ad9e7494aa2077c4e29a9625647f963 /apps/apps.c
parent61ab6919183fe804f3ed5cf26fcc121a4ecbb6af (diff)
Prepare to detect index changes in OCSP responder.
Retain open file handle and previous stat data for the CA index file, enabling detection and index reload (upcoming commit). Check requirements before entering accept loop. Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'apps/apps.c')
-rw-r--r--apps/apps.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/apps/apps.c b/apps/apps.c
index ef573552eb..5a32dc0a02 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -1538,12 +1538,27 @@ CA_DB *load_index(const char *dbfile, DB_ATTR *db_attr)
BIO *in;
CONF *dbattr_conf = NULL;
char buf[BSIZE];
+#ifndef OPENSSL_NO_POSIX_IO
+ FILE *dbfp;
+ struct stat dbst;
+#endif
in = BIO_new_file(dbfile, "r");
if (in == NULL) {
ERR_print_errors(bio_err);
goto err;
}
+
+#ifndef OPENSSL_NO_POSIX_IO
+ BIO_get_fp(in, &dbfp);
+ if (fstat(fileno(dbfp), &dbst) == -1) {
+ SYSerr(SYS_F_FSTAT, errno);
+ ERR_add_error_data(3, "fstat('", dbfile, "')");
+ ERR_print_errors(bio_err);
+ goto err;
+ }
+#endif
+
if ((tmpdb = TXT_DB_read(in, DB_NUMBER)) == NULL)
goto err;
@@ -1570,6 +1585,11 @@ CA_DB *load_index(const char *dbfile, DB_ATTR *db_attr)
}
}
+ retdb->dbfname = OPENSSL_strdup(dbfile);
+#ifndef OPENSSL_NO_POSIX_IO
+ retdb->dbst = dbst;
+#endif
+
err:
NCONF_free(dbattr_conf);
TXT_DB_free(tmpdb);
@@ -1715,6 +1735,7 @@ void free_index(CA_DB *db)
{
if (db) {
TXT_DB_free(db->db);
+ OPENSSL_free(db->dbfname);
OPENSSL_free(db);
}
}