From f7d0f66173ff91ae485397eb3629051aeb08ef1e Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 14 Oct 2016 17:20:04 +0000 Subject: Port to new librandom API. Interestingly, that new API makes implementing s6-fillurandom kind of a NOP. The waiting will be performed in the library. --- src/minutils/s6-fillurandompool.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/minutils/s6-fillurandompool.c b/src/minutils/s6-fillurandompool.c index 57cd88c..e925e3b 100644 --- a/src/minutils/s6-fillurandompool.c +++ b/src/minutils/s6-fillurandompool.c @@ -1,29 +1,14 @@ /* ISC license. */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include #include -#include - -static int getrandom (void *buf, size_t buflen, unsigned int flags) -{ -#ifdef SYS_getrandom - return syscall(SYS_getrandom, buf, buflen, flags) ; -#else - return (errno = ENOSYS, -1) ; -#endif -} +#include int main (void) { - char buf[256] ; + unsigned char c ; PROG = "s6-fillurandompool" ; - if (getrandom(buf, 256, 0) != 256) - strerr_diefu1sys(111, "getrandom") ; + if (!random_init()) + strerr_diefu1sys(111, "initialize random generator") ; + random_string(&c, 1) ; return 0 ; } -- cgit v1.2.3