From 1e192e901ccf34454967cc3f62a71432c50f2c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 17 Jan 2017 02:35:16 +0200 Subject: [PATCH] Post merge review fixes * Remove duplicate lines from tests * Use thd instead of current_thd * Remove extra wsrep_binlog_format_names * Correctly merge union patch from 5.5 wrt duplicate rows. * Correctly merge SELinux changes into 10.1 --- .gitignore | 2 +- .../suite/rpl/r/rpl_row_mysqlbinlog.result | 1 - .../suite/rpl/t/rpl_row_mysqlbinlog.test | 2 - scripts/mysqld_safe.sh | 4 - sql/item.cc | 2 +- sql/mysqld.cc | 4 - sql/sql_select.cc | 2 +- support-files/CMakeLists.txt | 20 ++- support-files/SELinux/CMakeLists.txt | 35 ----- support-files/SELinux/rhel4-mysql.fc | 41 ----- support-files/SELinux/rhel4-mysql.te | 147 ------------------ .../selinux/mysqld-safe.te} | 0 support-files/rpm/server-postin.sh | 2 +- 13 files changed, 23 insertions(+), 239 deletions(-) delete mode 100644 support-files/SELinux/CMakeLists.txt delete mode 100644 support-files/SELinux/rhel4-mysql.fc delete mode 100644 support-files/SELinux/rhel4-mysql.te rename support-files/{SELinux/centos6-mariadb.te => policy/selinux/mysqld-safe.te} (100%) diff --git a/.gitignore b/.gitignore index c76b08477c9ec..5d882f268ff3f 100644 --- a/.gitignore +++ b/.gitignore @@ -218,7 +218,7 @@ support-files/mysql.spec support-files/mysqld_multi.server support-files/wsrep.cnf support-files/wsrep_notify -support-files/SELinux/centos6-mariadb.pp +support-files/policy/selinux/mysqld-safe.pp tags tests/async_queries tests/bug25714 diff --git a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result index 08a2237df394e..7c7c6997b07a8 100644 --- a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result +++ b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result @@ -1,7 +1,6 @@ include/master-slave.inc [connection master] ---Setup Section -- ----Setup Section -- set timestamp=1000000000; CREATE TABLE t1(word VARCHAR(20)); CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY); diff --git a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test index 6f17824f43e20..678679f0cf132 100644 --- a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test +++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test @@ -11,8 +11,6 @@ --echo ---Setup Section -- ---echo ---Setup Section -- - # we need this for getting fixed timestamps inside of this test set timestamp=1000000000; diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 8faa11467d45b..59f69e79a5532 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -975,10 +975,6 @@ cmd="$cmd $args" # Avoid 'nohup: ignoring input' warning test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null" -# close stdout and stderr, everything goes to $logging now -exec 1>&- -exec 2>&- - log_notice "Starting $MYSQLD daemon with databases from $DATADIR" # variable to track the current number of "fast" (a.k.a. subsecond) restarts diff --git a/sql/item.cc b/sql/item.cc index 2e7bc8e20c0ae..643e5c85df55e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1133,7 +1133,7 @@ Item *Item_cache::safe_charset_converter(THD *thd, CHARSET_INFO *tocs) if (conv == example) return this; Item_cache *cache; - if (!conv || conv->fix_fields(current_thd, (Item **) NULL) || + if (!conv || conv->fix_fields(thd, (Item **) NULL) || !(cache= new (thd->mem_root) Item_cache_str(thd, conv))) return NULL; // Safe conversion is not possible, or OEM cache->setup(thd, conv); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b0bb0e5cd2282..5ff56daf7c2d8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -480,10 +480,6 @@ ulong opt_binlog_rows_event_max_size; my_bool opt_master_verify_checksum= 0; my_bool opt_slave_sql_verify_checksum= 1; const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS}; -#ifdef WITH_WSREP -const char *wsrep_binlog_format_names[]= - {"MIXED", "STATEMENT", "ROW", "NONE", NullS}; -#endif /* WITH_WSREP */ volatile sig_atomic_t calling_initgroups= 0; /**< Used in SIGSEGV handler. */ uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options; uint mysqld_extra_port; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f299e863bf268..1bd101bbe6f69 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -17972,7 +17972,7 @@ do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) error= NESTED_LOOP_OK; /* select_limit used */ } - join->thd->limit_found_rows= join->send_records; + join->thd->limit_found_rows= join->send_records - join->duplicate_rows; if (error == NESTED_LOOP_NO_MORE_ROWS || join->thd->killed == ABORT_QUERY) error= NESTED_LOOP_OK; diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index e2c449d3b80f4..40a28e6762548 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -56,10 +56,28 @@ IF(UNIX) INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${script} DESTINATION ${inst_location} COMPONENT Server_Scripts) ENDFOREACH() + + FIND_PROGRAM(CHECKMODULE checkmodule) + FIND_PROGRAM(SEMODULE_PACKAGE semodule_package) + MARK_AS_ADVANCED(CHECKMODULE SEMODULE_PACKAGE) + + # Build pp files in policy/selinux + IF(CHECKMODULE AND SEMODULE_PACKAGE) + FOREACH(pol mysqld-safe) + SET(src ${CMAKE_CURRENT_SOURCE_DIR}/policy/selinux/${pol}.te) + SET(mod ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${pol}-pp.dir/${pol}.mod) + SET(out ${CMAKE_CURRENT_SOURCE_DIR}/policy/selinux/${pol}.pp) + ADD_CUSTOM_COMMAND(OUTPUT ${out} + COMMAND ${CHECKMODULE} -M -m ${src} -o ${mod} + COMMAND ${SEMODULE_PACKAGE} -m ${mod} -o ${out} + DEPENDS ${src}) + ADD_CUSTOM_TARGET(${pol}-pp ALL DEPENDS ${out}) + ENDFOREACH() + ENDIF() + IF(INSTALL_SUPPORTFILESDIR) INSTALL(FILES magic DESTINATION ${inst_location} COMPONENT SupportFiles) INSTALL(DIRECTORY policy DESTINATION ${inst_location} COMPONENT SupportFiles) - ADD_SUBDIRECTORY(SELinux) ENDIF() CONFIGURE_FILE(mariadb.pc.in ${CMAKE_CURRENT_BINARY_DIR}/mariadb.pc @ONLY) diff --git a/support-files/SELinux/CMakeLists.txt b/support-files/SELinux/CMakeLists.txt deleted file mode 100644 index e3cdb26ca8fa9..0000000000000 --- a/support-files/SELinux/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2017, MariaDB -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -FIND_PROGRAM(CHECKMODULE checkmodule) -FIND_PROGRAM(SEMODULE_PACKAGE semodule_package) -MARK_AS_ADVANCED(CHECKMODULE SEMODULE_PACKAGE) - -SET(params DESTINATION ${INSTALL_SUPPORTFILESDIR}/SELinux COMPONENT SupportFiles) - -IF(CHECKMODULE AND SEMODULE_PACKAGE) - FOREACH(pol centos6-mariadb) - SET(src ${CMAKE_CURRENT_SOURCE_DIR}/${pol}.te) - SET(mod ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${pol}-pp.dir/${pol}.mod) - SET(out ${CMAKE_CURRENT_BINARY_DIR}/${pol}.pp) - ADD_CUSTOM_COMMAND(OUTPUT ${out} - COMMAND ${CHECKMODULE} -M -m ${src} -o ${mod} - COMMAND ${SEMODULE_PACKAGE} -m ${mod} -o ${out} - DEPENDS ${src}) - ADD_CUSTOM_TARGET(${pol}-pp ALL DEPENDS ${out}) - INSTALL(FILES ${out} ${params}) - ENDFOREACH() -ENDIF() -INSTALL(FILES centos6-mariadb.te rhel4-mysql.fc rhel4-mysql.te ${params}) diff --git a/support-files/SELinux/rhel4-mysql.fc b/support-files/SELinux/rhel4-mysql.fc deleted file mode 100644 index aa0fced4bbc42..0000000000000 --- a/support-files/SELinux/rhel4-mysql.fc +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2007 MySQL AB -# Use is subject to license terms -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - -# MySQL Database Server - -# -# /etc -# -/etc/my\.cnf -- gen_context(system_u:object_r:mysqld_etc_t,s0) -/etc/mysql(/.*)? gen_context(system_u:object_r:mysqld_etc_t,s0) - -# -# /usr -# Red Hat compatibility -/usr/libexec/mysqld -- gen_context(system_u:object_r:mysqld_exec_t,s0) - -# MySQL AB compatibility -/usr/sbin/mysqld(-max)? -- gen_context(system_u:object_r:mysqld_exec_t,s0) - -# -# /var -# -/var/lib/mysql(/.*)? gen_context(system_u:object_r:mysqld_db_t,s0) -/var/lib/mysql/mysql\.sock -s gen_context(system_u:object_r:mysqld_var_run_t,s0) - -/var/log/mysql.* -- gen_context(system_u:object_r:mysqld_log_t,s0) - -/var/run/mysqld(/.*)? gen_context(system_u:object_r:mysqld_var_run_t,s0) diff --git a/support-files/SELinux/rhel4-mysql.te b/support-files/SELinux/rhel4-mysql.te deleted file mode 100644 index d26092446401b..0000000000000 --- a/support-files/SELinux/rhel4-mysql.te +++ /dev/null @@ -1,147 +0,0 @@ -# Copyright (C) 2007 MySQL AB -# Use is subject to license terms -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - -policy_module(mysql,1.0.0) - -######################################## -# -# Declarations -# - -type mysqld_t; -type mysqld_exec_t; -init_daemon_domain(mysqld_t,mysqld_exec_t) - -type mysqld_var_run_t; -files_pid_file(mysqld_var_run_t) - -type mysqld_db_t; -files_type(mysqld_db_t) - -type mysqld_etc_t alias etc_mysqld_t; -files_config_file(mysqld_etc_t) - -type mysqld_log_t; -logging_log_file(mysqld_log_t) - -type mysqld_tmp_t; -files_tmp_file(mysqld_tmp_t) - -######################################## -# -# Local policy -# - -allow mysqld_t self:capability { dac_override setgid setuid sys_resource net_bind_service }; -dontaudit mysqld_t self:capability sys_tty_config; -allow mysqld_t self:process { setsched getsched setrlimit signal_perms rlimitinh }; -allow mysqld_t self:fifo_file { read write }; -allow mysqld_t self:unix_stream_socket create_stream_socket_perms; -allow mysqld_t self:tcp_socket create_stream_socket_perms; -allow mysqld_t self:udp_socket create_socket_perms; - -allow mysqld_t mysqld_db_t:dir create_dir_perms; -allow mysqld_t mysqld_db_t:file create_file_perms; -allow mysqld_t mysqld_db_t:lnk_file create_lnk_perms; -files_var_lib_filetrans(mysqld_t,mysqld_db_t,{ dir file }) - -allow mysqld_t mysqld_etc_t:file { getattr read }; -allow mysqld_t mysqld_etc_t:lnk_file { getattr read }; -allow mysqld_t mysqld_etc_t:dir list_dir_perms; - -allow mysqld_t mysqld_log_t:file create_file_perms; -logging_log_filetrans(mysqld_t,mysqld_log_t,file) - -allow mysqld_t mysqld_tmp_t:dir create_dir_perms; -allow mysqld_t mysqld_tmp_t:file create_file_perms; -files_tmp_filetrans(mysqld_t, mysqld_tmp_t, { file dir }) - -allow mysqld_t mysqld_var_run_t:dir rw_dir_perms; -allow mysqld_t mysqld_var_run_t:sock_file create_file_perms; -allow mysqld_t mysqld_var_run_t:file create_file_perms; -files_pid_filetrans(mysqld_t,mysqld_var_run_t,file) - -kernel_read_system_state(mysqld_t) -kernel_read_kernel_sysctls(mysqld_t) - -corenet_non_ipsec_sendrecv(mysqld_t) -corenet_tcp_sendrecv_all_if(mysqld_t) -corenet_udp_sendrecv_all_if(mysqld_t) -corenet_tcp_sendrecv_all_nodes(mysqld_t) -corenet_udp_sendrecv_all_nodes(mysqld_t) -corenet_tcp_sendrecv_all_ports(mysqld_t) -corenet_udp_sendrecv_all_ports(mysqld_t) -corenet_tcp_bind_all_nodes(mysqld_t) -corenet_tcp_bind_mysqld_port(mysqld_t) -corenet_tcp_connect_mysqld_port(mysqld_t) -corenet_sendrecv_mysqld_client_packets(mysqld_t) -corenet_sendrecv_mysqld_server_packets(mysqld_t) - -dev_read_sysfs(mysqld_t) - -fs_getattr_all_fs(mysqld_t) -fs_search_auto_mountpoints(mysqld_t) - -term_dontaudit_use_console(mysqld_t) - -domain_use_interactive_fds(mysqld_t) - -files_getattr_var_lib_dirs(mysqld_t) -files_read_etc_runtime_files(mysqld_t) -files_read_etc_files(mysqld_t) -files_read_usr_files(mysqld_t) -files_search_var_lib(mysqld_t) - -auth_use_nsswitch(mysqld_t) - -init_use_fds(mysqld_t) -init_use_script_ptys(mysqld_t) - -libs_use_ld_so(mysqld_t) -libs_use_shared_libs(mysqld_t) - -logging_send_syslog_msg(mysqld_t) - -miscfiles_read_localization(mysqld_t) - -sysnet_read_config(mysqld_t) - -userdom_dontaudit_use_unpriv_user_fds(mysqld_t) -# for /root/.my.cnf - should not be needed: -userdom_read_sysadm_home_content_files(mysqld_t) - -ifdef(`distro_redhat',` - # because Fedora has the sock_file in the database directory - type_transition mysqld_t mysqld_db_t:sock_file mysqld_var_run_t; -') - -ifdef(`targeted_policy',` - term_dontaudit_use_unallocated_ttys(mysqld_t) - term_dontaudit_use_generic_ptys(mysqld_t) - files_dontaudit_read_root_files(mysqld_t) -') - -optional_policy(` - daemontools_service_domain(mysqld_t, mysqld_exec_t) -') - -optional_policy(` - seutil_sigchld_newrole(mysqld_t) -') - -optional_policy(` - udev_read_db(mysqld_t) -') diff --git a/support-files/SELinux/centos6-mariadb.te b/support-files/policy/selinux/mysqld-safe.te similarity index 100% rename from support-files/SELinux/centos6-mariadb.te rename to support-files/policy/selinux/mysqld-safe.te diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh index fca66a96c041c..bdce35b1d0edd 100644 --- a/support-files/rpm/server-postin.sh +++ b/support-files/rpm/server-postin.sh @@ -96,7 +96,7 @@ if [ -f /etc/redhat-release ] ; then fi if grep 'CentOS release 6' /etc/redhat-release >/dev/null 2>&1; then if [ -x /usr/sbin/semodule ] ; then - /usr/sbin/semodule -i /usr/share/mysql/SELinux/centos6-mariadb.pp + /usr/sbin/semodule -i /usr/share/mysql/policy/selinux/mysqld-safe.pp fi fi fi