logging in.
--HG--
branch : HEAD
}
client_send_tagline(client, str_c(reply));
if (!nologin) {
- client_destroy(client, "Login with referral");
+ client_destroy_success(client, "Login with referral");
return TRUE;
}
} else if (nologin || proxy_self) {
}
client_send_tagline(client, "OK Logged in.");
- client_destroy(client, "Login");
+ client_destroy_success(client, "Login");
break;
case SASL_SERVER_REPLY_AUTH_FAILED:
case SASL_SERVER_REPLY_CLIENT_ERROR:
else {
client_send_tagline(client,
t_strconcat("NO ", data, NULL));
- client_destroy(client, data);
+ /* authentication itself succeeded, we just hit some
+ internal failure. */
+ client_destroy_success(client, data);
}
break;
case SASL_SERVER_REPLY_CONTINUE:
client_destroy(client, "Aborted login "
"(tried to use disabled plaintext authentication)");
} else {
- client_destroy(client, t_strdup_printf(
- "Aborted login (%u authentication attempts)",
- client->common.auth_attempts));
+ client_destroy(client, "Aborted login");
}
return 1;
}
if (fatal) {
client_send_line(client, t_strconcat("* BYE ",
msg, NULL));
- client_destroy(client, t_strconcat("Disconnected: ",
- msg, NULL));
+ client_destroy(client,
+ t_strconcat("Disconnected: ", msg, NULL));
return FALSE;
}
if (++client->bad_counter >= CLIENT_MAX_BAD_COMMANDS) {
client_send_line(client,
"* BYE Too many invalid IMAP commands.");
- client_destroy(client, "Disconnected: "
- "Too many invalid commands");
+ client_destroy(client,
+ "Disconnected: Too many invalid commands");
return FALSE;
}
client_send_tagline(client,
return;
client->destroyed = TRUE;
+ if (!client->login_success && reason != NULL) {
+ reason = t_strdup_printf("%s (auth failed, %u attempts)",
+ reason, client->common.auth_attempts);
+ }
if (reason != NULL)
client_syslog(&client->common, reason);
main_unref();
}
+void client_destroy_success(struct imap_client *client, const char *reason)
+{
+ client->login_success = TRUE;
+ client_destroy(client, reason);
+}
+
void client_destroy_internal_failure(struct imap_client *client)
{
client_send_line(client, "* BYE Internal login failure. "
const char *cmd_tag, *cmd_name;
+ unsigned int login_success:1;
unsigned int cmd_finished:1;
unsigned int proxy_login_sent:1;
unsigned int skip_line:1;
};
void client_destroy(struct imap_client *client, const char *reason);
+void client_destroy_success(struct imap_client *client, const char *reason);
void client_destroy_internal_failure(struct imap_client *client);
void client_send_line(struct imap_client *client, const char *line);
client->input = NULL;
client->output = NULL;
client->common.fd = -1;
- client_destroy(client, msg);
+ client_destroy_success(client, msg);
return -1;
} else if (strncmp(line, "P ", 2) == 0) {
/* If the backend server isn't Dovecot, the error message may
/* failed for some reason, probably server disconnected */
client_send_line(client, "* BYE Temporary login failure.");
- client_destroy(client, NULL);
+ client_destroy_success(client, NULL);
return;
}
return;
case -1:
/* disconnected */
- client_destroy(client, "Proxy: Remote disconnected");
+ client_destroy_success(client, "Proxy: Remote disconnected");
return;
}
}
client_send_line(client, "+OK Logged in.");
- client_destroy(client, "Login");
+ client_destroy_success(client, "Login");
break;
case SASL_SERVER_REPLY_AUTH_FAILED:
case SASL_SERVER_REPLY_CLIENT_ERROR:
else {
client_send_line(client,
t_strconcat("-ERR [IN-USE] ", data, NULL));
- client_destroy(client, data);
+ client_destroy_success(client, data);
}
break;
case SASL_SERVER_REPLY_CONTINUE:
client_destroy(client, "Aborted login "
"(tried to use disabled plaintext authentication)");
} else {
- client_destroy(client, t_strdup_printf(
- "Aborted login (%u authentication attempts)",
- client->common.auth_attempts));
+ client_destroy(client, "Aborted login");
}
return TRUE;
}
return &client->common;
}
+void client_destroy_success(struct pop3_client *client, const char *reason)
+{
+ client->login_success = TRUE;
+ client_destroy(client, reason);
+}
+
void client_destroy(struct pop3_client *client, const char *reason)
{
if (client->destroyed)
return;
client->destroyed = TRUE;
+ if (!client->login_success && reason != NULL) {
+ reason = t_strdup_printf("%s (auth failed, %u attempts)",
+ reason, client->common.auth_attempts);
+ }
if (reason != NULL)
client_syslog(&client->common, reason);
char *apop_challenge;
struct auth_connect_id auth_id;
+ unsigned int login_success:1;
unsigned int authenticating:1;
unsigned int auth_connected:1;
unsigned int destroyed:1;
};
void client_destroy(struct pop3_client *client, const char *reason);
+void client_destroy_success(struct pop3_client *client, const char *reason);
void client_destroy_internal_failure(struct pop3_client *client);
void client_send_line(struct pop3_client *client, const char *line);
/* failed for some reason, probably server disconnected */
client_send_line(client,
"-ERR [IN-USE] Temporary login failure.");
- client_destroy(client, NULL);
+ client_destroy_success(client, NULL);
return;
}
return;
case -1:
/* disconnected */
- client_destroy(client, "Proxy: Remote disconnected");
+ client_destroy_success(client, "Proxy: Remote disconnected");
return;
}
client->input = NULL;
client->output = NULL;
client->common.fd = -1;
- client_destroy(client, msg);
+ client_destroy_success(client, msg);
return;
}