Skip to content
This repository was archived by the owner on Jan 15, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion base/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,10 @@ int rotate_log_file(time_t rotation_time) {

if (stat_result == 0) {
chmod(log_file, log_file_stat.st_mode);
chown(log_file, log_file_stat.st_uid, log_file_stat.st_gid);
if (chown(log_file, log_file_stat.st_uid, log_file_stat.st_gid) < 0) {
perror("chown failed");
return ERROR;
}
}

/* log current host and service state if activated*/
Expand Down
14 changes: 11 additions & 3 deletions base/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,10 @@ int my_system_r(icinga_macros *mac, char *cmd, int timeout, int *early_timeout,
#endif

/* create a pipe */
pipe(fd);
if (pipe(fd) < 0) {
logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: pipe() in my_system_r() failed for command \"%s\"\n", cmd);
return STATE_UNKNOWN;
}

/* make the pipe non-blocking */
fcntl(fd[0], F_SETFL, O_NONBLOCK);
Expand Down Expand Up @@ -2507,9 +2510,14 @@ int daemon_init(void) {
/* change working directory. scuttle home if we're dumping core */
homedir = getenv("HOME");
if (daemon_dumps_core == TRUE && homedir != NULL)
chdir(homedir);
val = chdir(homedir);
else
chdir("/");
val = chdir("/");
if (val < 0) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Failed to change dir: %s\n", strerror(errno));
cleanup();
exit(ERROR);
}

umask(S_IWGRP | S_IWOTH);

Expand Down
5 changes: 4 additions & 1 deletion cgi/cgiutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3047,7 +3047,10 @@ int rotate_cgi_log_file() {

if (stat_result == 0) {
chmod(cgi_log_file, log_file_stat.st_mode);
chown(cgi_log_file, log_file_stat.st_uid, log_file_stat.st_gid);
if (chown(cgi_log_file, log_file_stat.st_uid, log_file_stat.st_gid) < 0) {
perror("chown failed");
return ERROR;
}
}

my_free(log_archive);
Expand Down