Handle hostnames with upper-case letters
[webmin.git] / mysql / save_root.cgi
1 #!/usr/local/bin/perl
2 # Update the password for root, both in MySQL and Webmin
3
4 require './mysql-lib.pl';
5 &ReadParse();
6 &error_setup($text{'root_err'});
7 $access{'perms'} == 1 || &error($text{'perms_ecannot'});
8
9 # Validate inputs
10 $in{'newpass1'} || &error($text{'root_epass1'});
11 $in{'newpass1'} eq $in{'newpass2'} || &error($text{'root_epass2'});
12
13 # Update MySQL
14 $esc = &escapestr($in{'newpass1'});
15 $user = $mysql_login || "root";
16 &execute_sql_logged($master_db,
17     "update user set password = $password_func('$esc') ".
18     "where user = '$user'");
19 &execute_sql_logged($master_db, 'flush privileges');
20
21 # Update webmin
22 $config{'pass'} = $in{'newpass1'};
23 &lock_file($module_config_file);
24 &save_module_config();
25 &unlock_file($module_config_file);
26
27 &webmin_log("root");
28 &redirect("");