]> the.earth.li Git - onak.git/blobdiff - cgi/lookup.c
Handle failed database initialisation more gracefully
[onak.git] / cgi / lookup.c
index 632a0a8cd58dd9974c3a47e510fc4c2615d5a849..2006e475cea9d70dba5c90aef601a93fc4a0f51e 100644 (file)
@@ -228,6 +228,11 @@ int main(int argc, char *argv[])
                initlogthing("lookup", config.logfile);
                catchsignals();
                dbctx = config.dbinit(config.backend, false);
+               if (dbctx == NULL) {
+                       logthing(LOGTHING_ERROR,
+                               "Failed to open key database.");
+                       goto err;
+               }
                switch (op) {
                case OP_GET:
                case OP_HGET:
@@ -305,6 +310,7 @@ int main(int argc, char *argv[])
                        puts("Unknown operation!");
                }
                dbctx->cleanupdb(dbctx);
+err:
                cleanuplogthing();
                cleanupconfig();
        }