summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2016-10-16 15:47:32 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2016-10-16 15:47:32 +0000
commit85d3f29ce384dea6cfbaa80215ce86d2d0358eba (patch)
treead3c759c61699b6a0d8b872565d7c1044e0afb7b
parent4a90dd1f9063fd5a91431ee6873c25c5c8229805 (diff)
downloads6-85d3f29ce384dea6cfbaa80215ce86d2d0358eba.tar.xz
Unconditionally switch s6-ftrigrd to surf (avoid boot stalling problems, and nobody cares about that RNG not being CS)
-rw-r--r--src/libs6/ftrig1.h1
-rw-r--r--src/libs6/ftrig1_make.c19
-rw-r--r--src/libs6/s6-ftrigrd.c4
3 files changed, 20 insertions, 4 deletions
diff --git a/src/libs6/ftrig1.h b/src/libs6/ftrig1.h
index 229de66..aa06b57 100644
--- 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
index 83ffca9..8352e64 100644
--- 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
index 3200300..ac79bd2 100644
--- 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 ;