commit 5a2d006699305fbb1f088d06c37c52a2f84d2cd0
parent 3f894f075f2fa9265544297b17e710fc097c063f
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Fri, 15 Jan 2021 00:18:42 +0000
Don't touch /dev/urandom when getrandom() exists
Diffstat:
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/librandom/random_init.c b/src/librandom/random_init.c
@@ -22,16 +22,10 @@ int random_init ()
#else
#ifdef SKALIBS_HASGETRANDOM
-#include <skalibs/djbunix.h>
#include <skalibs/random.h>
int random_init ()
{
-#ifdef SKALIBS_HASDEVURANDOM
- char seed[160] ;
- random_makeseed(seed) ;
- openwritenclose_unsafe("/dev/urandom", seed, 160) ;
-#endif
return 1 ;
}
@@ -66,9 +60,14 @@ int random_init ()
int random_init ()
{
- char seed[160] ;
- random_makeseed(seed) ;
- surf_init(&surf_here, seed) ;
+ static int initted = 0 ;
+ if (!initted)
+ {
+ char seed[160] ;
+ initted = 1 ;
+ random_makeseed(seed) ;
+ surf_init(&surf_here, seed) ;
+ }
return 1 ;
}