From 4e0de7b2a579d79876c98dddecaeb9b62e3e25df Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 5 Oct 2007 21:19:53 +0000 Subject: [PATCH] Use environment variable to set password --- mysql/CHANGELOG | 1 + mysql/mysql-lib.pl | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mysql/CHANGELOG b/mysql/CHANGELOG index 892a5cd51..def2b468d 100644 --- a/mysql/CHANGELOG +++ b/mysql/CHANGELOG @@ -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. diff --git a/mysql/mysql-lib.pl b/mysql/mysql-lib.pl index a432d10ed..aa3d5c69b 100644 --- a/mysql/mysql-lib.pl +++ b/mysql/mysql-lib.pl @@ -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) : ""); }