(des_rand_data): Use a table with random devices.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@745 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1996-09-15 21:39:23 +00:00
parent 56d530b451
commit 682884b05a

View File

@@ -156,23 +156,15 @@ des_rand_data(unsigned char *data, int size)
struct sigaction sa, osa;
int i, j;
pid_t pid;
char *rnd_devices[] = {"/dev/random",
"/dev/srandom",
NULL};
char **p;
/*
* If there is a /dev/random it's use is preferred.
*/
{
int fd = open("/dev/random", O_RDONLY);
if (fd != -1 && read(fd, data, size) == size)
{
close(fd);
return;
}
close(fd);
}
{
int fd = open("/dev/rnd", O_RDONLY);
if (fd != -1 && read(fd, data, size) == size)
{
for(p = rnd_devices; *p; p++) {
int fd = open(*p, O_RDONLY | O_NDELAY);
if(fd >= 0 && read(fd, data, size) == size) {
close(fd);
return;
}