summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-01-15 00:18:42 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-01-15 00:18:42 +0000
commit5a2d006699305fbb1f088d06c37c52a2f84d2cd0 (patch)
treecdbd00818c0e94c221695106554406786d198711 /src
parent3f894f075f2fa9265544297b17e710fc097c063f (diff)
downloadskalibs-5a2d006699305fbb1f088d06c37c52a2f84d2cd0.tar.xz
Don't touch /dev/urandom when getrandom() exists
Diffstat (limited to 'src')
-rw-r--r--src/librandom/random_init.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/librandom/random_init.c b/src/librandom/random_init.c
index e47f8df..72671df 100644
--- 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 ;
}