mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
New root password form
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
20
mysql/root_form.cgi
Normal file
20
mysql/root_form.cgi
Normal file
@@ -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'}, "<tt>$mysql_login</tt>");
|
||||
print &ui_table_row($text{'root_pass'}, "<tt>$mysql_pass</tt>");
|
||||
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'} ] ]);
|
||||
27
mysql/save_root.cgi
Normal file
27
mysql/save_root.cgi
Normal file
@@ -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("");
|
||||
@@ -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'},
|
||||
|
||||
Reference in New Issue
Block a user