added chunking advertising to ehlo response

Change-Id: I89b4c3e8bc1228d42ff97d4f47f2178e3b603723
Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
SJ 2016-08-17 21:47:19 +02:00
parent 2abdc19f7d
commit 28a9d86951
5 changed files with 13 additions and 3 deletions

View File

@ -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}, { "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)}, { "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)}, { "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_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)}, { "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)}, { "encrypt_messages", "integer", (void*) int_parser, offsetof(struct __config, encrypt_messages), "1", sizeof(int)},

View File

@ -25,6 +25,7 @@ struct __config {
int encrypt_messages; int encrypt_messages;
int enable_chunking;
int tls_enable; int tls_enable;
char pemfile[MAXVAL]; char pemfile[MAXVAL];
char cipher_list[MAXVAL]; char cipher_list[MAXVAL];

View File

@ -320,7 +320,7 @@ void initialise_configuration(){
initrules(data.folder_rules); initrules(data.folder_rules);
if(cfg.tls_enable > 0 && data.ctx == NULL && init_ssl() == OK){ 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){ if(open_database(&sdata, &cfg) == ERR){

View File

@ -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){ 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 tmpbuf[MAXBUFSIZE];
char extensions[SMALLBUFSIZE];
memset(extensions, 0, sizeof(extensions));
if(*protocol_state == SMTP_STATE_INIT) *protocol_state = SMTP_STATE_HELO; 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); if(sdata->tls == 0) snprintf(extensions, sizeof(extensions)-1, "%s", data->starttls);
else snprintf(tmpbuf, sizeof(tmpbuf)-1, SMTP_RESP_250_EXTENSIONS, cfg->hostid, ""); 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)); strncat(resp, tmpbuf, resplen-strlen(resp));
} }

View File

@ -36,6 +36,9 @@
#define SMTP_RESP_250_OK "250 Ok\r\n" #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_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 <CRLF>.<CRLF>\r\n" #define SMTP_RESP_354_DATA_OK "354 Send mail data; end it with <CRLF>.<CRLF>\r\n"
#define SMTP_RESP_421_ERR "421 %s Error: timed out\r\n" #define SMTP_RESP_421_ERR "421 %s Error: timed out\r\n"