mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 04:11:59 +01:00
introduced the server_id variable
This commit is contained in:
parent
28d12e9a52
commit
1d2ac1c117
@ -7,6 +7,11 @@
|
||||
; 5: debug
|
||||
verbosity=1
|
||||
|
||||
; unique server id. If you have more than 1 piler hosts combined,
|
||||
; then assign a unique value to each host. Possible values: 0-255
|
||||
server_id=0
|
||||
|
||||
|
||||
; piler daemon will use this user (and its group)
|
||||
; it it was started by root
|
||||
username=piler
|
||||
|
@ -91,6 +91,7 @@ struct _parse_rule config_parse_rules[] =
|
||||
{ "pidfile", "string", (void*) string_parser, offsetof(struct __config, pidfile), PIDFILE, MAXVAL-1},
|
||||
{ "piler_header_field", "string", (void*) string_parser, offsetof(struct __config, piler_header_field), "", MAXVAL-1},
|
||||
{ "queuedir", "string", (void*) string_parser, offsetof(struct __config, queuedir), QUEUE_DIR, MAXVAL-1},
|
||||
{ "server_id", "integer", (void*) int_parser, offsetof(struct __config, server_id), "0", sizeof(int)},
|
||||
{ "session_timeout", "integer", (void*) int_parser, offsetof(struct __config, session_timeout), "420", sizeof(int)},
|
||||
{ "spam_header_line", "string", (void*) string_parser, offsetof(struct __config, spam_header_line), "", MAXVAL-1},
|
||||
{ "tls_enable", "integer", (void*) int_parser, offsetof(struct __config, tls_enable), "0", sizeof(int)},
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "config.h"
|
||||
|
||||
struct __config {
|
||||
int server_id;
|
||||
char username[MAXVAL];
|
||||
|
||||
char hostid[MAXVAL];
|
||||
|
@ -26,7 +26,7 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da
|
||||
struct __counters counters;
|
||||
|
||||
|
||||
init_session_data(sdata);
|
||||
init_session_data(sdata, cfg->server_id);
|
||||
|
||||
if(cfg->verbosity > 1) printf("processing: %s\n", filename);
|
||||
|
||||
|
14
src/misc.c
14
src/misc.c
@ -211,13 +211,13 @@ int extractEmail(char *rawmail, char *email){
|
||||
}
|
||||
|
||||
|
||||
void create_id(char *id){
|
||||
void create_id(char *id, unsigned char server_id){
|
||||
int i;
|
||||
unsigned char buf[RND_STR_LEN/2];
|
||||
|
||||
memset(id, 0, SMALLBUFSIZE);
|
||||
|
||||
get_random_bytes(buf, RND_STR_LEN/2);
|
||||
get_random_bytes(buf, RND_STR_LEN/2, server_id);
|
||||
|
||||
for(i=0; i < RND_STR_LEN/2; i++){
|
||||
sprintf(id, "%02x", buf[i]);
|
||||
@ -231,7 +231,7 @@ void create_id(char *id){
|
||||
* reading from pool
|
||||
*/
|
||||
|
||||
int get_random_bytes(unsigned char *buf, int len){
|
||||
int get_random_bytes(unsigned char *buf, int len, unsigned char server_id){
|
||||
int fd, ret=0;
|
||||
struct taia now;
|
||||
char nowpack[TAIA_PACK];
|
||||
@ -246,7 +246,9 @@ int get_random_bytes(unsigned char *buf, int len){
|
||||
fd = open(RANDOM_POOL, O_RDONLY);
|
||||
if(fd == -1) return ret;
|
||||
|
||||
if(readFromEntropyPool(fd, buf+12, len-12) != len-12){
|
||||
*(buf + 12) = server_id;
|
||||
|
||||
if(readFromEntropyPool(fd, buf+12+1, len-12-1) != len-12-1){
|
||||
syslog(LOG_PRIORITY, "%s: %s", ERR_CANNOT_READ_FROM_POOL, RANDOM_POOL);
|
||||
}
|
||||
|
||||
@ -447,13 +449,13 @@ int is_email_address_on_my_domains(char *email, struct __config *cfg){
|
||||
}
|
||||
|
||||
|
||||
void init_session_data(struct session_data *sdata){
|
||||
void init_session_data(struct session_data *sdata, unsigned char server_id){
|
||||
int i;
|
||||
|
||||
|
||||
sdata->fd = -1;
|
||||
|
||||
create_id(&(sdata->ttmpfile[0]));
|
||||
create_id(&(sdata->ttmpfile[0]), server_id);
|
||||
unlink(sdata->ttmpfile);
|
||||
|
||||
snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", sdata->ttmpfile);
|
||||
|
@ -24,8 +24,8 @@ char *split(char *row, int ch, char *s, int size);
|
||||
char *split_str(char *row, char *what, char *s, int size);
|
||||
int trimBuffer(char *s);
|
||||
int extractEmail(char *rawmail, char *email);
|
||||
void create_id(char *id);
|
||||
int get_random_bytes(unsigned char *buf, int len);
|
||||
void create_id(char *id, unsigned char server_id);
|
||||
int get_random_bytes(unsigned char *buf, int len, unsigned char server_id);
|
||||
int readFromEntropyPool(int fd, void *_s, size_t n);
|
||||
int recvtimeout(int s, char *buf, int len, int timeout);
|
||||
int write1(int sd, char *buf, int use_ssl, SSL *ssl);
|
||||
@ -35,7 +35,7 @@ void write_pid_file(char *pidfile);
|
||||
int drop_privileges(struct passwd *pwd);
|
||||
|
||||
int is_email_address_on_my_domains(char *email, struct __config *cfg);
|
||||
void init_session_data(struct session_data *sdata);
|
||||
void init_session_data(struct session_data *sdata, unsigned char server_id);
|
||||
int read_from_stdin(struct session_data *sdata);
|
||||
void strtolower(char *s);
|
||||
|
||||
|
@ -400,7 +400,7 @@ int main(int argc, char **argv){
|
||||
if(read_key(&cfg)) p_clean_exit(ERR_READING_KEY, 1);
|
||||
|
||||
|
||||
init_session_data(&sdata);
|
||||
init_session_data(&sdata, cfg.server_id);
|
||||
|
||||
|
||||
mysql_init(&(sdata.mysql));
|
||||
|
@ -348,7 +348,7 @@ int main(int argc, char **argv){
|
||||
|
||||
setlocale(LC_CTYPE, cfg.locale);
|
||||
|
||||
init_session_data(&sdata);
|
||||
init_session_data(&sdata, cfg.server_id);
|
||||
|
||||
i = is_purge_allowed(&sdata, &cfg);
|
||||
if(i == 1){
|
||||
|
@ -212,7 +212,7 @@ int main(int argc, char **argv){
|
||||
}
|
||||
}
|
||||
|
||||
init_session_data(&sdata);
|
||||
init_session_data(&sdata, cfg.server_id);
|
||||
|
||||
|
||||
mysql_init(&(sdata.mysql));
|
||||
|
@ -54,7 +54,7 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
|
||||
|
||||
state = SMTP_STATE_INIT;
|
||||
|
||||
init_session_data(&sdata);
|
||||
init_session_data(&sdata, cfg->server_id);
|
||||
sdata.tls = 0;
|
||||
|
||||
bzero(&counters, sizeof(counters));
|
||||
@ -370,7 +370,7 @@ AFTER_PERIOD:
|
||||
unlink(sdata.ttmpfile);
|
||||
unlink(sdata.tmpframe);
|
||||
|
||||
init_session_data(&sdata);
|
||||
init_session_data(&sdata, cfg->server_id);
|
||||
}
|
||||
|
||||
state = SMTP_STATE_MAIL_FROM;
|
||||
@ -476,7 +476,7 @@ AFTER_PERIOD:
|
||||
unlink(sdata.ttmpfile);
|
||||
unlink(sdata.tmpframe);
|
||||
|
||||
init_session_data(&sdata);
|
||||
init_session_data(&sdata, cfg->server_id);
|
||||
|
||||
state = SMTP_STATE_HELO;
|
||||
|
||||
|
@ -60,7 +60,7 @@ int main(int argc, char **argv){
|
||||
load_rules(&sdata, &(data.archiving_rules), SQL_ARCHIVING_RULE_TABLE);
|
||||
load_rules(&sdata, &(data.retention_rules), SQL_RETENTION_RULE_TABLE);
|
||||
|
||||
init_session_data(&sdata);
|
||||
init_session_data(&sdata, cfg.server_id);
|
||||
|
||||
sdata.sent = 0;
|
||||
sdata.delivered = 0;
|
||||
|
@ -33,7 +33,7 @@ int main(int argc, char **argv){
|
||||
cfg = read_config(CONFIG_FILE);
|
||||
|
||||
|
||||
init_session_data(&sdata);
|
||||
init_session_data(&sdata, cfg.server_id);
|
||||
|
||||
sdata.sent = 0;
|
||||
sdata.tot_len = st.st_size;
|
||||
|
@ -40,7 +40,7 @@ int parse_it(char *filename, struct session_data *sdata, struct __data *data, st
|
||||
struct _state state;
|
||||
|
||||
|
||||
init_session_data(sdata);
|
||||
init_session_data(sdata, cfg->server_id);
|
||||
|
||||
if(stat(filename, &st) != 0){
|
||||
printf("cannot stat() %s\n", filename);
|
||||
|
Loading…
Reference in New Issue
Block a user