Skip to content

Commit

Permalink
login_disabled option before starttls for pop3
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul J Stevens committed Feb 18, 2015
1 parent 4392738 commit bd6f156
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dbmail.conf
Expand Up @@ -227,6 +227,11 @@ port = 110
# You can set an alternate banner to display when connecting to the service
# banner = DBMAIL pop3 server ready to rock

# If TLS is enabled, login before starttls is normally
# allowed. Use login_disabled=yes to change this
#
# login_disabled = no

#
# If yes, allows SMTP access from the host IP connecting by POP3.
# This requires addition configuration of your MTA
Expand Down
16 changes: 16 additions & 0 deletions src/pop3.c
Expand Up @@ -366,6 +366,7 @@ int pop3(ClientSession_T *session, const char *buffer)
int found = 0;
//int indx = 0;
int validate_result;
bool login_disabled = FALSE;
uint64_t result, top_lines, top_messageid, user_idnr;
unsigned char *md5_apop_he;
struct message *msg;
Expand Down Expand Up @@ -431,6 +432,15 @@ int pop3(ClientSession_T *session, const char *buffer)
}
}

if (state == CLIENTSTATE_INITIAL_CONNECT) {
if (server_conf->ssl) {
Field_T val;
GETCONFIGVALUE("login_disabled", "POP", val);
if (SMATCH(val, "yes"))
login_disabled = TRUE;
}
}

switch (cmdtype) {

case POP3_QUIT:
Expand Down Expand Up @@ -459,6 +469,9 @@ int pop3(ClientSession_T *session, const char *buffer)
if (state != CLIENTSTATE_INITIAL_CONNECT)
return pop3_error(session, "-ERR wrong command mode\r\n");

if (login_disabled && ! session->ci->sock->ssl_state)
return pop3_error(session, "-ERR try STLS\r\n");

if (session->username != NULL) {
/* reset username */
g_free(session->username);
Expand All @@ -478,6 +491,9 @@ int pop3(ClientSession_T *session, const char *buffer)
if (state != CLIENTSTATE_INITIAL_CONNECT)
return pop3_error(session, "-ERR wrong command mode\r\n");

if (login_disabled && ! session->ci->sock->ssl_state)
return pop3_error(session, "-ERR try STLS\r\n");

if (session->password != NULL) {
g_free(session->password);
session->password = NULL;
Expand Down

0 comments on commit bd6f156

Please sign in to comment.