]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Replace exit() with lib_exit()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 5 May 2021 09:44:03 +0000 (12:44 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 10 May 2021 18:38:22 +0000 (18:38 +0000)
17 files changed:
src/auth/checkpassword-reply.c
src/auth/db-checkpassword.c
src/config/doveconf.c
src/dict/main.c
src/doveadm/doveadm-mail.c
src/doveadm/doveadm-pw.c
src/doveadm/doveadm.c
src/lib-compression/bench-compression.c
src/lib-oauth2/test-oauth2-jwt.c
src/lib-test/test-common.c
src/lib-test/test-subprocess.c
src/lib/failures.c
src/lib/lib.h
src/lib/test-file-create-locked.c
src/master/main.c
src/util/rawlog.c
src/util/tcpwrap.c

index b449090d592484be4b911bb67e1462bab6cf1229..71f231aaafe4a6b2bbadb940eb71d165fefc6b21 100644 (file)
@@ -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) {
index dd7928b15f4fc816aac0f45afc3ba63151a88139..7d52eeff2d7a574aa04c9e4d80d15263128fc1ee 100644 (file)
@@ -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) {
index 9f519552b82993c5f25152e65474302b412ef1cb..dc18837c1c66dd0dcfc593728414ffd79d93d504 100644 (file)
@@ -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);
        }
 }
 
index 5ab0852a0a80be91a717315af1126c61b77b9c72..a8ab615002f30a00dd2b937ae151c38d9656de7b 100644 (file)
@@ -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();
index cd3edd7dc2212fc97474713e1f7e660d74e3f19f..6a9fb08b6b4b5cfd25f386adbe0b13f21a840b47 100644 (file)
@@ -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)
index a2ddc19ffc6c3da823a918deb98215ceb7c9c230..a2f770dea5071db4930555bf49153e48ef5b325f 100644 (file)
@@ -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;
                }
        }
index 7076c38ffa4b45cca8b001dd0538411507b6f093..d34fa17d7b28a7c2846236639316fbb86f6c00ea 100644 (file)
@@ -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)
index 98f3f2e7db034f71ee99a9ded94fd45a633b98ab..f0e64268e524a7fc4a3dba73e0d49caf2fbade8f 100644 (file)
@@ -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[])
index 4cfba64e9d3e48f434a2421c251096fee8b4678a..e46a1e405ea6e9dcb99f0cbad144560d0b4d3b96 100644 (file)
@@ -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);
 
index a2eaf6ccaee6d8417e79b1802fd07ed0a8d80d9a..feea7ecd88a7ee2f4c5a87b1d7abec63bbc98d77 100644 (file)
@@ -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);
 }
index b85c41f7aa2f8f5f8b5a10b9d65a4207cdf0fc76..4c51924b7e85d4327b0c8a4476df18985b489876 100644 (file)
@@ -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));
 }
index 8ac26269cdabe3efc949e3014ff98d6fa4dac269..4a9abd68f706674ba28703ae17430ba0c8985cdd 100644 (file)
@@ -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)
index 6ab56a2d75de680d9872ee9b3a40879a5141f19c..e16b4ce48cf7c3a4dd110de286a0ccde62516fa4 100644 (file)
@@ -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);
index 8bbefcf51114ade68f46bacab1dbf07c70ea5754..20ecdb6abd985183c5f9e10daa7a415689d331ee 100644 (file)
@@ -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"));
index 3b17fc762d1798fd8f92a090465ebb6f8c204059..a537b3a3cca8a924a26cb22a9bb54f08ac7b5648 100644 (file)
@@ -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;
                }
index 71388cb8cb556ee2d1e3a18291cedec81704f34c..f4e428b002246ce13c03d075f413348bb3af3c22 100644 (file)
@@ -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[])
index cd63fcaf4ca278f90342233f737333bb80c4a670..0d492bb8ebd8e16bd28fc4014a17d554418792ec 100644 (file)
@@ -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)