mirror of
git://anongit.mindrot.org/openssh.git
synced 2024-11-23 18:23:25 +08:00
Try EGD/PRNGD if random device fails.
When built --without-openssl, try EGD/PRGGD (if configured) as a last resort before failing.
This commit is contained in:
parent
e43a898043
commit
e409d79667
@ -88,7 +88,7 @@ _rs_init(u_char *buf, size_t n)
|
||||
static void
|
||||
getrnd(u_char *s, size_t len)
|
||||
{
|
||||
int fd;
|
||||
int fd, save_errno;
|
||||
ssize_t r;
|
||||
size_t o = 0;
|
||||
|
||||
@ -97,8 +97,14 @@ getrnd(u_char *s, size_t len)
|
||||
return;
|
||||
#endif /* HAVE_GETRANDOM */
|
||||
|
||||
if ((fd = open(SSH_RANDOM_DEV, O_RDONLY)) == -1)
|
||||
fatal("Couldn't open %s: %s", SSH_RANDOM_DEV, strerror(errno));
|
||||
if ((fd = open(SSH_RANDOM_DEV, O_RDONLY)) == -1) {
|
||||
save_errno = errno;
|
||||
/* Try egd/prngd before giving up. */
|
||||
if (seed_from_prngd(s, len) == 0)
|
||||
return;
|
||||
fatal("Couldn't open %s: %s", SSH_RANDOM_DEV,
|
||||
strerror(save_errno));
|
||||
}
|
||||
while (o < len) {
|
||||
r = read(fd, s + o, len - o);
|
||||
if (r < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user