summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2016-10-14 17:19:23 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2016-10-14 17:19:23 +0000
commit7218cdfb26040566143aaddc98f492d9b0976f0a (patch)
tree6b6c1e1e15319f8d6b8c74a882a862510c9e21df /src
parent3f3370eb9f6d7e7a47c559fbcdf915ec4452de90 (diff)
downloads6-networking-7218cdfb26040566143aaddc98f492d9b0976f0a.tar.xz
Port to new librandom API
Diffstat (limited to 'src')
-rw-r--r--src/clock/s6-taiclock.c3
-rw-r--r--src/minidentd/minidentd.c28
2 files changed, 15 insertions, 16 deletions
diff --git a/src/clock/s6-taiclock.c b/src/clock/s6-taiclock.c
index 99150b5..d8d371f 100644
--- a/src/clock/s6-taiclock.c
+++ b/src/clock/s6-taiclock.c
@@ -34,7 +34,7 @@ int tain_exchange (int s, ip46_t const *ip, uint16 port, tain_t *serversays, tai
int r ;
uint16 dummyport ;
tain_pack(query+4, &STAMP) ;
- if (badrandom_string(query+20, N-20) < N-20) return 0 ; /* cookie */
+ random_string(query+20, N-20) ; /* cookie */
r = socket_sendnb46_g(s, query, N, ip, port, deadline) ;
if (r < 0) return 0 ;
if (r < N) return (errno = EPIPE, 0) ;
@@ -96,6 +96,7 @@ int main (int argc, char const *const *argv)
}
if (!argc) dieusage() ;
if (!ip46_scan(argv[0], &ipremote)) dieusage() ;
+ if (!random_init()) strerr_diefu1sys(111, "init random generator") ;
sock = socket_udp46(ip46_is6(&ipremote)) ;
if (sock < 0) strerr_diefu1sys(111, "socket_udp") ;
diff --git a/src/minidentd/minidentd.c b/src/minidentd/minidentd.c
index a6dfee4..287a492 100644
--- a/src/minidentd/minidentd.c
+++ b/src/minidentd/minidentd.c
@@ -155,21 +155,16 @@ static void doit (char const *s, ip46_t const *localaddr, ip46_t const *remotead
return ;
}
- if (how == 3)
- {
- char name[9] ;
- char fmt[4 + UINT_FMT] = "uid " ;
- fmt[4 + uint_fmt(fmt+4, uid)] = 0 ;
- if (random_name(name, 8) < 8)
- {
- strerr_warnwu1sys("perform random") ;
- reply(lr, "ERROR", "UNKNOWN-ERROR") ;
- return ;
- }
- reply(lr, "UNIX", name) ;
- logreply("random", fmt, name) ;
- return ;
- }
+ if (how == 3)
+ {
+ char name[9] ;
+ char fmt[4 + UINT_FMT] = "uid " ;
+ fmt[4 + uint_fmt(fmt+4, uid)] = 0 ;
+ random_name(name, 8) ;
+ reply(lr, "UNIX", name) ;
+ logreply("random", fmt, name) ;
+ return ;
+ }
pw = getpwuid(uid) ;
if (!pw)
@@ -254,6 +249,9 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (ip46_is6(&localaddr) != ip46_is6(&remoteaddr))
strerr_dief1x(100, "local and remote address not of the same family") ;
+ if (!random_init())
+ strerr_diefu1sys(111, "init random generator") ;
+
tain_now_g() ;
for (;;)