From 5d345bd065ae1306884ed857dda3069aa5cf2cfc Mon Sep 17 00:00:00 2001 From: "Steffen (Daode) Nurpmeso" Date: Sat, 24 Dec 2016 14:03:24 +0100 Subject: [PATCH] Finally use /dev/arandom not /dev/urandom for OpenBSD --- auxlily.c | 8 +++++++- nail.h | 22 +++++++++++++--------- strings.c | 4 ++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/auxlily.c b/auxlily.c index ec1b1a8e..9aa0f2ef 100644 --- a/auxlily.c +++ b/auxlily.c @@ -103,7 +103,13 @@ _rand_init(void) _rand = smalloc(sizeof *_rand); - if ((u.fd = open("/dev/urandom", O_RDONLY)) != -1) { + if ((u.fd = open( +# if n_OS_OPENBSD + "/dev/arandom" +# else + "/dev/urandom" +# endif + , O_RDONLY)) != -1) { bool_t ok = (sizeof *_rand == (size_t)read(u.fd, _rand, sizeof *_rand)); close(u.fd); diff --git a/nail.h b/nail.h index 12e5bcc4..3f3c9870 100644 --- a/nail.h +++ b/nail.h @@ -302,20 +302,24 @@ #define n_ABS(A) ((A) < 0 ? -(A) : (A)) /* OS: we're not a library, only set what needs special treatment somewhere */ -#define OS_DRAGONFLY 0 -#define OS_SOLARIS 0 -#define OS_SUNOS 0 +#define n_OS_DRAGONFLY 0 +#define n_OS_OPENBSD 0 +#define n_OS_SOLARIS 0 +#define n_OS_SUNOS 0 #ifdef __DragonFly__ -# undef OS_DRAGONFLY -# define OS_DRAGONFLY 1 +# undef n_OS_DRAGONFLY +# define n_OS_DRAGONFLY 1 +#elif defined __OpenBSD__ +# undef n_OS_OPENBSD +# define n_OS_OPENBSD 1 #elif defined __solaris__ || defined __sun # if defined __SVR4 || defined __svr4__ -# undef OS_SOLARIS -# define OS_SOLARIS 1 +# undef n_OS_SOLARIS +# define n_OS_SOLARIS 1 # else -# undef OS_SUNOS -# define OS_SUNOS 1 +# undef n_OS_SUNOS +# define n_OS_SUNOS 1 # endif #endif diff --git a/strings.c b/strings.c index 436bab35..cb4ab99a 100644 --- a/strings.c +++ b/strings.c @@ -1061,12 +1061,12 @@ n_iconv_reset(iconv_t cd) /* Citrus project? */ # if defined _ICONV_H_ && defined __ICONV_F_HIDE_INVALID /* DragonFly 3.2.1 is special TODO newer DragonFly too, but different */ -# if OS_DRAGONFLY +# if n_OS_DRAGONFLY # define __INBCAST(S) (char ** __restrict__)n_UNCONST(S) # else # define __INBCAST(S) (char const **)n_UNCONST(S) # endif -# elif OS_SUNOS || OS_SOLARIS +# elif n_OS_SUNOS || n_OS_SOLARIS # define __INBCAST(S) (char const ** __restrict__)n_UNCONST(S) # endif # ifndef __INBCAST -- 2.11.4.GIT