@@ -21,7 +21,7 @@ invoke() {
21
21
fi
22
22
}
23
23
24
- MYSQL_BOOTSTRAP=" /usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables --default-storage-engine=myisam"
24
+ MYSQL_BOOTSTRAP=" /usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables --default-storage-engine=myisam --plugin-load-add=auth_socket "
25
25
26
26
test_passwordless_root_login () {
27
27
mysql --no-defaults -u root -h localhost < /dev/null > /dev/null 2>&1
@@ -40,12 +40,11 @@ set_mysql_rootpw() {
40
40
# this avoids us having to call "test" or "[" on $rootpw
41
41
cat << EOF > $tfile
42
42
USE mysql;
43
- UPDATE user SET password=PASSWORD("$rootpw ") WHERE user='root';
43
+ SET sql_log_bin=0;
44
+ UPDATE user SET password="", plugin="unix_socket" WHERE user='root';
44
45
FLUSH PRIVILEGES;
45
46
EOF
46
- if grep -q ' PASSWORD("")' $tfile ; then
47
- retval=0
48
- elif [ " $1 " = " online" ]; then
47
+ if [ " $1 " = " online" ]; then
49
48
mysql --no-defaults -u root -h localhost < $tfile > /dev/null
50
49
retval=$?
51
50
else
@@ -123,26 +122,30 @@ case "$1" in
123
122
# As the binlog cron scripts to need at least the Super_priv, I do first
124
123
# the old query which always succeeds and then the new which may or may not.
125
124
126
- # recreate the credentials file if not present or without mysql_upgrade stanza
125
+ # recreate the credentials file if not present or with debian-sys-maint
126
+ # still there
127
127
dc=$mysql_cfgdir /debian.cnf;
128
- if [ -e " $dc " -a -n " ` fgrep mysql_upgrade $dc 2> /dev/null` " ]; then
129
- pass=" ` sed -n ' s/^[ ]*password *= *// p' $dc | head -n 1` "
130
- else
131
- pass=` perl -e ' print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)' ` ;
128
+ if [ ! -e " $dc " -o -n " ` fgrep debian-sys-maint $dc 2> /dev/null` " ]; then
132
129
if [ ! -d " $mysql_cfgdir " ]; then install -o 0 -g 0 -m 0755 -d $mysql_cfgdir ; fi
130
+ if [ -e " $dc " ]; then
131
+ oldconf=` mktemp --tmpdir $mysql_cfgdir -t debian_old_config.XXXXXX`
132
+ cp $dc $oldconf
133
+ else
134
+ oldconf=' '
135
+ fi
133
136
umask 066
134
137
cat /dev/null > $dc
135
138
umask 022
136
139
echo " # Automatically generated for Debian scripts. DO NOT TOUCH!" >> $dc
137
140
echo " [client]" >> $dc
138
141
echo " host = localhost" >> $dc
139
- echo " user = debian-sys-maint " >> $dc
140
- echo " password = $pass " >> $dc
142
+ echo " user = root " >> $dc
143
+ echo " password = " >> $dc
141
144
echo " socket = $mysql_rundir /mysqld.sock" >> $dc
142
145
echo " [mysql_upgrade]" >> $dc
143
146
echo " host = localhost" >> $dc
144
- echo " user = debian-sys-maint " >> $dc
145
- echo " password = $pass " >> $dc
147
+ echo " user = root " >> $dc
148
+ echo " password = " >> $dc
146
149
echo " socket = $mysql_rundir /mysqld.sock" >> $dc
147
150
echo " basedir = /usr" >> $dc
148
151
fi
@@ -153,42 +156,45 @@ case "$1" in
153
156
# update privilege tables
154
157
password_column_fix_query=` /bin/echo -e \
155
158
" USE mysql;\n" \
159
+ " SET sql_log_bin=0;\n" \
156
160
" ALTER TABLE user CHANGE Password Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL;" `
157
- replace_query=` /bin/echo -e \
158
- " USE mysql;\n" \
159
- " SET sql_mode='';\n" \
160
- " REPLACE INTO user SET " \
161
- " host='localhost', user='debian-sys-maint', password=password('$pass '), " \
162
- " Select_priv='Y', Insert_priv='Y', Update_priv='Y', Delete_priv='Y', " \
163
- " Create_priv='Y', Drop_priv='Y', Reload_priv='Y', Shutdown_priv='Y', " \
164
- " Process_priv='Y', File_priv='Y', Grant_priv='Y', References_priv='Y', " \
165
- " Index_priv='Y', Alter_priv='Y', Super_priv='Y', Show_db_priv='Y', " \
166
- " Create_tmp_table_priv='Y', Lock_tables_priv='Y', Execute_priv='Y', " \
167
- " Repl_slave_priv='Y', Repl_client_priv='Y', Create_view_priv='Y', " \
168
- " Show_view_priv='Y', Create_routine_priv='Y', Alter_routine_priv='Y', " \
169
- " Create_user_priv='Y', Event_priv='Y', Trigger_priv='Y'," \
170
- " ssl_cipher='', x509_issuer='', x509_subject='';" ` ;
161
+
162
+ replace_query=" USE mysql; SET sql_mode='', sql_log_bin=0; DROP USER 'debian-sys-maint'@'localhost';"
163
+
171
164
# Engines supported by etch should be installed per default. The query sequence is supposed
172
165
# to be aborted if the CREATE TABLE fails due to an already existent table in which case the
173
166
# admin might already have chosen to remove one or more plugins. Newlines are necessary.
174
167
install_plugins=` /bin/echo -e \
175
168
" USE mysql;\n" \
169
+ " SET sql_log_bin=0;\n" \
176
170
" CREATE TABLE IF NOT EXISTS plugin (name char(64) COLLATE utf8_bin NOT NULL DEFAULT '', " \
177
171
" dl char(128) COLLATE utf8_bin NOT NULL DEFAULT '', " \
178
172
" PRIMARY KEY (name)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='MySQL plugins';" `
179
173
180
174
# Upgrade password column format before the root password gets set.
181
175
echo " $password_column_fix_query " | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
182
-
183
- db_get mariadb-server/root_password && rootpw=" $RET "
184
- if ! set_mysql_rootpw; then
185
- password_error=" yes"
186
- fi
187
-
176
+ # install unix_socket plugin but ignore if already there
188
177
set +e
189
- echo " $replace_query " | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
190
178
echo " $install_plugins " | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
191
179
set -e
180
+ # overly complicated here but ensures a plugin unix_socket is installed and is idpotent if already installed
181
+ echo " SET sql_log_bin=0; USE mysql; DELIMITER //; CREATE PROCEDURE debian_plugin_install(IN plugin_name CHAR(50), IN soname CHAR(50)) BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND EXECUTE
182
+ inst_plug; set @plugin_name=plugin_name; set @soname=soname ;set @install_plugin=CONCAT(\" INSTALL PLUGIN \" ,@plugin_name,\" SONAME '\" , @soname, \" '\" );PREPARE inst_plug FROM @install_plugin ;
183
+ select PLUGIN_NAME INTO @a from information_schema.plugins where PLUGIN_NAME=@plugin_name AND PLUGIN_STATUS='ACTIVE' AND PLUGIN_TYPE='AUTHENTICATION' AND PLUGIN_LIBRARY LIKE concat(@soname,'%'
184
+ ); DEALLOCATE PREPARE inst_plug; END// CALL debian_plugin_install('unix_socket', 'auth_socket') // DROP PROCEDURE debian_plugin_install//" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
185
+
186
+ db_get mariadb-server/root_password && rootpw=" $RET "
187
+ if ! set_mysql_rootpw; then
188
+ password_error=" yes"
189
+ # restore old config file if exists
190
+ [ -e $oldconf ] && mv $oldconf $dc
191
+ else
192
+ [ -e $oldconf ] && rm -f $oldconf
193
+ # purge debian-sys-maint user
194
+ set +e
195
+ echo " $replace_query " | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
196
+ set -e
197
+ fi
192
198
;;
193
199
194
200
abort-upgrade|abort-remove|abort-configure)
0 commit comments