Skip to content

Commit ec74380

Browse files
author
Paul J Stevens
committed
login_disabled option before starttls for pop3
1 parent edd6179 commit ec74380

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

dbmail.conf

+5
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ port = 110
227227
# You can set an alternate banner to display when connecting to the service
228228
# banner = DBMAIL pop3 server ready to rock
229229

230+
# If TLS is enabled, login before starttls is normally
231+
# allowed. Use login_disabled=yes to change this
232+
#
233+
# login_disabled = no
234+
230235
#
231236
# If yes, allows SMTP access from the host IP connecting by POP3.
232237
# This requires addition configuration of your MTA

src/pop3.c

+16
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ int pop3(ClientSession_T *session, const char *buffer)
366366
int found = 0;
367367
//int indx = 0;
368368
int validate_result;
369+
bool login_disabled = FALSE;
369370
uint64_t result, top_lines, top_messageid, user_idnr;
370371
unsigned char *md5_apop_he;
371372
struct message *msg;
@@ -431,6 +432,15 @@ int pop3(ClientSession_T *session, const char *buffer)
431432
}
432433
}
433434

435+
if (state == CLIENTSTATE_INITIAL_CONNECT) {
436+
if (server_conf->ssl) {
437+
Field_T val;
438+
GETCONFIGVALUE("login_disabled", "POP", val);
439+
if (SMATCH(val, "yes"))
440+
login_disabled = TRUE;
441+
}
442+
}
443+
434444
switch (cmdtype) {
435445

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

472+
if (login_disabled && ! session->ci->sock->ssl_state)
473+
return pop3_error(session, "-ERR try STLS\r\n");
474+
462475
if (session->username != NULL) {
463476
/* reset username */
464477
g_free(session->username);
@@ -478,6 +491,9 @@ int pop3(ClientSession_T *session, const char *buffer)
478491
if (state != CLIENTSTATE_INITIAL_CONNECT)
479492
return pop3_error(session, "-ERR wrong command mode\r\n");
480493

494+
if (login_disabled && ! session->ci->sock->ssl_state)
495+
return pop3_error(session, "-ERR try STLS\r\n");
496+
481497
if (session->password != NULL) {
482498
g_free(session->password);
483499
session->password = NULL;

0 commit comments

Comments
 (0)