From 53230ba274a37fa13d65e802c6ef3766cd0c6d91 Mon Sep 17 00:00:00 2001 From: Terje Rosten Date: Wed, 16 Nov 2016 13:41:27 +0100 Subject: [PATCH 1/5] Bug#25088048 ADDITIONAL ISSUES IN MYSQLD_SAFE Don't read --ledir option from config file. Ignore current working for finding location of mysqld Remove use of chown/chmod in scripts. Be helpful only when basedir is /var/log or /var/lib. Removed unused systemd files for SLES. Set explicit basedir in scripts. --- packaging/rpm-oel/mysql-systemd-start | 4 +- packaging/rpm-oel/mysql.init | 24 +++++----- packaging/rpm-oel/mysqld.service | 2 +- packaging/rpm-sles/CMakeLists.txt | 3 +- packaging/rpm-sles/mysql-systemd-start | 66 -------------------------- packaging/rpm-sles/mysql.conf | 1 - packaging/rpm-sles/mysql.init | 13 ++--- packaging/rpm-sles/mysqld.service | 48 ------------------- scripts/mysqld_safe.sh | 18 ++++++- 9 files changed, 41 insertions(+), 138 deletions(-) delete mode 100644 packaging/rpm-sles/mysql-systemd-start delete mode 100644 packaging/rpm-sles/mysql.conf delete mode 100644 packaging/rpm-sles/mysqld.service diff --git a/packaging/rpm-oel/mysql-systemd-start b/packaging/rpm-oel/mysql-systemd-start index 231a76087ac..af6e906efe1 100644 --- a/packaging/rpm-oel/mysql-systemd-start +++ b/packaging/rpm-oel/mysql-systemd-start @@ -22,7 +22,9 @@ install_db () { datadir=$(get_option mysqld datadir "/var/lib/mysql") # Restore log, dir, perms and SELinux contexts - [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || exit 1 + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + install -d -m 0755 -omysql -gmysql "$datadir" || exit 1 + fi log=/var/log/mysqld.log [ -e $log ] || touch $log chmod 0640 $log diff --git a/packaging/rpm-oel/mysql.init b/packaging/rpm-oel/mysql.init index 75ae672801b..50d1bba017d 100644 --- a/packaging/rpm-oel/mysql.init +++ b/packaging/rpm-oel/mysql.init @@ -70,18 +70,19 @@ start(){ ret=0 else # prepare for start - touch "$errlogfile" - chown mysql:mysql "$errlogfile" - chmod 0640 "$errlogfile" + if [ ! -e "$errlogfile" -a ! -h "$errlogfile" -a "x$(dirname "$errlogfile")" = "x/var/log" ]; then + install /dev/null -m0640 -omysql -gmysql "$errlogfile" + fi [ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile" if [ ! -d "$datadir/mysql" ] ; then # First, make sure $datadir is there with correct permissions - if [ ! -e "$datadir" -a ! -h "$datadir" ] - then - mkdir -p "$datadir" || exit 1 + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + install -d -m0755 -omysql -gmysql "$datadir" || exit 1 + fi + if [ ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + chown mysql:mysql "$datadir" + chmod 0755 "$datadir" fi - chown mysql:mysql "$datadir" - chmod 0755 "$datadir" if [ -x /sbin/restorecon ]; then /sbin/restorecon "$datadir" for dir in /var/lib/mysql-files ; do @@ -94,13 +95,14 @@ start(){ # Now create the database action $"Initializing MySQL database: " /usr/bin/mysql_install_db --rpm --datadir="$datadir" --user=mysql ret=$? - chown -R mysql:mysql "$datadir" if [ $ret -ne 0 ] ; then return $ret fi fi - chown mysql:mysql "$datadir" - chmod 0755 "$datadir" + if [ ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + chown mysql:mysql "$datadir" + chmod 0755 "$datadir" + fi # Pass all the options determined above, to ensure consistent behavior. # In many cases mysqld_safe would arrive at the same conclusions anyway # but we need to be sure. (An exception is that we don't force the diff --git a/packaging/rpm-oel/mysqld.service b/packaging/rpm-oel/mysqld.service index 78ef3bffe60..871f191c017 100644 --- a/packaging/rpm-oel/mysqld.service +++ b/packaging/rpm-oel/mysqld.service @@ -34,7 +34,7 @@ PermissionsStartOnly=true ExecStartPre=/usr/bin/mysql-systemd-start pre # Start main service -ExecStart=/usr/bin/mysqld_safe +ExecStart=/usr/bin/mysqld_safe --basedir=/usr # Don't signal startup success before a ping works ExecStartPost=/usr/bin/mysql-systemd-start post diff --git a/packaging/rpm-sles/CMakeLists.txt b/packaging/rpm-sles/CMakeLists.txt index b5ffaa15565..98aa4f4d222 100644 --- a/packaging/rpm-sles/CMakeLists.txt +++ b/packaging/rpm-sles/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -20,7 +20,6 @@ IF(UNIX) # Left in current directory, to be taken during build CONFIGURE_FILE(mysql.spec.in ${CMAKE_CURRENT_BINARY_DIR}/${SPECFILENAME} @ONLY) FOREACH(fedfile my.cnf my_config.h mysql.init - mysqld.service mysql-systemd-start mysql.conf filter-requires.sh filter-provides.sh) CONFIGURE_FILE(${fedfile} ${CMAKE_CURRENT_BINARY_DIR}/${fedfile} COPYONLY) ENDFOREACH() diff --git a/packaging/rpm-sles/mysql-systemd-start b/packaging/rpm-sles/mysql-systemd-start deleted file mode 100644 index 28472249eda..00000000000 --- a/packaging/rpm-sles/mysql-systemd-start +++ /dev/null @@ -1,66 +0,0 @@ -#! /bin/bash -# -# Scripts to run by MySQL systemd service -# -# Needed argument: pre | post -# -# pre mode : try to run mysql_install_db and fix perms and SELinux contexts -# post mode : ping server until answer is received -# - -install_db () { - # Note: something different than datadir=/var/lib/mysql requires SELinux policy changes (in enforcing mode) - datadir=$(/usr/bin/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p' | tail -n 1) - - # Restore log, dir, perms and SELinux contexts - [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || exit 1 - log=/var/log/mysqld.log - [ -e $log ] || touch $log - chmod 0640 $log - chown mysql:mysql $log || exit 1 - if [ -x /usr/sbin/restorecon ]; then - /usr/sbin/restorecon "$datadir" - /usr/sbin/restorecon $log - fi - - # If special mysql dir is in place, skip db install - [ -d "$datadir/mysql" ] && exit 0 - - # Create initial db - /usr/bin/mysql_install_db --rpm --datadir="$datadir" --user=mysql - - # Create a file to trigger execution of mysql_secure_installation - # after server has started - touch "$datadir"/.phase_two_required - - exit 0 -} - -pinger () { - # Wait for ping to answer to signal startup completed, - # might take a while in case of e.g. crash recovery - # MySQL systemd service will timeout script if no answer - ret=1 - while /bin/true ; do - sleep 1 - mysqladmin ping >/dev/null 2>&1 && ret=0 && break - done - - # If server has been started successfully and file created in - # install_db step is present we run mysql_secure_installation - if [ $ret -eq 0 -a -e "$datadir"/.phase_two_required -a -x /usr/bin/mysql_secure_installation ] ; then - /usr/bin/mysql_secure_installation --use-default --defaults-file=/etc/my.cnf - rm -f "$datadir"/.phase_two_required - fi - - exit 0 -} - -# main -case $1 in - "pre") install_db ;; - "post") pinger ;; -esac - -exit 0 - diff --git a/packaging/rpm-sles/mysql.conf b/packaging/rpm-sles/mysql.conf deleted file mode 100644 index 74cd5f836e7..00000000000 --- a/packaging/rpm-sles/mysql.conf +++ /dev/null @@ -1 +0,0 @@ -d /var/run/mysqld 0755 mysql mysql - diff --git a/packaging/rpm-sles/mysql.init b/packaging/rpm-sles/mysql.init index dda0bebba56..25762d9bee2 100644 --- a/packaging/rpm-sles/mysql.init +++ b/packaging/rpm-sles/mysql.init @@ -49,7 +49,6 @@ get_option () { datadir=$(get_option mysqld datadir "/var/lib/mysql") socket=$(get_option mysqld socket "$datadir/mysql.sock") pidfile=$(get_option mysqld_safe pid-file "/var/run/mysql/mysqld.pid") -logfile=$(get_option mysqld_safe log-error "/var/log/mysql/mysqld.log") install_db () { # Note: something different than datadir=/var/lib/mysql requires @@ -58,14 +57,16 @@ install_db () { logfile=$(get_option mysqld_safe log-error "/var/log/mysql/mysqld.log") # Restore log, dir, perms and SELinux contexts - [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || return 1 + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + install -d -m 0755 -omysql -gmysql "$datadir" || return 1 + fi - [ -e $logfile ] || touch $logfile || return 1 - chmod 0640 $logfile - chown mysql:mysql $logfile || return 1 + if [ ! -e "$logfile" -a ! -h "$logfile" -a "x$(dirname "$logfile")" = "x/var/log/mysql" ]; then + install /dev/null -omysql -gmysql "$logfile" || return 1 + fi if [ -x /usr/sbin/restorecon ]; then /usr/sbin/restorecon "$datadir" - /usr/sbin/restorecon $logfile + /usr/sbin/restorecon "$logfile" fi # If special mysql dir is in place, skip db install diff --git a/packaging/rpm-sles/mysqld.service b/packaging/rpm-sles/mysqld.service deleted file mode 100644 index 78ef3bffe60..00000000000 --- a/packaging/rpm-sles/mysqld.service +++ /dev/null @@ -1,48 +0,0 @@ -# -# Simple MySQL systemd service file -# -# systemd supports lots of fancy features, look here (and linked docs) for a full list: -# http://www.freedesktop.org/software/systemd/man/systemd.exec.html -# -# Note: this file ( /usr/lib/systemd/system/mysql.service ) -# will be overwritten on package upgrade, please copy the file to -# -# /etc/systemd/system/mysql.service -# -# to make needed changes. -# -# systemd-delta can be used to check differences between the two mysql.service files. -# - -[Unit] -Description=MySQL Community Server -After=network.target -After=syslog.target - -[Install] -WantedBy=multi-user.target -Alias=mysql.service - -[Service] -User=mysql -Group=mysql - -# Execute pre and post scripts as root -PermissionsStartOnly=true - -# Needed to create system tables etc. -ExecStartPre=/usr/bin/mysql-systemd-start pre - -# Start main service -ExecStart=/usr/bin/mysqld_safe - -# Don't signal startup success before a ping works -ExecStartPost=/usr/bin/mysql-systemd-start post - -# Give up if ping don't get an answer -TimeoutSec=600 - -Restart=always -PrivateTmp=false - - diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 4b103817ab6..a5c87a44e65 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -218,7 +218,13 @@ parse_arguments() { # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])! --core-file-size=*) core_file_size="$val" ;; - --ledir=*) ledir="$val" ;; + --ledir=*) + if [ -z "$pick_args" ]; then + log_error "--ledir option can only be used as command line option, found in config file" + exit 1 + fi + ledir="$val" + ;; --malloc-lib=*) set_malloc_lib "$val" ;; --mysqld=*) if [ -z "$pick_args" ]; then @@ -394,7 +400,15 @@ else relpkgdata='@pkgdatadir@' fi -MY_PWD=`pwd` +case "$0" in + /*) + MY_PWD='@prefix@' + ;; + *) + MY_PWD=`dirname $0` + MY_PWD=`dirname $MY_PWD` + ;; +esac # Check for the directories we would expect from a binary release install if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION" then From 42732cc195fd237c9b17490e96f1bb29db433b0b Mon Sep 17 00:00:00 2001 From: Dyre Tjeldvoll Date: Thu, 24 Nov 2016 09:57:54 +0100 Subject: [PATCH 2/5] Bug#25092566: CREATE TABLE WITH DATA DIRECTORY CLAUSE DOES NOT REQUIRE SPECIAL PRIVILEGES Require FILE privilege when creating tables using external data directory or index directory. --- mysql-test/r/partition_symlink.result | 2 ++ mysql-test/t/partition_symlink.test | 2 ++ sql/partition_info.cc | 26 +++++++++++++++++++++++++- sql/partition_info.h | 13 ++++++++++++- sql/sql_parse.cc | 19 ++++++++++++++++++- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/partition_symlink.result b/mysql-test/r/partition_symlink.result index f26a1642a52..91cc78f1361 100644 --- a/mysql-test/r/partition_symlink.result +++ b/mysql-test/r/partition_symlink.result @@ -4,6 +4,8 @@ DROP DATABASE IF EXISTS mysqltest2; # test.t1 have partitions in mysqltest2-directory! # user root: CREATE USER mysqltest_1@localhost; +# Need FILE permission to use external datadir or indexdir. +GRANT FILE ON *.* TO mysqltest_1@localhost; CREATE DATABASE mysqltest2; USE mysqltest2; CREATE TABLE t1 (a INT) ENGINE = MyISAM; diff --git a/mysql-test/t/partition_symlink.test b/mysql-test/t/partition_symlink.test index 5fdde8e0abc..9e57d616213 100644 --- a/mysql-test/t/partition_symlink.test +++ b/mysql-test/t/partition_symlink.test @@ -32,6 +32,8 @@ DROP DATABASE IF EXISTS mysqltest2; -- echo # test.t1 have partitions in mysqltest2-directory! -- echo # user root: CREATE USER mysqltest_1@localhost; +-- echo # Need FILE permission to use external datadir or indexdir. + GRANT FILE ON *.* TO mysqltest_1@localhost; CREATE DATABASE mysqltest2; USE mysqltest2; CREATE TABLE t1 (a INT) ENGINE = MyISAM; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index a0d09557b81..cd17e3366cf 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. 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 @@ -2550,6 +2550,30 @@ void partition_info::print_debug(const char *str, uint *value) DBUG_PRINT("info", ("parser: %s", str)); DBUG_VOID_RETURN; } + +bool has_external_data_or_index_dir(partition_info &pi) +{ + List_iterator part_it(pi.partitions); + for (partition_element *part= part_it++; part; part= part_it++) + { + if (part->data_file_name != NULL || part->index_file_name != NULL) + { + return true; + } + List_iterator subpart_it(part->subpartitions); + for (const partition_element *subpart= subpart_it++; + subpart; + subpart= subpart_it++) + { + if (subpart->data_file_name != NULL || subpart->index_file_name != NULL) + { + return true; + } + } + } + return false; +} + #else /* WITH_PARTITION_STORAGE_ENGINE */ /* For builds without partitioning we need to define these functions diff --git a/sql/partition_info.h b/sql/partition_info.h index 7bfbf8a1b1a..7ff6abeebd2 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -1,7 +1,7 @@ #ifndef PARTITION_INFO_INCLUDED #define PARTITION_INFO_INCLUDED -/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. 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 @@ -349,4 +349,15 @@ void init_all_partitions_iterator(partition_info *part_info, part_iter->get_next= get_next_partition_id_range; } +/** + Predicate which returns true if any partition or subpartition uses + an external data directory or external index directory. + + @param pi partitioning information + @retval true if any partition or subpartition has an external + data directory or external index directory. + @retval false otherwise + */ +bool has_external_data_or_index_dir(partition_info &pi); + #endif /* PARTITION_INFO_INCLUDED */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ac3901997f3..18cb758c9b5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -35,6 +35,9 @@ #include "sql_insert.h" // mysql_insert #include "sql_update.h" // mysql_update, mysql_multi_update #include "sql_partition.h" // struct partition_info +#ifdef WITH_PARTITION_STORAGE_ENGINE +#include "partition_info.h" // has_external_data_or_index_dir +#endif /* WITH_PARTITION_STORAGE_ENGINE */ #include "sql_db.h" // mysql_change_db, mysql_create_db, // mysql_rm_db, mysql_upgrade_db, // mysql_alter_db, @@ -2413,7 +2416,6 @@ case SQLCOM_PREPARE: copy. */ Alter_info alter_info(lex->alter_info, thd->mem_root); - if (thd->is_fatal_error) { /* If out of memory when creating a copy of alter_info. */ @@ -2421,6 +2423,15 @@ case SQLCOM_PREPARE: goto end_with_restore_list; } + if (((lex->create_info.used_fields & HA_CREATE_USED_DATADIR) != 0 || + (lex->create_info.used_fields & HA_CREATE_USED_INDEXDIR) != 0) && + check_access(thd, FILE_ACL, NULL, NULL, NULL, FALSE, FALSE)) + { + res= 1; + my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "FILE"); + goto end_with_restore_list; + } + if ((res= create_table_precheck(thd, select_tables, create_table))) goto end_with_restore_list; @@ -2458,6 +2469,12 @@ case SQLCOM_PREPARE: #ifdef WITH_PARTITION_STORAGE_ENGINE { partition_info *part_info= thd->lex->part_info; + if (part_info != NULL && has_external_data_or_index_dir(*part_info) && + check_access(thd, FILE_ACL, NULL, NULL, NULL, FALSE, FALSE)) + { + res= -1; + goto end_with_restore_list; + } if (part_info && !(part_info= thd->lex->part_info->get_clone(true))) { res= -1; From 202355104f3a4b2524a6b623886c8bf4db49c02e Mon Sep 17 00:00:00 2001 From: "mysql-builder@oracle.com" <> Date: Thu, 24 Nov 2016 21:53:55 +0100 Subject: [PATCH 3/5] From 64cc76bbf8e4d21cffdf2b2b3644ff8a71d4d97a Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Sat, 26 Nov 2016 20:41:48 +0530 Subject: [PATCH 4/5] Followup fix for Bug#25088048 - ADDITIONAL ISSUES IN MYSQLD_SAFE - Removed mysql.conf, mysqld.service and mysql-systemd-start from sles spec file (cherry picked from commit 35c1adc17c1a99b2c256d374500437a6ce21339e) --- packaging/rpm-sles/mysql.spec.in | 43 -------------------------------- 1 file changed, 43 deletions(-) diff --git a/packaging/rpm-sles/mysql.spec.in b/packaging/rpm-sles/mysql.spec.in index 6652cdcccb6..1b5f1806321 100644 --- a/packaging/rpm-sles/mysql.spec.in +++ b/packaging/rpm-sles/mysql.spec.in @@ -24,7 +24,6 @@ # Regression tests may take a long time, override the default to skip them %{!?runselftest:%global runselftest 0} -%{!?with_systemd: %global systemd 0} %{!?with_debuginfo: %global nodebuginfo 1} %{!?product_suffix: %global product_suffix community} %{!?feature_set: %global feature_set community} @@ -69,9 +68,6 @@ Source0: https://cdn.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/%{src URL: http://www.mysql.com/ Packager: MySQL Release Engineering Vendor: %{mysql_vendor} -Source1: mysql-systemd-start -Source2: mysqld.service -Source3: mysql.conf Source4: my_config.h Source90: filter-provides.sh Source91: filter-requires.sh @@ -81,9 +77,6 @@ BuildRequires: libaio-devel BuildRequires: ncurses-devel BuildRequires: openssl-devel BuildRequires: zlib-devel -%if 0%{?systemd} -BuildRequires: systemd -%endif BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) %if 0%{?rhel} > 6 @@ -141,15 +134,9 @@ Obsoletes: mariadb-server Obsoletes: mariadb-galera-server Provides: mysql = %{version}-%{release} Provides: mysql-tools = %{version}-%{release} -%if 0%{?systemd} -Requires(post): systemd -Requires(preun): systemd -Requires(postun): systemd -%else PreReq: insserv PreReq: sed PreReq: pwdutils -%endif Conflicts: otherproviders(mysql) Conflicts: otherproviders(mysql-debug) Conflicts: otherproviders(mysql-tools) @@ -435,13 +422,7 @@ make DESTDIR=%{buildroot} install install -D -m 0644 $MBD/release/support-files/mysql-log-rotate %{buildroot}%{_sysconfdir}/logrotate.d/mysql install -D -m 0644 $MBD/release/packaging/rpm-sles/my.cnf %{buildroot}%{_sysconfdir}/my.cnf install -d %{buildroot}%{_sysconfdir}/my.cnf.d -%if 0%{?systemd} -install -D -m 0755 %{SOURCE1} %{buildroot}%{_bindir}/mysql-systemd-start -install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/mysqld.service -%else install -D -m 0755 $MBD/release/packaging/rpm-sles/mysql.init %{buildroot}%{_sysconfdir}/init.d/mysql -%endif -install -D -m 0644 %{SOURCE3} %{buildroot}%{_prefix}/lib/tmpfiles.d/mysql.conf # Make library links install -d -m 0755 %{buildroot}%{_sysconfdir}/ld.so.conf.d @@ -461,9 +442,6 @@ rm -rf %{buildroot}%{_datadir}/mysql/mysql.server rm -rf %{buildroot}%{_datadir}/mysql/mysqld_multi.server rm -f %{buildroot}%{_datadir}/mysql/{ndb-config-2-node,config*}.ini rm -f %{buildroot}%{_datadir}/mysql/my-*.cnf -%if 0%{?systemd} -rm -rf %{buildroot}%{_sysconfdir}/init.d/mysql -%endif rm -rf %{buildroot}%{_bindir}/mysql_embedded rm -rf %{buildroot}%{_bindir}/mysql_setpermission rm -rf %{buildroot}%{_mandir}/man1/mysql_setpermission.1* @@ -496,31 +474,18 @@ datadir=$(/usr/bin/my_print_defaults server mysqld | grep '^--datadir=' | sed -n /bin/chmod 0755 "$datadir" /bin/touch /var/log/mysql/mysqld.log /bin/chown mysql:mysql /var/log/mysql/mysqld.log >/dev/null 2>&1 || : -%if 0%{?systemd} -%systemd_post mysqld.service -/sbin/service mysqld enable >/dev/null 2>&1 || : -%else /sbin/insserv /etc/init.d/mysql -%endif %preun server -%if 0%{?systemd} -%systemd_preun mysqld.service -%else if [ "$1" -eq 0 ]; then /usr/sbin/rcmysql stop >/dev/null 2>&1 || : /sbin/insserv /etc/init.d fi -%endif %postun server -%if 0%{?systemd} -%systemd_postun_with_restart mysqld.service -%else if [ $1 -ge 1 ]; then /usr/sbin/rcmysql condrestart >/dev/null 2>&1 || : fi -%endif %post libs -p /sbin/ldconfig @@ -596,9 +561,6 @@ fi %attr(755, root, root) %{_bindir}/replace %attr(755, root, root) %{_bindir}/resolve_stack_dump %attr(755, root, root) %{_bindir}/resolveip -%if 0%{?systemd} -%attr(755, root, root) %{_bindir}/mysql-systemd-start -%endif %attr(755, root, root) %{_sbindir}/mysqld %attr(755, root, root) %{_sbindir}/mysqld-debug %attr(755, root, root) %{_sbindir}/rcmysql @@ -629,12 +591,7 @@ fi %attr(644, root, root) %{_datadir}/mysql/mysql_test_data_timezone.sql %attr(644, root, root) %{_datadir}/mysql/mysql-log-rotate %attr(644, root, root) %{_datadir}/mysql/magic -%attr(644, root, root) %{_prefix}/lib/tmpfiles.d/mysql.conf -%if 0%{?systemd} -%attr(644, root, root) %{_unitdir}/mysqld.service -%else %attr(755, root, root) %{_sysconfdir}/init.d/mysql -%endif %attr(644, root, root) %config(noreplace,missingok) %{_sysconfdir}/logrotate.d/mysql %dir %attr(755, mysql, mysql) /var/lib/mysql %dir %attr(755, mysql, mysql) /var/run/mysql From c8f0eeb9c8596be83fefb7fef9f9871e53edb020 Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Mon, 28 Nov 2016 16:38:03 +0530 Subject: [PATCH 5/5] Bug#25159791 BASEDIR: COMMAND NOT FOUND ERROR WHILE STARTING SERVER WITH INIT SCRIPTS (cherry picked from commit 7a39efab8a59ebdcd562fb788bc004ff338796ea) --- packaging/rpm-oel/mysql-systemd-start | 2 +- packaging/rpm-oel/mysql.init | 6 +++--- packaging/rpm-sles/mysql.init | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/rpm-oel/mysql-systemd-start b/packaging/rpm-oel/mysql-systemd-start index af6e906efe1..c744bdceeb4 100644 --- a/packaging/rpm-oel/mysql-systemd-start +++ b/packaging/rpm-oel/mysql-systemd-start @@ -22,7 +22,7 @@ install_db () { datadir=$(get_option mysqld datadir "/var/lib/mysql") # Restore log, dir, perms and SELinux contexts - if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then install -d -m 0755 -omysql -gmysql "$datadir" || exit 1 fi log=/var/log/mysqld.log diff --git a/packaging/rpm-oel/mysql.init b/packaging/rpm-oel/mysql.init index 50d1bba017d..c3bbb277b91 100644 --- a/packaging/rpm-oel/mysql.init +++ b/packaging/rpm-oel/mysql.init @@ -76,10 +76,10 @@ start(){ [ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile" if [ ! -d "$datadir/mysql" ] ; then # First, make sure $datadir is there with correct permissions - if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then install -d -m0755 -omysql -gmysql "$datadir" || exit 1 fi - if [ ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + if [ ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then chown mysql:mysql "$datadir" chmod 0755 "$datadir" fi @@ -99,7 +99,7 @@ start(){ return $ret fi fi - if [ ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + if [ ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then chown mysql:mysql "$datadir" chmod 0755 "$datadir" fi diff --git a/packaging/rpm-sles/mysql.init b/packaging/rpm-sles/mysql.init index 25762d9bee2..62f2a62e1b9 100644 --- a/packaging/rpm-sles/mysql.init +++ b/packaging/rpm-sles/mysql.init @@ -57,7 +57,7 @@ install_db () { logfile=$(get_option mysqld_safe log-error "/var/log/mysql/mysqld.log") # Restore log, dir, perms and SELinux contexts - if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then install -d -m 0755 -omysql -gmysql "$datadir" || return 1 fi