From b55a8548bc74d8dbeefbc34b3e88d61c486934ff Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Thu, 12 Jan 2012 18:43:13 +0100 Subject: [PATCH] managesieve-login: Include hostname and timestamp in "temporary auth failure" message. --- src/managesieve-login/client-authenticate.c | 38 ++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/managesieve-login/client-authenticate.c b/src/managesieve-login/client-authenticate.c index 4c1d460f8..d0a406edf 100644 --- a/src/managesieve-login/client-authenticate.c +++ b/src/managesieve-login/client-authenticate.c @@ -4,12 +4,14 @@ #include "login-common.h" #include "base64.h" #include "buffer.h" +#include "hostpid.h" #include "ioloop.h" #include "istream.h" #include "ostream.h" #include "safe-memset.h" #include "str.h" #include "str-sanitize.h" +#include "time-util.h" #include "auth-client.h" #include "managesieve-parser.h" @@ -52,6 +54,7 @@ bool managesieve_client_auth_handle_reply { struct managesieve_client *msieve_client = (struct managesieve_client *) client; + const char *timestamp, *msg; if ( reply->host != NULL ) { string_t *resp_code; @@ -88,27 +91,24 @@ bool managesieve_client_auth_handle_reply return TRUE; } client_send_noresp(client, str_c(resp_code), reason); - } else if ( reply->nologin ) { - /* Authentication went ok, but for some reason user isn't - allowed to log in. Shouldn't probably happen. */ - if (reply->reason != NULL) { - client_send_line(client, - CLIENT_CMD_REPLY_AUTH_FAIL_REASON, - reply->reason); - } else if (reply->temp) { - client_send_line(client, - CLIENT_CMD_REPLY_AUTH_FAIL_TEMP, - AUTH_TEMP_FAILED_MSG); - } else if (reply->authz_failure) { - client_send_line(client, CLIENT_CMD_REPLY_AUTHZ_FAILED, - "Authorization failed"); - } else { - client_send_line(client, CLIENT_CMD_REPLY_AUTH_FAILED, - AUTH_FAILED_MSG); - } - } else { + } else if (!reply->nologin) { /* normal login/failure */ return FALSE; + } else if (reply->reason != NULL) { + client_send_line(client, CLIENT_CMD_REPLY_AUTH_FAIL_REASON, + reply->reason); + } else if (reply->temp) { + timestamp = t_strflocaltime("%Y-%m-%d %H:%M:%S", ioloop_time); + msg = t_strdup_printf(AUTH_TEMP_FAILED_MSG" [%s:%s]", + my_hostname, timestamp); + client_send_line(client, + CLIENT_CMD_REPLY_AUTH_FAIL_TEMP, msg); + } else if (reply->authz_failure) { + client_send_line(client, CLIENT_CMD_REPLY_AUTHZ_FAILED, + "Authorization failed"); + } else { + client_send_line(client, CLIENT_CMD_REPLY_AUTH_FAILED, + AUTH_FAILED_MSG); } i_assert(reply->nologin); -- GitLab