mirror of https://github.com/BOINC/boinc.git
check return value of mkdir()
Also gives a more sensible error message where get_log_path() is used. fixes CID 27696 found by Coverity
This commit is contained in:
parent
c19cb4675f
commit
b031fff422
|
@ -677,7 +677,9 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
installer();
|
||||
|
||||
get_log_path(log_path, "file_upload_handler.log");
|
||||
if (get_log_path(log_path, "file_upload_handler.log") == ERR_MKDIR) {
|
||||
fprintf(stderr, "Can't create log directory '%s' (errno: %d)\n", log_path, errno);
|
||||
}
|
||||
#ifndef _USING_FCGI_
|
||||
if (!freopen(log_path, "a", stderr)) {
|
||||
fprintf(stderr, "Can't open log file '%s' (errno: %d)\n",
|
||||
|
|
|
@ -429,7 +429,9 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
} else {
|
||||
char *stderr_buffer;
|
||||
get_log_path(path, "scheduler.log");
|
||||
if (get_log_path(path, "scheduler.log") == ERR_MKDIR) {
|
||||
fprintf(stderr, "Can't create log directory '%s' (errno: %d)\n", path, errno);
|
||||
}
|
||||
#ifndef _USING_FCGI_
|
||||
char buf[256];
|
||||
if (!freopen(path, "a", stderr)) {
|
||||
|
|
|
@ -143,7 +143,7 @@ int try_fopen(const char* path, FCGI_FILE*& f, const char *mode) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void get_log_path(char* p, const char* filename) {
|
||||
int get_log_path(char* p, const char* filename) {
|
||||
char host[256];
|
||||
const char *dir;
|
||||
|
||||
|
@ -153,10 +153,13 @@ void get_log_path(char* p, const char* filename) {
|
|||
dir = config.project_path("log_%s", host);
|
||||
sprintf(p, "%s/%s", dir, filename);
|
||||
mode_t old_mask = umask(0);
|
||||
mkdir(dir, 01770);
|
||||
// make log_x directory sticky and group-rwx
|
||||
// so that whatever apache puts there will be owned by us
|
||||
int retval = mkdir(dir, 01770);
|
||||
umask(old_mask);
|
||||
if (retval && errno != EEXIST) return ERR_MKDIR;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void filename_hash(const char* filename, int fanout, char* dir) {
|
||||
|
|
|
@ -38,7 +38,7 @@ extern void daemon_sleep(int);
|
|||
extern bool check_stop_sched();
|
||||
extern void install_stop_signal_handler();
|
||||
extern int try_fopen(const char* path, FILE*& f, const char* mode);
|
||||
extern void get_log_path(char*, const char*);
|
||||
extern int get_log_path(char*, const char*);
|
||||
|
||||
// convert filename to path in a hierarchical directory system
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue