From 6b69db73acf3bb2257086db460a7167fdcde73f3 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 11 May 2022 11:25:20 +0300 Subject: [PATCH] Remove getrandom() usage --- src/nfs_proxy.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nfs_proxy.cpp b/src/nfs_proxy.cpp index 3cf79280..5243c974 100644 --- a/src/nfs_proxy.cpp +++ b/src/nfs_proxy.cpp @@ -7,7 +7,6 @@ #define _XOPEN_SOURCE #include -#include #include #include @@ -84,7 +83,10 @@ json11::Json::object nfs_proxy_t::parse_args(int narg, const char *args[]) void nfs_proxy_t::run(json11::Json cfg) { - while (getrandom(&server_id, sizeof(server_id), 0) != sizeof(server_id)) {} + timespec tv; + clock_gettime(CLOCK_REALTIME, &tv); + srand48(tv.tv_sec*1000000000 + tv.tv_nsec); + server_id = (uint64_t)lrand48() | ((uint64_t)lrand48() << 31) | ((uint64_t)lrand48() << 62); // Parse options bind_address = cfg["bind"].string_value(); if (bind_address == "")