require libuuid
- require libuuid at build time and remove insufficiently seeded replacement for uuid()
This commit is contained in:
committed by
Paul Beckingham
parent
779e32540a
commit
fcfd50bd25
@@ -161,12 +161,6 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
<< " -random"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UUID
|
||||
<< " +uuid"
|
||||
#else
|
||||
<< " -uuid"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBGNUTLS
|
||||
<< " +tls"
|
||||
#else
|
||||
@@ -175,12 +169,10 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
<< "\n";
|
||||
|
||||
out << " libuuid: "
|
||||
#if defined (HAVE_UUID) and defined (HAVE_UUID_UNPARSE_LOWER)
|
||||
#ifdef HAVE_UUID_UNPARSE_LOWER
|
||||
<< "libuuid + uuid_unparse_lower"
|
||||
#elif defined (HAVE_UUID) and !defined (HAVE_UUID_UNPARSE_LOWER)
|
||||
<< "libuuid, no uuid_unparse_lower"
|
||||
#else
|
||||
<< "n/a"
|
||||
<< "libuuid, no uuid_unparse_lower"
|
||||
#endif
|
||||
<< "\n";
|
||||
|
||||
|
||||
29
src/util.cpp
29
src/util.cpp
@@ -230,8 +230,6 @@ int autoComplete (
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef HAVE_UUID
|
||||
|
||||
#ifndef HAVE_UUID_UNPARSE_LOWER
|
||||
// Older versions of libuuid don't have uuid_unparse_lower(), only uuid_unparse()
|
||||
void uuid_unparse_lower (uuid_t uu, char *out)
|
||||
@@ -256,33 +254,6 @@ const std::string uuid ()
|
||||
return std::string (buffer);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#else
|
||||
|
||||
#ifdef HAVE_RANDOM
|
||||
#define rand() random()
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string uuid ()
|
||||
{
|
||||
uint32_t time_low = ((rand () << 16) & 0xffff0000) | (rand () & 0xffff);
|
||||
uint16_t time_mid = rand () & 0xffff;
|
||||
uint16_t time_high_and_version = (rand () & 0x0fff) | 0x4000;
|
||||
uint16_t clock_seq = (rand () & 0x3fff) | 0x8000;
|
||||
uint8_t node [6];
|
||||
for (size_t i = 0; i < 6; i++)
|
||||
node[i] = rand() & 0xff;
|
||||
|
||||
char buffer[37];
|
||||
sprintf(buffer, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
time_low, time_mid, time_high_and_version, clock_seq >> 8, clock_seq & 0xff,
|
||||
node[0], node[1], node[2], node[3], node[4], node[5]);
|
||||
|
||||
return std::string (buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// On Solaris no flock function exists.
|
||||
#ifdef SOLARIS
|
||||
|
||||
@@ -34,9 +34,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <Task.h>
|
||||
|
||||
#ifdef HAVE_UUID
|
||||
#include <uuid/uuid.h>
|
||||
#endif
|
||||
|
||||
// util.cpp
|
||||
bool confirm (const std::string&);
|
||||
@@ -46,7 +44,7 @@ void delay (float);
|
||||
std::string formatBytes (size_t);
|
||||
int autoComplete (const std::string&, const std::vector<std::string>&, std::vector<std::string>&, int minimum = 1);
|
||||
|
||||
#if defined(HAVE_UUID) && !defined(HAVE_UUID_UNPARSE_LOWER)
|
||||
#ifndef HAVE_UUID_UNPARSE_LOWER
|
||||
void uuid_unparse_lower (uuid_t uu, char *out);
|
||||
#endif
|
||||
const std::string uuid ();
|
||||
|
||||
Reference in New Issue
Block a user