Commit 53db5edb authored by Daniel Black's avatar Daniel Black Committed by Sergei Golubchik

MDEV-14578: mysql_install_db install unix_socket plugin when...

MDEV-14578: mysql_install_db install unix_socket plugin when --auth-root-authentication-method=socket

$ cmake -DPLUGIN_AUTH_SOCKET=STATIC ../mariadb-server-10.2/

$ scripts/mysql_install_db --datadir=/tmp/mysqldatadir-auth-static --auth-root-socket-user=dan --auth-root-authentication-method=socket --builddir=.  --srcdir=../mariadb-server-10.2
Installing MariaDB/MySQL system tables in '/tmp/mysqldatadir-auth-static' ...
OK

$ client/mysql -S /tmp/mysql.sock -e 'show create user dan@localhost'
+----------------------------------------------------------+
| CREATE USER for dan@localhost                            |
+----------------------------------------------------------+
| CREATE USER 'dan'@'localhost' IDENTIFIED VIA unix_socket |
+----------------------------------------------------------+

$ cmake -DPLUGIN_AUTH_SOCKET=NO ../mariadb-server-10.2/
$ scripts/mysql_install_db --datadir=/tmp/mysqldatadir-auth-none --auth-root-socket-user=dan --auth-root-authentication-method=socket --builddir=.  --srcdir=../mariadb-server-10.2
Installing MariaDB/MySQL system tables in '/tmp/mysqldatadir-auth-none' ...
ERROR: 1126  Can't open shared library '.../plugin/auth_socket/auth_socket.so' (errno: 2, cannot open shared object file: No such file or directory)
2018-05-01 11:38:56 0 [ERROR] Aborting

$ cmake -DPLUGIN_AUTH_SOCKET=DYNAMIC ../mariadb-server-10.2/
$ scripts/mysql_install_db --datadir=/tmp/mysqldatadir-auth-dyn --auth-root-socket-user=dan --auth-root-authentication-method=socket --builddir=.  --srcdir=../mariadb-server-10.2
Installing MariaDB/MySQL system tables in '/tmp/mysqldatadir-auth-dyn' ...
OK
$ ./sql/mysqld  --datadir=/tmp/mysqldatadir-auth-dyn  --lc-messages-dir=${PWD}/sql/share --plugin-dir=./plugin/auth_socket/
$ client/mysql -S /tmp/mysql.sock -e 'show create user dan@localhost'
+----------------------------------------------------------+
| CREATE USER for dan@localhost                            |
+----------------------------------------------------------+
| CREATE USER 'dan'@'localhost' IDENTIFIED VIA unix_socket |
+----------------------------------------------------------+

$ sudo make install
$ sudo chmod a+rwx /usr/local/mysql/data
$ cd /usr/local/mysql/
$ scripts/mysql_install_db  --auth-root-socket-user=dan --auth-root-authentication-method=socket
Installing MariaDB/MySQL system tables in './data' ...
OK
..
$ bin/mysqld_safe
$ client/mysql -S /tmp/mysql.sock -e 'show create user dan@localhost'
+----------------------------------------------------------+
| CREATE USER for dan@localhost                            |
+----------------------------------------------------------+
| CREATE USER 'dan'@'localhost' IDENTIFIED VIA unix_socket |
+----------------------------------------------------------+

Merges #767
parent 1033fa4b
...@@ -307,6 +307,7 @@ then ...@@ -307,6 +307,7 @@ then
langdir="$basedir/sql/share/english" langdir="$basedir/sql/share/english"
srcpkgdatadir="$srcdir/scripts" srcpkgdatadir="$srcdir/scripts"
buildpkgdatadir="$builddir/scripts" buildpkgdatadir="$builddir/scripts"
plugindir="$builddir/plugin/auth_socket/"
elif test -n "$basedir" elif test -n "$basedir"
then then
bindir="$basedir/bin" # only used in the help text bindir="$basedir/bin" # only used in the help text
...@@ -335,6 +336,7 @@ then ...@@ -335,6 +336,7 @@ then
cannot_find_file fill_help_tables.sql @pkgdata_locations@ cannot_find_file fill_help_tables.sql @pkgdata_locations@
exit 1 exit 1
fi fi
plugindir="$basedir/@INSTALL_PLUGINDIR@"
else else
basedir="@prefix@" basedir="@prefix@"
bindir="@bindir@" bindir="@bindir@"
...@@ -342,6 +344,7 @@ else ...@@ -342,6 +344,7 @@ else
mysqld="@libexecdir@/mysqld" mysqld="@libexecdir@/mysqld"
srcpkgdatadir="@pkgdatadir@" srcpkgdatadir="@pkgdatadir@"
buildpkgdatadir="@pkgdatadir@" buildpkgdatadir="@pkgdatadir@"
plugindir="@INSTALL_PLUGINDIR@"
fi fi
# Set up paths to SQL scripts required for bootstrap # Set up paths to SQL scripts required for bootstrap
...@@ -460,6 +463,7 @@ mysqld_install_cmd_line() ...@@ -460,6 +463,7 @@ mysqld_install_cmd_line()
{ {
"$mysqld_bootstrap" $defaults $defaults_group_suffix "$mysqld_opt" --bootstrap $silent_startup\ "$mysqld_bootstrap" $defaults $defaults_group_suffix "$mysqld_opt" --bootstrap $silent_startup\
"--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 --enforce-storage-engine="" \ "--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 --enforce-storage-engine="" \
"--plugin-dir=${plugindir}" \
$args --max_allowed_packet=8M \ $args --max_allowed_packet=8M \
--net_buffer_length=16K --net_buffer_length=16K
} }
......
...@@ -46,8 +46,13 @@ INSERT INTO tmp_user_nopasswd VALUES ('localhost','root','','Y','Y','Y','Y','Y', ...@@ -46,8 +46,13 @@ INSERT INTO tmp_user_nopasswd VALUES ('localhost','root','','Y','Y','Y','Y','Y',
REPLACE INTO tmp_user_nopasswd SELECT @current_hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N','',0 FROM dual WHERE @current_hostname != 'localhost'; REPLACE INTO tmp_user_nopasswd SELECT @current_hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N','',0 FROM dual WHERE @current_hostname != 'localhost';
REPLACE INTO tmp_user_nopasswd VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N','',0); REPLACE INTO tmp_user_nopasswd VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N','',0);
REPLACE INTO tmp_user_nopasswd VALUES ('::1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N', '', 0); REPLACE INTO tmp_user_nopasswd VALUES ('::1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N', '', 0);
-- More secure root account using unix sucket auth. -- More secure root account using unix socket auth.
INSERT INTO tmp_user_socket VALUES ('localhost',IFNULL(@auth_root_socket, 'root'),'','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'unix_socket','','N', 'N','', 0); INSERT INTO tmp_user_socket VALUES ('localhost',IFNULL(@auth_root_socket, 'root'),'','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'unix_socket','','N', 'N','', 0);
-- Need aria support to lookup information_schema.plugins (result is tmptable)
IF @auth_root_socket is not null THEN
IF exists (SELECT 1 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'aria' AND support IN ('YES', 'DEFAULT', 'ENABLED')) THEN
IF not exists(select 1 from information_schema.plugins where plugin_name='unix_socket') THEN
INSTALL SONAME 'auth_socket'; END IF; END IF; END IF;
-- Anonymous user with no privileges. -- Anonymous user with no privileges.
INSERT INTO tmp_user_anonymous (host,user) VALUES ('localhost',''); INSERT INTO tmp_user_anonymous (host,user) VALUES ('localhost','');
INSERT INTO tmp_user_anonymous (host,user) SELECT @current_hostname,'' FROM dual WHERE @current_hostname != 'localhost'; INSERT INTO tmp_user_anonymous (host,user) SELECT @current_hostname,'' FROM dual WHERE @current_hostname != 'localhost';
......
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