Commit 9e9b85d5 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Open /dev/random early.

parent 0e2af8bc
...@@ -111,6 +111,20 @@ main(int argc, char **argv) ...@@ -111,6 +111,20 @@ main(int argc, char **argv)
char **arg; char **arg;
struct network *net; struct network *net;
gettime(&now);
rfd = open("/dev/urandom", O_RDONLY);
if(rfd < 0) {
perror("open(random)");
} else {
rc = read(rfd, &seed, sizeof(unsigned int));
if(rc < sizeof(unsigned int)) {
perror("read(random)");
}
}
seed ^= (now.tv_sec ^ now.tv_usec);
srandom(seed);
parse_address("ff02::cca6:c0f9:e182:5373", protocol_group, NULL); parse_address("ff02::cca6:c0f9:e182:5373", protocol_group, NULL);
protocol_port = 8475; protocol_port = 8475;
...@@ -334,8 +348,6 @@ main(int argc, char **argv) ...@@ -334,8 +348,6 @@ main(int argc, char **argv)
exit(1); exit(1);
} }
gettime(&now);
{ {
unsigned char dummy[16]; unsigned char dummy[16];
rc = parse_address(*arg, dummy, NULL); rc = parse_address(*arg, dummy, NULL);
...@@ -345,18 +357,6 @@ main(int argc, char **argv) ...@@ -345,18 +357,6 @@ main(int argc, char **argv)
} }
} }
rfd = open("/dev/urandom", O_RDONLY);
if(rfd < 0) {
perror("open(random)");
} else {
rc = read(rfd, &seed, sizeof(unsigned int));
if(rc < sizeof(unsigned int)) {
perror("read(random)");
}
}
seed ^= (now.tv_sec ^ now.tv_usec);
srandom(seed);
while(*arg) { while(*arg) {
debugf("Adding network %s.\n", *arg); debugf("Adding network %s.\n", *arg);
vrc = add_network(*arg); vrc = add_network(*arg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment