From 37d4babd381b85d3089a65a8a692b7fa575e1a8b Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 28 Oct 2016 21:46:25 +0200 Subject: [PATCH] added a queue id to piler-smtp Change-Id: Id616c31c709ccc3e986c7cbe46f23ec927efa5df Signed-off-by: SJ --- src/config.h | 1 + src/misc.c | 2 +- src/piler.c | 5 ++--- src/smtp.c | 7 ++++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/config.h b/src/config.h index e0fd48fc..a0362259 100644 --- a/src/config.h +++ b/src/config.h @@ -35,6 +35,7 @@ #define RANDOM_POOL "/dev/urandom" #define RND_STR_LEN 36 #define BUFLEN 32 +#define QUEUE_ID_LEN 16 #define IPLEN 16+1 #define KEYLEN 56 diff --git a/src/misc.c b/src/misc.c index 542e3e23..5178e79d 100644 --- a/src/misc.c +++ b/src/misc.c @@ -299,7 +299,7 @@ int extractEmail(char *rawmail, char *email){ void make_random_string(char *buf, int buflen){ int i, len; - static char alphanum[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + static char alphanum[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; len = strlen(alphanum); diff --git a/src/piler.c b/src/piler.c index 5ac97e07..1074d111 100644 --- a/src/piler.c +++ b/src/piler.c @@ -105,7 +105,6 @@ int process_email(char *filename, struct session_data *sdata, struct __data *dat sdata->tot_len = size; snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", filename); - snprintf(sdata->ttmpfile, SMALLBUFSIZE-1, "%s", filename); parser_state = parse_message(sdata, 1, data, cfg); post_parse(sdata, &parser_state, cfg); @@ -157,9 +156,9 @@ int process_email(char *filename, struct session_data *sdata, struct __data *dat gettimeofday(&tv2, &tz); - syslog(LOG_PRIORITY, "%s: size=%d/%d, attachments=%d, reference=%s, " + syslog(LOG_PRIORITY, "%s: piler-id=%s, size=%d/%d, attachments=%d, reference=%s, " "message-id=%s, retention=%d, folder=%d, delay=%.4f, status=%s", - filename, sdata->tot_len, sdata->stored_len, + filename, sdata->ttmpfile, sdata->tot_len, sdata->stored_len, parser_state.n_attachments, parser_state.reference, parser_state.message_id, parser_state.retention, data->folder, tvdiff(tv2,tv1)/1000000.0, status); diff --git a/src/smtp.c b/src/smtp.c index 91164adb..9b38965f 100644 --- a/src/smtp.c +++ b/src/smtp.c @@ -223,7 +223,8 @@ void process_command_mail_from(struct smtp_session *session, char *buf){ send(session->socket, SMTP_RESP_503_ERR, strlen(SMTP_RESP_503_ERR), 0); } else { - create_id(&(session->ttmpfile[0]), 15); + memset(&(session->ttmpfile[0]), 0, SMALLBUFSIZE); + make_random_string(&(session->ttmpfile[0]), QUEUE_ID_LEN); session->protocol_state = SMTP_STATE_MAIL_FROM; extractEmail(buf, session->mailfrom); @@ -314,6 +315,6 @@ void process_command_reset(struct smtp_session *session){ reset_bdat_counters(session); - create_id(&(session->ttmpfile[0]), 15); + memset(&(session->ttmpfile[0]), 0, SMALLBUFSIZE); + make_random_string(&(session->ttmpfile[0]), QUEUE_ID_LEN); } -