Correct mkdir logic for default log directory.

This commit is contained in:
counterpoint
2015-07-01 09:46:01 +01:00
parent 6c61dabfab
commit cc24777a90

View File

@ -1531,17 +1531,13 @@ int main(int argc, char **argv)
/** Use default log directory /var/log/maxscale/ */ /** Use default log directory /var/log/maxscale/ */
if(logdir == NULL) if(logdir == NULL)
{ {
if(mkdir(default_logdir,0777) != 0 && errno != EEXIST)
if(access(default_logdir,F_OK) != 0) {
{ fprintf(stderr,
if(mkdir(logdir,0555) != 0) "Error: Cannot create log directory: %s\n",
{ default_logdir);
fprintf(stderr, goto return_main;
"Error: Cannot create log directory: %s\n", }
default_logdir);
goto return_main;
}
}
logdir = strdup(default_logdir); logdir = strdup(default_logdir);
} }
@ -1598,7 +1594,7 @@ int main(int argc, char **argv)
/** /**
* Set a data directory for the mysqld library, we use * Set a data directory for the mysqld library, we use
* a unique directory name to avoid clauses if multiple * a unique directory name to avoid clauses if multiple
* instances of the gateway are beign run on the same * instances of the gateway are being run on the same
* machine. * machine.
*/ */