diff --git a/src/managesieve-login/client-authenticate.c b/src/managesieve-login/client-authenticate.c index 4c1d460f80c79652ad9b66feeee8f9826f57416c..d0a406edf25dc8f53b921b92bc56ce20baea21cf 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);