code cleanup

This commit is contained in:
SJ 2014-02-18 10:46:23 +01:00
parent f0687d6339
commit 7c1150052b
13 changed files with 25 additions and 150 deletions

7
configure vendored
View File

@ -3647,9 +3647,6 @@ ac_cv_lib_wrap=ac_cv_lib_wrap_main
fi
# Check whether --enable-tweak-sent-time was given.
if test "${enable_tweak_sent_time+set}" = set; then :
enableval=$enable_tweak_sent_time; have_tweak_sent_time=$enableval
@ -4516,7 +4513,7 @@ if test "${with_plugin_timeout+set}" = set; then :
timeout_binary=`which timeout`" $withval "
fi
if test "$withval" = "yes" || $withval = ""; then
if test "$withval" = "yes" || test "$withval" = ""; then
echo "please specify the value for plugin-timeout, eg. --with-plugin-timeout=15";
exit;
fi
@ -4749,8 +4746,6 @@ if test "$have_psql" = "yes"; then
defs="$defs -DNEED_PSQL"
fi
if test z`which pdftotext 2>/dev/null` != "z"; then
pdftotext=`which pdftotext`

View File

@ -44,7 +44,6 @@ have_zlib="no"
have_starttls="no"
have_tcpwrappers="no"
have_tweak_sent_time="no"
dnl have_multitenancy="no"
pdftotext="no"
catdoc="no"
@ -129,11 +128,6 @@ if test "$want_tcpwrappers" = "yes"; then
fi
dnl AC_ARG_ENABLE(multitenancy,
dnl [ --enable-multitenancy build piler with multitenancy support (!!!EXPERIMENTAL!!!)], have_multitenancy=$enableval, have_multitenancy="no")
AC_ARG_ENABLE(tweak-sent-time,
[ --tweak-sent-time tweak sent time], have_tweak_sent_time=$enableval, have_tweak_sent_time="no")
@ -267,7 +261,7 @@ AC_ARG_WITH(plugin-timeout,
timeout_binary=`which timeout`" $withval "
fi
if test "$withval" = "yes" || $withval = ""; then
if test "$withval" = "yes" || test "$withval" = ""; then
echo "please specify the value for plugin-timeout, eg. --with-plugin-timeout=15";
exit;
fi
@ -462,15 +456,6 @@ if test "$have_psql" = "yes"; then
defs="$defs -DNEED_PSQL"
fi
dnl if test "$have_multitenancy" = "yes"; then
dnl echo "multitenancy support: yes"
dnl defs="$defs -DHAVE_MULTITENANCY"
dnl objs="$objs multitenancy.o"
dnl else
dnl echo "multitenancy support: no"
dnl fi
if test z`which pdftotext 2>/dev/null` != "z"; then
pdftotext=`which pdftotext`
AC_DEFINE_UNQUOTED(HAVE_PDFTOTEXT, "$timeout_binary$pdftotext", [path to pdftotext])

View File

@ -11,11 +11,17 @@ source base
sql_pass = MYSQL_PASSWORD
sql_attr_uint = size
sql_attr_uint = arrived
sql_attr_uint = sent
sql_attr_uint = direction
sql_attr_uint = folder
sql_attr_uint = attachments
##
## From 0.1.25 these attributes are disabled for an optimized version
## If you have indexed data already, then don't exclude them otherwise
## you have to reindex all your emails
##
## sql_attr_uint = direction
## sql_attr_uint = arrived
## sql_attr_uint = folder
}
source delta : base

View File

@ -20,7 +20,11 @@ PID_NUMBER=`test -f ${PID_FILE} && cat ${PID_FILE}`
start() {
echo "starting searchd . . ."
su piler -c searchd
if [ `id -u` -eq 0 ]; then
su piler -c searchd
else
searchd
fi
}
stop() {

View File

@ -14,7 +14,7 @@
#define VERSION "0.1.25-master-branch"
#define BUILD 861
#define BUILD 864
#define HOSTID "mailarchiver"
@ -94,15 +94,8 @@
#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(?,?,?)"
#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_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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
#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=?"

View File

@ -305,11 +305,6 @@ struct __data {
SSL_CTX *ctx;
SSL *ssl;
#ifdef HAVE_MULTITENANCY
struct list *customers;
#endif
};

View File

@ -50,9 +50,6 @@ int store_index_data(struct session_data *sdata, struct _state *state, struct __
data->sql[data->pos] = (char *)&data->folder; data->type[data->pos] = TYPE_LONG; data->pos++;
data->sql[data->pos] = (char *)&state->n_attachments; data->type[data->pos] = TYPE_LONG; data->pos++;
data->sql[data->pos] = sdata->attachments; data->type[data->pos] = TYPE_STRING; data->pos++;
#ifdef HAVE_MULTITENANCY
data->sql[data->pos] = (char *)&sdata->customer_id; data->type[data->pos] = TYPE_SHORT; data->pos++;
#endif
if(p_exec_query(sdata, data->stmt_insert_into_sphinx_table, data) == OK) rc = OK;
@ -207,9 +204,6 @@ int store_meta_data(struct session_data *sdata, struct _state *state, struct __d
data->sql[data->pos] = sdata->digest; data->type[data->pos] = TYPE_STRING; data->pos++;
data->sql[data->pos] = sdata->bodydigest; data->type[data->pos] = TYPE_STRING; data->pos++;
data->sql[data->pos] = &vcode[0]; data->type[data->pos] = TYPE_STRING; data->pos++;
#ifdef HAVE_MULTITENANCY
data->sql[data->pos] = (char *)&sdata->customer_id; data->type[data->pos] = TYPE_SHORT; data->pos++;
#endif
if(p_exec_query(sdata, data->stmt_insert_into_meta_table, data) == ERR){
ret = ERR_EXISTS;

View File

@ -1,69 +0,0 @@
/*
* multitenancy.c, SJ
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <syslog.h>
#include <piler.h>
void load_customers(struct session_data *sdata, struct __data *data, struct __config *cfg){
int rc;
char s[SMALLBUFSIZE];
MYSQL_RES *res;
MYSQL_ROW row;
data->customers = NULL;
snprintf(s, sizeof(s)-1, "SELECT `id`, `guid` FROM `%s`", SQL_CUSTOMER_TABLE);
if(mysql_real_query(&(sdata->mysql), s, strlen(s)) == 0){
res = mysql_store_result(&(sdata->mysql));
if(res != NULL){
while((row = mysql_fetch_row(res))){
snprintf(s, sizeof(s)-1, "%s@%d", (char*)row[1], atoi(row[0]));
rc = append_list(&(data->customers), s);
if(cfg->verbosity >= _LOG_DEBUG && rc == 1) syslog(LOG_PRIORITY, "adding customer: id: %d, guid: '%s'", atoi(row[0]), row[1]);
if(rc == -1) syslog(LOG_PRIORITY, "error: failed to add customer: id: %d, guid: '%s'", atoi(row[0]), row[1]);
}
mysql_free_result(res);
}
}
}
unsigned char get_customer_id_by_rcpt_to_email(char *rcpttoemail, struct __data *data){
int len;
char *q;
struct list *p;
q = strchr(rcpttoemail, '@');
if(!q || strlen(q) < 3) return 0;
len = strlen(rcpttoemail) - strlen(q) + 1;
if(len < 5) return 0;
p = data->customers;
while(p != NULL){
if(strncasecmp(p->s, rcpttoemail, len) == 0){
q = strchr(p->s, '@');
if(!q || strlen(q) < 2) return 0;
return atoi(q+1);
}
p = p->r;
}
return 0;
}

View File

@ -233,10 +233,6 @@ void p_clean_exit(){
clearhash(data.mydomains);
#ifdef HAVE_MULTITENANCY
free_list(data.customers);
#endif
syslog(LOG_PRIORITY, "%s has been terminated", PROGNAME);
unlink(cfg.pidfile);
@ -312,10 +308,6 @@ void initialise_configuration(){
clearhash(data.mydomains);
#ifdef HAVE_MULTITENANCY
free_list(data.customers);
#endif
data.folder = 0;
data.recursive_folder_names = 0;
@ -323,10 +315,6 @@ void initialise_configuration(){
initrules(data.archiving_rules);
initrules(data.retention_rules);
#ifdef HAVE_MULTITENANCY
data.customers = NULL;
#endif
memset(data.starttls, 0, sizeof(data.starttls));
#ifdef HAVE_STARTTLS
@ -345,10 +333,6 @@ void initialise_configuration(){
load_mydomains(&sdata, &data, &cfg);
#ifdef HAVE_MULTITENANCY
load_customers(&sdata, &data, &cfg);
#endif
if(cfg.server_id > 0) insert_offset(&sdata, cfg.server_id);
close_database(&sdata);
@ -397,9 +381,6 @@ int main(int argc, char **argv){
inithash(data.mydomains);
initrules(data.archiving_rules);
initrules(data.retention_rules);
#ifdef HAVE_MULTITENANCY
data.customers = NULL;
#endif
data.ctx = NULL;
data.ssl = NULL;

View File

@ -66,8 +66,5 @@ int retrieve_file_from_archive(char *filename, int mode, char **buffer, FILE *de
void load_mydomains(struct session_data *sdata, struct __data *data, struct __config *cfg);
int is_email_address_on_my_domains(char *email, struct __data *data);
void load_customers(struct session_data *sdata, struct __data *data, struct __config *cfg);
unsigned char get_customer_id_by_rcpt_to_email(char *rcpttoemail, struct __data *data);
#endif /* _PILER_H */

View File

@ -199,9 +199,6 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
extractEmail(sdata.rcptto[i], rcpttoemail);
/* copy default config to enable policy support */
//memcpy(&my_cfg, cfg, sizeof(struct __config));
inj = ERR;
@ -421,15 +418,8 @@ AFTER_PERIOD:
state = SMTP_STATE_RCPT_TO;
/* check against blackhole addresses */
extractEmail(buf, rcpttoemail);
#ifdef HAVE_MULTITENANCY
if(sdata.customer_id == 0) sdata.customer_id = get_customer_id_by_rcpt_to_email(rcpttoemail, data);
#endif
if(sdata.num_of_rcpt_to < MAX_RCPT_TO-1) sdata.num_of_rcpt_to++;

View File

@ -367,7 +367,11 @@ create table if not exists `ldap` (
`ldap_base_dn` varchar(255) not null,
`ldap_bind_dn` varchar(255) not null,
`ldap_bind_pw` varchar(255) not null,
`ldap_auditor_member_dn` varchar(255) default null
`ldap_auditor_member_dn` varchar(255) default null,
`ldap_mail_attr` varchar(128) default null,
`ldap_account_objectclass` varchar(128) default null,
`ldap_distributionlist_attr` varchar(128) default null,
`ldap_distributionlist_objectclass` varchar(128) default null
) Engine=InnoDB;

View File

@ -133,7 +133,7 @@ $config['PASSWORD_CHANGE_ENABLED'] = 0;
$config['ENABLE_STATISTICS'] = 1;
$config['ENABLE_HISTORY'] = 1;
$config['ENABLE_REMOTE_IMAGES'] = '0';
$config['ENABLE_ON_THE_FLY_VERIFICATION'] = 1;
$config['ENABLE_ON_THE_FLY_VERIFICATION'] = 0;
$config['ENABLE_LDAP_IMPORT_FEATURE'] = 0;
$config['ENABLE_FOLDER_RESTRICTIONS'] = 0;
$config['SEARCH_RESULT_CHECKBOX_CHECKED'] = 0;