$OpenBSD: patch-scripts_mysql_install_db_sh,v 1.19 2020/08/12 14:43:54 sthen Exp $

Index: scripts/mysql_install_db.sh
--- scripts/mysql_install_db.sh.orig
+++ scripts/mysql_install_db.sh
@@ -30,7 +30,8 @@ args=""
 defaults=""
 defaults_group_suffix=""
 mysqld_opt=""
-user=""
+user=_mysql
+group=_mysql
 silent_startup="--silent-startup"
 
 force=0
@@ -149,6 +150,8 @@ parse_arguments()
         # as 'user' (crucial e.g. if log-bin=/some_other_path/
         # where a chown of datadir won't help)
         user=`parse_arg "$arg"` ;;
+      --group=*)
+        group=`parse_arg "$arg"` ;;
       --skip-name-resolve) ip_only=1 ;;
       --verbose) verbose=1 ; silent_startup="" ;;
       --rpm) in_rpm=1 ;;
@@ -328,7 +331,6 @@ then
   srcpkgdatadir="$srcdir/scripts"
   buildpkgdatadir="$builddir/scripts"
   plugindir="$builddir/plugin/auth_socket"
-  pamtooldir="$builddir/plugin/auth_pam"
 elif test -n "$basedir"
 then
   bindir="$basedir/bin" # only used in the help text
@@ -357,8 +359,7 @@ then
     cannot_find_file fill_help_tables.sql @pkgdata_locations@
     exit 1
   fi
-  plugindir=`find_in_dirs --dir auth_pam.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin $basedir/lib/*/mariadb19/plugin`
-  pamtooldir=$plugindir
+  plugindir=`find_in_dirs --dir auth_ed25519.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin $basedir/lib/*/mariadb19/plugin`
 # relative from where the script was run for a relocatable install
 elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mysqld"
 then
@@ -369,7 +370,6 @@ then
   srcpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@"
   buildpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@"
   plugindir="$basedir/@INSTALL_PLUGINDIR@"
-  pamtooldir=$plugindir
 else
   basedir="@prefix@"
   bindir="@bindir@"
@@ -378,7 +378,6 @@ else
   srcpkgdatadir="@pkgdatadir@"
   buildpkgdatadir="@pkgdatadir@"
   plugindir="@pkgplugindir@"
-  pamtooldir="@pkgplugindir@"
 fi
 
 # Set up paths to SQL scripts required for bootstrap
@@ -467,11 +466,11 @@ do
   fi
   if test -n "$user"
   then
-    chown $user "$dir"
+    chown -f $user:$group "$dir"
     if test $? -ne 0
     then
-      echo "Cannot change ownership of the database directories to the '$user'"
-      echo "user.  Check that you have the necessary permissions and try again."
+      echo "Cannot change ownership of the database directories to '$user:$group'"
+      echo "user/group.  Check that you have the necessary permissions and try again."
       exit 1
     fi
   fi
@@ -479,25 +478,6 @@ done
 
 if test -n "$user"
 then
-  if test -z "$srcdir" -a "$in_rpm" -eq 0
-  then
-    chown 0 "$pamtooldir/auth_pam_tool_dir/auth_pam_tool" && \
-    chmod 04755 "$pamtooldir/auth_pam_tool_dir/auth_pam_tool"
-    if test $? -ne 0
-    then
-        echo "Couldn't set an owner to '$pamtooldir/auth_pam_tool_dir/auth_pam_tool'."
-        echo "It must be root, the PAM authentication plugin doesn't work otherwise.."
-        echo
-    fi
-    chown $user "$pamtooldir/auth_pam_tool_dir" && \
-    chmod 0700 "$pamtooldir/auth_pam_tool_dir"
-    if test $? -ne 0
-    then
-        echo "Cannot change ownership of the '$pamtooldir/auth_pam_tool_dir' directory"
-        echo "to the '$user' user. Check that you have the necessary permissions and try again."
-        echo
-    fi
-  fi
   args="$args --user=$user"
 fi
 
@@ -602,10 +582,6 @@ fi
 # the screen.
 if test "$cross_bootstrap" -eq 0 && test -z "$srcdir"
 then
-  s_echo
-  s_echo "To start mysqld at boot time you have to copy"
-  s_echo "support-files/mysql.server to the right place for your system"
-
   if test "$auth_root_authentication_method" = normal
   then
     echo
@@ -642,10 +618,7 @@ then
   then
     echo
     echo "You can start the MariaDB daemon with:"
-    echo "cd '$basedir' ; $bindir/mysqld_safe --datadir='$ldata'"
-    echo
-    echo "You can test the MariaDB daemon with mysql-test-run.pl"
-    echo "cd '$basedir/mysql-test' ; perl mysql-test-run.pl"
+    echo "/etc/rc.d/mysqld start"
   fi
 
   echo
