summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2016-10-14 17:20:04 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2016-10-14 17:20:04 +0000
commitf7d0f66173ff91ae485397eb3629051aeb08ef1e (patch)
tree919523bcae7933a3c0f667c1f45f8d7048e3b75c
parent23d21be24c15bd38bf3b68803da31b51f309ec4b (diff)
downloads6-linux-utils-f7d0f66173ff91ae485397eb3629051aeb08ef1e.tar.gz
s6-linux-utils-f7d0f66173ff91ae485397eb3629051aeb08ef1e.tar.xz
s6-linux-utils-f7d0f66173ff91ae485397eb3629051aeb08ef1e.zip
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.
-rw-r--r--src/minutils/s6-fillurandompool.c25
1 files changed, 5 insertions, 20 deletions
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 <unistd.h>
-#include <errno.h>
-#include <sys/syscall.h>
 #include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
-
-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 <skalibs/random.h>
 
 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 ;
 }