1
/* Copyright (c) 2002-2012 Dovecot authors, see the included COPYING file */
1
/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */
3
3
#include "login-common.h"
6
6
#include "hex-binary.h"
10
9
#include "ostream.h"
11
10
#include "safe-memset.h"
13
12
#include "str-sanitize.h"
14
#include "time-util.h"
15
13
#include "auth-client.h"
16
14
#include "../pop3/pop3-capability.h"
17
15
#include "ssl-proxy.h"
33
31
str_append(str, "+OK\r\n");
34
32
str_append(str, capability_string);
36
if (ssl_initialized && !client->common.tls)
34
if (client_is_tls_enabled(&client->common) && !client->common.tls)
37
35
str_append(str, "STLS\r\n");
38
36
if (!client->common.set->disable_plaintext_auth ||
39
37
client->common.secured)
54
bool pop3_client_auth_handle_reply(struct client *client,
55
const struct client_auth_reply *reply)
52
void pop3_client_auth_result(struct client *client,
53
enum client_auth_result result,
54
const struct client_auth_reply *reply ATTR_UNUSED,
57
const char *timestamp, *msg;
62
if (reply->reason != NULL) {
63
client_send_line(client, CLIENT_CMD_REPLY_AUTH_FAILED,
65
} else if (reply->temp) {
66
timestamp = t_strflocaltime("%Y-%m-%d %H:%M:%S", ioloop_time);
67
msg = t_strdup_printf(AUTH_TEMP_FAILED_MSG" [%s:%s]",
68
my_hostname, timestamp);
69
client_send_line(client, CLIENT_CMD_REPLY_AUTH_FAIL_TEMP, msg);
71
client_send_line(client, CLIENT_CMD_REPLY_AUTH_FAILED,
58
case CLIENT_AUTH_RESULT_SUCCESS:
59
/* nothing to be done for POP3 */
61
case CLIENT_AUTH_RESULT_TEMPFAIL:
62
client_send_reply(client, POP3_CMD_REPLY_TEMPFAIL, text);
64
case CLIENT_AUTH_RESULT_AUTHFAILED:
65
case CLIENT_AUTH_RESULT_AUTHFAILED_REASON:
66
case CLIENT_AUTH_RESULT_AUTHZFAILED:
67
case CLIENT_AUTH_RESULT_SSL_REQUIRED:
68
client_send_reply(client, POP3_CMD_REPLY_AUTH_ERROR, text);
71
client_send_reply(client, POP3_CMD_REPLY_ERROR, text);
75
if (!client->destroyed)
76
client_auth_failed(client);
80
76
bool cmd_auth(struct pop3_client *pop3_client, const char *args)
134
130
if (!client_check_plaintext_auth(client, TRUE))
137
client_send_line(client, CLIENT_CMD_REPLY_BAD,
138
"No username given.");
133
client_send_reply(client, POP3_CMD_REPLY_ERROR,
134
"No username given.");
166
162
if (pop3_client->apop_challenge == NULL) {
167
163
if (client->set->auth_verbose)
168
164
client_log(client, "APOP failed: APOP not enabled");
169
client_send_line(client, CLIENT_CMD_REPLY_BAD,
170
"APOP not enabled.");
165
client_send_reply(client, POP3_CMD_REPLY_ERROR,
166
"APOP not enabled.");
176
172
if (p == NULL || strlen(p+1) != 32) {
177
173
if (client->set->auth_verbose)
178
174
client_log(client, "APOP failed: Invalid parameters");
179
client_send_line(client, CLIENT_CMD_REPLY_BAD,
180
"Invalid parameters.");
175
client_send_reply(client, POP3_CMD_REPLY_ERROR,
176
"Invalid parameters.");
193
189
client_log(client, "APOP failed: "
194
190
"Invalid characters in MD5 response");
196
client_send_line(client, CLIENT_CMD_REPLY_BAD,
197
"Invalid characters in MD5 response.");
192
client_send_reply(client, POP3_CMD_REPLY_ERROR,
193
"Invalid characters in MD5 response.");