summaryrefslogtreecommitdiffstats
path: root/src/daemon/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/daemon/daemon.c (renamed from daemon/daemon.c)14
1 files changed, 7 insertions, 7 deletions
diff --git a/daemon/daemon.c b/src/daemon/daemon.c
index 433fa0373..d9a4b81de 100644
--- a/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -60,7 +60,7 @@ static void fix_directory_file_permissions(const char *dirname, uid_t uid, gid_t
closedir(dir);
}
-void change_dir_ownership(const char *dir, uid_t uid, gid_t gid, bool recursive)
+static void change_dir_ownership(const char *dir, uid_t uid, gid_t gid, bool recursive)
{
if (chown(dir, uid, gid) == -1)
netdata_log_error("Cannot chown directory '%s' to %u:%u", dir, (unsigned int)uid, (unsigned int)gid);
@@ -68,7 +68,7 @@ void change_dir_ownership(const char *dir, uid_t uid, gid_t gid, bool recursive)
fix_directory_file_permissions(dir, uid, gid, recursive);
}
-void clean_directory(char *dirname)
+static void clean_directory(char *dirname)
{
DIR *dir = opendir(dirname);
if(!dir) return;
@@ -84,7 +84,7 @@ void clean_directory(char *dirname)
closedir(dir);
}
-void prepare_required_directories(uid_t uid, gid_t gid) {
+static void prepare_required_directories(uid_t uid, gid_t gid) {
change_dir_ownership(netdata_configured_cache_dir, uid, gid, true);
change_dir_ownership(netdata_configured_varlib_dir, uid, gid, false);
change_dir_ownership(netdata_configured_lock_dir, uid, gid, false);
@@ -98,7 +98,7 @@ void prepare_required_directories(uid_t uid, gid_t gid) {
clean_directory(netdata_configured_lock_dir);
}
-int become_user(const char *username, int pid_fd) {
+static int become_user(const char *username, int pid_fd) {
int am_i_root = (getuid() == 0)?1:0;
struct passwd *pw = getpwnam(username);
@@ -245,7 +245,7 @@ static void oom_score_adj(void) {
}
int written = 0;
- int fd = open("/proc/self/oom_score_adj", O_WRONLY);
+ int fd = open("/proc/self/oom_score_adj", O_WRONLY | O_CLOEXEC);
if(fd != -1) {
snprintfz(buf, sizeof(buf) - 1, "%d", (int)wanted_score);
ssize_t len = strlen(buf);
@@ -276,7 +276,7 @@ static void process_nice_level(void) {
else
netdata_log_debug(D_SYSTEM, "Set netdata nice level to %d.", nice_level);
#endif // HAVE_NICE
-};
+}
#define SCHED_FLAG_NONE 0x00
#define SCHED_FLAG_PRIORITY_CONFIGURABLE 0x01 // the priority is user configurable
@@ -478,7 +478,7 @@ int become_daemon(int dont_fork, const char *user)
// generate our pid file
int pidfd = -1;
if(pidfile[0]) {
- pidfd = open(pidfile, O_WRONLY | O_CREAT, 0644);
+ pidfd = open(pidfile, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);
if(pidfd >= 0) {
if(ftruncate(pidfd, 0) != 0)
netdata_log_error("Cannot truncate pidfile '%s'.", pidfile);