@cryptotaxi247 / netdata-1 / commits / be9ac7cac

use v4 UUIDs (#20002)

* use v4 UUIDs * added comments to UUID generations

Costa Tsaousis committed Mar 31, 2025 at 11:34 UTC be9ac7cac95fcbcf6fb17eb880eda53fb89cda3a
3 files changed +5 -2
src/daemon/machine-guid.c
+1 -1
@@ -168,7 +168,7 @@ static ND_MACHINE_GUID machine_guid_get_or_create(void) {
168 if (UUIDiszero(h.uuid)) {
169 // If the status file does not contain a GUID, generate a new one.
170 nd_log(NDLS_DAEMON, NDLP_INFO, "MACHINE_GUID: generating a new GUID");
171 - uuid_generate_time(h.uuid.uuid);
171 + uuid_generate(h.uuid.uuid);
172 }
173 else
174 nd_log(NDLS_DAEMON, NDLP_INFO, "MACHINE_GUID: got previous GUID from daemon status file");
src/libnetdata/os/uuid_generate.c
+3
@@ -29,6 +29,8 @@ void os_uuid_generate_time(void *out) {
29 #endif
30
31 void os_uuid_generate(void *out) {
32 + // IMPORTANT: this generates a UUIDv4, which is random
33 + // and falls back to uuid_generate_time() if high resolution random generated is not available
34 uuid_generate(out);
35 }
36
@@ -37,6 +39,7 @@ void os_uuid_generate_random(void *out) {
39 }
40
41 void os_uuid_generate_time(void *out) {
42 + // IMPORTANT: this generates a UUIDv1, which is not random and may suffer from collisions
43 uuid_generate_time(out);
44 }
45
src/web/api/v1/api_v1_manage.c
+1 -1
@@ -35,7 +35,7 @@ static char *get_mgmt_api_key(void) {
35 if(!guid[0]) {
36 nd_uuid_t uuid;
37
38 - uuid_generate_time(uuid);
38 + uuid_generate(uuid);
39 uuid_unparse_lower(uuid, guid);
40 guid[GUID_LEN] = '\0';
41