Commit ea11cbca authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Move initialisation of random generator earlier.

parent 80c003b0
......@@ -211,6 +211,22 @@ main(int argc, char **argv)
SHIFTE();
gettimeofday(&now, NULL);
fd = open("/dev/urandom", O_RDONLY);
if(fd < 0) {
perror("open(random)");
memcpy(&seed, myid + 12, 4);
} else {
rc = read(fd, &seed, sizeof(unsigned int));
if(rc < sizeof(unsigned int)) {
perror("read(random)");
exit(1);
}
close(fd);
}
seed ^= (now.tv_sec ^ now.tv_usec);
srandom(seed);
reboot_time = now.tv_sec;
seqno = (random() & 0xFF);
......@@ -245,21 +261,6 @@ main(int argc, char **argv)
close(fd);
}
fd = open("/dev/urandom", O_RDONLY);
if(fd < 0) {
perror("open(random)");
memcpy(&seed, myid + 12, 4);
seed ^= now.tv_sec ^ now.tv_usec;
} else {
rc = read(fd, &seed, sizeof(unsigned int));
if(rc < sizeof(unsigned int)) {
perror("read(random)");
exit(1);
}
close(fd);
}
srandom(seed);
rc = kernel_setup(1);
if(rc < 0) {
fprintf(stderr, "kernel_setup failed.\n");
......
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