From: Jonathan McDowell Date: Wed, 31 Jul 2019 18:08:37 +0000 (+0100) Subject: Exit on failure to initialise a dynamic DB backend X-Git-Tag: onak-0.6.0~48 X-Git-Url: https://the.earth.li/gitweb/?a=commitdiff_plain;h=1a9c2d7545a4bafd7a601a8983192c4861d89c68;p=onak.git Exit on failure to initialise a dynamic DB backend The dynamic DB backend does a lot of checks to ensure it can load the requested backend successfully, but didn't actually check that it initialised correctly. Bomb out with a graceful error message if this happens rather than leading the caller to think everything is ok. --- diff --git a/keydb_dynamic.c b/keydb_dynamic.c index 9e4e3bc..ef42fbe 100644 --- a/keydb_dynamic.c +++ b/keydb_dynamic.c @@ -291,11 +291,20 @@ struct onak_dbctx *keydb_dynamic_init(struct onak_db_config *dbcfg, soname = NULL; exit(EXIT_FAILURE); } - free(soname); - soname = NULL; privctx->loadeddbctx = backend_init(dbcfg, readonly); + if (privctx->loadeddbctx == NULL) { + logthing(LOGTHING_CRITICAL, + "Failed to initialise dynamic backend: %s", + soname); + free(soname); + soname = NULL; + exit(EXIT_FAILURE); + } + free(soname); + soname = NULL; + if (privctx->loadeddbctx != NULL) { dbctx->cleanupdb = dynamic_cleanupdb; dbctx->starttrans = dynamic_starttrans;