Don't ENXIO on open("/dev/random") if there is not enough
entropy collected. It's undocumented, noone else does it and it leads to "named" errors during boot for me. Generally, consumers of "/dev/random" should be prepared to wait. (The other uses of "rnd_have_entropy" look bogus to me too, but this needs more consideration.)
This commit is contained in:
parent
6dda78f17a
commit
3759e5b9d8
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: rnd.c,v 1.46 2005/02/27 00:26:58 perry Exp $ */
|
/* $NetBSD: rnd.c,v 1.47 2005/04/15 20:21:23 drochner Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.46 2005/02/27 00:26:58 perry Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.47 2005/04/15 20:21:23 drochner Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
@ -226,9 +226,6 @@ rnd_wakeup_readers(void)
|
||||||
printf("rnd: have initial entropy (%u)\n",
|
printf("rnd: have initial entropy (%u)\n",
|
||||||
rndpool_get_entropy_count(&rnd_pool));
|
rndpool_get_entropy_count(&rnd_pool));
|
||||||
#endif
|
#endif
|
||||||
/*
|
|
||||||
* Allow open of /dev/random now, too.
|
|
||||||
*/
|
|
||||||
rnd_have_entropy = 1;
|
rnd_have_entropy = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,21 +346,9 @@ rndopen(dev_t dev, int flags, int ifmt, struct proc *p)
|
||||||
if (rnd_ready == 0)
|
if (rnd_ready == 0)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
|
|
||||||
if (minor(dev) == RND_DEV_URANDOM)
|
if (minor(dev) == RND_DEV_URANDOM || minor(dev) == RND_DEV_RANDOM)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
/*
|
|
||||||
* If this is the strong random device and we have never collected
|
|
||||||
* entropy (or have not yet) don't allow it to be opened. This will
|
|
||||||
* prevent waiting forever for something that just will not appear.
|
|
||||||
*/
|
|
||||||
if (minor(dev) == RND_DEV_RANDOM) {
|
|
||||||
if (rnd_have_entropy == 0)
|
|
||||||
return (ENXIO);
|
|
||||||
else
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue