diff --git a/base/logging.c b/base/logging.c index cc0245086..a222415aa 100644 --- a/base/logging.c +++ b/base/logging.c @@ -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*/ diff --git a/base/utils.c b/base/utils.c index 606e682e3..976a225f4 100644 --- a/base/utils.c +++ b/base/utils.c @@ -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); @@ -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); diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c index 694ba383b..bc8765601 100644 --- a/cgi/cgiutils.c +++ b/cgi/cgiutils.c @@ -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);