From 2b8c2657e4577b6f9c26622482db2354b22b2216 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 28 Dec 2020 15:51:14 +0000 Subject: [PATCH 1/2] Implements getrandom's wrapper for handful of BSD. Signed-off-by: David Carlier --- library/entropy_poll.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/library/entropy_poll.c b/library/entropy_poll.c index 5250a7bfe..84b70fe6f 100644 --- a/library/entropy_poll.c +++ b/library/entropy_poll.c @@ -109,6 +109,21 @@ static int getrandom_wrapper( void *buf, size_t buflen, unsigned int flags ) #endif /* SYS_getrandom */ #endif /* __linux__ || __midipix__ */ +#if defined(__FreeBSD__) || defined(__DragonFly__) +#include +#if (defined(__FreeBSD__) && __FreeBSD_version >= 1200000) || \ + (defined(__DragonFly__) && __DragonFly_version >= 500700) +#include +#include +#define HAVE_GETRANDOM +static int getrandom_wrapper( void *buf, size_t buflen, unsigned int flags ) +{ + return getrandom( buf, buflen, flags ); +} +#endif /* (__FreeBSD__ && __FreeBSD_version >= 1200000) || + (__DragonFly__ && __DragonFly_version >= 500700) */ +#endif /* __FreeBSD__ || __DragonFly__ */ + /* * Some BSD systems provide KERN_ARND. * This is equivalent to reading from /dev/urandom, only it doesn't require an From 4971c3fce77a9d62cd68adec908ed5a7e3cab477 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 12 Feb 2021 11:11:55 +0000 Subject: [PATCH 2/2] Changelog entry. Signed-off-by: David Carlier --- ChangeLog.d/getentropy.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ChangeLog.d/getentropy.txt diff --git a/ChangeLog.d/getentropy.txt b/ChangeLog.d/getentropy.txt new file mode 100644 index 000000000..460798f58 --- /dev/null +++ b/ChangeLog.d/getentropy.txt @@ -0,0 +1,3 @@ +Changes + * On recent enough versions of FreeBSD and DragonFlyBSD, the entropy module + now uses the getrandom syscall instead of reading from /dev/urandom.