summaryrefslogtreecommitdiffstats
path: root/spawn
diff options
context:
space:
mode:
authorMarkos Fountoulakis <44345837+mfundul@users.noreply.github.com>2020-06-16 19:34:19 +0300
committerGitHub <noreply@github.com>2020-06-16 19:34:19 +0300
commitc4fd4aa07c2abb18f5839e1b910294c39c3e30be (patch)
treeccdb55838aad45b01b9686604168be7ff54ff0ff /spawn
parentac9c33c3443b5de4fc96f815eccab435eda504f9 (diff)
Get netdata execution path early to avoid user permission issues (#9339)
* Get netdata execution path early to avoid user permission issues
Diffstat (limited to 'spawn')
-rw-r--r--spawn/spawn.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/spawn/spawn.c b/spawn/spawn.c
index 8b3afcf3b2..0bacbbca16 100644
--- a/spawn/spawn.c
+++ b/spawn/spawn.c
@@ -190,8 +190,6 @@ struct spawn_cmd_info *spawn_get_unprocessed_cmd(void)
int create_spawn_server(uv_loop_t *loop, uv_pipe_t *spawn_channel, uv_process_t *process)
{
uv_process_options_t options = {0};
- size_t exepath_size;
- char exepath[FILENAME_MAX];
char *args[3];
int ret;
#define SPAWN_SERVER_DESCRIPTORS (3)
@@ -202,15 +200,6 @@ int create_spawn_server(uv_loop_t *loop, uv_pipe_t *spawn_channel, uv_process_t
passwd = getpwuid(getuid());
user = (passwd && passwd->pw_name) ? passwd->pw_name : "";
- exepath_size = sizeof(exepath);
- ret = uv_exepath(exepath, &exepath_size);
- if (0 != ret) {
- error("uv_exepath(\"%s\", %u) (user: %s) failed (%s).", exepath, (unsigned)exepath_size, user,
- uv_strerror(ret));
- fatal("Cannot start netdata without the spawn server.");
- }
-
- exepath[exepath_size] = '\0';
args[0] = exepath;
args[1] = SPAWN_SERVER_COMMAND_LINE_ARGUMENT;
args[2] = NULL;
@@ -231,8 +220,7 @@ int create_spawn_server(uv_loop_t *loop, uv_pipe_t *spawn_channel, uv_process_t
ret = uv_spawn(loop, process, &options); /* execute the netdata binary again as the netdata user */
if (0 != ret) {
- error("uv_spawn (process: \"%s\", %u) (user: %s) failed (%s).", exepath, (unsigned)exepath_size, user,
- uv_strerror(ret));
+ error("uv_spawn (process: \"%s\") (user: %s) failed (%s).", exepath, user, uv_strerror(ret));
fatal("Cannot start netdata without the spawn server.");
}