diff --git a/src/cfg.c b/src/cfg.c index d3fa5e1e..1ce2ddd0 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -68,6 +68,7 @@ struct _parse_rule config_parse_rules[] = { "clamd_socket", "string", (void*) string_parser, offsetof(struct __config, clamd_socket), CLAMD_SOCKET, MAXVAL-1}, { "debug", "integer", (void*) int_parser, offsetof(struct __config, debug), "0", sizeof(int)}, { "default_retention_days", "integer", (void*) int_parser, offsetof(struct __config, default_retention_days), "2557", sizeof(int)}, + { "enable_chunking", "integer", (void*) int_parser, offsetof(struct __config, enable_chunking), "0", sizeof(int)}, { "enable_cjk", "integer", (void*) int_parser, offsetof(struct __config, enable_cjk), "0", sizeof(int)}, { "enable_folders", "integer", (void*) int_parser, offsetof(struct __config, enable_folders), "0", sizeof(int)}, { "encrypt_messages", "integer", (void*) int_parser, offsetof(struct __config, encrypt_messages), "1", sizeof(int)}, diff --git a/src/cfg.h b/src/cfg.h index 47d74a29..8689d9ca 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -25,6 +25,7 @@ struct __config { int encrypt_messages; + int enable_chunking; int tls_enable; char pemfile[MAXVAL]; char cipher_list[MAXVAL]; diff --git a/src/piler.c b/src/piler.c index 7caf7ee4..ba6168ec 100644 --- a/src/piler.c +++ b/src/piler.c @@ -320,7 +320,7 @@ void initialise_configuration(){ initrules(data.folder_rules); if(cfg.tls_enable > 0 && data.ctx == NULL && init_ssl() == OK){ - snprintf(data.starttls, sizeof(data.starttls)-1, "250-STARTTLS\r\n"); + snprintf(data.starttls, sizeof(data.starttls)-1, SMTP_EXTENSION_STARTTLS); } if(open_database(&sdata, &cfg) == ERR){ diff --git a/src/smtp.c b/src/smtp.c index 636dd443..8be40007 100644 --- a/src/smtp.c +++ b/src/smtp.c @@ -22,11 +22,16 @@ void process_command_ehlo_lhlo(struct session_data *sdata, struct __data *data, int *protocol_state, char *resp, int resplen, struct __config *cfg){ char tmpbuf[MAXBUFSIZE]; + char extensions[SMALLBUFSIZE]; + + memset(extensions, 0, sizeof(extensions)); if(*protocol_state == SMTP_STATE_INIT) *protocol_state = SMTP_STATE_HELO; - if(sdata->tls == 0) snprintf(tmpbuf, sizeof(tmpbuf)-1, SMTP_RESP_250_EXTENSIONS, cfg->hostid, data->starttls); - else snprintf(tmpbuf, sizeof(tmpbuf)-1, SMTP_RESP_250_EXTENSIONS, cfg->hostid, ""); + if(sdata->tls == 0) snprintf(extensions, sizeof(extensions)-1, "%s", data->starttls); + if(cfg->enable_chunking == 1) strncat(extensions, SMTP_EXTENSION_CHUNKING, sizeof(extensions)-strlen(extensions)-2); + + snprintf(tmpbuf, sizeof(tmpbuf)-1, SMTP_RESP_250_EXTENSIONS, cfg->hostid, extensions); strncat(resp, tmpbuf, resplen-strlen(resp)); } diff --git a/src/smtpcodes.h b/src/smtpcodes.h index 130136bb..038bd130 100644 --- a/src/smtpcodes.h +++ b/src/smtpcodes.h @@ -36,6 +36,9 @@ #define SMTP_RESP_250_OK "250 Ok\r\n" #define SMTP_RESP_250_EXTENSIONS "250-%s\r\n250-PIPELINING\r\n%s250-SIZE\r\n250 8BITMIME\r\n" +#define SMTP_EXTENSION_STARTTLS "250-STARTTLS\r\n" +#define SMTP_EXTENSION_CHUNKING "250-CHUNKING\r\n" + #define SMTP_RESP_354_DATA_OK "354 Send mail data; end it with .\r\n" #define SMTP_RESP_421_ERR "421 %s Error: timed out\r\n"