mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 06:20:12 +01:00
src: encode piler child serial to piler_id
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
37424a0952
commit
d2cf3a4deb
@ -338,7 +338,7 @@ struct data {
|
||||
struct import *import;
|
||||
struct licence licence;
|
||||
char *dedup;
|
||||
int child_serial;
|
||||
unsigned char child_serial;
|
||||
int pos;
|
||||
|
||||
#ifdef HAVE_TRE
|
||||
|
@ -26,7 +26,7 @@ int import_message(struct session_data *sdata, struct data *data, struct config
|
||||
struct counters counters;
|
||||
|
||||
|
||||
init_session_data(sdata, cfg);
|
||||
init_session_data(sdata, 0, cfg);
|
||||
|
||||
if(data->import->extra_recipient){
|
||||
snprintf(sdata->rcptto[0], SMALLBUFSIZE-1, "%s", data->import->extra_recipient);
|
||||
|
13
src/misc.c
13
src/misc.c
@ -331,13 +331,13 @@ void make_random_string(char *buf, int buflen){
|
||||
}
|
||||
|
||||
|
||||
void create_id(char *id, unsigned char server_id){
|
||||
void create_id(char *id, unsigned char server_id, unsigned char child_serial){
|
||||
int i;
|
||||
unsigned char buf[RND_STR_LEN/2];
|
||||
|
||||
memset(id, 0, SMALLBUFSIZE);
|
||||
|
||||
get_random_bytes(buf, RND_STR_LEN/2, server_id);
|
||||
get_random_bytes(buf, RND_STR_LEN/2, server_id, child_serial);
|
||||
|
||||
for(i=0; i < RND_STR_LEN/2; i++){
|
||||
sprintf(id, "%02x", buf[i]);
|
||||
@ -351,7 +351,7 @@ void create_id(char *id, unsigned char server_id){
|
||||
* reading from pool
|
||||
*/
|
||||
|
||||
int get_random_bytes(unsigned char *buf, int len, unsigned char server_id){
|
||||
int get_random_bytes(unsigned char *buf, int len, unsigned char server_id, unsigned char child_serial){
|
||||
int fd, ret=0;
|
||||
struct taia now;
|
||||
char nowpack[TAIA_PACK];
|
||||
@ -367,8 +367,9 @@ int get_random_bytes(unsigned char *buf, int len, unsigned char server_id){
|
||||
if(fd == -1) return ret;
|
||||
|
||||
*(buf + 12) = server_id;
|
||||
*(buf + 14) = child_serial;
|
||||
|
||||
if(readFromEntropyPool(fd, buf+12+1, len-12-1) != len-12-1){
|
||||
if(readFromEntropyPool(fd, buf+14+1, len-14-1) != len-14-1){
|
||||
syslog(LOG_PRIORITY, "%s: %s", ERR_CANNOT_READ_FROM_POOL, RANDOM_POOL);
|
||||
}
|
||||
|
||||
@ -544,13 +545,13 @@ int drop_privileges(struct passwd *pwd){
|
||||
}
|
||||
|
||||
|
||||
void init_session_data(struct session_data *sdata, struct config *cfg){
|
||||
void init_session_data(struct session_data *sdata, unsigned char child_serial, struct config *cfg){
|
||||
int i;
|
||||
|
||||
|
||||
sdata->fd = -1;
|
||||
|
||||
create_id(&(sdata->ttmpfile[0]), cfg->server_id);
|
||||
create_id(&(sdata->ttmpfile[0]), cfg->server_id, child_serial);
|
||||
unlink(sdata->ttmpfile);
|
||||
|
||||
snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", sdata->ttmpfile);
|
||||
|
@ -28,8 +28,8 @@ char *split_str(char *row, char *what, char *s, int size);
|
||||
int trimBuffer(char *s);
|
||||
int extractEmail(char *rawmail, char *email);
|
||||
void make_random_string(char *buf, int buflen);
|
||||
void create_id(char *id, unsigned char server_id);
|
||||
int get_random_bytes(unsigned char *buf, int len, unsigned char server_id);
|
||||
void create_id(char *id, unsigned char server_id, unsigned char child_serial);
|
||||
int get_random_bytes(unsigned char *buf, int len, unsigned char server_id, unsigned char child_serial);
|
||||
int readFromEntropyPool(int fd, void *_s, ssize_t n);
|
||||
int recvtimeout(int s, char *buf, int len, int timeout);
|
||||
int write1(struct net *net, void *buf, int buflen);
|
||||
@ -39,7 +39,7 @@ void close_connection(struct net *net);
|
||||
void write_pid_file(char *pidfile);
|
||||
int drop_privileges(struct passwd *pwd);
|
||||
|
||||
void init_session_data(struct session_data *sdata, struct config *cfg);
|
||||
void init_session_data(struct session_data *sdata, unsigned char child_serial, struct config *cfg);
|
||||
int read_from_stdin(struct session_data *sdata);
|
||||
void strtolower(char *s);
|
||||
|
||||
|
@ -110,7 +110,7 @@ int process_email(char *filename, struct session_data *sdata, struct data *data,
|
||||
}
|
||||
#endif
|
||||
|
||||
init_session_data(sdata, cfg);
|
||||
init_session_data(sdata, data->child_serial, cfg);
|
||||
|
||||
sdata->tot_len = size;
|
||||
|
||||
@ -247,7 +247,7 @@ void child_main(struct child *ptr){
|
||||
|
||||
if(cfg.verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "child (pid: %d, serial: %d) started main() working on '%s'", getpid(), ptr->serial, dir);
|
||||
|
||||
data.child_serial = ptr->serial;
|
||||
data.child_serial = ptr->serial % 255;
|
||||
|
||||
while(1){
|
||||
if(received_sighup == 1){
|
||||
|
@ -571,7 +571,7 @@ int main(int argc, char **argv){
|
||||
if(read_key(&cfg)) p_clean_exit(ERR_READING_KEY, 1);
|
||||
|
||||
|
||||
init_session_data(&sdata, &cfg);
|
||||
init_session_data(&sdata, 0, &cfg);
|
||||
|
||||
|
||||
if(open_database(&sdata, &cfg) == ERR){
|
||||
@ -581,7 +581,7 @@ int main(int argc, char **argv){
|
||||
|
||||
if(where_condition){
|
||||
|
||||
init_session_data(&sdata2, &cfg);
|
||||
init_session_data(&sdata2, 0, &cfg);
|
||||
|
||||
strcpy(cfg.mysqlhost, "127.0.0.1");
|
||||
cfg.mysqlport = 9306;
|
||||
|
@ -76,6 +76,7 @@ int main(int argc, char **argv){
|
||||
srand(getpid());
|
||||
|
||||
data.folder = 0;
|
||||
data.child_serial = 0;
|
||||
data.recursive_folder_names = 0;
|
||||
data.quiet = 0;
|
||||
|
||||
|
@ -234,7 +234,7 @@ int main(int argc, char **argv){
|
||||
initrules(data.retention_rules);
|
||||
initrules(data.folder_rules);
|
||||
|
||||
init_session_data(&sdata, &cfg);
|
||||
init_session_data(&sdata, 0, &cfg);
|
||||
|
||||
|
||||
if(open_database(&sdata, &cfg) == ERR){
|
||||
|
@ -73,7 +73,7 @@ int main(int argc, char **argv){
|
||||
load_rules(&sdata, &data, data.folder_rules, SQL_FOLDER_RULE_TABLE);
|
||||
|
||||
|
||||
init_session_data(&sdata, &cfg);
|
||||
init_session_data(&sdata, 0, &cfg);
|
||||
|
||||
sdata.delivered = 0;
|
||||
sdata.tot_len = st.st_size;
|
||||
|
Loading…
Reference in New Issue
Block a user