Commit 93a5fb00 authored by Monty's avatar Monty

MDEV-27477 Remaining SUSE patches for 10.2+

This patch let's you specify not only user to use but also group that
MariaDB should use.

Original patch:
https://github.com/openSUSE/mysql-packaging/blob/master/patches/mysql-patches/mariadb-10.2.3-group.patch

Author:   Kristyna Streitova
Reviewer: monty@mariadb.org
parent 8d9b1aa0
...@@ -163,6 +163,7 @@ ENDIF() ...@@ -163,6 +163,7 @@ ENDIF()
SET(HOSTNAME "hostname") SET(HOSTNAME "hostname")
SET(MYSQLD_USER "mysql") SET(MYSQLD_USER "mysql")
SET(MYSQLD_GROUP "mysql")
ENDIF(UNIX) ENDIF(UNIX)
# Really ugly, one script, "mysql_install_db", needs prefix set to ".", # Really ugly, one script, "mysql_install_db", needs prefix set to ".",
......
...@@ -30,6 +30,7 @@ defaults="" ...@@ -30,6 +30,7 @@ defaults=""
defaults_group_suffix="" defaults_group_suffix=""
mysqld_opt="" mysqld_opt=""
user="" user=""
group=""
silent_startup="--silent-startup" silent_startup="--silent-startup"
force=0 force=0
...@@ -98,6 +99,11 @@ Usage: $0 [OPTIONS] ...@@ -98,6 +99,11 @@ Usage: $0 [OPTIONS]
user. You must be root to use this option. By default user. You must be root to use this option. By default
mysqld runs using your current login name and files and mysqld runs using your current login name and files and
directories that it creates will be owned by you. directories that it creates will be owned by you.
--group=group_name The login group to use for running mysqld. Files and
directories created by mysqld will be owned by this
group. You must be root to use this option. By default
mysqld runs using your current group and files and
directories that it creates will be owned by you.
--upgrade-info Store mysql_upgrade_info in the installed data directory. --upgrade-info Store mysql_upgrade_info in the installed data directory.
All other options are passed to the mysqld program All other options are passed to the mysqld program
...@@ -146,11 +152,11 @@ parse_arguments() ...@@ -146,11 +152,11 @@ parse_arguments()
--builddir=*) builddir=`parse_arg "$arg"` ;; --builddir=*) builddir=`parse_arg "$arg"` ;;
--srcdir=*) srcdir=`parse_arg "$arg"` ;; --srcdir=*) srcdir=`parse_arg "$arg"` ;;
--ldata=*|--datadir=*|--data=*) ldata=`parse_arg "$arg"` ;; --ldata=*|--datadir=*|--data=*) ldata=`parse_arg "$arg"` ;;
--user=*)
# Note that the user will be passed to mysqld so that it runs # Note that the user will be passed to mysqld so that it runs
# as 'user' (crucial e.g. if log-bin=/some_other_path/ # as 'user' (crucial e.g. if log-bin=/some_other_path/
# where a chown of datadir won't help) # where a chown of datadir won't help)
user=`parse_arg "$arg"` ;; --user=*) user=`parse_arg "$arg"` ;;
--group=*) group=`parse_arg "$arg"` ;;
--skip-name-resolve) ip_only=1 ;; --skip-name-resolve) ip_only=1 ;;
--verbose) verbose=1 ; silent_startup="" ;; --verbose) verbose=1 ; silent_startup="" ;;
--rpm) in_rpm=1 ;; --rpm) in_rpm=1 ;;
...@@ -461,7 +467,12 @@ do ...@@ -461,7 +467,12 @@ do
fi fi
if test -n "$user" if test -n "$user"
then then
chown $user "$dir" if test -z "$group"
then
chown $user $dir
else
chown $user:$group $dir
fi
if test $? -ne 0 if test $? -ne 0
then then
echo "Cannot change ownership of the database directories to the '$user'" echo "Cannot change ownership of the database directories to the '$user'"
...@@ -476,6 +487,11 @@ then ...@@ -476,6 +487,11 @@ then
args="$args --user=$user" args="$args --user=$user"
fi fi
if test -n "$group"
then
args="$args --group=$group"
fi
# When doing a "cross bootstrap" install, no reference to the current # When doing a "cross bootstrap" install, no reference to the current
# host should be added to the system tables. So we filter out any # host should be added to the system tables. So we filter out any
# lines which contain the current host name. # lines which contain the current host name.
......
...@@ -29,6 +29,7 @@ logging=init ...@@ -29,6 +29,7 @@ logging=init
want_syslog=0 want_syslog=0
syslog_tag= syslog_tag=
user='@MYSQLD_USER@' user='@MYSQLD_USER@'
group='@MYSQLD_GROUP@'
pid_file= pid_file=
err_log= err_log=
err_log_base= err_log_base=
...@@ -318,6 +319,7 @@ parse_arguments() { ...@@ -318,6 +319,7 @@ parse_arguments() {
--pid[-_]file=*) pid_file="$val" ;; --pid[-_]file=*) pid_file="$val" ;;
--plugin[-_]dir=*) PLUGIN_DIR="$val" ;; --plugin[-_]dir=*) PLUGIN_DIR="$val" ;;
--user=*) user="$val"; SET_USER=1 ;; --user=*) user="$val"; SET_USER=1 ;;
--group=*) group="$val"; SET_USER=1 ;;
--log[-_]basename=*|--hostname=*|--loose[-_]log[-_]basename=*) --log[-_]basename=*|--hostname=*|--loose[-_]log[-_]basename=*)
pid_file="$val.pid"; pid_file="$val.pid";
err_log_base="$val"; err_log_base="$val";
...@@ -720,6 +722,7 @@ then ...@@ -720,6 +722,7 @@ then
if test "$user" != "root" -o $SET_USER = 1 if test "$user" != "root" -o $SET_USER = 1
then then
USER_OPTION="--user=$user" USER_OPTION="--user=$user"
GROUP_OPTION="--group=$group"
fi fi
if test -n "$open_files" if test -n "$open_files"
then then
...@@ -742,7 +745,12 @@ then ...@@ -742,7 +745,12 @@ then
log_error "Fatal error Can't create database directory '$mysql_unix_port'" log_error "Fatal error Can't create database directory '$mysql_unix_port'"
exit 1 exit 1
fi fi
chown $user $mysql_unix_port_dir if [ "$user" -a "$group" ]; then
chown $user:$group $mysql_unix_port_dir
else
[ "$user" ] && chown $user $mysql_unix_port_dir
[ "$group" ] && chgrp $group $mysql_unix_port_dir
fi
chmod 755 $mysql_unix_port_dir chmod 755 $mysql_unix_port_dir
fi fi
......
...@@ -29,6 +29,7 @@ ELSE() ...@@ -29,6 +29,7 @@ ELSE()
SET(CFLAGS ${CMAKE_C_FLAGS}) SET(CFLAGS ${CMAKE_C_FLAGS})
SET(CXXFLAGS ${CMAKE_CXX_FLAGS}) SET(CXXFLAGS ${CMAKE_CXX_FLAGS})
SET(MYSQLD_USER "mysql") SET(MYSQLD_USER "mysql")
SET(MYSQLD_GROUP "mysql")
SET(ini_file_extension "cnf") SET(ini_file_extension "cnf")
SET(HOSTNAME "hostname") SET(HOSTNAME "hostname")
ENDIF() ENDIF()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment