diff --git a/mysys/my_default.cc b/mysys/my_default.cc index 1317e3627bc..37ef4146efa 100644 --- a/mysys/my_default.cc +++ b/mysys/my_default.cc @@ -127,6 +127,8 @@ extern PSI_file_key key_file_cnf; #endif PSI_memory_key key_memory_defaults; +#define ALT_LOAD_DEFAULTS + /** arguments separator @@ -908,6 +910,21 @@ static int search_default_file_with_ext(Process_option_func opt_handler, } else { if (!(fp = mysql_file_fopen(key_file_cnf, name, O_RDONLY, MYF(0)))) return 1; /* Ignore wrong files */ + +#ifdef ALT_LOAD_DEFAULTS + /* Check for untrusted source. */ + /* FIXME: seems like race condition by now, need review! + { + struct stat st; + if (fstat (fileno(fp), &st) < 0) + goto success; + + if (!getuid() && (st.st_uid || (st.st_mode & 022))) + goto success; + } + */ +#endif /* ALT_LOAD_DEFAULTS */ + } while (mysql_file_getline(buff, sizeof(buff) - 1, fp, is_login_file)) { @@ -1111,6 +1128,10 @@ static int search_default_file_with_ext(Process_option_func opt_handler, if (opt_handler(handler_ctx, curr_gr, option, name)) goto err; } } + +#ifdef ALT_LOAD_DEFAULTS +success: +#endif /* ALT_LOAD_DEFAULTS */ mysql_file_fclose(fp, MYF(0)); return (0); @@ -1578,6 +1599,12 @@ static const char **init_default_directories(MEM_ROOT *alloc) { errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs); #endif /* DEFAULT_SYSCONFDIR */ +#ifdef ALT_LOAD_DEFAULTS + /* FIXME: it *is* defined but /var/lib/mysql/my.cnf gets ignored somehow */ + /* #ifdef MYSQL_DATADIR */ + errors += add_directory(alloc, MYSQL_DATADIR, dirs); + /* #endif */ +#endif /* ALT_LOAD_DEFAULTS */ #endif if ((env = getenv("MYSQL_HOME"))) errors += add_directory(alloc, env, dirs);