Use environment variable to set password

This commit is contained in:
Jamie Cameron
2007-10-05 21:19:53 +00:00
parent 8c249faeaf
commit 4e0de7b2a5
2 changed files with 4 additions and 1 deletions

View File

@@ -56,3 +56,4 @@ Improved detection of support for views, which avoids errors with information_sc
---- Changes since 1.370 ----
Added an option on the backup form to create the destination directory if missing.
Re-wrote the backup form to use the new Webmin UI library.
The MySQL password is no longer passed on the command line.

View File

@@ -89,11 +89,13 @@ local $pass = defined($_[1]) ? $_[1] : $mysql_pass;
local $host = defined($_[2]) ? $_[2] : $config{'host'};
local $port = defined($_[3]) ? $_[3] : $config{'port'};
local $sock = defined($_[4]) ? $_[4] : $config{'sock'};
$ENV{'MYSQL_PWD'} = $pass;
return ($sock ? " -S $sock" : "").
($host ? " -h $host" : "").
($port ? " -P $port" : "").
($login ? " -u ".quotemeta($login) : "").
($pass && $mysql_version >= 4.1 ? " --password=".quotemeta($pass) :
($mysql_version >= 5.0 ? "" : # Password comes from environment
$pass && $mysql_version >= 4.1 ? " --password=".quotemeta($pass) :
$pass ? " -p".quotemeta($pass) : "");
}