summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2016-09-15 11:48:18 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2016-09-15 11:48:18 +0000
commit6f3e9754ef9446cb8a9f98e593aed23a730c4c10 (patch)
treea973052c9a8c818a830ce3304996e45598989863 /src
parent8cbb5587ff1b3770ff570bc120ea532cd62357bb (diff)
downloads6-linux-utils-6f3e9754ef9446cb8a9f98e593aed23a730c4c10.tar.gz
s6-linux-utils-6f3e9754ef9446cb8a9f98e593aed23a730c4c10.tar.xz
s6-linux-utils-6f3e9754ef9446cb8a9f98e593aed23a730c4c10.zip
Add s6-fillurandompool
Diffstat (limited to 'src')
-rw-r--r--src/minutils/deps-exe/s6-fillurandompool1
-rw-r--r--src/minutils/s6-fillurandompool.c26
2 files changed, 27 insertions, 0 deletions
diff --git a/src/minutils/deps-exe/s6-fillurandompool b/src/minutils/deps-exe/s6-fillurandompool
new file mode 100644
index 0000000..e7187fe
--- /dev/null
+++ b/src/minutils/deps-exe/s6-fillurandompool
@@ -0,0 +1 @@
+-lskarnet
diff --git a/src/minutils/s6-fillurandompool.c b/src/minutils/s6-fillurandompool.c
new file mode 100644
index 0000000..775f289
--- /dev/null
+++ b/src/minutils/s6-fillurandompool.c
@@ -0,0 +1,26 @@
+/* ISC license. */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <skalibs/strerr2.h>
+#include <skalibs/djbunix.h>
+
+#define USAGE "s6-fillurandompool"
+
+static int getrandom (void *buf, size_t buflen, unsigned int flags)
+{
+  return syscall(SYS_getrandom, buf, buflen, flags) ;
+}
+
+int main (void)
+{
+  char buf[256] ;
+  PROG = "s6-fillurandompool" ;
+  if (getrandom(buf, 256, 0) != 256)
+    strerr_diefu1sys(111, "getrandom") ;
+  return 0 ;
+}