mirror of
https://github.com/webmin/webmin.git
synced 2025-07-25 01:23:45 +00:00
Prevent password change when it makes no sense https://github.com/virtualmin/virtualmin-gpl/issues/648
This commit is contained in:
@ -865,6 +865,7 @@ root_epass1=No new password entered
|
|||||||
root_epass2=Passwords do not match
|
root_epass2=Passwords do not match
|
||||||
root_none=No password!
|
root_none=No password!
|
||||||
root_auto=Automatic (typically <tt>root</tt>)
|
root_auto=Automatic (typically <tt>root</tt>)
|
||||||
|
root_socket=The MySQL <tt>$1</tt> user is using Unix socket authentication, so no password is needed and the password cannot be changed.
|
||||||
|
|
||||||
mysqlpass_err=MySQL safe mode
|
mysqlpass_err=MySQL safe mode
|
||||||
mysqlpass_esafecmd=The command $1 needed to start MySQL with authentication disabled was not found
|
mysqlpass_esafecmd=The command $1 needed to start MySQL with authentication disabled was not found
|
||||||
|
@ -2005,5 +2005,19 @@ if ($mysql_module_version =~ /mariadb/i) {
|
|||||||
return $htext;
|
return $htext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# mysql_login_type(user)
|
||||||
|
# Returns one of 'password' or 'socket'
|
||||||
|
sub mysql_login_type
|
||||||
|
{
|
||||||
|
my ($user) = @_;
|
||||||
|
my $rv;
|
||||||
|
eval {
|
||||||
|
local $main::error_must_die = 1;
|
||||||
|
$rv = &execute_sql_safe($master_db, "select plugin from user where user = ?", $user);
|
||||||
|
};
|
||||||
|
return 'password' if ($@); # Old version without plugins
|
||||||
|
return $rv->{'data'}->[0]->[0] =~ /unix_socket/i ? 'socket' : 'password';
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
@ -6,19 +6,27 @@ require './mysql-lib.pl';
|
|||||||
$access{'perms'} == 1 || &error($text{'perms_ecannot'});
|
$access{'perms'} == 1 || &error($text{'perms_ecannot'});
|
||||||
&ui_print_header(undef, $text{'root_title'}, "");
|
&ui_print_header(undef, $text{'root_title'}, "");
|
||||||
|
|
||||||
print &ui_form_start("save_root.cgi", "post");
|
$mode = &mysql_login_type($mysql_login || 'root');
|
||||||
print &ui_table_start($text{'root_header'}, undef, 2);
|
if ($mode eq 'socket') {
|
||||||
|
print &ui_alert_box(&text('root_socket', $mysql_login), 'warn');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print &ui_form_start("save_root.cgi", "post");
|
||||||
|
print &ui_table_start($text{'root_header'}, undef, 2);
|
||||||
|
|
||||||
print &ui_table_row($text{'root_user'},
|
print &ui_table_row($text{'root_user'},
|
||||||
$mysql_login ? "<tt>$mysql_login</tt>" : "<label>$text{'root_auto'}</label>");
|
$mysql_login ? "<tt>$mysql_login</tt>"
|
||||||
print &ui_table_row($text{'root_pass'},
|
: "<label>$text{'root_auto'}</label>");
|
||||||
$mysql_pass ? "<tt>$mysql_pass</tt>" : &ui_text_color($text{'root_none'}, 'danger'));
|
print &ui_table_row($text{'root_pass'},
|
||||||
print &ui_table_row($text{'root_newpass1'},
|
$mysql_pass ? "<tt>$mysql_pass</tt>"
|
||||||
&ui_password("newpass1", undef, 20));
|
: &ui_text_color($text{'root_none'}, 'danger'));
|
||||||
print &ui_table_row($text{'root_newpass2'},
|
print &ui_table_row($text{'root_newpass1'},
|
||||||
&ui_password("newpass2", undef, 20));
|
&ui_password("newpass1", undef, 20));
|
||||||
|
print &ui_table_row($text{'root_newpass2'},
|
||||||
|
&ui_password("newpass2", undef, 20));
|
||||||
|
|
||||||
print &ui_table_end();
|
print &ui_table_end();
|
||||||
print &ui_form_end([ [ undef, $text{'root_ok'} ] ]);
|
print &ui_form_end([ [ undef, $text{'root_ok'} ] ]);
|
||||||
|
}
|
||||||
|
|
||||||
&ui_print_footer("", $text{'index_return'});
|
&ui_print_footer("", $text{'index_return'});
|
||||||
|
Reference in New Issue
Block a user