From 63899aa02541074e6a03aaf217a6e87c0fc6b46d Mon Sep 17 00:00:00 2001 From: SJ Date: Wed, 15 May 2013 10:34:49 +0200 Subject: [PATCH] customer fix --- src/config.h | 16 ++++++++++++---- src/parser.c | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/config.h b/src/config.h index fc1d0522..6340dd0c 100644 --- a/src/config.h +++ b/src/config.h @@ -12,9 +12,9 @@ #define PROGNAME "piler" #define PILERGETD_PROGNAME "pilergetd" -#define VERSION "0.1.24-master-branch" +#define VERSION "0.1.24-dbfix-branch" -#define BUILD 811 +#define BUILD 815 #define HOSTID "mailarchiver" @@ -86,14 +86,22 @@ #define SQL_COUNTER_TABLE "counter" #define SQL_OPTION_TABLE "option" #define SQL_DOMAIN_TABLE "domain" +#define SQL_CUSTOMER_TABLE "customer" #define SQL_MESSAGES_VIEW "v_messages" #define SQL_ATTACHMENTS_VIEW "v_attachment" #define SQL_PREPARED_STMT_GET_DOMAINS "SELECT `domain` FROM `" SQL_DOMAIN_TABLE "`" #define SQL_PREPARED_STMT_GET_META_ID_BY_MESSAGE_ID "SELECT id FROM " SQL_METADATA_TABLE " WHERE message_id=?" #define SQL_PREPARED_STMT_INSERT_INTO_RCPT_TABLE "INSERT INTO " SQL_RECIPIENT_TABLE " (`id`,`to`,`todomain`) VALUES(?,?,?)" -#define SQL_PREPARED_STMT_INSERT_INTO_SPHINX_TABLE "INSERT INTO " SQL_SPHINX_TABLE " (`id`, `from`, `to`, `fromdomain`, `todomain`, `subject`, `body`, `arrived`, `sent`, `size`, `direction`, `folder`, `attachments`, `attachment_types`) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)" -#define SQL_PREPARED_STMT_INSERT_INTO_META_TABLE "INSERT INTO " SQL_METADATA_TABLE " (`from`,`fromdomain`,`subject`,`spam`,`arrived`,`sent`,`retained`,`size`,`hlen`,`direction`,`attachments`,`piler_id`,`message_id`,`reference`,`digest`,`bodydigest`,`vcode`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" + +#ifdef HAVE_MULTITENANCY + #define SQL_PREPARED_STMT_INSERT_INTO_SPHINX_TABLE "INSERT INTO " SQL_SPHINX_TABLE " (`id`, `from`, `to`, `fromdomain`, `todomain`, `subject`, `body`, `arrived`, `sent`, `size`, `direction`, `folder`, `attachments`, `attachment_types`, `customer`) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" + #define SQL_PREPARED_STMT_INSERT_INTO_META_TABLE "INSERT INTO " SQL_METADATA_TABLE " (`from`,`fromdomain`,`subject`,`spam`,`arrived`,`sent`,`retained`,`size`,`hlen`,`direction`,`attachments`,`piler_id`,`message_id`,`reference`,`digest`,`bodydigest`,`vcode`,`customer`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" +#else + #define SQL_PREPARED_STMT_INSERT_INTO_SPHINX_TABLE "INSERT INTO " SQL_SPHINX_TABLE " (`id`, `from`, `to`, `fromdomain`, `todomain`, `subject`, `body`, `arrived`, `sent`, `size`, `direction`, `folder`, `attachments`, `attachment_types`) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)" + #define SQL_PREPARED_STMT_INSERT_INTO_META_TABLE "INSERT INTO " SQL_METADATA_TABLE " (`from`,`fromdomain`,`subject`,`spam`,`arrived`,`sent`,`retained`,`size`,`hlen`,`direction`,`attachments`,`piler_id`,`message_id`,`reference`,`digest`,`bodydigest`,`vcode`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" +#endif + #define SQL_PREPARED_STMT_INSERT_INTO_ATTACHMENT_TABLE "INSERT INTO " SQL_ATTACHMENT_TABLE " (`piler_id`,`attachment_id`,`sig`,`name`,`type`,`size`,`ptr`) VALUES(?,?,?,?,?,?,?)" #define SQL_PREPARED_STMT_GET_ATTACHMENT_ID_BY_SIGNATURE "SELECT `id` FROM `" SQL_ATTACHMENT_TABLE "` WHERE `sig`=?" #define SQL_PREPARED_STMT_GET_ATTACHMENT_POINTER "SELECT `piler_id`, `attachment_id` FROM " SQL_ATTACHMENT_TABLE " WHERE id=?" diff --git a/src/parser.c b/src/parser.c index 431c65d9..296f081d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -271,7 +271,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int snprintf(state->attachments[state->n_attachments].shorttype, TINYBUFSIZE-1, "%s", p); if(strcmp("other", p)){ - state->b64fd = open(state->attachments[state->n_attachments].aname, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR); + state->b64fd = open(state->attachments[state->n_attachments].aname, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); state->attachments[state->n_attachments].dumped = 1; }