diff --git a/mysql/CHANGELOG b/mysql/CHANGELOG
index 96feffd7d..3cb5b2517 100644
--- a/mysql/CHANGELOG
+++ b/mysql/CHANGELOG
@@ -70,3 +70,4 @@ Converted all user interface code to use the new Webmin UI library, for a more c
Added a Module Config option to show databases and tables using just their names, which is much faster under MySQL 5 as it avoids the need to count their tables, fields and rows.
---- Changes since 1.410 ----
Display a more friendly error if a scheduled backup cannot be performed because MySQL is down.
+The root password can be more easily change by the new 'Change Administration Password' page.
diff --git a/mysql/index.cgi b/mysql/index.cgi
index f4d4542f7..0a8713d88 100755
--- a/mysql/index.cgi
+++ b/mysql/index.cgi
@@ -209,18 +209,21 @@ else {
'list_tprivs.cgi', 'list_cprivs.cgi',
'edit_cnf.cgi', 'list_procs.cgi',
$canvars ? ( 'list_vars.cgi' ) : ( ),
+ 'root_form.cgi',
);
@titles = ( $text{'users_title'}, $text{'dbs_title'},
$text{'hosts_title'}, $text{'tprivs_title'},
$text{'cprivs_title'},$text{'cnf_title'},
$text{'procs_title'},
$canvars ? ( $text{'vars_title'} ) : ( ),
+ $text{'root_title'},
);
@images = ( 'images/users.gif', 'images/dbs.gif',
'images/hosts.gif', 'images/tprivs.gif',
'images/cprivs.gif', 'images/cnf.gif',
'images/procs.gif',
$canvars ? ( 'images/vars.gif' ) : ( ),
+ 'images/root.gif',
);
if ($access{'perms'} == 2) {
# Remove my.cnf and database connections icons
diff --git a/mysql/lang/en b/mysql/lang/en
index ef4b0ad6d..d8c4cca02 100644
--- a/mysql/lang/en
+++ b/mysql/lang/en
@@ -615,6 +615,7 @@ log_execfile=Executed SQL commands from file $1
log_importupload=Imported data from uploaded file
log_importfile=Imported data from file $1
log_set=Changed $1 MySQL variables
+log_root=Changed administration password
backup_title=Backup Database
backup_title2=Backup All Databases
@@ -821,3 +822,13 @@ compat_no_field_options=Field options
config_echarset=Missing or invalid-looking character set
+root_title=Change Administration Password
+root_header=New administration password
+root_user=Administration login
+root_pass=Current password
+root_newpass1=New password
+root_newpass2=Repeat password
+root_ok=Change Now
+root_err=Failed to change administration password
+root_epass1=No new password entered
+root_epass2=Passwords do not match
diff --git a/mysql/log_parser.pl b/mysql/log_parser.pl
index 4a1c45cf4..245a7c66a 100644
--- a/mysql/log_parser.pl
+++ b/mysql/log_parser.pl
@@ -87,6 +87,9 @@ elsif ($action eq 'import') {
elsif ($action eq 'set') {
return &text('log_set', $object);
}
+elsif ($action eq 'root') {
+ return $text{'log_root'};
+ }
else {
return undef;
}
diff --git a/mysql/root_form.cgi b/mysql/root_form.cgi
new file mode 100644
index 000000000..026529f2d
--- /dev/null
+++ b/mysql/root_form.cgi
@@ -0,0 +1,20 @@
+#!/usr/local/bin/perl
+# Show a form for changing the MySQL root password
+
+require './mysql-lib.pl';
+&ReadParse();
+$access{'perms'} == 1 || &error($text{'perms_ecannot'});
+&ui_print_header(undef, $text{'root_title'}, "");
+
+print &ui_form_start("save_root.cgi", "post");
+print &ui_table_start($text{'root_header'}, undef, 2, [ "width=30%" ]);
+
+print &ui_table_row($text{'root_user'}, "$mysql_login");
+print &ui_table_row($text{'root_pass'}, "$mysql_pass");
+print &ui_table_row($text{'root_newpass1'},
+ &ui_password("newpass1", undef, 20));
+print &ui_table_row($text{'root_newpass2'},
+ &ui_password("newpass2", undef, 20));
+
+print &ui_table_end();
+print &ui_form_end([ [ undef, $text{'root_ok'} ] ]);
diff --git a/mysql/save_root.cgi b/mysql/save_root.cgi
new file mode 100644
index 000000000..4768b5295
--- /dev/null
+++ b/mysql/save_root.cgi
@@ -0,0 +1,27 @@
+#!/usr/local/bin/perl
+# Update the password for root, both in MySQL and Webmin
+
+require './mysql-lib.pl';
+&ReadParse();
+&error_setup($text{'root_err'});
+$access{'perms'} == 1 || &error($text{'perms_ecannot'});
+
+# Validate inputs
+$in{'newpass1'} || &error($text{'root_epass1'});
+$in{'newpass1'} eq $in{'newpass2'} || &error($text{'root_epass2'});
+
+# Update MySQL
+$esc = &escapestr($in{'newpass1'});
+&execute_sql_logged($master_db,
+ "update user set password = $password_func('$esc') ".
+ "where user = '$mysql_login'");
+&execute_sql_logged($master_db, 'flush privileges');
+
+# Update webmin
+$config{'pass'} = $in{'newpass1'};
+&lock_file($module_config_file);
+&save_module_config();
+&unlock_file($module_config_file);
+
+&webmin_log("root");
+&redirect("");
diff --git a/mysql/save_user.cgi b/mysql/save_user.cgi
index b922950f4..447e310de 100755
--- a/mysql/save_user.cgi
+++ b/mysql/save_user.cgi
@@ -70,7 +70,9 @@ if (!$in{'delete'} && !$in{'new'} &&
elsif ($in{'mysqlpass_mode'} == 2) {
$config{'pass'} = undef;
}
- &write_file("$module_config_directory/config", \%config);
+ &lock_file($module_config_file);
+ &save_module_config();
+ &unlock_file($module_config_file);
}
if ($in{'delete'}) {
&webmin_log("delete", "user", $in{'olduser'},