diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-01-15 00:18:42 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2021-01-15 00:18:42 +0000 |
commit | 5a2d006699305fbb1f088d06c37c52a2f84d2cd0 (patch) | |
tree | cdbd00818c0e94c221695106554406786d198711 | |
parent | 3f894f075f2fa9265544297b17e710fc097c063f (diff) | |
download | skalibs-5a2d006699305fbb1f088d06c37c52a2f84d2cd0.tar.gz skalibs-5a2d006699305fbb1f088d06c37c52a2f84d2cd0.tar.xz skalibs-5a2d006699305fbb1f088d06c37c52a2f84d2cd0.zip |
Don't touch /dev/urandom when getrandom() exists
-rw-r--r-- | src/librandom/random_init.c | 17 |
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 ; } |