commit 85d3f29ce384dea6cfbaa80215ce86d2d0358eba
parent 4a90dd1f9063fd5a91431ee6873c25c5c8229805
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Sun, 16 Oct 2016 15:47:32 +0000
Unconditionally switch s6-ftrigrd to surf (avoid boot stalling problems, and nobody cares about that RNG not being CS)
Diffstat:
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/libs6/ftrig1.h b/src/libs6/ftrig1.h
@@ -17,6 +17,7 @@ struct ftrig1_s
} ;
#define FTRIG1_ZERO { .fd = -1, .fdw = -1, .name = STRALLOC_ZERO }
+extern void ftrig1_init (void) ;
extern int ftrig1_make (ftrig1_t *, char const *) ;
extern void ftrig1_free (ftrig1_t *) ;
diff --git a/src/libs6/ftrig1_make.c b/src/libs6/ftrig1_make.c
@@ -9,9 +9,26 @@
#include <skalibs/tai.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
+#include <skalibs/surf.h>
#include <skalibs/random.h>
#include "ftrig1.h"
+static SURFSchedule surf_ctx = SURFSCHEDULE_ZERO ;
+
+void ftrig1_init (void)
+{
+ char seed[160] ;
+ random_makeseed(seed) ;
+ surf_init(&surf_ctx, seed) ;
+}
+
+static inline void surfname (char *s, unsigned int n)
+{
+ static char const oklist[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz-_0123456789abcdef" ;
+ surf(&surf_ctx, s, n) ;
+ while (n--) s[n] = oklist[s[n] & 63] ;
+}
+
int ftrig1_make (ftrig1_t *f, char const *path)
{
ftrig1_t ff = FTRIG1_ZERO ;
@@ -25,7 +42,7 @@ int ftrig1_make (ftrig1_t *f, char const *path)
tmp[pathlen + 2 + FTRIG1_PREFIXLEN] = ':' ;
if (!timestamp(tmp + pathlen + 3 + FTRIG1_PREFIXLEN)) return 0 ;
tmp[pathlen + 28 + FTRIG1_PREFIXLEN] = ':' ;
- random_name(tmp + pathlen + 29 + FTRIG1_PREFIXLEN, 16) ;
+ surfname(tmp + pathlen + 29 + FTRIG1_PREFIXLEN, 16) ;
tmp[pathlen + 45 + FTRIG1_PREFIXLEN] = 0 ;
{
diff --git a/src/libs6/s6-ftrigrd.c b/src/libs6/s6-ftrigrd.c
@@ -13,7 +13,6 @@
#include <skalibs/stralloc.h>
#include <skalibs/sig.h>
#include <skalibs/tai.h>
-#include <skalibs/random.h>
#include <skalibs/djbunix.h>
#include <skalibs/iopause.h>
#include <skalibs/unixmessage.h>
@@ -195,8 +194,7 @@ int main (void)
if (ndelay_on(0) < 0) strerr_diefu2sys(111, "ndelay_on ", "0") ;
if (ndelay_on(1) < 0) strerr_diefu2sys(111, "ndelay_on ", "1") ;
if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ;
- if (!random_init())
- strerr_diefu1sys(111, "init random generator") ;
+ ftrig1_init() ;
{
tain_t deadline ;