mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 18:50:12 +01:00
improved queue id generation
Change-Id: I8a0f91eabd3eaf6c074946f723147a3f6ef925d9 Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
parent
37d4babd38
commit
cf1d7bdf45
23
src/misc.c
23
src/misc.c
@ -297,12 +297,33 @@ int extractEmail(char *rawmail, char *email){
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Generate a random string from /dev/urandom or
|
||||
* using the rand() function if not possible
|
||||
*/
|
||||
|
||||
void make_random_string(char *buf, int buflen){
|
||||
int i, len;
|
||||
int i, len, fd;
|
||||
int urandom=0;
|
||||
static char alphanum[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
unsigned char s[QUEUE_ID_LEN];
|
||||
|
||||
len = strlen(alphanum);
|
||||
|
||||
fd = open(RANDOM_POOL, O_RDONLY);
|
||||
if(fd != -1){
|
||||
if(readFromEntropyPool(fd, s, sizeof(s)) == sizeof(s)){
|
||||
for(i=0; i<QUEUE_ID_LEN; i++){
|
||||
*(buf+i) = alphanum[s[i] % len];
|
||||
}
|
||||
|
||||
urandom = 1;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
if(urandom == 1) return;
|
||||
|
||||
for(i=0; i<buflen; i++){
|
||||
*(buf+i) = alphanum[rand() % len];
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ int process_email(char *filename, struct session_data *sdata, struct __data *dat
|
||||
|
||||
gettimeofday(&tv2, &tz);
|
||||
|
||||
syslog(LOG_PRIORITY, "%s: piler-id=%s, size=%d/%d, attachments=%d, reference=%s, "
|
||||
syslog(LOG_PRIORITY, "%s: %s, size=%d/%d, attachments=%d, reference=%s, "
|
||||
"message-id=%s, retention=%d, folder=%d, delay=%.4f, status=%s",
|
||||
filename, sdata->ttmpfile, sdata->tot_len, sdata->stored_len,
|
||||
parser_state.n_attachments, parser_state.reference, parser_state.message_id,
|
||||
|
Loading…
Reference in New Issue
Block a user