summaryrefslogtreecommitdiffstats
path: root/src/registry/registry_internals.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/registry/registry_internals.c (renamed from registry/registry_internals.c)14
1 files changed, 7 insertions, 7 deletions
diff --git a/registry/registry_internals.c b/src/registry/registry_internals.c
index 74f12b558..54fad4254 100644
--- a/registry/registry_internals.c
+++ b/src/registry/registry_internals.c
@@ -11,7 +11,7 @@ struct registry registry;
// parse a GUID and re-generated to be always lower case
// this is used as a protection against the variations of GUIDs
int regenerate_guid(const char *guid, char *result) {
- uuid_t uuid;
+ nd_uuid_t uuid;
if(unlikely(uuid_parse(guid, uuid) == -1)) {
netdata_log_info("Registry: GUID '%s' is not a valid GUID.", guid);
return -1;
@@ -35,12 +35,12 @@ static inline char *registry_fix_machine_name(char *name, size_t *len) {
char *s = name?name:"";
// skip leading spaces
- while(*s && isspace(*s)) s++;
+ while(*s && isspace((uint8_t)*s)) s++;
// make sure all spaces are a SPACE
char *t = s;
while(*t) {
- if(unlikely(isspace(*t)))
+ if(unlikely(isspace((uint8_t)*t)))
*t = ' ';
t++;
@@ -270,14 +270,14 @@ char *registry_get_this_machine_hostname(void) {
return registry.hostname;
}
-char *registry_get_this_machine_guid(void) {
+const char *registry_get_this_machine_guid(void) {
static char guid[GUID_LEN + 1] = "";
if(likely(guid[0]))
return guid;
// read it from disk
- int fd = open(registry.machine_guid_filename, O_RDONLY);
+ int fd = open(registry.machine_guid_filename, O_RDONLY | O_CLOEXEC);
if(fd != -1) {
char buf[GUID_LEN + 1];
if(read(fd, buf, GUID_LEN) != GUID_LEN)
@@ -298,14 +298,14 @@ char *registry_get_this_machine_guid(void) {
// generate a new one?
if(!guid[0]) {
- uuid_t uuid;
+ nd_uuid_t uuid;
uuid_generate_time(uuid);
uuid_unparse_lower(uuid, guid);
guid[GUID_LEN] = '\0';
// save it
- fd = open(registry.machine_guid_filename, O_WRONLY|O_CREAT|O_TRUNC, 444);
+ fd = open(registry.machine_guid_filename, O_WRONLY|O_CREAT|O_TRUNC | O_CLOEXEC, 444);
if(fd == -1)
fatal("Cannot create unique machine id file '%s'. Please fix this.", registry.machine_guid_filename);