From: Marco Bettini Date: Tue, 27 Sep 2022 13:43:45 +0000 (+0000) Subject: auth: Replace i_() with e_() X-Git-Tag: 2.4.0~3507 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb182af9ebe09510a821884dbbaa042ffde21171;p=thirdparty%2Fdovecot%2Fcore.git auth: Replace i_() with e_() --- diff --git a/src/auth/auth-cache.c b/src/auth/auth-cache.c index 46f697cee7..fb635f7118 100644 --- a/src/auth/auth-cache.c +++ b/src/auth/auth-cache.c @@ -8,12 +8,14 @@ #include "var-expand.h" #include "auth-request.h" #include "auth-cache.h" +#include "auth-common.h" #include struct auth_cache { HASH_TABLE(char *, struct auth_cache_node *) hash; struct auth_cache_node *head, *tail; + struct event *event; size_t max_size, size_left; unsigned int ttl_secs, neg_ttl_secs; @@ -191,7 +193,7 @@ static void sig_auth_cache_clear(const siginfo_t *si ATTR_UNUSED, void *context) { struct auth_cache *cache = context; - i_info("SIGHUP received, %u cache entries flushed", + e_info(cache->event, "SIGHUP received, %u cache entries flushed", auth_cache_clear(cache)); } @@ -202,18 +204,18 @@ static void sig_auth_cache_stats(const siginfo_t *si ATTR_UNUSED, void *context) size_t cache_used; total_count = cache->hit_count + cache->miss_count; - i_info("Authentication cache hits %u/%u (%u%%)", + e_info(cache->event, "Authentication cache hits %u/%u (%u%%)", cache->hit_count, total_count, total_count == 0 ? 100 : (cache->hit_count * 100 / total_count)); - i_info("Authentication cache inserts: " + e_info(cache->event, "Authentication cache inserts: " "positive: %u entries %llu bytes, " "negative: %u entries %llu bytes", cache->pos_entries, cache->pos_size, cache->neg_entries, cache->neg_size); cache_used = cache->max_size - cache->size_left; - i_info("Authentication cache current size: " + e_info(cache->event, "Authentication cache current size: " "%zu bytes used of %zu bytes (%u%%)", cache_used, cache->max_size, (unsigned int)(cache_used * 100ULL / cache->max_size)); @@ -236,6 +238,7 @@ struct auth_cache *auth_cache_new(size_t max_size, unsigned int ttl_secs, cache->size_left = max_size; cache->ttl_secs = ttl_secs; cache->neg_ttl_secs = neg_ttl_secs; + cache->event = event_create(auth_event); lib_signals_set_handler(SIGHUP, LIBSIG_FLAGS_SAFE, sig_auth_cache_clear, cache); @@ -254,6 +257,7 @@ void auth_cache_free(struct auth_cache **_cache) auth_cache_clear(cache); hash_table_destroy(&cache->hash); + event_unref(&cache->event); i_free(cache); } diff --git a/src/auth/auth-policy.c b/src/auth/auth-policy.c index 0a7d85a793..65e630a5c7 100644 --- a/src/auth/auth-policy.c +++ b/src/auth/auth-policy.c @@ -227,7 +227,8 @@ void auth_policy_init(void) auth_policy_json_template = i_strdup(str_c(template)); if (global_auth_settings->policy_log_only) - i_warning("auth-policy: Currently in log-only mode. Ignoring " + e_warning(auth_event, + "auth-policy: Currently in log-only mode. Ignoring " "tarpit and disconnect instructions from policy server"); } diff --git a/src/auth/auth-token.c b/src/auth/auth-token.c index b61b7b9152..48afcc6808 100644 --- a/src/auth/auth-token.c +++ b/src/auth/auth-token.c @@ -42,19 +42,19 @@ auth_token_read_secret(const char *path, fd = open(path, O_RDONLY); if (fd == -1) { if (errno != ENOENT) - i_error("open(%s) failed: %m", path); + e_error(auth_event, "open(%s) failed: %m", path); return -1; } if (fstat(fd, &st) < 0) { - i_error("fstat(%s) failed: %m", path); + e_error(auth_event, "fstat(%s) failed: %m", path); i_close_fd(&fd); return -1; } /* check secret len and file type */ if (st.st_size != AUTH_TOKEN_SECRET_LEN || !S_ISREG(st.st_mode)) { - i_error("Corrupted token secret file: %s", path); + e_error(auth_event, "Corrupted token secret file: %s", path); i_close_fd(&fd); i_unlink(path); return -1; @@ -62,7 +62,7 @@ auth_token_read_secret(const char *path, /* verify that we're not dealing with a symbolic link */ if (lstat(path, &lst) < 0) { - i_error("lstat(%s) failed: %m", path); + e_error(auth_event, "lstat(%s) failed: %m", path); i_close_fd(&fd); return -1; } @@ -72,7 +72,7 @@ auth_token_read_secret(const char *path, st.st_uid != geteuid() || st.st_nlink > 1 || !S_ISREG(lst.st_mode) || st.st_ino != lst.st_ino || !CMP_DEV_T(st.st_dev, lst.st_dev)) { - i_error("Compromised token secret file: %s", path); + e_error(auth_event, "Compromised token secret file: %s", path); i_close_fd(&fd); i_unlink(path); return -1; @@ -82,13 +82,13 @@ auth_token_read_secret(const char *path, ret = read_full(fd, secret_r, AUTH_TOKEN_SECRET_LEN); if (ret < 0) - i_error("read(%s) failed: %m", path); + e_error(auth_event, "read(%s) failed: %m", path); else if (ret == 0) { - i_error("Token secret file unexpectedly shrank: %s", path); + e_error(auth_event, "Token secret file unexpectedly shrank: %s", path); ret = -1; } if (close(fd) < 0) - i_error("close(%s) failed: %m", path); + e_error(auth_event, "close(%s) failed: %m", path); e_debug(auth_event, "Read auth token secret from %s", path); return ret; @@ -109,15 +109,15 @@ auth_token_write_secret(const char *path, umask(old_mask); if (fd == -1) { - i_error("open(%s) failed: %m", temp_path); + e_error(auth_event, "open(%s) failed: %m", temp_path); return -1; } ret = write_full(fd, secret, AUTH_TOKEN_SECRET_LEN); if (ret < 0) - i_error("write(%s) failed: %m", temp_path); + e_error(auth_event, "write(%s) failed: %m", temp_path); if (close(fd) < 0) { - i_error("close(%s) failed: %m", temp_path); + e_error(auth_event, "close(%s) failed: %m", temp_path); ret = -1; } @@ -127,7 +127,7 @@ auth_token_write_secret(const char *path, } if (rename(temp_path, path) < 0) { - i_error("rename(%s, %s) failed: %m", temp_path, path); + e_error(auth_event, "rename(%s, %s) failed: %m", temp_path, path); i_unlink(temp_path); return -1; } @@ -146,7 +146,8 @@ void auth_token_init(void) random_fill(auth_token_secret, sizeof(auth_token_secret)); if (auth_token_write_secret(secret_path, auth_token_secret) < 0) { - i_error("Failed to write auth token secret file; " + e_error(auth_event, + "Failed to write auth token secret file; " "returned tokens will be invalid once auth restarts"); } } diff --git a/src/auth/db-sql.c b/src/auth/db-sql.c index f5ad3ba386..c6a51c7bfd 100644 --- a/src/auth/db-sql.c +++ b/src/auth/db-sql.c @@ -7,6 +7,7 @@ #include "settings.h" #include "auth-request.h" #include "auth-worker-server.h" +#include "auth-common.h" #include "db-sql.h" #include @@ -162,13 +163,15 @@ void db_sql_check_userdb_warning(struct db_sql_connection *conn) if (strcmp(conn->set.user_query, default_db_sql_settings.user_query) != 0) { - i_warning("sql: Ignoring changed user_query in %s, " + e_warning(auth_event, + "sql: Ignoring changed user_query in %s, " "because userdb sql not used. " "(If this is intentional, set userdb_warning_disable=yes)", conn->config_path); } else if (strcmp(conn->set.iterate_query, default_db_sql_settings.iterate_query) != 0) { - i_warning("sql: Ignoring changed iterate_query in %s, " + e_warning(auth_event, + "sql: Ignoring changed iterate_query in %s, " "because userdb sql not used. " "(If this is intentional, set userdb_warning_disable=yes)", conn->config_path); diff --git a/src/auth/main.c b/src/auth/main.c index 828bb7ffa9..d572ecd3d7 100644 --- a/src/auth/main.c +++ b/src/auth/main.c @@ -311,7 +311,8 @@ static void main_deinit(void) static void worker_connected(struct master_service_connection *conn) { if (auth_worker_has_connections()) { - i_error("Auth workers can handle only a single client"); + e_error(auth_event, + "Auth workers can handle only a single client"); return; } diff --git a/src/auth/test-auth-cache.c b/src/auth/test-auth-cache.c index ea71b1baff..05efcf2353 100644 --- a/src/auth/test-auth-cache.c +++ b/src/auth/test-auth-cache.c @@ -19,6 +19,8 @@ auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT + 1] = { { '\0', NULL, NULL } }; +struct event *auth_event; + struct var_expand_table * auth_request_get_var_expand_table_full(const struct auth_request *auth_request ATTR_UNUSED, const char *username ATTR_UNUSED, @@ -74,9 +76,13 @@ static void test_auth_cache_parse_key(void) int main(void) { + lib_init(); + auth_event = event_create(NULL); static void (*const test_functions[])(void) = { test_auth_cache_parse_key, NULL }; - return test_run(test_functions); + int ret = test_run(test_functions); + event_unref(&auth_event); + return ret; }