From 40e325de3aeb3d65eeeba46c0492fe7d08a799ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= <ckoenig@posteo.de> Date: Tue, 30 May 2023 22:50:29 +0200 Subject: [PATCH] Fix getrandom() for glibc <2.25 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König <ckoenig@posteo.de> --- src/config/password.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/config/password.c b/src/config/password.c index de476c258..a060a8598 100644 --- a/src/config/password.c +++ b/src/config/password.c @@ -12,8 +12,15 @@ #include "log.h" #include "config/config.h" #include "password.h" -// genrandom() +// getrandom() is only available since glibc 2.25 +// https://www.gnu.org/software/gnulib/manual/html_node/sys_002frandom_002eh.html +#if !defined(__GLIBC__) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25) #include <sys/random.h> +#else +// getrandom_fallback() +#include "daemon.h" +#define getrandom getrandom_fallback +#endif // Randomness generator #include "webserver/x509.h" @@ -352,4 +359,4 @@ bool verify_password(const char *password, const char* pwhash) return result; } -} \ No newline at end of file +} -- GitLab