--- rpms/smeserver-mysql/sme10/smeserver-mysql-2.7.0-bz11899-sclo.patch 2022/03/14 02:39:16 1.4 +++ rpms/smeserver-mysql/sme10/smeserver-mysql-2.7.0-bz11899-sclo.patch 2022/03/16 07:29:20 1.8 @@ -15,6 +15,37 @@ diff -Nur --no-dereference smeserver-mys flush-engine-log flush-general-log flush-slow-log fi endscript +diff -Nur --no-dereference smeserver-mysql-2.7.0.old/rootscl/sbin/e-smith/systemd/mariadb_VER_-initialize smeserver-mysql-2.7.0/rootscl/sbin/e-smith/systemd/mariadb_VER_-initialize +--- smeserver-mysql-2.7.0.old/rootscl/sbin/e-smith/systemd/mariadb_VER_-initialize 2022-03-12 00:27:43.000000000 -0500 ++++ smeserver-mysql-2.7.0/rootscl/sbin/e-smith/systemd/mariadb_VER_-initialize 2022-03-13 01:24:53.334000000 -0500 +@@ -34,8 +34,11 @@ + fi + exit $ret + fi +- # set root password +- /opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysqld --bootstrap --datadir="$datadir" --user="mysql" < /var/lib/mysql/set.password ++ # set root password , 104 and above have a different syntax and allow root passwordless access ++ if [ !!!VER!!! -le 103 ] ++ then ++ /opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysqld --bootstrap --datadir="$datadir" --user="mysql" < /var/lib/mysql/set.password ++ fi + # upgrade does not need to be run on a fresh datadir + #echo "5.7.24" >"$datadir/mysql_upgrade_info" + # In case we're running as root, make sure files are owned properly +@@ -46,7 +49,10 @@ + /sbin/e-smith/expand-template /etc/e-smith/sql/init!!!VER!!!/00_restore_dumped_dbs + fi + else +- # else we set root password anyway ! just to be sure ! +- /opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysqld --bootstrap --datadir="$datadir" --user="mysql" < /var/lib/mysql/set.password +- ++ # else we set root password anyway ! just to be sure ! 104 and above have a different syntax and allow root passwordless access ++ if [ !!!VER!!! -le 103 ] ++ then ++ /opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysqld --bootstrap --datadir="$datadir" --user="mysql" < /var/lib/mysql/set.password ++ fi ++ exit 0 + fi diff -Nur --no-dereference smeserver-mysql-2.7.0.old/rootscl/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/11configMysql_VER_ smeserver-mysql-2.7.0/rootscl/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/11configMysql_VER_ --- smeserver-mysql-2.7.0.old/rootscl/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/11configMysql_VER_ 2022-03-12 16:39:10.000000000 -0500 +++ smeserver-mysql-2.7.0/rootscl/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/11configMysql_VER_ 2022-03-13 21:14:10.966000000 -0400 @@ -39,31 +70,96 @@ diff -Nur --no-dereference smeserver-mys then exit_value=0 HOME=/root +diff -Nur --no-dereference smeserver-mysql-2.7.0.old/createlinks smeserver-mysql-2.7.0/createlinks +--- smeserver-mysql-2.7.0.old/createlinks 2022-03-12 16:41:41.000000000 -0500 ++++ smeserver-mysql-2.7.0/createlinks 2022-03-14 00:59:46.386000000 -0400 +@@ -113,6 +113,7 @@ + templates2events("/etc/my.cnf", $event); + templates2events("/root/.my.cnf", $event); + templates2events("/var/lib/mysql/set.password", $event); ++templates2events("/var/lib/mysql/set.password2", $event); + templates2events("/etc/phpMyAdmin/config.inc.php", $event); + templates2events("/etc/opt/rh/rh-mariadb$_/my.cnf", $event); + safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/mariadb$_-mariadb"); diff -Nur --no-dereference smeserver-mysql-2.7.0.old/root/etc/e-smith/templates/var/lib/mysql/set.password smeserver-mysql-2.7.0/root/etc/e-smith/templates/var/lib/mysql/set.password --- smeserver-mysql-2.7.0.old/root/etc/e-smith/templates/var/lib/mysql/set.password 2022-03-11 10:32:13.000000000 -0500 -+++ smeserver-mysql-2.7.0/root/etc/e-smith/templates/var/lib/mysql/set.password 2022-03-13 22:32:50.035000000 -0400 -@@ -3,9 +3,20 @@ - - my $pw = esmith::util::LdapPassword(); - -- $OUT .= "use mysql;\n"; -- $OUT .= "ALTER TABLE user MODIFY Password char(41) NOT NULL default '';\n"; -- $OUT .= "UPDATE user SET password=password('$pw') WHERE user='root';\n"; -- $OUT .= "DELETE FROM user WHERE user='';\n"; -+ $OUT .= "DELIMITER //\n"; -+ $OUT .= "use mysql //\n"; -+ $OUT .= "SET \@vers := (SELECT REPLACE(SUBSTRING( \@\@VERSION , 1 , LOCATE( '.' , \@\@VERSION, LOCATE( '.' , \@\@VERSION )+1 ) ), '.','' ) ) //\n"; -+ $OUT .= "BEGIN NOT ATOMIC \n"; -+ $OUT .= "IF \@vers < 104 THEN \n"; -+ $OUT .= " ALTER TABLE user MODIFY Password char(41) NOT NULL default '';\n"; -+ $OUT .= " UPDATE user SET password=password('$pw') WHERE user='root';\n"; -+ $OUT .= " DELETE FROM db WHERE user='';\n"; -+ $OUT .= " DELETE FROM user WHERE user='';\n"; -+ $OUT .= "ELSE \n"; -+ $OUT .= " SET PASSWORD FOR 'root'\@localhost = PASSWORD(\"$pw\"); \n"; -+ $OUT .= "END IF; \n"; -+ $OUT .= "END // \n"; -+ $OUT .= "DELIMITER ; \n"; ++++ smeserver-mysql-2.7.0/root/etc/e-smith/templates/var/lib/mysql/set.password 2022-03-14 00:55:17.357000000 -0400 +@@ -6,6 +6,7 @@ + $OUT .= "use mysql;\n"; + $OUT .= "ALTER TABLE user MODIFY Password char(41) NOT NULL default '';\n"; + $OUT .= "UPDATE user SET password=password('$pw') WHERE user='root';\n"; ++ $OUT .= "DELETE FROM db WHERE user='';\n"; + $OUT .= "DELETE FROM user WHERE user='';\n"; $OUT .= "FLUSH PRIVILEGES;\n"; -+ } +diff -Nur --no-dereference smeserver-mysql-2.7.0.old/root/etc/e-smith/templates/var/lib/mysql/set.password2 smeserver-mysql-2.7.0/root/etc/e-smith/templates/var/lib/mysql/set.password2 +--- smeserver-mysql-2.7.0.old/root/etc/e-smith/templates/var/lib/mysql/set.password2 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-mysql-2.7.0/root/etc/e-smith/templates/var/lib/mysql/set.password2 2022-03-14 00:54:10.293000000 -0400 +@@ -0,0 +1,9 @@ ++{ ++ use esmith::util; ++ ++ my $pw = esmith::util::LdapPassword(); ++ ++ $OUT .= "use mysql;\n"; ++ $OUT .= "SET PASSWORD FOR 'root'\@localhost = PASSWORD(\"$pw\"); \n"; ++ $OUT .= "FLUSH PRIVILEGES;\n"; ++} +diff -Nur --no-dereference smeserver-mysql-2.7.0.old/root/etc/e-smith/templates.metadata/var/lib/mysql/set.password2 smeserver-mysql-2.7.0/root/etc/e-smith/templates.metadata/var/lib/mysql/set.password2 +--- smeserver-mysql-2.7.0.old/root/etc/e-smith/templates.metadata/var/lib/mysql/set.password2 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-mysql-2.7.0/root/etc/e-smith/templates.metadata/var/lib/mysql/set.password2 2022-03-14 00:58:28.856000000 -0400 +@@ -0,0 +1,3 @@ ++PERMS=0400 ++UID="root" ++GID="root" +diff -Nur --no-dereference smeserver-mysql-2.7.0.old/rootscl/sbin/e-smith/systemd/mariadb_VER_-post smeserver-mysql-2.7.0/rootscl/sbin/e-smith/systemd/mariadb_VER_-post +--- smeserver-mysql-2.7.0.old/rootscl/sbin/e-smith/systemd/mariadb_VER_-post 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-mysql-2.7.0/rootscl/sbin/e-smith/systemd/mariadb_VER_-post 2022-03-14 02:28:09.537000000 -0400 +@@ -0,0 +1,18 @@ ++#!/bin/bash ++ ++for i in $(seq 1 20); ++do ++ if [ -S !!!SOCKET!!! ] ++ then ++ /usr/bin/mysql!!!VER!!! < /var/lib/mysql/set.password2 ++ echo "root password set" ++ exit 0 ++ fi ++ echo waiting for rh-mariadb105-mariadb to start to set root password ++ sleep 1 ++done ++echo failed to set root password ++# we fail silently, mariadb will still work, only issue is for phpmyadmin ++# and non socket access ++exit 0 ++ +diff -Nur smeserver-mysql-2.7.0.old/rootscl/etc/e-smith/events/actions/mariadb_VER_-dump-tables smeserver-mysql-2.7.0/rootscl/etc/e-smith/events/actions/mariadb_VER_-dump-tables +--- smeserver-mysql-2.7.0.old/rootscl/etc/e-smith/events/actions/mariadb_VER_-dump-tables 2022-03-12 04:00:37.000000000 +0100 ++++ smeserver-mysql-2.7.0/rootscl/etc/e-smith/events/actions/mariadb_VER_-dump-tables 2022-03-16 08:25:24.372541028 +0100 +@@ -35,12 +35,12 @@ + echo $message | /usr/bin/mail -s "error on backup of $db MariaDB !!!VER!!! database" admin + fi + message="$message \nThere was an error trying to dump database $db, please check for table errors in this db. Forcing a backup of the corrupted DB." +- /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqldump --force --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mariadb!!!VER!!!/"$db"-failed.dump || message="$message \nFailed to force backup of corrupted db $db as $db-failed.dump" >&2 ++ /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqldump --socket=!!!SOCKET!!! --force --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mariadb!!!VER!!!/"$db"-failed.dump || message="$message \nFailed to force backup of corrupted db $db as $db-failed.dump" >&2 + if [ "$fixtables" = "enabled" ]; then + repair="failure" + message="$message \nTrying to auto-repair the db and do a backup after..." +- /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqlcheck -s --auto-repair -c "$db" && \ +- /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mariadb!!!VER!!!/"$db".dump && repair="success" ++ /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqlcheck --socket=!!!SOCKET!!! -s --auto-repair -c "$db" && \ ++ /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqldump --socket=!!!SOCKET!!! --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mariadb!!!VER!!!/"$db".dump && repair="success" + message="$message \n => $repair" + fi + echo $message +@@ -52,7 +52,7 @@ + echo "mysqld is disabled - no tables dumped" >&2 + exit 0 + fi +-for db in $(/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql -BNre "show databases;"|egrep -vi "^information_schema$|^performance_schema$") ++for db in $(/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql --socket=!!!SOCKET!!! -BNre "show databases;"|egrep -vi "^information_schema$|^performance_schema$") + do +- /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mariadb!!!VER!!!/"$db".dump || onfailure $db ++ /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqldump --socket=!!!SOCKET!!! --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mariadb!!!VER!!!/"$db".dump || onfailure $db + done