The boost mt code uses uninitialized memory for extra randomness,
which is a bad idea in general but more importantly makes valgrind
unhappy. Use /dev/urandom instead.
Unfortunately this introduces a link time dependency.. meh!
Fixes: #12736
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit
dbcaa544856fcc99ab912a101c4a28e1eb3fb94e)
Conflicts:
ceph.spec.in (trivial resolution)
%endif
BuildRequires: gcc-c++
BuildRequires: boost-devel
+BuildRequires: boost-random
%if 0%{defined suse_version}
BuildRequires: libbz2-devel
%else
LIBS="${saved_LIBS}"
AC_SUBST(BOOST_THREAD_LIBS)
+# boost-random
+BOOST_RANDOM_LIBS=""
+saved_LIBS="${LIBS}"
+LIBS=""
+AC_CHECK_LIB(boost_random, main, [],
+ [AC_CHECK_LIB(boost_random, main, [],
+ AC_MSG_FAILURE(["Boost random library not found."]))])
+BOOST_RANDOM_LIBS="${LIBS}"
+LIBS="${saved_LIBS}"
+AC_SUBST(BOOST_RANDOM_LIBS)
+
#
# Check for boost_program_options library (defines BOOST_PROGRAM_OPTIONS_LIBS).
#
libboost-program-options-dev (>= 1.42),
libboost-system-dev (>= 1.42),
libboost-thread-dev (>= 1.42),
+ libboost-random-dev,
libcurl4-gnutls-dev,
libedit-dev,
libexpat1-dev,
LIBCOMMON_DEPS += \
$(LIBERASURE_CODE) \
$(LIBMSG) $(LIBAUTH) \
- $(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH)
+ $(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH) \
+ $(BOOST_RANDOM_LIBS)
if LINUX
LIBCOMMON_DEPS += -lrt
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
+#include <boost/random/random_device.hpp>
struct uuid_d {
boost::uuids::uuid uuid;
}
void generate_random() {
- boost::uuids::random_generator gen;
+ boost::random::random_device rng("/dev/urandom");
+ boost::uuids::basic_random_generator<boost::random::random_device> gen(&rng);
uuid = gen();
}