From: Sage Weil Date: Mon, 24 Aug 2015 18:51:47 +0000 (-0400) Subject: uuid: use boost::random:random_device X-Git-Tag: v0.94.8~6^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=187d308b5b0cb0512b442bbad1bddfda8ef9203f;p=ceph.git uuid: use boost::random:random_device 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 (cherry picked from commit dbcaa544856fcc99ab912a101c4a28e1eb3fb94e) Conflicts: ceph.spec.in (trivial resolution) --- diff --git a/ceph.spec.in b/ceph.spec.in index 600afc50676c..6e06a18c3677 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -50,6 +50,7 @@ BuildRequires: sharutils %endif BuildRequires: gcc-c++ BuildRequires: boost-devel +BuildRequires: boost-random %if 0%{defined suse_version} BuildRequires: libbz2-devel %else diff --git a/configure.ac b/configure.ac index 2fa729bcda1d..cf3cb209de09 100644 --- a/configure.ac +++ b/configure.ac @@ -882,6 +882,17 @@ BOOST_THREAD_LIBS="${LIBS}" 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). # diff --git a/debian/control b/debian/control index c16db0f550dd..bce749bbc9c9 100644 --- a/debian/control +++ b/debian/control @@ -27,6 +27,7 @@ Build-Depends: autoconf, 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, diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 8fa29899c10f..ed37ceffb29e 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -134,7 +134,8 @@ noinst_HEADERS += \ LIBCOMMON_DEPS += \ $(LIBERASURE_CODE) \ $(LIBMSG) $(LIBAUTH) \ - $(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH) + $(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH) \ + $(BOOST_RANDOM_LIBS) if LINUX LIBCOMMON_DEPS += -lrt diff --git a/src/include/uuid.h b/src/include/uuid.h index df9e71a46622..03e6b5ad32c7 100644 --- a/src/include/uuid.h +++ b/src/include/uuid.h @@ -11,6 +11,7 @@ #include #include #include +#include struct uuid_d { boost::uuids::uuid uuid; @@ -25,7 +26,8 @@ struct uuid_d { } void generate_random() { - boost::uuids::random_generator gen; + boost::random::random_device rng("/dev/urandom"); + boost::uuids::basic_random_generator gen(&rng); uuid = gen(); }