Yes, the problem is that the $output file doesn't get the chmod and is world readable while `mariadb-secure-installation` is running.
After launching `mariadb-secure-installation` and hitting <enter> for no password (first question), we can see:
[root@cent7 ~]# ls -la .my* | grep -v .mysql_history
|
-rw-------. 1 root root 70 Aug 23 19:11 .my.cnf.2257
|
-rw-r--r--. 1 root root 130 Aug 23 19:11 .my.output.2257
|
-rw-------. 1 root root 32 Aug 23 19:11 .mysql.2257
|
[root@cent7 ~]# cat .my.output.2257
|
CREATE USER for root@localhost
|
CREATE USER `root`@`localhost` IDENTIFIED VIA mysql_native_password USING 'invalid' OR unix_socket
|
[root@cent7 ~]#
|
Above, the read bits are less secure for `.my.output.2257` than other files but so far there is no sensitive content in the file.
If we answer no for "Switch to unix_socket authentication [Y/n]" it prompts for "Change the root password? [Y/n]". After answering yes to change the password, there is a moment where the password hash is in the file, eg:
[root@cent7 ~]# tail -F .my.output.2472
|
CREATE USER for root@localhost
|
CREATE USER `root`@`localhost` IDENTIFIED VIA mysql_native_password USING '*F97AEB38B3275C06D822FC9341A2151642C81988' OR unix_socket
|
tail: .my.output.2472: file truncated
|
tail: ‘.my.output.2472’ has become inaccessible: No such file or directory
|
This isn't a problem for the files $config and $command because the prepare() function calls chmod on them before they are used. It should be safe after doing this for $output in prepare because the file is truncated/written later in `do_query()` but never explicitly rm/create:
$mysql_command --defaults-file=$config $defaults_extra_file $no_defaults $args <$command >$output
|
I'd like to work on this.