Control: forwarded -1 https://github.com/getdnsapi/getdns/pull/182
On Mon, 2016-01-18 at 13:59:00 +0000, Steven Chamberlain wrote: > Guillem Jover wrote: > > Steven Chamberlain wrote: > > > getdns FTBFS on kfreebsd because it lacks a getentropy implementation > > > for the FreeBSD kernel. But there is one already in LibreSSL Portable > > > we can use, and works fine here. > > > > BTW, libbsd has also a getentropy(3) implementation (lifted too from > > LibreSSL), which is currently not exposed but if people want to use it > > I could make it public, instead of embedding this in all sorts of > > places. The difference being that libbsd is already in Debian, while > > LibreSSL is not. > > > > <http://cgit.freedesktop.org/libbsd/tree/src> > I think the only use case for getentropy is arc4random, so perhaps don't > export getentropy(3), but lets try to standardise on one implementation > of arc4random (in libbsd?) and try to get more people using that? > > It would be nice to have the kernel-specific parts (getentropy) confined > to libbsd, and that may become even more important if applications start > sandboxing (e.g. can't read /dev/urandom any more, have to use sysctls). > Or if getrandom(2) becomes standard, we'd only need to implement it in > one place (as a supplement / eventual replacement to getentropy(3)). Sure, I've now implemented this and sent a pull request to upstream, plus the required packaging bits, attached here both for convenience. Thanks, Guillem
diff --git i/debian/control w/debian/control index 8b27205..ffa1c40 100644 --- i/debian/control +++ w/debian/control @@ -8,6 +8,7 @@ Build-Depends: autotools-dev, check, debhelper (>= 9), dh-autoreconf, + libbsd-dev, libev-dev, libevent-dev, libexpat-dev,
From 1fb763761b90c3269d818a736a6c81469b89629d Mon Sep 17 00:00:00 2001 From: Guillem Jover <guil...@hadrons.org> Date: Thu, 9 Jun 2016 01:55:07 +0200 Subject: [PATCH] Use libbsd when available Use the libbsd (https://libbsd.freedesktop.org/) overlay to transparently use the bsd compatibility layer without needing any actual code changes. Remove now unnecessary direct access to libbsd includes. And remove checks for unused functions. --- configure.ac | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index a471327..0807f01 100644 --- a/configure.ac +++ b/configure.ac @@ -238,7 +238,7 @@ if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/ AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL]) # libressl provides these compat functions, but they may also be # declared by the OS in libc. See if they have been declared. - AC_CHECK_DECLS([strlcpy,strlcat,arc4random,arc4random_uniform,reallocarray]) + AC_CHECK_DECLS([strlcpy,arc4random,arc4random_uniform]) else AC_MSG_RESULT([no]) fi @@ -928,7 +928,7 @@ dnl ----- Start of "Things needed for gldns" section dnl ----- dnl --------------------------------------------------------------------------- -AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h bsd/string.h sys/select.h],,, [AC_INCLUDES_DEFAULT]) +AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h sys/select.h],,, [AC_INCLUDES_DEFAULT]) dnl Check the printf-format attribute (if any) dnl result in HAVE_ATTR_FORMAT. @@ -967,6 +967,14 @@ AC_MSG_RESULT($ac_cv_c_unused_attribute) if test $ac_cv_c_unused_attribute = yes; then AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute]) fi +# Check for libbsd, so that the next function checks pick it as their +# system implementation. +PKG_CHECK_MODULES([LIBBSD],[libbsd-overlay],[ +LIBS="$LIBS $LIBBSD_LIBS" +CFLAGS="$CFLAGS $LIBBSD_CFLAGS" +],[ +AC_MSG_WARN([libbsd not found or usable; using embedded code instead]) +]) AC_CHECK_DECLS([strlcpy,arc4random,arc4random_uniform]) AC_REPLACE_FUNCS(inet_pton) AC_REPLACE_FUNCS(inet_ntop) @@ -1050,10 +1058,6 @@ AH_BOTTOM([ #include <assert.h> #include <string.h> -#ifdef HAVE_BSD_STRING_H -#include <bsd/string.h> -#endif - /* the version of the windows API enabled */ #ifndef WINVER #define WINVER 0x0600 // 0x0502 -- 2.8.1