From: Timo Sirainen Date: Wed, 5 May 2021 09:44:03 +0000 (+0300) Subject: global: Replace exit() with lib_exit() X-Git-Tag: 2.3.16~161 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6d52674782e6ec72ee54895a1657e29333496f18;p=thirdparty%2Fdovecot%2Fcore.git global: Replace exit() with lib_exit() --- diff --git a/src/auth/checkpassword-reply.c b/src/auth/checkpassword-reply.c index b449090d59..71f231aaaf 100644 --- a/src/auth/checkpassword-reply.c +++ b/src/auth/checkpassword-reply.c @@ -94,7 +94,7 @@ int main(void) if (write_full(4, str_data(str), str_len(str)) < 0) { i_error("checkpassword: write_full() failed: %m"); - exit(111); + lib_exit(111); } authorized = getenv("AUTHORIZED"); if (authorized == NULL) { diff --git a/src/auth/db-checkpassword.c b/src/auth/db-checkpassword.c index dd7928b15f..7d52eeff2d 100644 --- a/src/auth/db-checkpassword.c +++ b/src/auth/db-checkpassword.c @@ -374,7 +374,7 @@ checkpassword_exec(struct db_checkpassword *db, struct auth_request *request, if (dup2(fd_out, 3) < 0 || dup2(fd_in, 4) < 0) { e_error(authdb_event(request), "dup2() failed: %m"); - exit(111); + lib_exit(111); } if (!authenticate) { diff --git a/src/config/doveconf.c b/src/config/doveconf.c index 9f519552b8..dc18837c1c 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -826,13 +826,13 @@ static void hostname_verify_format(const char *arg) hash_table_destroy(&hosts); if (duplicates) - exit(EX_CONFIG); + lib_exit(EX_CONFIG); else { host2 = t_strdup(str_c(host)); hostname_format_write(host, &fmt, 0); printf("No duplicate host hashes in %s .. %s\n", str_c(host), host2); - exit(0); + lib_exit(0); } } diff --git a/src/dict/main.c b/src/dict/main.c index 5ab0852a0a..a8ab615002 100644 --- a/src/dict/main.c +++ b/src/dict/main.c @@ -130,7 +130,7 @@ static void main_deinit(void) { /* FIXME: we're not able to do a clean deinit currently without larger changes. */ - exit(0); + lib_exit(0); timeout_remove(&to_proctitle); dict_connections_destroy_all(); diff --git a/src/doveadm/doveadm-mail.c b/src/doveadm/doveadm-mail.c index cd3edd7dc2..6a9fb08b6b 100644 --- a/src/doveadm/doveadm-mail.c +++ b/src/doveadm/doveadm-mail.c @@ -857,7 +857,7 @@ void doveadm_mail_help(const struct doveadm_mail_cmd *cmd) { fprintf(stderr, "doveadm %s "DOVEADM_CMD_MAIL_USAGE_PREFIX" %s\n", cmd->name, cmd->usage_args == NULL ? "" : cmd->usage_args); - exit(EX_USAGE); + lib_exit(EX_USAGE); } void doveadm_mail_try_help_name(const char *cmd_name) diff --git a/src/doveadm/doveadm-pw.c b/src/doveadm/doveadm-pw.c index a2ddc19ffc..a2f770dea5 100644 --- a/src/doveadm/doveadm-pw.c +++ b/src/doveadm/doveadm-pw.c @@ -81,7 +81,7 @@ static void cmd_pw(int argc, char *argv[]) for (i = 0; i < count; i++) printf("%s ", schemes[i]->name); printf("\n"); - exit(0); + lib_exit(0); } if (argc != optind) @@ -100,7 +100,7 @@ static void cmd_pw(int argc, char *argv[]) if (strcmp(plaintext, check) != 0) { i_error("Passwords don't match!"); if (--lives == 0) - exit(1); + lib_exit(1); plaintext = NULL; } } diff --git a/src/doveadm/doveadm.c b/src/doveadm/doveadm.c index 7076c38ffa..d34fa17d7b 100644 --- a/src/doveadm/doveadm.c +++ b/src/doveadm/doveadm.c @@ -134,7 +134,7 @@ usage_to(FILE *out, const char *prefix) doveadm_mail_usage(str); doveadm_usage_compress_lines(out, str_c(str), prefix); - exit(EX_USAGE); + lib_exit(EX_USAGE); } void usage(void) @@ -146,7 +146,7 @@ static void ATTR_NORETURN help_to(const struct doveadm_cmd *cmd, FILE *out) { fprintf(out, "doveadm %s %s\n", cmd->name, cmd->short_usage); - exit(EX_USAGE); + lib_exit(EX_USAGE); } void help(const struct doveadm_cmd *cmd) @@ -158,7 +158,7 @@ static void ATTR_NORETURN help_to_ver2(const struct doveadm_cmd_ver2 *cmd, FILE *out) { fprintf(out, "doveadm %s %s\n", cmd->name, cmd->usage); - exit(EX_USAGE); + lib_exit(EX_USAGE); } void help_ver2(const struct doveadm_cmd_ver2 *cmd) diff --git a/src/lib-compression/bench-compression.c b/src/lib-compression/bench-compression.c index 98f3f2e7db..f0e64268e5 100644 --- a/src/lib-compression/bench-compression.c +++ b/src/lib-compression/bench-compression.c @@ -96,7 +96,7 @@ static void print_usage(const char *prog) { fprintf(stderr, "Usage: %s block_size count level\n", prog); fprintf(stderr, "Runs with 1000 8k blocks using level 6 if nothing given\n"); - exit(1); + lib_exit(1); } int main(int argc, const char *argv[]) diff --git a/src/lib-oauth2/test-oauth2-jwt.c b/src/lib-oauth2/test-oauth2-jwt.c index 4cfba64e9d..e46a1e405e 100644 --- a/src/lib-oauth2/test-oauth2-jwt.c +++ b/src/lib-oauth2/test-oauth2-jwt.c @@ -609,7 +609,7 @@ static void test_jwt_rs_token(void) tokenbuf->data, tokenbuf->used, sig, DCRYPT_PADDING_RSA_PKCS1, &error)) { i_error("dcrypt signing failed: %s", error); - exit(1); + lib_exit(1); } dcrypt_key_unref_private(&key); @@ -646,7 +646,7 @@ static void test_jwt_ps_token(void) tokenbuf->data, tokenbuf->used, sig, DCRYPT_PADDING_RSA_PKCS1_PSS, &error)) { i_error("dcrypt signing failed: %s", error); - exit(1); + lib_exit(1); } dcrypt_key_unref_private(&key); @@ -673,14 +673,14 @@ static void test_jwt_ec_token(void) if (!dcrypt_keypair_generate(&pair, DCRYPT_KEY_EC, 0, "prime256v1", &error)) { i_error("dcrypt keypair generate failed: %s", error); - exit(1); + lib_exit(1); } /* export public key */ buffer_t *keybuf = t_buffer_create(256); if (!dcrypt_key_store_public(pair.pub, DCRYPT_FORMAT_PEM, keybuf, &error)) { i_error("dcrypt key store failed: %s", error); - exit(1); + lib_exit(1); } oauth2_validation_key_cache_evict(key_cache, "default"); save_key("ES256", str_c(keybuf)); @@ -693,7 +693,7 @@ static void test_jwt_ec_token(void) tokenbuf->data, tokenbuf->used, sig, DCRYPT_PADDING_DEFAULT, &error)) { i_error("dcrypt signing failed: %s", error); - exit(1); + lib_exit(1); } dcrypt_keypair_unref(&pair); diff --git a/src/lib-test/test-common.c b/src/lib-test/test-common.c index a2eaf6ccae..feea7ecd88 100644 --- a/src/lib-test/test-common.c +++ b/src/lib-test/test-common.c @@ -461,5 +461,5 @@ test_exit(int status) i_free_and_null(test_prefix); t_pop_last_unsafe(); /* as we were within a T_BEGIN { tests[i].func(); } T_END */ lib_deinit(); - exit(status); + lib_exit(status); } diff --git a/src/lib-test/test-subprocess.c b/src/lib-test/test-subprocess.c index b85c41f7aa..4c51924b7e 100644 --- a/src/lib-test/test-subprocess.c +++ b/src/lib-test/test-subprocess.c @@ -72,7 +72,7 @@ test_subprocess_child(int (*func)(void *context), void *context, if (!continue_test) { lib_deinit(); - exit(ret); + lib_exit(ret); } test_exit((test_has_failed() ? 1 : 0)); } diff --git a/src/lib/failures.c b/src/lib/failures.c index 8ac26269cd..4a9abd68f7 100644 --- a/src/lib/failures.c +++ b/src/lib/failures.c @@ -310,7 +310,7 @@ void failure_exit(int status) recursed = TRUE; failure_exit_callback(&status); } - exit(status); + lib_exit(status); } static void log_timestamp_add(const struct failure_context *ctx, string_t *str) diff --git a/src/lib/lib.h b/src/lib/lib.h index 6ab56a2d75..e16b4ce48c 100644 --- a/src/lib/lib.h +++ b/src/lib/lib.h @@ -81,6 +81,7 @@ void lib_atexit_priority(lib_atexit_callback_t *callback, int priority); /* Manually run the atexit callbacks. lib_deinit() also does this if not explicitly called. */ void lib_atexit_run(void); +#define lib_exit(status) exit(status) void lib_init(void); bool lib_is_initialized(void); diff --git a/src/lib/test-file-create-locked.c b/src/lib/test-file-create-locked.c index 8bbefcf511..20ecdb6abd 100644 --- a/src/lib/test-file-create-locked.c +++ b/src/lib/test-file-create-locked.c @@ -67,11 +67,11 @@ static void test_file_create_locked_basic(void) test_assert(fd > 0); test_assert(created); if (test_has_failed()) - exit(1); + lib_exit(1); create_file(".test-temp-file-create-locked-child"); sleep(60); i_close_fd(&fd); - exit(0); + lib_exit(0); default: /* parent */ test_assert(wait_for_file(pid, ".test-temp-file-create-locked-child")); diff --git a/src/master/main.c b/src/master/main.c index 3b17fc762d..a537b3a3cc 100644 --- a/src/master/main.c +++ b/src/master/main.c @@ -819,7 +819,7 @@ int main(int argc, char *argv[]) if (!master_service_parse_option(master_service, c, optarg)) { print_help(); - exit(FATAL_DEFAULT); + lib_exit(FATAL_DEFAULT); } break; } diff --git a/src/util/rawlog.c b/src/util/rawlog.c index 71388cb8cb..f4e428b002 100644 --- a/src/util/rawlog.c +++ b/src/util/rawlog.c @@ -367,7 +367,7 @@ static void rawlog_open(enum rawlog_flags flags) io_loop_destroy(&ioloop); lib_deinit(); - exit(0); + lib_exit(0); } int main(int argc, char *argv[]) diff --git a/src/util/tcpwrap.c b/src/util/tcpwrap.c index cd63fcaf4c..0d492bb8eb 100644 --- a/src/util/tcpwrap.c +++ b/src/util/tcpwrap.c @@ -40,7 +40,7 @@ static void tcpwrap_client_handle(struct tcpwrap_client *client, int check_fd, (void)write_full(client->fd, "0\n", 2); else (void)write_full(client->fd, "1\n", 2); - exit(0); + lib_exit(0); } static void tcpwrap_client_input(struct tcpwrap_client *client)