Fix: getgrnam is not MT-Safe, use getgrnam_r
[lttng-tools.git] / src / bin / lttng-relayd / health-relayd.c
index ba996621b0058ca62f94a7d1c4b001a5737b1b2e..9b4eefcd55f93e7ad6e9e5e018a398b76fc75f5a 100644 (file)
@@ -105,8 +105,15 @@ static int create_lttng_rundir_with_perm(const char *rundir)
                int is_root = !getuid();
 
                if (is_root) {
-                       ret = chown(rundir, 0,
-                                       utils_get_group_id(tracing_group_name));
+                       gid_t gid;
+
+                       ret = utils_get_group_id(tracing_group_name, true, &gid);
+                       if (ret) {
+                               /* Default to root group. */
+                               gid = 0;
+                       }
+
+                       ret = chown(rundir, 0, gid);
                        if (ret < 0) {
                                ERR("Unable to set group on %s", rundir);
                                PERROR("chown");
@@ -256,8 +263,15 @@ void *thread_manage_health(void *data)
        is_root = !getuid();
        if (is_root) {
                /* lttng health client socket path permissions */
-               ret = chown(health_unix_sock_path, 0,
-                               utils_get_group_id(tracing_group_name));
+               gid_t gid;
+
+               ret = utils_get_group_id(tracing_group_name, true, &gid);
+               if (ret) {
+                       /* Default to root group. */
+                       gid = 0;
+               }
+
+               ret = chown(health_unix_sock_path, 0, gid);
                if (ret < 0) {
                        ERR("Unable to set group on %s", health_unix_sock_path);
                        PERROR("chown");
This page took 0.024267 seconds and 5 git commands to generate.