Add extra check for MYSQL_PWD variable
authorJamie Cameron <jcameron@webmin.com>
Fri, 6 Feb 2009 23:17:42 +0000 (23:17 +0000)
committerJamie Cameron <jcameron@webmin.com>
Fri, 6 Feb 2009 23:17:42 +0000 (23:17 +0000)
31 files changed:
mysql/config
mysql/config-aix
mysql/config-cobalt-linux
mysql/config-coherent-linux
mysql/config-debian-linux
mysql/config-debian-linux-2.2-*
mysql/config-freebsd
mysql/config-gentoo-linux
mysql/config-mandrake-linux
mysql/config-mandrake-linux-10.1-*
mysql/config-msc-linux
mysql/config-netbsd
mysql/config-open-linux
mysql/config-openmamba-linux
mysql/config-redhat-linux
mysql/config-redhat-linux-7.0-*
mysql/config-slackware-linux-8.0-*
mysql/config-sol-linux
mysql/config-solaris-10
mysql/config-solaris-11-*
mysql/config-solaris-9
mysql/config-suse-linux
mysql/config-suse-linux-7.1-*
mysql/config-trustix-linux
mysql/config-turbo-linux
mysql/config-united-linux
mysql/config-windows
mysql/config.info
mysql/index.cgi
mysql/lang/en
mysql/mysql-lib.pl

index 588cb5d..2894d29 100644 (file)
@@ -19,3 +19,4 @@ mysql_data=/usr/local/mysql/var
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index ff6f30c..5a32424 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/usr/local/var/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index b5c0114..f0a82b0 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 025b0d1..f8e1451 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 1b81487..06d7138 100644 (file)
@@ -17,3 +17,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index f2582ce..aac7c89 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/mysql/my.cnf
 max_text=1000
+nopwd=0
index ff6f30c..5a32424 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/usr/local/var/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 3a1a769..ee51b14 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/mysql/my.cnf
 max_text=1000
+nopwd=0
index b5c0114..f0a82b0 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 025b0d1..f8e1451 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index dafc207..a3ce11b 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 2caab77..b34af02 100644 (file)
@@ -17,3 +17,4 @@ passwd_mode=0
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index b5c0114..f0a82b0 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index b5c0114..f0a82b0 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index b5c0114..f0a82b0 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 025b0d1..f8e1451 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index c3d4c29..714a650 100644 (file)
@@ -22,3 +22,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index fbb60b6..f85a183 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 9c503a5..566ee56 100644 (file)
@@ -19,3 +19,4 @@ mysql_data=/var/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 8b7595c..3d274df 100755 (executable)
@@ -19,3 +19,4 @@ mysql_data=/var/mysql/5.0/data
 max_dbs=50
 my_cnf=/etc/mysql/my.cnf
 max_text=1000
+nopwd=0
index 6512d8a..5c07199 100644 (file)
@@ -19,3 +19,4 @@ mysql_data=/var/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 969a815..4ca6250 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 3877ade..efdcc9a 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 3877ade..efdcc9a 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index b5c0114..f0a82b0 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 3877ade..efdcc9a 100644 (file)
@@ -18,3 +18,4 @@ mysql_data=/var/lib/mysql
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 94655e1..c92ed5b 100644 (file)
@@ -18,3 +18,4 @@ passwd_mode=0
 max_dbs=50
 my_cnf=/etc/my.cnf
 max_text=1000
+nopwd=0
index 8db77a4..a3d02e8 100644 (file)
@@ -6,6 +6,7 @@ style=Show databases and tables as,1,1-List,0-Icons,2-Names only
 add_mode=Use vertical row editing interface,1,1-Yes,0-No
 blob_mode=Show blob and text fields as,1,0-Data in table,1-Links to download
 nodbi=Use DBI to connect if available?,1,0-Yes,1-No
+nopwd=Use MYSQL_PWD variable to pass password?,1,0-Yes,1-No
 date_subs=Do <tt>strftime</tt> substitution of backup destinations?,1,1-Yes,0-No
 passwd_mode=Password hashing mode,1,1-Old,0-Default
 encoding=Encoding for database content,3,Default (from current language)
index 583aa1b..9d1ff99 100755 (executable)
@@ -32,7 +32,7 @@ if ($mysql_version < 0) {
        &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
                &help_search_link("mysql", "man", "doc", "google"));
        print &text('index_elibrary', "<tt>$config{'mysql'}</tt>",
-                 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
+                 "../config.cgi?$module_name"),"<p>\n";
        print &text('index_mysqlver', "$config{'mysql'} -V"),"\n";
        print "<pre>$out</pre>\n";
        &ui_print_footer("/", $text{'index'});
@@ -42,7 +42,7 @@ elsif (!$mysql_version) {
        &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
                &help_search_link("mysql", "man", "doc", "google"));
        print &text('index_ever', "<tt>$config{'mysql'}</tt>",
-                 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
+                 "../config.cgi?$module_name"),"<p>\n";
        print &text('index_mysqlver', "$config{'mysql'} -V"),"\n";
        print "<pre>$out</pre>\n";
        &ui_print_footer("/", $text{'index'});
@@ -52,7 +52,17 @@ open(VERSION, ">$module_config_directory/version");
 print VERSION $mysql_version,"\n";
 close(VERSION);
 
+# Check if MYSQL_PWD works
 ($r, $rout) = &is_mysql_running();
+if ($r > 0 && !&working_env_pass()) {
+       &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
+               &help_search_link("mysql", "man", "doc", "google"));
+       print &text('index_eenvpass', "<tt>$config{'mysql'}</tt>",
+                   "../config.cgi?$module_name"),"<p>\n";
+       &ui_print_footer("/", $text{'index'});
+       exit;
+       }
+
 if ($r == 0) {
        # Not running .. need to start it
        &main_header();
@@ -69,13 +79,6 @@ if ($r == 0) {
                print "</form>\n";
                }
        }
-elsif ($r == -1 && $access{'user'} && 0) {
-       # Running, but the user's password is wrong
-       &main_header();
-       print "<b>",&text('index_nouser', "<tt>$access{'user'}</tt>"),
-             "</b><p>\n";
-       print &text('index_emsg', "<tt>$rout</tt>"),"<p>\n";
-       }
 elsif ($r == -1) {
        # Running, but webmin doesn't know the root (or user's) password!
        &main_header();
index 5da26f2..2034ca1 100644 (file)
@@ -24,6 +24,7 @@ index_version=MySQL version $1
 index_nomod=Warning: The Perl module $1 is not installed on your system, so Webmin will not be able to reliably access your MySQL database. <a href='$2'>Click here</a> to install it now.
 index_nomods=Warning: The Perl modules $1 and $2 are not installed on your system, so Webmin will not be able to reliably access your MySQL database. <a href='$3'>Click here</a> to install them now.
 index_mysqlver=The command <tt>$1</tt> returned :
+index_eenvpass=The MySQL client program $1 does not accept passwords passed using the <tt>MYSQL_PWD</tt> environment variable. To ensure that Webmin is able to fully communicate with MySQL, this option should be turned off on the <a href='$2'>module configuration</a> page.
 index_nodbs=You do not have access to any MySQL databases.
 index_nodbs2=No MySQL databases were found on your system.
 index_backup=Backup Databases
index bb64988..4fac033 100644 (file)
@@ -115,7 +115,7 @@ return ($sock ? " -S $sock" : "").
 sub is_mysql_running
 {
 # First type regular connection
-if ($driver_handle) {
+if ($driver_handle && !$config{'nodbi'}) {
        local $main::error_must_die = 1;
        local ($data, $rv);
        eval { $data = &execute_sql_safe(undef, "select version()") };
@@ -245,7 +245,7 @@ if ($gconfig{'debug_what_sql'}) {
        &webmin_debug_log('SQL', "db=$_[0] sql=$sql".$params);
        }
 $sql =~ s/\\/\\\\/g;
-if ($driver_handle) {
+if ($driver_handle && !$config{'nodbi'}) {
        # Use the DBI interface
        local $cstr = "database=$_[0]";
        $cstr .= ";host=$config{'host'}" if ($config{'host'});
@@ -627,7 +627,19 @@ else {
 # Returns 1 if passing the password via an environment variable is supported
 sub supports_env_pass
 {
-return $mysql_version >= 4.1;
+return $mysql_version >= 4.1 && !$config{'nopwd'};
+}
+
+# working_env_pass()
+# Returns 1 if MYSQL_PWD can be used to pass the password to mysql
+sub working_env_pass
+{
+return 1 if (!&supports_env_pass());   # Not even used
+local $config{'nodbi'} = 1;
+local $data;
+local $main::error_must_die = 1;
+eval { $data = &execute_sql_safe(undef, "select version()") };
+return $@ || !$data ? 0 : 1;
 }
 
 # user_priv_cols()