diff options
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 106 |
1 files changed, 82 insertions, 24 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b35e2545a18..db0080451f2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -400,6 +400,7 @@ ulonglong log_output_options; my_bool opt_log_queries_not_using_indexes= 0; bool opt_error_log= IF_WIN(1,0); bool opt_disable_networking=0, opt_skip_show_db=0; +bool opt_skip_name_resolve=0; my_bool opt_character_set_client_handshake= 1; bool server_id_supplied = 0; bool opt_endinfo, using_udf_functions; @@ -856,12 +857,15 @@ void Buffered_logs::print() /** Logs reported before a logger is available. */ static Buffered_logs buffered_logs; +#ifndef EMBEDDED_LIBRARY /** Error reporter that buffer log messages. @param level log message level @param format log message format string */ -void buffered_option_error_reporter(enum loglevel level, const char *format, ...) +C_MODE_START +static void buffered_option_error_reporter(enum loglevel level, + const char *format, ...) { va_list args; char buffer[1024]; @@ -871,6 +875,8 @@ void buffered_option_error_reporter(enum loglevel level, const char *format, ... va_end(args); buffered_logs.buffer(level, buffer); } +C_MODE_END +#endif /* !EMBEDDED_LIBRARY */ #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ static my_socket unix_sock,ip_sock; @@ -972,7 +978,6 @@ uint connection_count= 0; pthread_handler_t signal_hand(void *arg); static int mysql_init_variables(void); -extern "C" void option_error_reporter(enum loglevel level, const char *format, ...); static int get_options(int *argc_ptr, char ***argv_ptr); static bool add_terminator(DYNAMIC_ARRAY *options); extern "C" my_bool mysqld_get_one_option(int, const struct my_option *, char *); @@ -3600,7 +3605,6 @@ static int init_common_variables() if (item_create_init()) return 1; item_init(); - mysys_uses_curses=0; #ifdef USE_REGEX my_regex_init(&my_charset_latin1); #endif @@ -4020,9 +4024,8 @@ static int init_server_components() } } - proc_info_hook= (const char *(*)(void *, const char *, const char *, - const char *, const unsigned int)) - set_thd_proc_info; + proc_info_hook= set_thd_proc_info; + #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE /* Parsing the performance schema command line option may have reported @@ -5343,11 +5346,11 @@ inline void kill_broken_server() void handle_connections_sockets() { - my_socket sock,new_sock; + my_socket UNINIT_VAR(sock), UNINIT_VAR(new_sock); uint error_count=0; THD *thd; struct sockaddr_storage cAddr; - int ip_flags=0,socket_flags=0,flags,retval; + int ip_flags=0,socket_flags=0,flags=0,retval; st_vio *vio_tmp; #ifdef HAVE_POLL int socket_count= 0; @@ -5359,8 +5362,6 @@ void handle_connections_sockets() DBUG_ENTER("handle_connections_sockets"); - LINT_INIT(new_sock); - #ifndef HAVE_POLL FD_ZERO(&clientFDs); #endif @@ -6211,9 +6212,6 @@ Can't be set to 1 if --log-slave-updates is used.", #endif {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"skip-name-resolve", OPT_SKIP_RESOLVE, - "Don't resolve hostnames. All hostnames are IP's or 'localhost'.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-new", OPT_SKIP_NEW, "Don't use new, possibly wrong routines.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-slave-start", 0, @@ -6965,6 +6963,7 @@ static int mysql_init_variables(void) opt_log= opt_slow_log= 0; opt_bin_log= 0; opt_disable_networking= opt_skip_show_db=0; + opt_skip_name_resolve= 0; opt_ignore_builtin_innodb= 0; opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0; opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name ! @@ -7334,6 +7333,7 @@ mysqld_get_one_option(int optid, opt_specialflag|= SPECIAL_NO_HOST_CACHE; break; case (int) OPT_SKIP_RESOLVE: + opt_skip_name_resolve= 1; opt_specialflag|=SPECIAL_NO_RESOLVE; break; case (int) OPT_WANT_CORE: @@ -7423,10 +7423,7 @@ mysqld_get_one_option(int optid, /** Handle arguments for multiple key caches. */ -extern "C" int mysql_getopt_value(uchar **value, - const char *keyname, uint key_length, - const struct my_option *option, - int *error); +C_MODE_START static uchar* * mysql_getopt_value(const char *keyname, uint key_length, @@ -7462,7 +7459,7 @@ mysql_getopt_value(const char *keyname, uint key_length, return option->value; } -void option_error_reporter(enum loglevel level, const char *format, ...) +static void option_error_reporter(enum loglevel level, const char *format, ...) { va_list args; va_start(args, format); @@ -7476,6 +7473,7 @@ void option_error_reporter(enum loglevel level, const char *format, ...) va_end(args); } +C_MODE_END /** Get server options from the command line, @@ -7711,6 +7709,48 @@ fn_format_relative_to_data_home(char * to, const char *name, } +/** + Test a file path to determine if the path is compatible with the secure file + path restriction. + + @param path null terminated character string + + @return + @retval TRUE The path is secure + @retval FALSE The path isn't secure +*/ + +bool is_secure_file_path(char *path) +{ + char buff1[FN_REFLEN], buff2[FN_REFLEN]; + /* + All paths are secure if opt_secure_file_path is 0 + */ + if (!opt_secure_file_priv) + return TRUE; + + if (strlen(path) >= FN_REFLEN) + return FALSE; + + if (my_realpath(buff1, path, 0)) + { + /* + The supplied file path might have been a file and not a directory. + */ + int length= (int)dirname_length(path); + if (length >= FN_REFLEN) + return FALSE; + memcpy(buff2, path, length); + buff2[length]= '\0'; + if (length == 0 || my_realpath(buff1, buff2, 0)) + return FALSE; + } + convert_dirname(buff2, buff1, NullS); + if (strncmp(opt_secure_file_priv, buff2, strlen(opt_secure_file_priv))) + return FALSE; + return TRUE; +} + static int fix_paths(void) { char buff[FN_REFLEN],*pos; @@ -7771,10 +7811,26 @@ static int fix_paths(void) */ if (opt_secure_file_priv) { - convert_dirname(buff, opt_secure_file_priv, NullS); - x_free(opt_secure_file_priv); - opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE)); + if (*opt_secure_file_priv == 0) + { + opt_secure_file_priv= 0; + } + else + { + if (strlen(opt_secure_file_priv) >= FN_REFLEN) + opt_secure_file_priv[FN_REFLEN-1]= '\0'; + if (my_realpath(buff, opt_secure_file_priv, 0)) + { + sql_print_warning("Failed to normalize the argument for --secure-file-priv."); + return 1; + } + char *secure_file_real_path= (char *)my_malloc(FN_REFLEN, MYF(MY_FAE)); + convert_dirname(secure_file_real_path, buff, NullS); + my_free(opt_secure_file_priv, MYF(0)); + opt_secure_file_priv= secure_file_real_path; + } } + return 0; } @@ -7918,8 +7974,9 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, key_master_info_data_lock, key_master_info_run_lock, key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock, key_relay_log_info_log_space_lock, key_relay_log_info_run_lock, - key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data, key_LOCK_error_messages, - key_LOG_INFO_lock, key_LOCK_thread_count; + key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data, + key_LOCK_error_messages, key_LOG_INFO_lock, key_LOCK_thread_count, + key_PARTITION_LOCK_auto_inc; static PSI_mutex_info all_server_mutexes[]= { @@ -7973,7 +8030,8 @@ static PSI_mutex_info all_server_mutexes[]= { &key_TABLE_SHARE_LOCK_ha_data, "TABLE_SHARE::LOCK_ha_data", 0}, { &key_LOCK_error_messages, "LOCK_error_messages", PSI_FLAG_GLOBAL}, { &key_LOG_INFO_lock, "LOG_INFO::lock", 0}, - { &key_LOCK_thread_count, "LOCK_thread_count", PSI_FLAG_GLOBAL} + { &key_LOCK_thread_count, "LOCK_thread_count", PSI_FLAG_GLOBAL}, + { &key_PARTITION_LOCK_auto_inc, "HA_DATA_PARTITION::LOCK_auto_inc", 0} }; PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger, |