diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index 2ab79f5c5..8092e3a1a 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -258,7 +258,7 @@ static void blockbuf_register(blockbuf_t* bb); static void blockbuf_unregister(blockbuf_t* bb); static bool logfile_set_enabled(logfile_id_t id, bool val); static char* add_slash(char* str); -static bool file_exists(char* filename); +static bool file_exists_and_is_writable(char* filename); static bool file_is_symlink(char* filename); @@ -1800,9 +1800,11 @@ static char* add_slash( * * * @details Note, that an space character is written to the end of file. + * TODO: recall what was the reason for not succeeding with simply + * calling access, and fstat. vraa 26.11.13 * */ -static bool file_exists( +static bool file_exists_and_is_writable( char* filename, bool* writable) { @@ -1815,7 +1817,7 @@ static bool file_exists( } else { - fd = open(filename, O_CREAT|O_EXCL); + fd = open(filename, O_CREAT|O_EXCL, S_IRWXU); /** file exist */ if (fd == -1) @@ -1979,7 +1981,8 @@ static bool logfile_init( * If file exists but is different type, create fails and * new, increased sequence number is added to file name. */ - if (file_exists(logfile->lf_full_file_name, &writable)) + if (file_exists_and_is_writable(logfile->lf_full_file_name, + &writable)) { if (!writable || file_is_symlink(logfile->lf_full_file_name)) @@ -1993,7 +1996,9 @@ static bool logfile_init( { writable = false; - if (file_exists(logfile->lf_full_link_name, &writable)) + if (file_exists_and_is_writable( + logfile->lf_full_link_name, + &writable)) { if (!writable || !file_is_symlink(logfile->lf_full_link_name)) diff --git a/server/core/gateway.c b/server/core/gateway.c index 5b6551de0..8882578ab 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -514,8 +514,11 @@ int main(int argc, char **argv) goto return_main; } } - +#if 0 while ((opt = getopt(argc, argv, "dc:m:")) != -1) +#else + while ((opt = getopt(argc, argv, "dc:")) != -1) +#endif { bool succp = true; @@ -555,7 +558,7 @@ int main(int argc, char **argv) print_log_n_stderr(true, true, logerr, logerr, 0); } break; - +#if 0 case 'm': { char* ldlib_env = getenv("LD_LIBRARY_PATH"); @@ -611,11 +614,17 @@ int main(int argc, char **argv) free(abs_path); } break; - +#endif default: +#if 0 fprintf(stderr, "*\n* Usage : maxscale [-d] [-c ] [-m ]\n*\n"); +#else + fprintf(stderr, + "*\n* Usage : maxscale [-d] [-c ]\n*\n"); +#endif succp = false; break; } @@ -780,7 +789,7 @@ int main(int argc, char **argv) } /** * 2. if home dir wasn't specified in MAXSCALE_HOME, - * try access /etc/MaxScale.cnf. + * try access /etc/MaxScale/MaxScale.cnf. */ if (home_dir == NULL) { @@ -788,7 +797,7 @@ int main(int argc, char **argv) cnf_file = get_config_filename(&home_dir, tmp); } /** - * 3. if /etc/MaxScale.cnf didn't exist or wasn't accessible, home + * 3. if /etc/MaxScale/MaxScale.cnf didn't exist or wasn't accessible, home * isn't specified. Thus, try to access $PWD/MaxScale.cnf . */ if (home_dir == NULL)