diff --git a/lib/util_mosq.c b/lib/util_mosq.c index 5ef19b2a..b7036061 100644 --- a/lib/util_mosq.c +++ b/lib/util_mosq.c @@ -28,8 +28,10 @@ Contributors: # include #endif -#ifdef __linux__ -# include +#if !defined(WITH_TLS) && defined(__linux__) +# if defined(__GLIBC__) && __GLIBC_PREREQ(2, 25) +# include +# endif #endif #ifdef WITH_TLS @@ -310,12 +312,11 @@ int util__random_bytes(void *bytes, int count) if(RAND_bytes(bytes, count) == 1){ rc = MOSQ_ERR_SUCCESS; } -#else -# ifdef __GLIBC__ +#elif defined(__GLIBC__) && __GLIBC_PREREQ(2, 25) if(getrandom(bytes, count, 0) == 0){ rc = MOSQ_ERR_SUCCESS; } -# elif defined(WIN32) +#elif defined(WIN32) HRYPTPROV provider; if(!CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)){ @@ -327,14 +328,13 @@ int util__random_bytes(void *bytes, int count) } CryptReleaseContext(provider, 0); -# else +#else int i; for(i=0; i