Introduced the consolidated_store variable

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2020-09-02 11:13:55 +02:00
parent f195c5eb6c
commit 98506d5b3a
4 changed files with 22 additions and 11 deletions

View File

@ -34,6 +34,14 @@ default_retention_days=2557
; which will cause problems.
encrypt_messages=1
; If the previous 3 letter store top directories, eg. /var/piler/store/00/5f4
; are consolidated (1) to a single zip file or not (0).
; Eg. cd /var/piler/store/00
; zip -r -0 5f3.zip 5f3
; After the consolidation (ie. zipping the given directory) piler tries to
; read the given file from the appropriate zip file.
consolidated_store=0
; number of worker processes, ie. the number of simultaneous smtp connections to piler.
; This value should be the number of cpus + 1, ie. 2 for a single cpu host
number_of_worker_processes=2

View File

@ -300,12 +300,14 @@ void assemble_filename(char *filename, int len, char *s, struct config *cfg){
char zipfilename[SMALLBUFSIZE];
struct stat st;
/*
* If the zip file exists, then fix the filename to be '<zipfile> <relative filename>'
*/
snprintf(zipfilename, sizeof(zipfilename)-1, "%s/%02x/%c%c%c.zip", cfg->queuedir, cfg->server_id, s[8], s[9], s[10]);
if(stat(zipfilename, &st)){
if(cfg->consolidated_store == 1 && stat(zipfilename, &st) == 0){
// If the zip file exists, then fix the filename to be '<zipfile> <relative filename>'
snprintf(filename, len-1, "%s %c%c%c/%c%c/%c%c/%s.m",
zipfilename, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s);
}
else {
snprintf(filename, len-1, "%s/%02x/%c%c%c/%c%c/%c%c/%s.m",
cfg->queuedir, cfg->server_id, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s);
#ifdef HAVE_SUPPORT_FOR_COMPAT_STORAGE_LAYOUT
@ -314,9 +316,6 @@ void assemble_filename(char *filename, int len, char *s, struct config *cfg){
cfg->queuedir, cfg->server_id, s[RND_STR_LEN-6], s[RND_STR_LEN-5], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s);
}
#endif
} else {
snprintf(filename, len-1, "%s %c%c%c/%c%c/%c%c/%s.m",
zipfilename, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s);
}
}
@ -327,7 +326,11 @@ void assemble_attachment_filename(char *filename, int len, char *s, int attachme
snprintf(zipfilename, sizeof(zipfilename)-1, "%s/%02x/%c%c%c.zip", cfg->queuedir, cfg->server_id, s[8], s[9], s[10]);
if(stat(zipfilename, &st)){
if(cfg->consolidated_store == 1 && stat(zipfilename, &st) == 0){
snprintf(filename, len-1, "%s %c%c%c/%c%c/%c%c/%s.a%d",
zipfilename, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s, attachment_id);
}
else {
snprintf(filename, len-1, "%s/%02x/%c%c%c/%c%c/%c%c/%s.a%d", cfg->queuedir, cfg->server_id, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s, attachment_id);
#ifdef HAVE_SUPPORT_FOR_COMPAT_STORAGE_LAYOUT
@ -336,9 +339,6 @@ void assemble_attachment_filename(char *filename, int len, char *s, int attachme
cfg->queuedir, cfg->server_id, s[RND_STR_LEN-6], s[RND_STR_LEN-5], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s, attachment_id);
}
#endif
} else {
snprintf(filename, len-1, "%s %c%c%c/%c%c/%c%c/%s.a%d",
zipfilename, s[8], s[9], s[10], s[RND_STR_LEN-4], s[RND_STR_LEN-3], s[RND_STR_LEN-2], s[RND_STR_LEN-1], s, attachment_id);
}
}

View File

@ -48,6 +48,7 @@ struct _parse_rule config_parse_rules[] =
{ "clamd_addr", "string", (void*) string_parser, offsetof(struct config, clamd_addr), "", MAXVAL-1},
{ "clamd_port", "integer", (void*) int_parser, offsetof(struct config, clamd_port), "0", sizeof(int)},
{ "clamd_socket", "string", (void*) string_parser, offsetof(struct config, clamd_socket), CLAMD_SOCKET, MAXVAL-1},
{ "consolidated_store", "integer", (void*) int_parser, offsetof(struct config, consolidated_store), "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)},
{ "enable_chunking", "integer", (void*) int_parser, offsetof(struct config, enable_chunking), "0", sizeof(int)},

View File

@ -23,6 +23,8 @@ struct config {
int clamd_port;
char clamd_socket[MAXVAL];
int consolidated_store;
int encrypt_messages;
int enable_chunking;