Fix: sessiond: instance uuid is not sufficiently unique
[lttng-tools.git] / src / common / uuid.c
index 26fb61e99449a5a9f3a0b40a262787c36996c49c..0e01c2185cc819327066dab0b9580059432d2d97 100644 (file)
@@ -7,6 +7,9 @@
  */
 
 #include <common/compat/string.h>
+#include <common/random.h>
+#include <common/error.h>
+
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -78,18 +81,15 @@ int lttng_uuid_generate(lttng_uuid uuid_out)
        }
 
        if (!lttng_uuid_is_init) {
-               /*
-                * We don't need cryptographic quality randomness to
-                * generate UUIDs, seed rand with the epoch.
-                */
-               const time_t epoch = time(NULL);
-
-               if (epoch == (time_t) -1) {
-                       ret = -1;
+               seed_t new_seed;
+
+               ret = lttng_produce_best_effort_random_seed(&new_seed);
+               if (ret) {
+                       ERR("Failed to initialize random seed while generating UUID");
                        goto end;
                }
-               srand(epoch);
 
+               srand(new_seed);
                lttng_uuid_is_init = true;
        }
 
This page took 0.024007 seconds and 4 git commands to generate.