summaryrefslogtreecommitdiffstats
path: root/daemon/daemon.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-10 09:18:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-10 09:19:08 +0000
commita2d7dede737947d7c6afa20a88e1f0c64e0eb96c (patch)
treefed4aff7dbe0be00cf91de6261d98bc0eb9a2449 /daemon/daemon.c
parentReleasing debian version 1.41.0-1. (diff)
downloadnetdata-a2d7dede737947d7c6afa20a88e1f0c64e0eb96c.tar.xz
netdata-a2d7dede737947d7c6afa20a88e1f0c64e0eb96c.zip
Merging upstream version 1.42.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'daemon/daemon.c')
-rw-r--r--daemon/daemon.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/daemon/daemon.c b/daemon/daemon.c
index 0d1d17324..c7f0b51c6 100644
--- a/daemon/daemon.c
+++ b/daemon/daemon.c
@@ -4,11 +4,11 @@
#include <sched.h>
char pidfile[FILENAME_MAX + 1] = "";
-char claimingdirectory[FILENAME_MAX + 1];
-char exepath[FILENAME_MAX + 1];
+char claiming_directory[FILENAME_MAX + 1];
+char netdata_exe_path[FILENAME_MAX + 1];
+char netdata_exe_file[FILENAME_MAX + 1];
-void get_netdata_execution_path(void)
-{
+void get_netdata_execution_path(void) {
int ret;
size_t exepath_size = 0;
struct passwd *passwd = NULL;
@@ -17,14 +17,18 @@ void get_netdata_execution_path(void)
passwd = getpwuid(getuid());
user = (passwd && passwd->pw_name) ? passwd->pw_name : "";
- exepath_size = sizeof(exepath) - 1;
- ret = uv_exepath(exepath, &exepath_size);
+ exepath_size = sizeof(netdata_exe_file) - 1;
+ ret = uv_exepath(netdata_exe_file, &exepath_size);
if (0 != ret) {
- netdata_log_error("uv_exepath(\"%s\", %u) (user: %s) failed (%s).", exepath, (unsigned)exepath_size, user,
- uv_strerror(ret));
+ netdata_log_error("uv_exepath(\"%s\", %u) (user: %s) failed (%s).", netdata_exe_file, (unsigned)exepath_size, user,
+ uv_strerror(ret));
fatal("Cannot start netdata without getting execution path.");
}
- exepath[exepath_size] = '\0';
+
+ netdata_exe_file[exepath_size] = '\0';
+
+ strcpy(netdata_exe_path, netdata_exe_file);
+ dirname(netdata_exe_path);
}
static void chown_open_file(int fd, uid_t uid, gid_t gid) {
@@ -99,7 +103,7 @@ void prepare_required_directories(uid_t uid, gid_t gid) {
change_dir_ownership(netdata_configured_varlib_dir, uid, gid, false);
change_dir_ownership(netdata_configured_lock_dir, uid, gid, false);
change_dir_ownership(netdata_configured_log_dir, uid, gid, false);
- change_dir_ownership(claimingdirectory, uid, gid, false);
+ change_dir_ownership(claiming_directory, uid, gid, false);
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/registry", netdata_configured_varlib_dir);
@@ -516,7 +520,7 @@ int become_daemon(int dont_fork, const char *user)
sched_setscheduler_set();
// Set claiming directory based on user config directory with correct ownership
- snprintfz(claimingdirectory, FILENAME_MAX, "%s/cloud.d", netdata_configured_varlib_dir);
+ snprintfz(claiming_directory, FILENAME_MAX, "%s/cloud.d", netdata_configured_varlib_dir);
if(user && *user) {
if(become_user(user, pidfd) != 0) {