X-Git-Url: https://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=onak.c;fp=onak.c;h=a588b51d2fc667c668b4aa3106dabc9a2d7794be;hp=d21ce7afb683c99cb675aa5c453d1f1006bb55de;hb=23538b7a1fe44e6e04e15d58b6fe809a6ad2ca31;hpb=79425efea806599b611de4e3b25bdc36516e7522 diff --git a/onak.c b/onak.c index d21ce7a..a588b51 100644 --- a/onak.c +++ b/onak.c @@ -218,6 +218,12 @@ int main(int argc, char *argv[]) usage(); } else if (!strcmp("dump", argv[optind])) { dbctx = config.dbinit(config.backend, true); + if (dbctx == NULL) { + logthing(LOGTHING_ERROR, + "Failed to open key database."); + rc = EXIT_FAILURE; + goto err; + } dumpstate.count = dumpstate.filenum = 0; dumpstate.maxcount = 100000; dumpstate.fd = -1; @@ -245,6 +251,12 @@ int main(int argc, char *argv[]) result); dbctx = config.dbinit(config.backend, false); + if (dbctx == NULL) { + logthing(LOGTHING_ERROR, + "Failed to open key database."); + rc = EXIT_FAILURE; + goto err; + } result = cleankeys(dbctx, &keys, config.clean_policies); logthing(LOGTHING_INFO, "%d keys cleaned.", @@ -287,6 +299,12 @@ int main(int argc, char *argv[]) } } else if (!strcmp("clean", argv[optind])) { dbctx = config.dbinit(config.backend, true); + if (dbctx == NULL) { + logthing(LOGTHING_ERROR, + "Failed to open key database."); + rc = EXIT_FAILURE; + goto err; + } if (binary) { result = read_openpgp_stream(stdin_getchar, NULL, &packets, 0); @@ -373,6 +391,12 @@ int main(int argc, char *argv[]) } } dbctx = config.dbinit(config.backend, false); + if (dbctx == NULL) { + logthing(LOGTHING_ERROR, + "Failed to open key database."); + rc = EXIT_FAILURE; + goto err; + } if (!strcmp("index", argv[optind])) { find_keys(dbctx, search, keyid, &fingerprint, ishex, isfp, dispfp, skshash, @@ -487,6 +511,7 @@ int main(int argc, char *argv[]) usage(); } +err: cleanuplogthing(); cleanupconfig(); free(configfile);