]> the.earth.li Git - onak.git/blobdiff - cgi/add.c
Handle failed database initialisation more gracefully
[onak.git] / cgi / add.c
index 5775e81ce3f209702ac25a5620920e612360a212..90824ccce7b5715b9c350f693e42ab6a05f06029 100644 (file)
--- a/cgi/add.c
+++ b/cgi/add.c
@@ -87,7 +87,12 @@ int main(int argc, char *argv[])
                        }
                        catchsignals();
                        dbctx = config.dbinit(config.backend, false);
-                       
+                       if (dbctx == NULL) {
+                               logthing(LOGTHING_ERROR,
+                                       "Failed to open key database.");
+                               goto err;
+                       }
+
                        count = cleankeys(dbctx, &keys, config.clean_policies);
                        logthing(LOGTHING_INFO, "%d keys cleaned.",
                                        count);
@@ -109,6 +114,7 @@ int main(int argc, char *argv[])
                        puts("No OpenPGP packets found in input.");
                        end_html();
                }
+err:
                cleanuplogthing();
                cleanupconfig();
        }