]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Use auth_request.event for logging whenever possible
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 31 Oct 2019 14:39:26 +0000 (16:39 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 12 Mar 2021 12:18:13 +0000 (12:18 +0000)
src/auth/auth-cache.c
src/auth/auth-penalty.c
src/auth/auth-request.c
src/auth/db-checkpassword.c
src/auth/mech-winbind.c
src/auth/userdb-blocking.c
src/auth/userdb-ldap.c
src/auth/userdb-passwd.c
src/auth/userdb.c

index 9a7b7da5adbf4d2e571abddf99e72d1c831f2e4b..9d9e292af10e74e2cbb46e6b0bb7b995092704d6 100644 (file)
@@ -365,7 +365,8 @@ auth_request_expand_cache_key(const struct auth_request *request,
                                               auth_cache_escape, &error) < 0 &&
            !error_logged) {
                error_logged = TRUE;
-               i_error("Failed to expand auth cache key %s: %s", key, error);
+               e_error(authdb_event(request),
+                       "Failed to expand auth cache key %s: %s", key, error);
        }
        return str_c(value);
 }
index 8fdc98dba0dc631f2ee7db32bf4b80c793cfbfc4..3816902a0a2c03cc714916575e51e1311069bebd 100644 (file)
@@ -76,7 +76,8 @@ static void auth_penalty_anvil_callback(const char *reply, void *context)
                        master_service_stop(master_service);
                }
        } else if (sscanf(reply, "%u %lu", &penalty, &last_penalty) != 2) {
-               i_error("Invalid PENALTY-GET reply: %s", reply);
+               e_error(request->auth_request->event,
+                       "Invalid PENALTY-GET reply: %s", reply);
        } else {
                if ((time_t)last_penalty > ioloop_time) {
                        /* time moved backwards? */
index 9151807dc64307c56bb08a89a9af4a28f1edb8fc..4d875336fe9ae036e04a4d7a721debeec9f5575d 100644 (file)
@@ -1976,7 +1976,8 @@ void auth_request_set_userdb_field(struct auth_request *request,
                /* FIXME: the system_user is for backwards compatibility */
                static bool warned = FALSE;
                if (!warned) {
-                       i_warning("userdb: Replace system_user with system_groups_user");
+                       e_warning(authdb_event(request),
+                                 "Replace system_user with system_groups_user");
                        warned = TRUE;
                }
                name = "system_groups_user";
index 7663b609264a5b7983ae85394b9368b63adf38ef..ffa2497f3be05796e881ebbbd10f9905405a5115 100644 (file)
@@ -279,7 +279,8 @@ checkpassword_get_cmd(struct auth_request *request, const char *args,
 
        str = t_str_new(256);
        if (auth_request_var_expand(str, args, request, NULL, &error) <= 0) {
-               i_error("Failed to expand checkpassword_path=%s: %s",
+               e_error(authdb_event(request),
+                       "Failed to expand checkpassword_path=%s: %s",
                        args, error);
        }
 
@@ -368,7 +369,7 @@ static void checkpassword_child_output(struct chkpw_auth_request *request)
        io_remove(&request->io_out);
 
        if (close(request->fd_out) < 0)
-               i_error("checkpassword: close() failed: %m");
+               e_error(authdb_event(request->request), "close() failed: %m");
        request->fd_out = -1;
 }
 
index 0b4b5a54036da2e497e032a77164e442a6309e2e..d2525db9bdc1d0e601009bd39d4fd1715bbefea2 100644 (file)
@@ -95,7 +95,8 @@ static void sigchld_handler(const siginfo_t *si ATTR_UNUSED,
 
 static void
 winbind_helper_connect(const struct auth_settings *set,
-                      struct winbind_helper *winbind)
+                      struct winbind_helper *winbind,
+                      struct event *event)
 {
        int infd[2], outfd[2];
        pid_t pid;
@@ -104,7 +105,7 @@ winbind_helper_connect(const struct auth_settings *set,
                return;
 
        if (pipe(infd) < 0) {
-               i_error("pipe() failed: %m");
+               e_error(event, "pipe() failed: %m");
                return;
        }
        if (pipe(outfd) < 0) {
@@ -114,7 +115,7 @@ winbind_helper_connect(const struct auth_settings *set,
 
        pid = fork();
        if (pid < 0) {
-               i_error("fork() failed: %m");
+               e_error(event, "fork() failed: %m");
                i_close_fd(&infd[0]); i_close_fd(&infd[1]);
                i_close_fd(&outfd[0]); i_close_fd(&outfd[1]);
                return;
@@ -293,7 +294,8 @@ mech_winbind_auth_initial(struct auth_request *auth_request,
        struct winbind_auth_request *request =
                (struct winbind_auth_request *)auth_request;
 
-       winbind_helper_connect(auth_request->set, request->winbind);
+       winbind_helper_connect(auth_request->set, request->winbind,
+                              auth_request->event);
        mech_generic_auth_initial(auth_request, data, data_size);
 }
 
index 044886d313bd281358f9c027ee29c440733c096b..4163259118bb7a40c4f6ef6ef7904be3e329bca3 100644 (file)
@@ -41,7 +41,8 @@ static bool user_callback(const char *reply, void *context)
                }
        } else {
                result = USERDB_RESULT_INTERNAL_FAILURE;
-               i_error("BUG: auth-worker sent invalid user reply");
+               e_error(authdb_event(request),
+                       "BUG: auth-worker sent invalid user reply");
                args = "";
        }
 
index 13d0055ac3f5c868b03a2caefb2f7552cabe6dac..5ae085fb2cc0225952ddeb3c091d8fd7acc31b4b 100644 (file)
@@ -179,7 +179,7 @@ static void userdb_ldap_iterate_callback(struct ldap_connection *conn,
                                                res, TRUE);
        while (db_ldap_result_iterate_next(ldap_iter, &name, &values)) {
                if (strcmp(name, "user") != 0) {
-                       i_warning("ldap: iterate: "
+                       e_warning(authdb_event(request->auth_request), "iterate: "
                                  "Ignoring field not named 'user': %s", name);
                        continue;
                }
index 609445e474ae16b4ab26da4e38efeea56aad1f91..1e3dc56289e447d438c489b8a24d6ad45c7cfe33 100644 (file)
@@ -44,7 +44,7 @@ passwd_check_warnings(struct auth_request *auth_request,
 
        msecs = timeval_diff_msecs(&end_tv, start_tv);
        if (msecs >= PASSWD_SLOW_WARN_MSECS) {
-               i_warning("passwd: Lookup for %s took %u secs",
+               e_warning(authdb_event(auth_request), "Lookup for %s took %u secs",
                          auth_request->fields.user, msecs/1000);
                return;
        }
@@ -66,7 +66,8 @@ passwd_check_warnings(struct auth_request *auth_request,
                /* start from beginning */
                module->slow_count = module->fast_count = 0;
        } else {
-               i_warning("passwd: %u%% of last %u lookups took over "
+               e_warning(authdb_event(auth_request),
+                         "%u%% of last %u lookups took over "
                          "%u milliseconds, "
                          "you may want to set blocking=yes for userdb",
                          percentage, PASSDB_SLOW_MASTER_WARN_COUNT_INTERVAL,
index dfb3cef1ed579abd096a61cd872470b0b21890bb..c4a6d7babe96db7b86d64ed57eabc1fa043107f2 100644 (file)
@@ -69,7 +69,10 @@ uid_t userdb_parse_uid(struct auth_request *request, const char *str)
 
        switch (i_getpwnam(str, &pw)) {
        case -1:
-               i_error("getpwnam() failed: %m");
+               if (request == NULL)
+                       i_error("getpwnam() failed: %m");
+               else
+                       e_error(authdb_event(request), "getpwnam() failed: %m");
                return (uid_t)-1;
        case 0:
                if (request != NULL) {