#!/usr/bin/perl # save_user.cgi # Save, create or delete a user require './mysql-lib.pl'; &ReadParse(); $access{'perms'} == 1 || &error($text{'perms_ecannot'}); if ($in{'delete'}) { # Delete some user &execute_sql_logged($master_db, "delete from user where user = '$in{'olduser'}' ". "and host = '$in{'oldhost'}'"); } else { # Validate inputs &error_setup($text{'user_err'}); $in{'mysqluser_def'} || $in{'mysqluser'} =~ /^\S+$/ || &error($text{'user_euser'}); $in{'host_def'} || $in{'host'} =~ /^\S+$/ || &error($text{'user_ehost'}); if ($in{'mysqlpass_mode'} eq '0' && $in{'mysqlpas'} =~ /\\/) { &error($text{'user_eslash'}); } %perms = map { $_, 1 } split(/\0/, $in{'perms'}); @desc = &table_structure($master_db, 'user'); %fieldmap = map { lc($_->{'field'}), $_->{'index'} } @desc; $host = $in{'host_def'} ? '%' : $in{'host'}; $oldhost = $in{'oldhost'}; $user = $in{'mysqluser_def'} ? '' : $in{'mysqluser'}; $olduser = defined($in{'olduser'}) ? $in{'olduser'} : $user; @pfields = map { $_->[0] } &priv_fields('user'); my @ssl_field_names = &ssl_fields(); my @ssl_field_values = map { '' } @ssl_field_names; my @other_field_names = &other_user_fields(); my @other_field_values = map { '' } @other_field_names; my ($ver, $variant) = &get_remote_mysql_variant(); my $plugin = &get_mysql_plugin(1); # Create a new user if ($in{'new'}) { &create_user({ 'user', $olduser, 'pass', $in{'mysqlpass'}, 'host', $host, 'perms', \%perms, 'pfields', \@pfields, 'ssl_field_names', \@ssl_field_names, 'ssl_field_values', \@ssl_field_values, 'other_field_names', \@other_field_names, 'other_field_values', \@other_field_values, }); } # Update an existing user else { # Rename user and/or host, if requested my $changing_user = ($user ne $olduser); my $changing_host = ($host ne $oldhost); if ($changing_user || $changing_host) { &rename_user({ 'user', $user, 'olduser', $olduser, 'host', $host, 'oldhost', $oldhost, }); $olduser = $user if ($changing_user); $oldhost = $host if ($changing_host); } # Update user password, if requested if ($in{'mysqlpass_mode'} == 4) { # Never used for admin accounts &change_user_password(undef, $olduser, $oldhost); } elsif ($in{'mysqlpass_mode'} != 1) { ($in{'mysqlpass_mode'} eq '0' && !$in{'mysqlpass'}) && &error($text{'root_epass1'}); my $pass = $in{'mysqlpass'} || ''; &change_user_password($pass, $olduser, $oldhost); } &update_privileges({ 'user', $olduser, 'host', $oldhost, 'perms', \%perms, 'pfields', \@pfields }); } # Save various limits my %mdb104_diff = ('max_connections', 'max_connections_per_hour', 'max_questions', 'max_queries_per_hour', 'max_updates', 'max_updates_per_hour'); foreach $f ('max_user_connections', 'max_connections', 'max_questions', 'max_updates') { next if (&compare_version_numbers($ver, 5) < 0 || !defined($in{$f.'_def'})); $in{$f.'_def'} || $in{$f} =~ /^\d+$/ || &error($text{'user_e'.$f}); if ($variant eq "mariadb" && &compare_version_numbers($ver, "10.4") >= 0) { my $f_tbl_diff = $mdb104_diff{$f} || $f; &execute_sql_logged($mysql::master_db, "alter user '$olduser'\@'$oldhost' with $f_tbl_diff " .($in{$f.'_def'} ? 0 : $in{$f}).""); } else { &execute_sql_logged($master_db, "update user set $f = ? ". "where user = ? and host = ?", $in{$f.'_def'} ? 0 : $in{$f}, $olduser, $oldhost); } } # Set SSL fields if ($variant eq "mariadb" && &compare_version_numbers($ver, "10.4") >= 0) { if ($in{'ssl_type'} =~ /^(NONE|SSL|X509)$/) { &execute_sql_logged($mysql::master_db, "alter user '$olduser'\@'$oldhost' require $in{'ssl_type'}"); } } else { if (&compare_version_numbers($ver, 5) >= 0 && defined($in{'ssl_type'}) && (!$in{'new'} || $in{'ssl_type'} || $in{'ssl_cipher'})) { &execute_sql_logged($master_db, "update user set ssl_type = ? ". "where user = ? and host = ?", $in{'ssl_type'}, $olduser, $oldhost); &execute_sql_logged($master_db, "update user set ssl_cipher = ? ". "where user = ? and host = ?", $in{'ssl_cipher'}, $olduser, $oldhost); } } } &execute_sql_logged($master_db, 'flush privileges'); # Log actions if ($in{'delete'}) { &webmin_log("delete", "user", $in{'olduser'}, { 'user' => $in{'olduser'}, 'host' => $in{'oldhost'} } ); } elsif ($in{'new'}) { &webmin_log("create", "user", $in{'mysqluser_def'} ? '' : $in{'mysqluser'}, { 'user' => $in{'mysqluser_def'} ? '' : $in{'mysqluser'}, 'host' => $in{'host_def'} ? '' : $in{'host'} } ); } else { &webmin_log("modify", "user", $in{'mysqluser_def'} ? '' : $in{'mysqluser'}, { 'user' => $in{'mysqluser_def'} ? '' : $in{'mysqluser'}, 'host' => $in{'host_def'} ? '' : $in{'host'} } ); } &redirect("list_users.cgi");
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
help | Folder | 0755 |
|
|
images | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
CHANGELOG | File | 8.12 KB | 0644 |
|
acl_security.pl | File | 4.43 KB | 0755 |
|
backup.pl | File | 4.17 KB | 0755 |
|
backup_config.pl | File | 1.01 KB | 0755 |
|
backup_db.cgi | File | 8.07 KB | 0755 |
|
backup_form.cgi | File | 6.78 KB | 0755 |
|
cgi_args.pl | File | 577 B | 0755 |
|
config | File | 522 B | 0644 |
|
config-AlmaLinux-7.0-ALL | File | 418 B | 0644 |
|
config-Amazon-Linux-2-ALL | File | 403 B | 0644 |
|
config-CentOS-Linux-7.0-ALL | File | 418 B | 0644 |
|
config-CentOS-Stream-Linux-8.0-ALL | File | 418 B | 0644 |
|
config-CloudLinux-8.0-ALL | File | 418 B | 0644 |
|
config-Oracle-Linux-8.0-ALL | File | 418 B | 0644 |
|
config-Redhat-Enterprise-Linux-7.0-ALL | File | 418 B | 0644 |
|
config-Rocky-Linux-7.0-ALL | File | 418 B | 0644 |
|
config-Scientific-Linux-7.0-ALL | File | 403 B | 0644 |
|
config-Ubuntu-Linux-16.04-17.99 | File | 453 B | 0644 |
|
config-Ubuntu-Linux-18.04-ALL | File | 420 B | 0644 |
|
config-aix | File | 479 B | 0644 |
|
config-cobalt-linux | File | 417 B | 0644 |
|
config-coherent-linux | File | 419 B | 0644 |
|
config-debian-linux | File | 416 B | 0644 |
|
config-debian-linux-10.0-ALL | File | 420 B | 0644 |
|
config-debian-linux-2.2-9.0 | File | 436 B | 0644 |
|
config-freebsd | File | 479 B | 0644 |
|
config-freebsd-8-ALL | File | 516 B | 0644 |
|
config-gentoo-linux | File | 413 B | 0644 |
|
config-mandrake-linux | File | 399 B | 0644 |
|
config-mandrake-linux-10.1-ALL | File | 401 B | 0644 |
|
config-msc-linux | File | 421 B | 0644 |
|
config-netbsd | File | 431 B | 0644 |
|
config-open-linux | File | 417 B | 0644 |
|
config-openSUSE-Linux-15.0-ALL | File | 403 B | 0644 |
|
config-openmamba-linux | File | 417 B | 0644 |
|
config-pardus-linux | File | 346 B | 0644 |
|
config-redhat-linux | File | 417 B | 0644 |
|
config-redhat-linux-24.0 | File | 421 B | 0644 |
|
config-redhat-linux-25.0-ALL | File | 418 B | 0644 |
|
config-redhat-linux-7.0-23.0 | File | 419 B | 0644 |
|
config-slackware-linux-8.0-ALL | File | 449 B | 0644 |
|
config-sol-linux | File | 455 B | 0644 |
|
config-solaris-10 | File | 440 B | 0644 |
|
config-solaris-11-ALL | File | 490 B | 0644 |
|
config-solaris-9 | File | 498 B | 0644 |
|
config-suse-linux | File | 409 B | 0644 |
|
config-suse-linux-7.1-ALL | File | 407 B | 0644 |
|
config-syno-linux | File | 528 B | 0755 |
|
config-trustix-linux | File | 407 B | 0644 |
|
config-turbo-linux | File | 417 B | 0644 |
|
config-united-linux | File | 407 B | 0644 |
|
config-windows | File | 568 B | 0644 |
|
config.info | File | 1.58 KB | 0644 |
|
config.info.bg | File | 2.74 KB | 0644 |
|
config.info.ca | File | 1.7 KB | 0644 |
|
config.info.cs | File | 1.46 KB | 0644 |
|
config.info.de | File | 1.62 KB | 0644 |
|
config.info.es | File | 813 B | 0644 |
|
config.info.fi | File | 0 B | 0644 |
|
config.info.fr | File | 1.85 KB | 0644 |
|
config.info.hu | File | 1.32 KB | 0644 |
|
config.info.it | File | 1.54 KB | 0644 |
|
config.info.ja | File | 1.7 KB | 0644 |
|
config.info.nl | File | 1.67 KB | 0644 |
|
config.info.no | File | 1.54 KB | 0644 |
|
config.info.pl | File | 808 B | 0644 |
|
config.info.pt_BR | File | 1.68 KB | 0644 |
|
config.info.ru | File | 1.27 KB | 0644 |
|
config.info.sv | File | 677 B | 0644 |
|
config.info.tr | File | 1.13 KB | 0644 |
|
config.info.uk | File | 1.31 KB | 0644 |
|
config.info.zh | File | 320 B | 0644 |
|
config.info.zh_TW | File | 891 B | 0644 |
|
config_info.pl | File | 575 B | 0755 |
|
cpan_modules.pl | File | 84 B | 0755 |
|
create_table.cgi | File | 1.02 KB | 0755 |
|
csv.cgi | File | 2.26 KB | 0755 |
|
csv_form.cgi | File | 1.67 KB | 0755 |
|
defaultacl | File | 85 B | 0644 |
|
delete_cprivs.cgi | File | 1.15 KB | 0755 |
|
delete_dbs.cgi | File | 1.04 KB | 0755 |
|
delete_fields.cgi | File | 665 B | 0755 |
|
delete_hosts.cgi | File | 1018 B | 0755 |
|
delete_tprivs.cgi | File | 1.1 KB | 0755 |
|
delete_users.cgi | File | 941 B | 0755 |
|
download.cgi | File | 1.07 KB | 0755 |
|
drop_dbase.cgi | File | 1.86 KB | 0755 |
|
drop_dbases.cgi | File | 1.39 KB | 0755 |
|
drop_table.cgi | File | 1.27 KB | 0755 |
|
drop_tables.cgi | File | 1.75 KB | 0755 |
|
edit_cnf.cgi | File | 2.92 KB | 0755 |
|
edit_cpriv.cgi | File | 2.34 KB | 0755 |
|
edit_db.cgi | File | 1.73 KB | 0755 |
|
edit_dbase.cgi | File | 6.46 KB | 0755 |
|
edit_field.cgi | File | 4.99 KB | 0755 |
|
edit_host.cgi | File | 1.48 KB | 0755 |
|
edit_index.cgi | File | 1.83 KB | 0755 |
|
edit_manual.cgi | File | 952 B | 0755 |
|
edit_ssl.cgi | File | 1.59 KB | 0755 |
|
edit_table.cgi | File | 2.85 KB | 0755 |
|
edit_tpriv.cgi | File | 2.21 KB | 0755 |
|
edit_user.cgi | File | 4.64 KB | 0755 |
|
edit_view.cgi | File | 2.17 KB | 0755 |
|
exec.cgi | File | 1.53 KB | 0755 |
|
exec_file.cgi | File | 2.48 KB | 0755 |
|
exec_form.cgi | File | 3.63 KB | 0755 |
|
import.cgi | File | 1.99 KB | 0755 |
|
index.cgi | File | 10.83 KB | 0755 |
|
install_check.pl | File | 549 B | 0755 |
|
kill_procs.cgi | File | 385 B | 0755 |
|
list_cprivs.cgi | File | 2.21 KB | 0755 |
|
list_dbs.cgi | File | 1.89 KB | 0755 |
|
list_hosts.cgi | File | 1.76 KB | 0755 |
|
list_procs.cgi | File | 1.42 KB | 0755 |
|
list_tprivs.cgi | File | 2.03 KB | 0755 |
|
list_users.cgi | File | 2.73 KB | 0755 |
|
list_vars.cgi | File | 1.72 KB | 0755 |
|
log_parser.pl | File | 3.25 KB | 0755 |
|
login.cgi | File | 819 B | 0755 |
|
module.info | File | 190 B | 0644 |
|
module.info.af | File | 0 B | 0644 |
|
module.info.af.auto | File | 131 B | 0644 |
|
module.info.ar | File | 0 B | 0644 |
|
module.info.ar.auto | File | 211 B | 0644 |
|
module.info.be | File | 0 B | 0644 |
|
module.info.be.auto | File | 204 B | 0644 |
|
module.info.bg | File | 0 B | 0644 |
|
module.info.bg.auto | File | 215 B | 0644 |
|
module.info.ca | File | 127 B | 0644 |
|
module.info.ca.auto | File | 14 B | 0644 |
|
module.info.cs | File | 34 B | 0644 |
|
module.info.cs.auto | File | 103 B | 0644 |
|
module.info.da | File | 0 B | 0644 |
|
module.info.da.auto | File | 127 B | 0644 |
|
module.info.de | File | 127 B | 0644 |
|
module.info.de.auto | File | 14 B | 0644 |
|
module.info.el | File | 0 B | 0644 |
|
module.info.el.auto | File | 226 B | 0644 |
|
module.info.es | File | 40 B | 0644 |
|
module.info.es.auto | File | 110 B | 0644 |
|
module.info.eu | File | 0 B | 0644 |
|
module.info.eu.auto | File | 134 B | 0644 |
|
module.info.fa | File | 0 B | 0644 |
|
module.info.fa.auto | File | 198 B | 0644 |
|
module.info.fi | File | 0 B | 0644 |
|
module.info.fi.auto | File | 140 B | 0644 |
|
module.info.fr | File | 43 B | 0644 |
|
module.info.fr.auto | File | 138 B | 0644 |
|
module.info.he | File | 0 B | 0644 |
|
module.info.he.auto | File | 167 B | 0644 |
|
module.info.hr | File | 0 B | 0644 |
|
module.info.hr.auto | File | 153 B | 0644 |
|
module.info.hu | File | 35 B | 0644 |
|
module.info.hu.auto | File | 113 B | 0644 |
|
module.info.it | File | 33 B | 0644 |
|
module.info.it.auto | File | 102 B | 0644 |
|
module.info.ja | File | 43 B | 0644 |
|
module.info.ja.auto | File | 128 B | 0644 |
|
module.info.ko | File | 40 B | 0644 |
|
module.info.ko.auto | File | 128 B | 0644 |
|
module.info.lt | File | 0 B | 0644 |
|
module.info.lt.auto | File | 172 B | 0644 |
|
module.info.lv | File | 0 B | 0644 |
|
module.info.lv.auto | File | 133 B | 0644 |
|
module.info.ms | File | 142 B | 0644 |
|
module.info.ms.auto | File | 14 B | 0644 |
|
module.info.mt | File | 0 B | 0644 |
|
module.info.mt.auto | File | 137 B | 0644 |
|
module.info.nl | File | 30 B | 0644 |
|
module.info.nl.auto | File | 98 B | 0644 |
|
module.info.no | File | 29 B | 0644 |
|
module.info.no.auto | File | 98 B | 0644 |
|
module.info.pl | File | 34 B | 0644 |
|
module.info.pl.auto | File | 103 B | 0644 |
|
module.info.pt | File | 40 B | 0644 |
|
module.info.pt.auto | File | 116 B | 0644 |
|
module.info.pt_BR | File | 0 B | 0644 |
|
module.info.pt_BR.auto | File | 166 B | 0644 |
|
module.info.ro | File | 0 B | 0644 |
|
module.info.ro.auto | File | 155 B | 0644 |
|
module.info.ru | File | 47 B | 0644 |
|
module.info.ru.auto | File | 165 B | 0644 |
|
module.info.sk | File | 0 B | 0644 |
|
module.info.sk.auto | File | 141 B | 0644 |
|
module.info.sl | File | 0 B | 0644 |
|
module.info.sl.auto | File | 135 B | 0644 |
|
module.info.sv | File | 28 B | 0644 |
|
module.info.sv.auto | File | 104 B | 0644 |
|
module.info.th | File | 0 B | 0644 |
|
module.info.th.auto | File | 292 B | 0644 |
|
module.info.tr | File | 35 B | 0644 |
|
module.info.tr.auto | File | 110 B | 0644 |
|
module.info.uk | File | 0 B | 0644 |
|
module.info.uk.auto | File | 210 B | 0644 |
|
module.info.ur | File | 0 B | 0644 |
|
module.info.ur.auto | File | 229 B | 0644 |
|
module.info.vi | File | 0 B | 0644 |
|
module.info.vi.auto | File | 184 B | 0644 |
|
module.info.zh | File | 33 B | 0644 |
|
module.info.zh.auto | File | 92 B | 0644 |
|
module.info.zh_TW | File | 36 B | 0644 |
|
module.info.zh_TW.auto | File | 98 B | 0644 |
|
mysql-lib.pl | File | 51.37 KB | 0755 |
|
newdb.cgi | File | 1.07 KB | 0755 |
|
newdb_form.cgi | File | 1.45 KB | 0755 |
|
postinstall.pl | File | 192 B | 0644 |
|
prefs.info | File | 69 B | 0644 |
|
root_form.cgi | File | 855 B | 0755 |
|
save_cnf.cgi | File | 2.83 KB | 0755 |
|
save_cpriv.cgi | File | 2.67 KB | 0755 |
|
save_db.cgi | File | 2.68 KB | 0755 |
|
save_field.cgi | File | 4.72 KB | 0755 |
|
save_host.cgi | File | 2.35 KB | 0755 |
|
save_index.cgi | File | 1.39 KB | 0755 |
|
save_manual.cgi | File | 526 B | 0755 |
|
save_root.cgi | File | 1.04 KB | 0755 |
|
save_ssl.cgi | File | 2.03 KB | 0755 |
|
save_sync.cgi | File | 454 B | 0755 |
|
save_tpriv.cgi | File | 2.6 KB | 0755 |
|
save_user.cgi | File | 4.85 KB | 0755 |
|
save_vars.cgi | File | 755 B | 0755 |
|
save_view.cgi | File | 1.84 KB | 0755 |
|
search_form.cgi | File | 1.38 KB | 0755 |
|
start.cgi | File | 218 B | 0755 |
|
stop.cgi | File | 203 B | 0755 |
|
syslog_logs.pl | File | 1.11 KB | 0755 |
|
table_form.cgi | File | 1.95 KB | 0755 |
|
useradmin_update.pl | File | 2.6 KB | 0755 |
|
view-lib.pl | File | 3.56 KB | 0755 |
|
view_table.cgi | File | 15.06 KB | 0755 |
|