Use MYSQL_PWD more often
authorJamie Cameron <jcameron@webmin.com>
Mon, 5 Jan 2009 17:54:10 +0000 (17:54 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 5 Jan 2009 17:54:10 +0000 (17:54 +0000)
mysql/CHANGELOG
mysql/mysql-lib.pl

index 84f780d..0db556a 100644 (file)
@@ -75,3 +75,6 @@ The root password can be more easily change by the new 'Change Administration Pa
 Display the number of tables and records created when executing SQL for a restore.
 ---- Changes since 1.430 ----
 Improved the input for setting the default value for new fields, and added support for CURRENT_TIMESTAMP.
+---- Changes since 1.440 ----
+The correct character set is ready from my.cnf when connecting using DBI mode, thanks to jianxia.
+The password is passed to all MySQL commands using the MYSQL_PWD environment variables on systems running MySQL 4.1 and later, version 5.1 in older Webmin releases.
index 00ac533..bb64988 100644 (file)
@@ -96,12 +96,14 @@ 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;
+if (&supports_env_pass()) {
+       $ENV{'MYSQL_PWD'} = $pass;
+       }
 return ($sock ? " -S $sock" : "").
        ($host ? " -h $host" : "").
        ($port ? " -P $port" : "").
        ($login ? " -u ".quotemeta($login) : "").
-       ($mysql_version >= 5.1 ? "" :   # Password comes from environment
+       (&supports_env_pass() ? "" :    # Password comes from environment
         $pass && $mysql_version >= 4.1 ? " --password=".quotemeta($pass) :
         $pass ? " -p".quotemeta($pass) : "");
 }
@@ -621,6 +623,13 @@ else {
        }
 }
 
+# supports_env_pass()
+# Returns 1 if passing the password via an environment variable is supported
+sub supports_env_pass
+{
+return $mysql_version >= 4.1;
+}
+
 # user_priv_cols()
 # Returns the number of columns used for privileges in the user table
 sub user_priv_cols