File mysql-community-server-5.1.45-group.patch of Package mariadb.import4830

PATCH-P0-FEATURE-UPSTREAM: Adds group option

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

Maintainer: Michal Hrusecky <mhrusecky@suse.cz>

Index: configure.in
===================================================================
--- configure.in.orig
+++ configure.in
@@ -793,6 +793,14 @@ AC_ARG_WITH(mysqld-user,
     [ MYSQLD_USER=mysql ]
     )
 AC_SUBST(MYSQLD_USER)
+AC_ARG_WITH(mysqld-group,
+    [  --with-mysqld-group=groupname   
+                          What group the mysqld daemon shall be run as.],
+    [ MYSQLD_GROUP=$withval ],
+    [ MYSQLD_GROUP=mysql ]
+    )
+AC_SUBST(MYSQLD_GROUP)
+
 
 # If we should allow LOAD DATA LOCAL
 AC_MSG_CHECKING(If we should should enable LOAD DATA LOCAL by default)
Index: scripts/Makefile.am
===================================================================
--- scripts/Makefile.am.orig
+++ scripts/Makefile.am
@@ -185,6 +185,7 @@ SUFFIXES = .sh
 	  -e 's!@''TARGET_LINUX''@!@TARGET_LINUX@!' \
 	  -e "s!@""CONF_COMMAND""@!@CONF_COMMAND@!" \
 	  -e 's!@''MYSQLD_USER''@!@MYSQLD_USER@!' \
+	  -e 's!@''MYSQLD_GROUP''@!@MYSQLD_GROUP@!' \
 	  -e 's!@''STATIC_NSS_FLAGS''@!@STATIC_NSS_FLAGS@!' \
 	  -e 's!@''NON_THREADED_LIBS''@!@NON_THREADED_LIBS@!' \
 	  -e 's!@''ZLIB_DEPS''@!@ZLIB_DEPS@!' \
Index: scripts/mysqld_safe.sh
===================================================================
--- scripts/mysqld_safe.sh.orig
+++ scripts/mysqld_safe.sh
@@ -19,6 +19,7 @@ logging=init
 want_syslog=0
 syslog_tag=
 user='@MYSQLD_USER@'
+group='@MYSQLD_GROUP@'
 pid_file=
 err_log=
 
@@ -162,6 +163,7 @@ parse_arguments() {
       --datadir=*) DATADIR="$val" ;;
       --pid-file=*) pid_file="$val" ;;
       --user=*) user="$val"; SET_USER=1 ;;
+      --group=*) group="$val"; SET_USER=1 ;;
 
       # these might have been set in a [mysqld_safe] section of my.cnf
       # they are added to mysqld command line to override settings from my.cnf
@@ -388,11 +390,17 @@ then
   if test "$user" != "root" -o $SET_USER = 1
   then
     USER_OPTION="--user=$user"
+    GROUP_OPTION="--group=$group"
   fi
   # Change the err log to the right user, if it is in use
   if [ $want_syslog -eq 0 ]; then
     touch "$err_log"
-    chown $user "$err_log"
+    if [ "$user" -a "$group" ]; then
+      chown $user:$group $err_log
+    else
+      [ "$user" ] && chown $user $err_log
+      [ "$group" ] && chgrp $group $err_log
+    fi
   fi
   if test -n "$open_files"
   then
@@ -407,7 +415,12 @@ mysql_unix_port_dir=`dirname $safe_mysql
 if [ ! -d $mysql_unix_port_dir ]
 then
   mkdir $mysql_unix_port_dir
-  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
 fi
 
Index: scripts/mysql_install_db.sh
===================================================================
--- scripts/mysql_install_db.sh.orig
+++ scripts/mysql_install_db.sh
@@ -28,6 +28,7 @@ args=""
 defaults=""
 mysqld_opt=""
 user=""
+group=""
 
 force=0
 in_rpm=0
@@ -63,6 +64,11 @@ Usage: $0 [OPTIONS]
                        user.  You must be root to use this option.  By default
                        mysqld runs using your current login name and files and
                        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.
 
 All other options are passed to the mysqld program
 
@@ -103,11 +109,11 @@ parse_arguments()
       --builddir=*) builddir=`parse_arg "$arg"` ;;
       --srcdir=*)  srcdir=`parse_arg "$arg"` ;;
       --ldata=*|--datadir=*) ldata=`parse_arg "$arg"` ;;
-      --user=*)
         # Note that the user will be passed to mysqld so that it runs
         # as 'user' (crucial e.g. if log-bin=/some_other_path/
         # 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 ;;
       --verbose) verbose=1 ;; # Obsolete
       --rpm) in_rpm=1 ;;
@@ -360,7 +366,12 @@ do
   fi
   if test -w / -a ! -z "$user"
   then
-    chown $user $dir
+    if test -z "$group"
+    then
+      chown $user $dir
+    else
+      chown $user:$group $dir
+    fi
   fi
 done
 
@@ -369,6 +380,11 @@ then
   args="$args --user=$user"
 fi
 
+if test -n "$group"
+then
+  args="$args --group=$group"
+fi
+
 # When doing a "cross bootstrap" install, no reference to the current
 # host should be added to the system tables.  So we filter out any
 # lines which contain the current host name.
openSUSE Build Service is sponsored by