From 36b5bea13825d6cceddf0e6d637dd66e2303a9d0 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Mon, 9 Dec 2013 22:11:57 -0800 Subject: [PATCH 01/19] Output entities in UTF-8 if using that charset https://github.com/webmin/webmin/issues/102 --- file/lang.cgi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/file/lang.cgi b/file/lang.cgi index 23ad5e934..96c955b38 100755 --- a/file/lang.cgi +++ b/file/lang.cgi @@ -13,6 +13,18 @@ if (&get_charset() eq $default_charset) { print $k,"=",&entities_to_ascii($text{$k}),"\n"; } } +elsif (&get_charset() eq 'UTF-8') { + # Convert any HTML entities to UTF-8 to match the output charset + eval "use Encode"; + foreach $k (keys %text) { + $str = $text{$k}; + if ($str =~ /&#(\d+);|&([a-z]+);/) { + $str = Encode::encode('utf-8', + &entities_to_ascii($str)); + } + print $k,"=",$str,"\n"; + } + } else { # Don't do HTML entity conversion for other character sets foreach $k (keys %text) { From a9a09a1ecfded6bca338b6e7e8bf35a9bf281f97 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 10 Dec 2013 18:33:34 -0800 Subject: [PATCH 02/19] Convert local to my --- acl/acl-lib.pl | 64 ++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/acl/acl-lib.pl b/acl/acl-lib.pl index b0a6d6fcd..a76fd4e14 100755 --- a/acl/acl-lib.pl +++ b/acl/acl-lib.pl @@ -38,7 +38,6 @@ sub list_users { my ($only) = @_; my (%miniserv, @rv, %acl, %logout); -local %_; &read_acl(undef, \%acl); &get_miniserv_config(\%miniserv); foreach my $a (split(/\s+/, $miniserv{'logouttimes'})) { @@ -49,7 +48,7 @@ foreach my $a (split(/\s+/, $miniserv{'logouttimes'})) { open(PWFILE, $miniserv{'userfile'}); while() { s/\r|\n//g; - local @user = split(/:/, $_); + my @user = split(/:/, $_); if (@user) { my %user; next if ($only && &indexof($user[0], @$only) < 0); @@ -217,14 +216,14 @@ my %miniserv; open(GROUPS, "$config_directory/webmin.groups"); while() { s/\r|\n//g; - local @g = split(/:/, $_); + my @g = split(/:/, $_); if (@g) { next if ($only && &indexof($g[0], @$only) < 0); - local $group = { 'name' => $g[0], - 'members' => [ split(/\s+/, $g[1]) ], - 'modules' => [ split(/\s+/, $g[2]) ], - 'desc' => $g[3], - 'ownmods' => [ split(/\s+/, $g[4]) ] }; + my $group = { 'name' => $g[0], + 'members' => [ split(/\s+/, $g[1]) ], + 'modules' => [ split(/\s+/, $g[2]) ], + 'desc' => $g[3], + 'ownmods' => [ split(/\s+/, $g[4]) ] }; push(@rv, $group); } } @@ -617,7 +616,7 @@ else { elsif (defined($user{'theme'})) { $miniserv{"preroot_".$user{'name'}} = ""; } - local @logout = split(/\s+/, $miniserv{'logouttimes'}); + my @logout = split(/\s+/, $miniserv{'logouttimes'}); @logout = grep { $_ !~ /^$username=/ } @logout; if (defined($user{'logouttime'})) { push(@logout, "$user{'name'}=$user{'logouttime'}"); @@ -626,7 +625,7 @@ else { &put_miniserv_config(\%miniserv); &unlock_file($ENV{'MINISERV_CONFIG'}); - local @times; + my @times; push(@times, "days", $user{'days'}) if ($user{'days'} ne ''); push(@times, "hours", $user{'hoursfrom'}."-".$user{'hoursto'}) if ($user{'hoursfrom'}); @@ -717,13 +716,13 @@ else { if ($username ne $user{'name'} && !$user{'proto'}) { # Rename all .acl files if user renamed foreach $m (@mods, "") { - local $file = "$config_directory/$m/$username.acl"; + my $file = "$config_directory/$m/$username.acl"; if (-r $file) { &rename_file($file, "$config_directory/$m/$user{'name'}.acl"); } } - local $file = "$config_directory/$username.acl"; + my $file = "$config_directory/$username.acl"; if (-r $file) { &rename_file($file, "$config_directory/$user{'name'}.acl"); } @@ -751,7 +750,7 @@ if ($oldpass ne $user->{'pass'} && $user->{'pass'} ne '*LK*') { # Password change detected .. update change time # and save the old one - local $nolock = $oldpass; + my $nolock = $oldpass; $nolock =~ s/^\!//; unshift(@{$user->{'olds'}}, $nolock); if ($miniserv->{'pass_oldblock'}) { @@ -1098,7 +1097,7 @@ if ($group{'proto'}) { else { # Update local file &lock_file("$config_directory/webmin.groups"); - local $lref = &read_file_lines("$config_directory/webmin.groups"); + my $lref = &read_file_lines("$config_directory/webmin.groups"); foreach $l (@$lref) { if ($l =~ /^([^:]+):/ && $1 eq $groupname) { $l = &group_line(\%group); @@ -1111,7 +1110,7 @@ else { if ($groupname ne $group{'name'} && !$group{'proto'}) { # Rename all .gacl files if group renamed foreach my $m (@{$group{'modules'}}, "") { - local $file = "$config_directory/$m/$groupname.gacl"; + my $file = "$config_directory/$m/$groupname.gacl"; if (-r $file) { &rename_file($file, "$config_directory/$m/$group{'name'}.gacl"); @@ -1331,7 +1330,7 @@ sub delete_session_user return 1 if (&is_readonly_mode()); &open_session_db($_[0]); foreach my $s (keys %sessiondb) { - local ($u,$t) = split(/\s+/, $sessiondb{$s}); + my ($u,$t) = split(/\s+/, $sessiondb{$s}); if ($u eq $_[1]) { delete($sessiondb{$s}); } @@ -1355,7 +1354,7 @@ sub rename_session_user return 1 if (&is_readonly_mode()); &open_session_db(\%miniserv); foreach my $s (keys %sessiondb) { - local ($u,$t) = split(/\s+/, $sessiondb{$s}); + my ($u,$t) = split(/\s+/, $sessiondb{$s}); if ($u eq $_[1]) { $sessiondb{$s} = "$_[2] $t"; } @@ -1579,10 +1578,9 @@ my ($allusers, $allgroups, $mod, $members, $access) = @_; foreach my $m (@$members) { if ($m !~ /^\@(.*)$/) { # Member is a user - local ($u) = grep { $_->{'name'} eq $m } @$allusers; + my ($u) = grep { $_->{'name'} eq $m } @$allusers; if ($u) { - local $aclfile = - "$config_directory/$mod/$u->{'name'}.acl"; + my $aclfile = "$config_directory/$mod/$u->{'name'}.acl"; &lock_file($aclfile); &save_module_acl($access, $u->{'name'}, $mod, 1); chmod(0640, $aclfile) if (-r $aclfile); @@ -1591,10 +1589,10 @@ foreach my $m (@$members) { } else { # Member is a group - local $gname = substr($m, 1); - local ($g) = grep { $_->{'name'} eq $gname } @$allgroups; + my $gname = substr($m, 1); + my ($g) = grep { $_->{'name'} eq $gname } @$allgroups; if ($g) { - local $aclfile = + my $aclfile = "$config_directory/$mod/$g->{'name'}.gacl"; &lock_file($aclfile); &save_group_module_acl($access, $g->{'name'}, $mod, 1); @@ -1742,11 +1740,11 @@ if ($miniserv{'pass_nouser'}) { $pass =~ /\Q$name\E/i && return $text{'cpass_name'}; } if ($miniserv{'pass_nodict'}) { - local $temp = &transname(); + my $temp = &transname(); &open_tempfile(TEMP, ">$temp", 0, 1); &print_tempfile(TEMP, $pass,"\n"); &close_tempfile(TEMP); - local $unknown; + my $unknown; if (&has_command("ispell")) { open(SPELL, "ispell -a <$temp |"); while() { @@ -1758,7 +1756,7 @@ if ($miniserv{'pass_nodict'}) { } elsif (&has_command("spell")) { open(SPELL, "spell <$temp |"); - local $line = ; + my $line = ; $unknown++ if ($line); close(SPELL); } @@ -1769,9 +1767,9 @@ if ($miniserv{'pass_nodict'}) { $unknown || return $text{'cpass_dict'}; } if ($miniserv{'pass_oldblock'} && $user) { - local $c = 0; + my $c = 0; foreach my $o (@{$user->{'olds'}}) { - local $enc = &encrypt_password($pass, $o); + my $enc = &encrypt_password($pass, $o); $enc eq $o && return $text{'cpass_old'}; last if ($c++ > $miniserv{'pass_oldblock'}); } @@ -1916,15 +1914,15 @@ return 1 if ($found); # Already setup if (!$user) { # Create a user if need be $user = "anonymous"; - local $uinfo = { 'name' => $user, - 'pass' => '*LK*', - 'modules' => [ $mod ], - }; + my $uinfo = { 'name' => $user, + 'pass' => '*LK*', + 'modules' => [ $mod ], + }; &create_user($uinfo); } else { # Make sure the user has the module - local ($uinfo) = grep { $_->{'name'} eq $user } &list_users(); + my ($uinfo) = grep { $_->{'name'} eq $user } &list_users(); if ($uinfo && &indexof($mod, @{$uinfo->{'modules'}}) < 0) { push(@{$uinfo->{'modules'}}, $mod); &modify_user($uinfo->{'name'}, $uinfo); From ca624ebbc64a1c81ebc8d8e11e79978d15bf8eea Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 10 Dec 2013 18:41:39 -0800 Subject: [PATCH 03/19] Remove use of $_ --- acl/acl-lib.pl | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/acl/acl-lib.pl b/acl/acl-lib.pl index a76fd4e14..4303c1028 100755 --- a/acl/acl-lib.pl +++ b/acl/acl-lib.pl @@ -46,9 +46,9 @@ foreach my $a (split(/\s+/, $miniserv{'logouttimes'})) { } } open(PWFILE, $miniserv{'userfile'}); -while() { - s/\r|\n//g; - my @user = split(/:/, $_); +while(my $l = ) { + $l =~ s/\r|\n//g; + my @user = split(/:/, $l); if (@user) { my %user; next if ($only && &indexof($user[0], @$only) < 0); @@ -214,9 +214,9 @@ my %miniserv; # Add groups from local files open(GROUPS, "$config_directory/webmin.groups"); -while() { - s/\r|\n//g; - my @g = split(/:/, $_); +while(my $l = ) { + $l =~ s/\r|\n//g; + my @g = split(/:/, $l); if (@g) { next if ($only && &indexof($g[0], @$only) < 0); my $group = { 'name' => $g[0], @@ -522,7 +522,6 @@ sub modify_user my $username = $_[0]; my %user = %{$_[1]}; my (%miniserv, @pwfile, @acl, @mods, $m); -local $_; &get_miniserv_config(\%miniserv); if ($user{'proto'}) { @@ -617,7 +616,7 @@ else { $miniserv{"preroot_".$user{'name'}} = ""; } my @logout = split(/\s+/, $miniserv{'logouttimes'}); - @logout = grep { $_ !~ /^$username=/ } @logout; + @logout = grep { !/^$username=/ } @logout; if (defined($user{'logouttime'})) { push(@logout, "$user{'name'}=$user{'logouttime'}"); } @@ -638,8 +637,8 @@ else { $allow =~ s/:/;/g; my $deny = $user{'deny'}; $deny =~ s/:/;/g; - foreach (@pwfile) { - if (/^([^:]+):([^:]*)/ && $1 eq $username) { + foreach my $l (@pwfile) { + if ($l =~ /^([^:]+):([^:]*)/ && $1 eq $username) { &add_old_password(\%user, "$2", \%miniserv); &print_tempfile(PWFILE, "$user{'name'}:$user{'pass'}:", @@ -658,7 +657,7 @@ else { "\n"); } else { - &print_tempfile(PWFILE, $_); + &print_tempfile(PWFILE, $l); } } &close_tempfile(PWFILE); @@ -670,12 +669,12 @@ else { @acl = ; close(ACL); &open_tempfile(ACL, ">".&acl_filename()); - foreach (@acl) { - if (/^(\S+):/ && $1 eq $username) { + foreach my $l (@acl) { + if ($l =~ /^(\S+):/ && $1 eq $username) { &print_tempfile(ACL, &acl_line($_[1], \@mods)); } else { - &print_tempfile(ACL, $_); + &print_tempfile(ACL, $l); } } &close_tempfile(ACL); @@ -715,7 +714,7 @@ else { if ($username ne $user{'name'} && !$user{'proto'}) { # Rename all .acl files if user renamed - foreach $m (@mods, "") { + foreach my $m (@mods, "") { my $file = "$config_directory/$m/$username.acl"; if (-r $file) { &rename_file($file, @@ -773,13 +772,12 @@ sub delete_user { my ($username) = @_; my (@pwfile, @acl, %miniserv); -local $_; &lock_file($ENV{'MINISERV_CONFIG'}); &get_miniserv_config(\%miniserv); delete($miniserv{"preroot_".$username}); my @logout = split(/\s+/, $miniserv{'logouttimes'}); -@logout = grep { $_ !~ /^$username=/ } @logout; +@logout = grep { !/^$username=/ } @logout; $miniserv{'logouttimes'} = join(" ", @logout); &put_miniserv_config(\%miniserv); &unlock_file($ENV{'MINISERV_CONFIG'}); @@ -789,9 +787,9 @@ open(PWFILE, $miniserv{'userfile'}); @pwfile = ; close(PWFILE); &open_tempfile(PWFILE, ">$miniserv{'userfile'}"); -foreach (@pwfile) { - if (!/^([^:]+):/ || $1 ne $username) { - &print_tempfile(PWFILE, $_); +foreach my $l (@pwfile) { + if ($l !~ /^([^:]+):/ || $1 ne $username) { + &print_tempfile(PWFILE, $l); } } &close_tempfile(PWFILE); @@ -802,9 +800,9 @@ open(ACL, &acl_filename()); @acl = ; close(ACL); &open_tempfile(ACL, ">".&acl_filename()); -foreach (@acl) { - if (!/^([^:]+):/ || $1 ne $username) { - &print_tempfile(ACL, $_); +foreach my $l (@acl) { + if ($l !~ /^([^:]+):/ || $1 ne $username) { + &print_tempfile(ACL, $l); } } &close_tempfile(ACL); @@ -1098,7 +1096,7 @@ else { # Update local file &lock_file("$config_directory/webmin.groups"); my $lref = &read_file_lines("$config_directory/webmin.groups"); - foreach $l (@$lref) { + foreach my $l (@$lref) { if ($l =~ /^([^:]+):/ && $1 eq $groupname) { $l = &group_line(\%group); } From 558f83d875073359e14009dd9729e426d7804927 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 10 Dec 2013 19:27:46 -0800 Subject: [PATCH 04/19] Formal parameter conversion --- acl/acl-lib.pl | 342 ++++++++++++++++++++++++------------------------- 1 file changed, 169 insertions(+), 173 deletions(-) diff --git a/acl/acl-lib.pl b/acl/acl-lib.pl index 4303c1028..ea6134cb1 100755 --- a/acl/acl-lib.pl +++ b/acl/acl-lib.pl @@ -352,8 +352,7 @@ settings from for this new user. =cut sub create_user { -my %user = %{$_[0]}; -my $clone = $_[1]; +my ($user, $clone) = @_; my %miniserv; my @mods = &list_modules(); @@ -366,7 +365,7 @@ if ($miniserv{'userdb'} && !$miniserv{'userdb_addto'}) { if ($proto eq "mysql" || $proto eq "postgresql") { # Add user with SQL my $cmd = $dbh->prepare("insert into webmin_user (name,pass) values (?, ?)"); - $cmd && $cmd->execute($user{'name'}, $user{'pass'}) || + $cmd && $cmd->execute($user->{'name'}, $user->{'pass'}) || &error("Failed to add user : ".$dbh->errstr); $cmd->finish(); my $cmd = $dbh->prepare("select max(id) from webmin_user"); @@ -376,9 +375,9 @@ if ($miniserv{'userdb'} && !$miniserv{'userdb_addto'}) { # Add other attributes my $cmd = $dbh->prepare("insert into webmin_user_attr (id,attr,value) values (?, ?, ?)"); - foreach my $attr (keys %user) { + foreach my $attr (keys %$user) { next if ($attr eq "name" || $attr eq "pass"); - my $value = $user{$attr}; + my $value = $user->{$attr}; if ($attr eq "olds" || $attr eq "modules" || $attr eq "ownmods") { $value = join(" ", @$value); @@ -388,20 +387,20 @@ if ($miniserv{'userdb'} && !$miniserv{'userdb_addto'}) { $dbh->errstr); $cmd->finish(); } - $_[0]->{'id'} = $id; - $_[0]->{'proto'} = $proto; + $user->{'id'} = $id; + $user->{'proto'} = $proto; } elsif ($proto eq "ldap") { # Add user to LDAP - my $dn = "cn=".$user{'name'}.",".$prefix; + my $dn = "cn=".$user->{'name'}.",".$prefix; my @attrs = ( "objectClass", $args->{'userclass'}, - "cn", $user{'name'}, - "webminPass", $user{'pass'} ); + "cn", $user->{'name'}, + "webminPass", $user->{'pass'} ); my @webminattrs; - foreach my $attr (keys %user) { + foreach my $attr (keys %$user) { next if ($attr eq "name" || $attr eq "pass" || $attr eq "modules"); - my $value = $user{$attr}; + my $value = $user->{$attr}; if ($attr eq "olds" || $attr eq "ownmods") { $value = join(" ", @$value); } @@ -411,102 +410,102 @@ if ($miniserv{'userdb'} && !$miniserv{'userdb_addto'}) { if (@webminattrs) { push(@attrs, "webminAttr", \@webminattrs); } - if (@{$user{'modules'}}) { - push(@attrs, "webminModule", $user{'modules'}); + if (@{$user->{'modules'}}) { + push(@attrs, "webminModule", $user->{'modules'}); } my $rv = $dbh->add($dn, attr => \@attrs); if (!$rv || $rv->code) { &error("Failed to add user to LDAP : ". ($rv ? $rv->error : "Unknown error")); } - $_[0]->{'id'} = $dn; - $_[0]->{'proto'} = 'ldap'; + $user->{'id'} = $dn; + $user->{'proto'} = 'ldap'; } &disconnect_userdb($miniserv{'userdb'}, $dbh); - $user{'proto'} = $proto; + $user->{'proto'} = $proto; } else { # Adding to local files &lock_file($ENV{'MINISERV_CONFIG'}); - if ($user{'theme'}) { - $miniserv{"preroot_".$user{'name'}} = - $user{'theme'}.($user{'overlay'} ? " ".$user{'overlay'} : ""); + if ($user->{'theme'}) { + $miniserv{"preroot_".$user->{'name'}} = + $user->{'theme'}.($user->{'overlay'} ? " ".$user->{'overlay'} : ""); } - elsif (defined($user{'theme'})) { - $miniserv{"preroot_".$user{'name'}} = ""; + elsif (defined($user->{'theme'})) { + $miniserv{"preroot_".$user->{'name'}} = ""; } - if (defined($user{'logouttime'})) { + if (defined($user->{'logouttime'})) { my @logout = split(/\s+/, $miniserv{'logouttimes'}); - push(@logout, "$user{'name'}=$user{'logouttime'}"); + push(@logout, "$user->{'name'}=$user->{'logouttime'}"); $miniserv{'logouttimes'} = join(" ", @logout); } &put_miniserv_config(\%miniserv); &unlock_file($ENV{'MINISERV_CONFIG'}); my @times; - push(@times, "days", $user{'days'}) if ($user{'days'} ne ''); - push(@times, "hours", $user{'hoursfrom'}."-".$user{'hoursto'}) - if ($user{'hoursfrom'}); + push(@times, "days", $user->{'days'}) if ($user->{'days'} ne ''); + push(@times, "hours", $user->{'hoursfrom'}."-".$user->{'hoursto'}) + if ($user->{'hoursfrom'}); &lock_file($miniserv{'userfile'}); &open_tempfile(PWFILE, ">>$miniserv{'userfile'}"); - my $allow = $user{'allow'}; + my $allow = $user->{'allow'}; $allow =~ s/:/;/g; - my $deny = $user{'deny'}; + my $deny = $user->{'deny'}; $deny =~ s/:/;/g; &print_tempfile(PWFILE, - "$user{'name'}:$user{'pass'}:$user{'sync'}:$user{'cert'}:", + "$user->{'name'}:$user->{'pass'}:$user->{'sync'}:$user->{'cert'}:", ($allow ? "allow $allow" : $deny ? "deny $deny" : ""),":", join(" ", @times),":", - $user{'lastchange'},":", - join(" ", @{$user{'olds'}}),":", - $user{'minsize'},":", - $user{'nochange'},":", - $user{'temppass'},":", - $user{'twofactor_provider'},":", - $user{'twofactor_id'},":", - $user{'twofactor_apikey'}, + $user->{'lastchange'},":", + join(" ", @{$user->{'olds'}}),":", + $user->{'minsize'},":", + $user->{'nochange'},":", + $user->{'temppass'},":", + $user->{'twofactor_provider'},":", + $user->{'twofactor_id'},":", + $user->{'twofactor_apikey'}, "\n"); &close_tempfile(PWFILE); &unlock_file($miniserv{'userfile'}); &lock_file(&acl_filename()); &open_tempfile(ACL, ">>".&acl_filename()); - &print_tempfile(ACL, &acl_line(\%user, \@mods)); + &print_tempfile(ACL, &acl_line($user, \@mods)); &close_tempfile(ACL); &unlock_file(&acl_filename()); - delete($gconfig{"lang_".$user{'name'}}); - $gconfig{"lang_".$user{'name'}} = $user{'lang'} if ($user{'lang'}); - delete($gconfig{"notabs_".$user{'name'}}); - $gconfig{"notabs_".$user{'name'}} = $user{'notabs'} if ($user{'notabs'}); - delete($gconfig{"skill_".$user{'name'}}); - $gconfig{"skill_".$user{'name'}} = $user{'skill'} if ($user{'skill'}); - delete($gconfig{"risk_".$user{'name'}}); - $gconfig{"risk_".$user{'name'}} = $user{'risk'} if ($user{'risk'}); - delete($gconfig{"rbacdeny_".$user{'name'}}); - $gconfig{"rbacdeny_".$user{'name'}} = $user{'rbacdeny'} if ($user{'rbacdeny'}); - delete($gconfig{"ownmods_".$user{'name'}}); - $gconfig{"ownmods_".$user{'name'}} = join(" ", @{$user{'ownmods'}}) - if (@{$user{'ownmods'}}); - delete($gconfig{"theme_".$user{'name'}}); - if ($user{'theme'}) { - $gconfig{"theme_".$user{'name'}} = - $user{'theme'}.($user{'overlay'} ? " ".$user{'overlay'} : ""); + delete($gconfig{"lang_".$user->{'name'}}); + $gconfig{"lang_".$user->{'name'}} = $user->{'lang'} if ($user->{'lang'}); + delete($gconfig{"notabs_".$user->{'name'}}); + $gconfig{"notabs_".$user->{'name'}} = $user->{'notabs'} if ($user->{'notabs'}); + delete($gconfig{"skill_".$user->{'name'}}); + $gconfig{"skill_".$user->{'name'}} = $user->{'skill'} if ($user->{'skill'}); + delete($gconfig{"risk_".$user->{'name'}}); + $gconfig{"risk_".$user->{'name'}} = $user->{'risk'} if ($user->{'risk'}); + delete($gconfig{"rbacdeny_".$user->{'name'}}); + $gconfig{"rbacdeny_".$user->{'name'}} = $user->{'rbacdeny'} if ($user->{'rbacdeny'}); + delete($gconfig{"ownmods_".$user->{'name'}}); + $gconfig{"ownmods_".$user->{'name'}} = join(" ", @{$user->{'ownmods'}}) + if (@{$user->{'ownmods'}}); + delete($gconfig{"theme_".$user->{'name'}}); + if ($user->{'theme'}) { + $gconfig{"theme_".$user->{'name'}} = + $user->{'theme'}.($user->{'overlay'} ? " ".$user->{'overlay'} : ""); } - elsif (defined($user{'theme'})) { - $gconfig{"theme_".$user{'name'}} = ''; + elsif (defined($user->{'theme'})) { + $gconfig{"theme_".$user->{'name'}} = ''; } - $gconfig{"readonly_".$user{'name'}} = $user{'readonly'} - if (defined($user{'readonly'})); - $gconfig{"realname_".$user{'name'}} = $user{'real'} - if (defined($user{'real'})); + $gconfig{"readonly_".$user->{'name'}} = $user->{'readonly'} + if (defined($user->{'readonly'})); + $gconfig{"realname_".$user->{'name'}} = $user->{'real'} + if (defined($user->{'real'})); &write_file("$config_directory/config", \%gconfig); } # Copy ACLs from user being cloned if ($clone) { - ©_acl_files($clone, $user{'name'}, [ "", @mods ]); + ©_acl_files($clone, $user->{'name'}, [ "", @mods ]); } } @@ -519,12 +518,11 @@ to create_user. =cut sub modify_user { -my $username = $_[0]; -my %user = %{$_[1]}; +my ($username, $user) = @_; my (%miniserv, @pwfile, @acl, @mods, $m); &get_miniserv_config(\%miniserv); -if ($user{'proto'}) { +if ($user->{'proto'}) { # In users and groups DB my ($dbh, $proto) = &connect_userdb($miniserv{'userdb'}); &error("Failed to connect to user database : $dbh") if (!ref($dbh)); @@ -532,35 +530,35 @@ if ($user{'proto'}) { # Get old password, for change detection my $cmd = $dbh->prepare( "select pass from webmin_user where id = ?"); - $cmd && $cmd->execute($user{'id'}) || + $cmd && $cmd->execute($user->{'id'}) || &error("Failed to get old password : ".$dbh->errstr); my ($oldpass) = $cmd->fetchrow(); $cmd->finish(); - &add_old_password(\%user, $oldpass, \%miniserv); + &add_old_password($user, $oldpass, \%miniserv); # Update primary details my $cmd = $dbh->prepare("update webmin_user set name = ?, ". "pass = ? where id = ?"); - $cmd && $cmd->execute($user{'name'}, $user{'pass'}, - $user{'id'}) || + $cmd && $cmd->execute($user->{'name'}, $user->{'pass'}, + $user->{'id'}) || &error("Failed to update user : ".$dbh->errstr); $cmd->finish(); # Re-save attributes my $cmd = $dbh->prepare("delete from webmin_user_attr ". "where id = ?"); - $cmd && $cmd->execute($user{'id'}) || + $cmd && $cmd->execute($user->{'id'}) || &error("Failed to delete attrs : ".$dbh->errstr); my $cmd = $dbh->prepare("insert into webmin_user_attr ". "(id,attr,value) values (?, ?, ?)"); - foreach my $attr (keys %user) { + foreach my $attr (keys %$user) { next if ($attr eq "name" || $attr eq "pass"); - my $value = $user{$attr}; + my $value = $user->{$attr}; if ($attr eq "olds" || $attr eq "modules" || $attr eq "ownmods") { $value = join(" ", @$value); } - $cmd->execute($user{'id'}, $attr, $value) || + $cmd->execute($user->{'id'}, $attr, $value) || &error("Failed to add user attribute : ". $dbh->errstr); $cmd->finish(); @@ -568,26 +566,26 @@ if ($user{'proto'}) { } elsif ($proto eq "ldap") { # Rename in LDAP if needed - if ($user{'name'} ne $username) { - my $newdn = $user{'id'}; - $newdn =~ s/^cn=\Q$username\E,/cn=$user{'name'},/; - my $rv = $dbh->moddn($user{'id'}, - newrdn => "cn=$user{'name'}"); + if ($user->{'name'} ne $username) { + my $newdn = $user->{'id'}; + $newdn =~ s/^cn=\Q$username\E,/cn=$user->{'name'},/; + my $rv = $dbh->moddn($user->{'id'}, + newrdn => "cn=$user->{'name'}"); if (!$rv || $rv->code) { &error("Failed to rename user : ". ($rv ? $rv->error : "Unknown error")); } - $user{'id'} = $newdn; + $user->{'id'} = $newdn; } # Re-save all the attributes - my @attrs = ( "cn", $user{'name'}, - "webminPass", $user{'pass'} ); + my @attrs = ( "cn", $user->{'name'}, + "webminPass", $user->{'pass'} ); my @webminattrs; - foreach my $attr (keys %user) { + foreach my $attr (keys %$user) { next if ($attr eq "name" || $attr eq "desc" || $attr eq "modules"); - my $value = $user{$attr}; + my $value = $user->{$attr}; if ($attr eq "olds" || $attr eq "ownmods") { $value = join(" ", @$value); } @@ -595,8 +593,8 @@ if ($user{'proto'}) { defined($value) ? $attr."=".$value : $attr); } push(@attrs, "webminAttr", \@webminattrs); - push(@attrs, "webminModule", $user{'modules'}); - my $rv = $dbh->modify($user{'id'}, replace => { @attrs }); + push(@attrs, "webminModule", $user->{'modules'}); + my $rv = $dbh->modify($user->{'id'}, replace => { @attrs }); if (!$rv || $rv->code) { &error("Failed to modify user : ". ($rv ? $rv->error : "Unknown error")); @@ -608,52 +606,52 @@ else { # In local files &lock_file($ENV{'MINISERV_CONFIG'}); delete($miniserv{"preroot_".$username}); - if ($user{'theme'}) { - $miniserv{"preroot_".$user{'name'}} = - $user{'theme'}.($user{'overlay'} ? " ".$user{'overlay'} : ""); + if ($user->{'theme'}) { + $miniserv{"preroot_".$user->{'name'}} = + $user->{'theme'}.($user->{'overlay'} ? " ".$user->{'overlay'} : ""); } - elsif (defined($user{'theme'})) { - $miniserv{"preroot_".$user{'name'}} = ""; + elsif (defined($user->{'theme'})) { + $miniserv{"preroot_".$user->{'name'}} = ""; } my @logout = split(/\s+/, $miniserv{'logouttimes'}); @logout = grep { !/^$username=/ } @logout; - if (defined($user{'logouttime'})) { - push(@logout, "$user{'name'}=$user{'logouttime'}"); + if (defined($user->{'logouttime'})) { + push(@logout, "$user->{'name'}=$user->{'logouttime'}"); } $miniserv{'logouttimes'} = join(" ", @logout); &put_miniserv_config(\%miniserv); &unlock_file($ENV{'MINISERV_CONFIG'}); my @times; - push(@times, "days", $user{'days'}) if ($user{'days'} ne ''); - push(@times, "hours", $user{'hoursfrom'}."-".$user{'hoursto'}) - if ($user{'hoursfrom'}); + push(@times, "days", $user->{'days'}) if ($user->{'days'} ne ''); + push(@times, "hours", $user->{'hoursfrom'}."-".$user->{'hoursto'}) + if ($user->{'hoursfrom'}); &lock_file($miniserv{'userfile'}); open(PWFILE, $miniserv{'userfile'}); @pwfile = ; close(PWFILE); &open_tempfile(PWFILE, ">$miniserv{'userfile'}"); - my $allow = $user{'allow'}; + my $allow = $user->{'allow'}; $allow =~ s/:/;/g; - my $deny = $user{'deny'}; + my $deny = $user->{'deny'}; $deny =~ s/:/;/g; foreach my $l (@pwfile) { if ($l =~ /^([^:]+):([^:]*)/ && $1 eq $username) { - &add_old_password(\%user, "$2", \%miniserv); + &add_old_password($user, "$2", \%miniserv); &print_tempfile(PWFILE, - "$user{'name'}:$user{'pass'}:", - "$user{'sync'}:$user{'cert'}:", + "$user->{'name'}:$user->{'pass'}:", + "$user->{'sync'}:$user->{'cert'}:", ($allow ? "allow $allow" : $deny ? "deny $deny" : ""),":", join(" ", @times),":", - $user{'lastchange'},":", - join(" ", @{$user{'olds'}}),":", - $user{'minsize'},":", - $user{'nochange'},":", - $user{'temppass'},":", - $user{'twofactor_provider'},":", - $user{'twofactor_id'},":", - $user{'twofactor_apikey'}, + $user->{'lastchange'},":", + join(" ", @{$user->{'olds'}}),":", + $user->{'minsize'},":", + $user->{'nochange'},":", + $user->{'temppass'},":", + $user->{'twofactor_provider'},":", + $user->{'twofactor_id'},":", + $user->{'twofactor_apikey'}, "\n"); } else { @@ -671,7 +669,7 @@ else { &open_tempfile(ACL, ">".&acl_filename()); foreach my $l (@acl) { if ($l =~ /^(\S+):/ && $1 eq $username) { - &print_tempfile(ACL, &acl_line($_[1], \@mods)); + &print_tempfile(ACL, &acl_line($user, \@mods)); } else { &print_tempfile(ACL, $l); @@ -681,55 +679,55 @@ else { &unlock_file(&acl_filename()); delete($gconfig{"lang_".$username}); - $gconfig{"lang_".$user{'name'}} = $user{'lang'} if ($user{'lang'}); + $gconfig{"lang_".$user->{'name'}} = $user->{'lang'} if ($user->{'lang'}); delete($gconfig{"notabs_".$username}); - $gconfig{"notabs_".$user{'name'}} = $user{'notabs'} - if ($user{'notabs'}); + $gconfig{"notabs_".$user->{'name'}} = $user->{'notabs'} + if ($user->{'notabs'}); delete($gconfig{"skill_".$username}); - $gconfig{"skill_".$user{'name'}} = $user{'skill'} if ($user{'skill'}); + $gconfig{"skill_".$user->{'name'}} = $user->{'skill'} if ($user->{'skill'}); delete($gconfig{"risk_".$username}); - $gconfig{"risk_".$user{'name'}} = $user{'risk'} if ($user{'risk'}); + $gconfig{"risk_".$user->{'name'}} = $user->{'risk'} if ($user->{'risk'}); delete($gconfig{"rbacdeny_".$username}); - $gconfig{"rbacdeny_".$user{'name'}} = $user{'rbacdeny'} - if ($user{'rbacdeny'}); + $gconfig{"rbacdeny_".$user->{'name'}} = $user->{'rbacdeny'} + if ($user->{'rbacdeny'}); delete($gconfig{"ownmods_".$username}); - $gconfig{"ownmods_".$user{'name'}} = join(" ", @{$user{'ownmods'}}) - if (@{$user{'ownmods'}}); + $gconfig{"ownmods_".$user->{'name'}} = join(" ", @{$user->{'ownmods'}}) + if (@{$user->{'ownmods'}}); delete($gconfig{"theme_".$username}); - if ($user{'theme'}) { - $gconfig{"theme_".$user{'name'}} = - $user{'theme'}.($user{'overlay'} ? " ".$user{'overlay'} : ""); + if ($user->{'theme'}) { + $gconfig{"theme_".$user->{'name'}} = + $user->{'theme'}.($user->{'overlay'} ? " ".$user->{'overlay'} : ""); } - elsif (defined($user{'theme'})) { - $gconfig{"theme_".$user{'name'}} = ''; + elsif (defined($user->{'theme'})) { + $gconfig{"theme_".$user->{'name'}} = ''; } delete($gconfig{"readonly_".$username}); - $gconfig{"readonly_".$user{'name'}} = $user{'readonly'} - if (defined($user{'readonly'})); + $gconfig{"readonly_".$user->{'name'}} = $user->{'readonly'} + if (defined($user->{'readonly'})); delete($gconfig{"realname_".$username}); - $gconfig{"realname_".$user{'name'}} = $user{'real'} - if (defined($user{'real'})); + $gconfig{"realname_".$user->{'name'}} = $user->{'real'} + if (defined($user->{'real'})); &write_file("$config_directory/config", \%gconfig); } -if ($username ne $user{'name'} && !$user{'proto'}) { +if ($username ne $user->{'name'} && !$user->{'proto'}) { # Rename all .acl files if user renamed foreach my $m (@mods, "") { my $file = "$config_directory/$m/$username.acl"; if (-r $file) { &rename_file($file, - "$config_directory/$m/$user{'name'}.acl"); + "$config_directory/$m/$user->{'name'}.acl"); } } my $file = "$config_directory/$username.acl"; if (-r $file) { - &rename_file($file, "$config_directory/$user{'name'}.acl"); + &rename_file($file, "$config_directory/$user->{'name'}.acl"); } } -if ($miniserv{'session'} && $username ne $user{'name'}) { +if ($miniserv{'session'} && $username ne $user->{'name'}) { # Modify all sessions for the renamed user - &rename_session_user(\&miniserv, $username, $user{'name'}); + &rename_session_user(\&miniserv, $username, $user->{'name'}); } } @@ -922,8 +920,7 @@ keys are : =cut sub create_group { -my %group = %{$_[0]}; -my $clone = $_[1]; +my ($group, $clone) = @_; my %miniserv; &get_miniserv_config(\%miniserv); @@ -934,7 +931,7 @@ if ($miniserv{'userdb'} && !$miniserv{'userdb_addto'}) { if ($proto eq "mysql" || $proto eq "postgresql") { # Add group with SQL my $cmd = $dbh->prepare("insert into webmin_group (name,description) values (?, ?)"); - $cmd && $cmd->execute($group{'name'}, $group{'desc'}) || + $cmd && $cmd->execute($group->{'name'}, $group->{'desc'}) || &error("Failed to add group : ".$dbh->errstr); $cmd->finish(); my $cmd = $dbh->prepare("select max(id) from webmin_group"); @@ -944,9 +941,9 @@ if ($miniserv{'userdb'} && !$miniserv{'userdb_addto'}) { # Add other attributes my $cmd = $dbh->prepare("insert into webmin_group_attr (id,attr,value) values (?, ?, ?)"); - foreach my $attr (keys %group) { + foreach my $attr (keys %$group) { next if ($attr eq "name" || $attr eq "desc"); - my $value = $group{$attr}; + my $value = $group->{$attr}; if ($attr eq "members" || $attr eq "modules" || $attr eq "ownmods") { $value = join(" ", @$value); @@ -961,15 +958,15 @@ if ($miniserv{'userdb'} && !$miniserv{'userdb_addto'}) { } elsif ($proto eq "ldap") { # Add group to LDAP - my $dn = "cn=".$group{'name'}.",".$prefix; + my $dn = "cn=".$group->{'name'}.",".$prefix; my @attrs = ( "objectClass", $args->{'groupclass'}, - "cn", $group{'name'}, - "webminDesc", $group{'desc'} ); + "cn", $group->{'name'}, + "webminDesc", $group->{'desc'} ); my @webminattrs; - foreach my $attr (keys %group) { + foreach my $attr (keys %$group) { next if ($attr eq "name" || $attr eq "desc" || $attr eq "modules"); - my $value = $group{$attr}; + my $value = $group->{$attr}; if ($attr eq "members" || $attr eq "ownmods") { $value = join(" ", @$value); } @@ -978,8 +975,8 @@ if ($miniserv{'userdb'} && !$miniserv{'userdb_addto'}) { if (@webminattrs) { push(@attrs, "webminAttr", \@webminattrs); } - if (@{$group{'modules'}}) { - push(@attrs, "webminModule", $group{'modules'}); + if (@{$group->{'modules'}}) { + push(@attrs, "webminModule", $group->{'modules'}); } my $rv = $dbh->add($dn, attr => \@attrs); if (!$rv || $rv->code) { @@ -990,20 +987,20 @@ if ($miniserv{'userdb'} && !$miniserv{'userdb_addto'}) { $_[0]->{'proto'} = 'ldap'; } &disconnect_userdb($miniserv{'userdb'}, $dbh); - $group{'proto'} = $proto; + $group->{'proto'} = $proto; } else { # Adding to local files &lock_file("$config_directory/webmin.groups"); open(GROUP, ">>$config_directory/webmin.groups"); - print GROUP &group_line(\%group),"\n"; + print GROUP &group_line($group),"\n"; close(GROUP); &unlock_file("$config_directory/webmin.groups"); } if ($clone) { # Clone ACLs from original group - ©_acl_files($clone, $group{'name'}, [ "", &list_modules() ], + ©_acl_files($clone, $group->{'name'}, [ "", &list_modules() ], "group", "group"); } } @@ -1017,12 +1014,11 @@ returned by list_groups. =cut sub modify_group { -my $groupname = $_[0]; -my %group = %{$_[1]}; +my ($groupname, $group) = @_; my %miniserv; &get_miniserv_config(\%miniserv); -if ($group{'proto'}) { +if ($group->{'proto'}) { # In users and groups DB my ($dbh, $proto) = &connect_userdb($miniserv{'userdb'}); &error("Failed to connect to group database : $dbh") if (!ref($dbh)); @@ -1030,26 +1026,26 @@ if ($group{'proto'}) { # Update primary details my $cmd = $dbh->prepare("update webmin_group set name = ?, ". "description = ? where id = ?"); - $cmd && $cmd->execute($group{'name'}, $group{'desc'}, - $group{'id'}) || + $cmd && $cmd->execute($group->{'name'}, $group->{'desc'}, + $group->{'id'}) || &error("Failed to update group : ".$dbh->errstr); $cmd->finish(); # Re-save attributes my $cmd = $dbh->prepare("delete from webmin_group_attr ". "where id = ?"); - $cmd && $cmd->execute($group{'id'}) || + $cmd && $cmd->execute($group->{'id'}) || &error("Failed to delete attrs : ".$dbh->errstr); my $cmd = $dbh->prepare("insert into webmin_group_attr ". "(id,attr,value) values (?, ?, ?)"); - foreach my $attr (keys %group) { + foreach my $attr (keys %$group) { next if ($attr eq "name" || $attr eq "desc"); - my $value = $group{$attr}; + my $value = $group->{$attr}; if ($attr eq "members" || $attr eq "modules" || $attr eq "ownmods") { $value = join(" ", @$value); } - $cmd->execute($group{'id'}, $attr, $value) || + $cmd->execute($group->{'id'}, $attr, $value) || &error("Failed to add group attribute : ". $dbh->errstr); $cmd->finish(); @@ -1057,34 +1053,34 @@ if ($group{'proto'}) { } elsif ($proto eq "ldap") { # Rename in LDAP if needed - if ($group{'name'} ne $groupname) { - my $newdn = $group{'id'}; - $newdn =~ s/^cn=\Q$groupname\E,/cn=$group{'name'},/; - my $rv = $dbh->moddn($group{'id'}, - newrdn => "cn=$group{'name'}"); + if ($group->{'name'} ne $groupname) { + my $newdn = $group->{'id'}; + $newdn =~ s/^cn=\Q$groupname\E,/cn=$group->{'name'},/; + my $rv = $dbh->moddn($group->{'id'}, + newrdn => "cn=$group->{'name'}"); if (!$rv || $rv->code) { &error("Failed to rename group : ". ($rv ? $rv->error : "Unknown error")); } - $group{'id'} = $newdn; + $group->{'id'} = $newdn; } # Re-save all the attributes - my @attrs = ( "cn", $group{'name'}, - "webminDesc", $group{'desc'} ); + my @attrs = ( "cn", $group->{'name'}, + "webminDesc", $group->{'desc'} ); my @webminattrs; - foreach my $attr (keys %group) { + foreach my $attr (keys %$group) { next if ($attr eq "name" || $attr eq "desc" || $attr eq "modules"); - my $value = $group{$attr}; + my $value = $group->{$attr}; if ($attr eq "members" || $attr eq "ownmods") { $value = join(" ", @$value); } push(@webminattrs, $attr."=".$value); } push(@attrs, "webminAttr", \@webminattrs); - push(@attrs, "webminModule", $group{'modules'}); - my $rv = $dbh->modify($group{'id'}, replace => { @attrs }); + push(@attrs, "webminModule", $group->{'modules'}); + my $rv = $dbh->modify($group->{'id'}, replace => { @attrs }); if (!$rv || $rv->code) { &error("Failed to modify group : ". ($rv ? $rv->error : "Unknown error")); @@ -1098,20 +1094,20 @@ else { my $lref = &read_file_lines("$config_directory/webmin.groups"); foreach my $l (@$lref) { if ($l =~ /^([^:]+):/ && $1 eq $groupname) { - $l = &group_line(\%group); + $l = &group_line($group); } } &flush_file_lines("$config_directory/webmin.groups"); &unlock_file("$config_directory/webmin.groups"); } -if ($groupname ne $group{'name'} && !$group{'proto'}) { +if ($groupname ne $group->{'name'} && !$group->{'proto'}) { # Rename all .gacl files if group renamed - foreach my $m (@{$group{'modules'}}, "") { + foreach my $m (@{$group->{'modules'}}, "") { my $file = "$config_directory/$m/$groupname.gacl"; if (-r $file) { &rename_file($file, - "$config_directory/$m/$group{'name'}.gacl"); + "$config_directory/$m/$group->{'name'}.gacl"); } } } From 54b82eb3cdff0c1d42081e89b03a48fba8598bba Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 10 Dec 2013 21:55:11 -0800 Subject: [PATCH 05/19] Added formal parameters to functions --- acl/acl-lib.pl | 77 ++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/acl/acl-lib.pl b/acl/acl-lib.pl index ea6134cb1..0f6a2c5e4 100755 --- a/acl/acl-lib.pl +++ b/acl/acl-lib.pl @@ -15,7 +15,8 @@ BEGIN { push(@INC, ".."); }; use WebminCore; &init_config(); do 'md5-lib.pl'; -%access = &get_module_acl(); +our (%sessiondb); +our %access = &get_module_acl(); $access{'switch'} = 0 if (&is_readonly_mode()); =head2 list_users([&only-users]) @@ -1222,11 +1223,12 @@ Internal function to generate a group file line =cut sub group_line { -return join(":", $_[0]->{'name'}, - join(" ", @{$_[0]->{'members'}}), - join(" ", @{$_[0]->{'modules'}}), - $_[0]->{'desc'}, - join(" ", @{$_[0]->{'ownmods'}}) ); +my ($group) = @_; +return join(":", $group->{'name'}, + join(" ", @{$group->{'members'}}), + join(" ", @{$group->{'modules'}}), + $group->{'desc'}, + join(" ", @{$group->{'ownmods'}}) ); } =head2 acl_line(&user, &allmodules) @@ -1236,8 +1238,8 @@ Internal function to generate an ACL file line. =cut sub acl_line { -my %user = %{$_[0]}; -return "$user{'name'}: ".join(' ', @{$user{'modules'}})."\n"; +my ($user) = @_; +return "$user->{'name'}: ".join(' ', @{$user->{'modules'}})."\n"; } =head2 can_edit_user(user, [&groups]) @@ -1247,20 +1249,21 @@ Returns 1 if the current Webmin user can edit some other user. =cut sub can_edit_user { +my ($username, $groups) = @_; return 1 if ($access{'users'} eq '*'); if ($access{'users'} eq '~') { - return $base_remote_user eq $_[0]; + return $base_remote_user eq $username; } -my $glist = $_[1] ? $_[1] : [ &list_groups() ]; +my $glist = $groups || [ &list_groups() ]; foreach my $u (split(/\s+/, $access{'users'})) { if ($u =~ /^_(\S+)$/) { foreach my $g (@$glist) { return 1 if ($g->{'name'} eq $1 && - &indexof($_[0], @{$g->{'members'}}) >= 0); + &indexof($username, @{$g->{'members'}}) >= 0); } } else { - return 1 if ($u eq $_[0]); + return 1 if ($u eq $username); } } return 0; @@ -1275,8 +1278,9 @@ Opens the session database, and ties it to the sessiondb hash. Parameters are : =cut sub open_session_db { -my $sfile = $_[0]->{'sessiondb'} ? $_[0]->{'sessiondb'} : - $_[0]->{'pidfile'} =~ /^(.*)\/[^\/]+$/ ? "$1/sessiondb" +my ($miniserv) = @_; +my $sfile = $miniserv->{'sessiondb'} ? $miniserv->{'sessiondb'} : + $miniserv->{'pidfile'} =~ /^(.*)\/[^\/]+$/ ? "$1/sessiondb" : return; eval "use SDBM_File"; dbmopen(%sessiondb, $sfile, 0700); @@ -1297,15 +1301,16 @@ Deletes one session from the database. Parameters are : =item miniserv - The Webmin miniserv.conf file as a hash ref, as supplied by get_miniserv_config. -=item user - ID of the session to remove. +=item id - ID of the session to remove. =cut sub delete_session_id { +my ($miniserv, $sid) = @_; return 1 if (&is_readonly_mode()); -&open_session_db($_[0]); -my $ex = exists($sessiondb{$_[1]}); -delete($sessiondb{$_[1]}); +&open_session_db($miniserv); +my $ex = exists($sessiondb{$sid}); +delete($sessiondb{$sid}); dbmclose(%sessiondb); return $ex; } @@ -1321,11 +1326,12 @@ Deletes all sessions for some user. Parameters are : =cut sub delete_session_user { +my ($miniserv, $username) = @_; return 1 if (&is_readonly_mode()); -&open_session_db($_[0]); +&open_session_db($miniserv); foreach my $s (keys %sessiondb) { - my ($u,$t) = split(/\s+/, $sessiondb{$s}); - if ($u eq $_[1]) { + my ($u, $t) = split(/\s+/, $sessiondb{$s}); + if ($u eq $username) { delete($sessiondb{$s}); } } @@ -1345,12 +1351,13 @@ Changes the username in all sessions for some user. Parameters are : =cut sub rename_session_user { +my ($miniserv, $oldusername, $newusername) = @_; return 1 if (&is_readonly_mode()); -&open_session_db(\%miniserv); +&open_session_db($miniserv); foreach my $s (keys %sessiondb) { - my ($u,$t) = split(/\s+/, $sessiondb{$s}); - if ($u eq $_[1]) { - $sessiondb{$s} = "$_[2] $t"; + my ($u, $t) = split(/\s+/, $sessiondb{$s}); + if ($u eq $oldusername) { + $sessiondb{$s} = "$newusername $t"; } } dbmclose(%sessiondb); @@ -1372,23 +1379,24 @@ are : =cut sub update_members { -foreach my $m (@{$_[3]}) { +my ($allusers, $allgroups, $mods, $mems) = @_; +foreach my $m (@$mems) { if ($m !~ /^\@(.*)$/) { # Member is a user - my ($u) = grep { $_->{'name'} eq $m } @{$_[0]}; + my ($u) = grep { $_->{'name'} eq $m } @$allusers; if ($u) { - $u->{'modules'} = [ @{$_[2]}, @{$u->{'ownmods'}} ]; + $u->{'modules'} = [ @$mods, @{$u->{'ownmods'}} ]; &modify_user($u->{'name'}, $u); } } else { # Member is a group my $gname = substr($m, 1); - my ($g) = grep { $_->{'name'} eq $gname } @{$_[1]}; + my ($g) = grep { $_->{'name'} eq $gname } @$allgroups; if ($g) { - $g->{'modules'} = [ @{$_[2]}, @{$g->{'ownmods'}} ]; + $g->{'modules'} = [ @$mods, @{$g->{'ownmods'}} ]; &modify_group($g->{'name'}, $g); - &update_members($_[0], $_[1], $g->{'modules'}, + &update_members($allusers, $allgroups, $g->{'modules'}, $g->{'members'}); } } @@ -1671,8 +1679,9 @@ returned by get_unixauth. =cut sub save_unixauth { +my ($miniserv, $authlist) = @_; my @ua; -foreach my $ua (@{$_[1]}) { +foreach my $ua (@$authlist) { if ($ua->[0] ne "*") { push(@ua, "$ua->[0]=$ua->[1]"); } @@ -1680,7 +1689,7 @@ foreach my $ua (@{$_[1]}) { push(@ua, $ua->[1]); } } -$_[0]->{'unixauth'} = join(" ", @ua); +$miniserv->{'unixauth'} = join(" ", @ua); } =head2 delete_from_groups(user|@group) @@ -1800,7 +1809,7 @@ Returns a string encrypted in MD5 format. =cut sub hash_md5_session { -my $passwd = $_[0]; +my ($passwd) = @_; my $use_md5 = &md5_perl_module(); # Add the password From fe4557e1e7c07a99d018f181aebcac6504fff138 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 11 Dec 2013 11:46:01 -0800 Subject: [PATCH 06/19] Make ui_date_input themeable http://sourceforge.net/p/webadmin/bugs/4331/ --- ui-lib.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/ui-lib.pl b/ui-lib.pl index f19d6c58e..7766f27a5 100755 --- a/ui-lib.pl +++ b/ui-lib.pl @@ -1355,6 +1355,7 @@ The parameters are : =cut sub ui_date_input { +return &theme_ui_date_input(@_) if (defined(&theme_ui_date_input)); my ($day, $month, $year, $dayname, $monthname, $yearname, $dis) = @_; my $rv; $rv .= ""; From 3837f880d257875908078ba2139e33ccb87b9d35 Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Thu, 12 Dec 2013 11:44:17 +0800 Subject: [PATCH 07/19] Malaysian translation update -> apache/lang/ms_MY --- apache/lang/ms_MY | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/apache/lang/ms_MY b/apache/lang/ms_MY index 8edac2ff0..67a0e529b 100644 --- a/apache/lang/ms_MY +++ b/apache/lang/ms_MY @@ -597,10 +597,86 @@ mod_alias_tredir2=lencongan URL sementara mod_apachessl_bancifher=Senarai suit sifer, sebagaimana SSLRequireCipher, kecuali ia melarangnya mod_apachessl_cachepaht=Lokasi pelaksana pelayan cache global, gcache mod_apachessl_cacheport=Port/Soket pelaksana pelayan cache global +mod_apachessl_cacherundir=Menetapkan direktori dimana gcache dijalankan untuk menyah-pijat +mod_apachessl_cafile=Fail dengan Penguakuasaan Sijil dalam +mod_apachessl_capath=Lokasi ke direktori dengan Penguakuasaan Sijil dalam +mod_apachessl_cdnfile=Fail terhadap pelanggan DN diperiksa +mod_apachessl_crlcheckall=Semak semua sijil dalam rantaian terhadap CRL +mod_apachessl_ecachepaht=Pelaksana pelayan cache global hilang +mod_apachessl_ecacheport=Ralat pada Nombor port atau fail soket +mod_apachessl_ecacherundir=Hilang direktori dimana gcache dijalankan dalam +mod_apachessl_ecdnfile=Hilang fail terhadap pelanggan DN yang diperiksa +mod_apachessl_eramdomfileb=Bait mestilah integer +mod_apachessl_esesstimeout=Masa dalam saat mestilah integer +mod_apachessl_exportcert=Sijil pelanggan eksport dan rantaian sijil di belakang mereka untuk CGIs mod_band_ent=IP atau domain mod_band_size=Saiz fail maksimum mod_cern_meta_default=Lalai mod_cern_meta_default2=Lalai +mod_env_clear=Bersihkan +mod_env_default=Lalai +mod_env_evalue='$1' bukanlah nilai pembolehubah yang sah +mod_env_evar='$1' bukanlah nama pembolehubah yang sah +mod_env_pass=Melepasi +mod_env_passall=Lepaskan semua pembolehubah persekitaran untuk CGIs +mod_env_set=Tetapkan pada.. +mod_env_value=Nilai +mod_env_var=Pembolehubah +mod_imap_action=Tindakan ke atas penggunaan imagemaps yang tidak betul +mod_imap_defact=Tindakan lalai untuk imagemaps +mod_imap_default=Lalai +mod_imap_default2=Lalai +mod_imap_defbase=Asas lalai untuk imagemaps +mod_imap_disperr=Paparkan ralat pelayan +mod_imap_donoth=Jangan lakukan apa pun +mod_imap_eurl='$1' bukanlah URL yang sah +mod_imap_form=Tunjukan menu yang diformatkan +mod_imap_godefurl=Pergi ke URL lalai +mod_imap_goimap=Pergi ke URL imagemap +mod_imap_goref=Pergi ke URL yang dirujuk +mod_imap_gourl=Pergi ke URL... +mod_imap_imapurl=URL imagemap +mod_imap_refurl=URL yang dirujuk +mod_imap_root=Root pelayan +mod_imap_semiform=Tunjukan menu yang separa diformatkan +mod_imap_unform=Tunjukan menu yang tidak diformatkan +mod_imap_url=URL... +mod_include_default=Lalai +mod_include_incl=Proses termasuklah pada fail dengan melaksanakan sedikit? +mod_include_set=Ya dan tetapkan tarikh last-modified +mod_log_agent_default=Lalai +mod_log_agent_file=Fail.. +mod_log_agent_program=Program.. +mod_log_config_default=Lalai +mod_log_config_deflog=Format log lalai +mod_log_config_file=Fail.. +mod_log_config_filprog=Fail atau program +mod_log_config_format=Format +mod_log_config_ifset=Jika tidak ditetapkan +mod_log_config_log=Fail log capaian +mod_log_config_program=Program.. +mod_log_config_write=Menulis kepada +mod_log_referer_default=Lalai +mod_log_referer_file=Fail.. +mod_log_referer_log=Fail log yang dirujuk +mod_log_referer_program=Program.. +mod_mime_cenc=Pengekodan kandungan +mod_mime_cencs=Pengekodan kandungan +mod_mime_clang=Bahasa kandungan +mod_mime_clangs=Bahasa kandungan +mod_mime_default=Lalai +mod_mime_deflang=Fail bahasa lalai +mod_mime_enc=Pengekodan +mod_mime_magic_none=Tiada +mod_mime_none=Tiada +mod_mime_type=Jenis +mod_negotiation_def=Lalai +mod_php_ename='$1' bukanlah nama yang sah +mod_php_name_header=Tetapan +mod_php_value_header=Nilai +mod_proxy_all=Semua +mod_proxy_default=Lalai +mod_proxy_domain=Domain mod_ssl_proto=Protokol SSL mod_ssl_req=Diperlukan mod_userdir_default=Lalai From f5862790cdb8c414b94a5b2c4bb416a7b1d9e1ef Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Fri, 13 Dec 2013 20:19:57 +0800 Subject: [PATCH 08/19] Add option to skip generated javascript for ui_opt_textbox --- ui-lib.pl | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ui-lib.pl b/ui-lib.pl index 7766f27a5..2ae94a1cb 100755 --- a/ui-lib.pl +++ b/ui-lib.pl @@ -636,7 +636,7 @@ $rv .= "
\n"; @@ -681,14 +683,16 @@ if ($buttons && @$buttons) { $rv .= "\n"; } $rv .= "
\n"; -# When going back to a form, re-enable any text fields generated by -# ui_opt_textbox that aren't in the default state. -$rv .= "\n"; +if ( !$nojs ) { + # When going back to a form, re-enable any text fields generated by + # ui_opt_textbox that aren't in the default state. + $rv .= "\n"; +} return $rv; } From 19a0f940c9f057172aedfecf14751ae284500297 Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Fri, 13 Dec 2013 20:29:11 +0800 Subject: [PATCH 09/19] ui-lib conversion -> dhcpd/index.cgi --- dhcpd/index.cgi | 69 +++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/dhcpd/index.cgi b/dhcpd/index.cgi index 813b9a670..4f5eed16a 100755 --- a/dhcpd/index.cgi +++ b/dhcpd/index.cgi @@ -72,11 +72,9 @@ if ($st[7] != $config{'dhcpd_size'} || $st[9] != $config{'dhcpd_mtime'}) { # Create lookup type HTML # XXX change text, add to lookup_* -$match = "\n"; +print ui_select("match", undef, [ [0,$text{'index_match0'},"selected"], + [1,$text{'index_match1'},""], + [2,$text{'index_match2'},""] ]); # get top-level hosts foreach $h (&find("host", $conf)) { @@ -267,24 +265,22 @@ if ($show_subnet_delete) { # Show too-many forms if ($show_subnet_shared) { - print "\n"; + print &ui_table_start(undef, undef, 2); if (@ulinks >= $display_max) { # Could not show all subnets, so show lookup form - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; + print &ui_form_start("lookup_subnet.cgi", "get"); + print &ui_table_row($text{'index_subtoomany'}, &ui_submit($text{'index_sublook2'})); + print &ui_table_row($matches, &ui_textbox("subnet", "", 30)); + print &ui_form_end(undef,undef,1); } if (@slinks >= $display_max) { # Could not show all shared nets, so show lookup form - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; + print &ui_form_start("lookup_shared.cgi", "get"); + print &ui_table_row($text{'index_shatoomany'}, &ui_submit($text{'index_shalook2'})); + print &ui_table_row($matches, &ui_textbox("shared", "", 30)); + print &ui_form_end(undef,undef,1); } - print "
$text{'index_subtoomany'}$matches
$text{'index_shatoomany'}$matches
\n"; + print &ui_table_end(); } print &ui_hr(); @@ -419,24 +415,22 @@ if ($show_host_delete) { # Show too-many forms if ($show_host_group) { - print "\n"; + print &ui_table_start(undef, undef, 2); if (@hlinks >= $display_max) { # Could not show all hosts, so show lookup form - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; + print &ui_form_start("lookup_host.cgi", "get"); + print &ui_table_row($text{'index_hsttoomany'}, &ui_submit($text{'index_hstlook2'})); + print &ui_table_row($matches, &ui_textbox("host", "", 30)); + print &ui_form_end(undef,undef,1); } if (@glinks >= $display_max) { # Could not show all groups, so show lookup form - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; + print &ui_form_start("lookup_group.cgi", "get"); + print &ui_table_row($text{'index_grptoomany'}, &ui_submit($text{'index_grplook2'})); + print &ui_table_row($matches, &ui_textbox("group", "", 30)); + print &ui_form_end(undef,undef,1); } - print "
$text{'index_hsttoomany'}$matches
$text{'index_grptoomany'}$matches
\n"; + print &ui_table_end(); } print &ui_hr(); @@ -451,7 +445,7 @@ if ($config{'dhcpd_version'} >= 3 && $access{'zones'}) { @zones = sort { $a->{'values'}->[0] <=> $b->{'values'}->[0] } @zones; if (@zones) { # display zones - print "","$text{'index_addzone'}  \n" if $access{'c_sub'}; + print &ui_link("edit_zones.cgi?new=1",$text{'index_addzone'})."  "\n" if $access{'c_sub'}; foreach $z (@zones) { # print "ZONE: $z->{'value'}
"; push(@zlinks, "edit_zones.cgi?idx=$z->{'index'}"); @@ -470,7 +464,7 @@ if ($config{'dhcpd_version'} >= 3 && $access{'zones'}) { else { print "$text{'index_nozones'}

\n"; } - print "","$text{'index_addzone'}  \n" if $access{'c_sub'}; + print &ui_link("edit_zones.cgi?new=1",$text{'index_addzone'})."  "\n" if $access{'c_sub'}; print &ui_hr(); } @@ -573,7 +567,7 @@ for (my $l = 0; $l < $_[2]; $l++) { push(@links, $msg); } else { - push(@links, "$msg"); + push(@links, &ui_link("?$_[1]order=$l\&$_[4]",$msg) ); } } print "$_[3] ",&ui_links_row(\@links),"\n"; @@ -668,15 +662,12 @@ print &ui_columns_end(); #&zone_table(\@zones, 0, scalar(@zones), \@zlinks, \@ztitles); sub zone_table { -local $i; -print "\n"; -print "\n"; +my $i; +print &ui_table_start($text{'index_zone'}, "width=95%", 2); for ($i = $_[1]; $i < $_[2]; $i++) { - print "\n"; - print "\n"; + print &ui_table_row(undef, &ui_link($_[3]->[$i],$_[4]->[$i]) ); } -print "
", $text{'index_zone'}, "
\n"; - print "[$i]>", $_[4]->[$i], "
\n" +print &ui_table_end(); } sub subnet_add_links From 30a929c14e17c0629914a6535099ca79a9dc9543 Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Fri, 13 Dec 2013 20:29:45 +0800 Subject: [PATCH 10/19] replace hr with ui_hr() --- certmgr/gencert.cgi | 2 +- certmgr/signcsr.cgi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/certmgr/gencert.cgi b/certmgr/gencert.cgi index 9c740a4f9..aac6b5e74 100755 --- a/certmgr/gencert.cgi +++ b/certmgr/gencert.cgi @@ -38,7 +38,7 @@ if (!$in{'cn'}) { $in{'cn'}=&get_system_hostname(); } if (!$in{'days'}) { $in{'days'}=$config{'default_days'}; } if ($error) { - print "


$text{'gencert_error'}\n
    \n"; + print &ui_hr()."$text{'gencert_error'}\n
      \n"; print "$error
    \n$text{'gencert_pleasefix'}\n"; } diff --git a/certmgr/signcsr.cgi b/certmgr/signcsr.cgi index 3c67ff6f9..ed822d070 100755 --- a/certmgr/signcsr.cgi +++ b/certmgr/signcsr.cgi @@ -33,7 +33,7 @@ if ($in{'submitted'} eq "sign") { } if ($error) { - print "
    $text{'signcsr_error'}\n
      \n"; + print &ui_hr()."$text{'signcsr_error'}\n
        \n"; print "$error
      \n$text{'gencert_pleasefix'}\n"; } From e8811cc23e16244c99469637572fb69ae53a9732 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 13 Dec 2013 09:21:43 -0800 Subject: [PATCH 11/19] Decode raw format slave zone files https://sourceforge.net/p/webadmin/bugs/4172/ --- bind8/CHANGELOG | 1 + bind8/lang/en | 1 + bind8/records-lib.pl | 27 ++++++++++++++++++++++++++- bind8/view_text.cgi | 22 ++++++++++++++-------- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/bind8/CHANGELOG b/bind8/CHANGELOG index a9cf7abbf..a0bc1a0ee 100644 --- a/bind8/CHANGELOG +++ b/bind8/CHANGELOG @@ -139,3 +139,4 @@ Changed all links to zones to use the zone name instead of an index, to prevent Added a module configuration option to use the SPF type for Sender Permitted From records. ---- Changes since 1.660 ---- Added a warning if the chroot directory that Webmin thinks BIND is using looks wrong. +Slave zone files in raw format can now be displayed by Webmin. diff --git a/bind8/lang/en b/bind8/lang/en index b524ea2c5..14dbfd460 100644 --- a/bind8/lang/en +++ b/bind8/lang/en @@ -300,6 +300,7 @@ text_undo=Undo text_ecannot=You are not allowed to edit record files text_none=However the file is currently empty, probably because the zone has not yet been transferred from the master server. text_soa=Increase serial number automatically +text_rawformat=This zone is in raw binary format, and so cannot be displayed as text. restart_err=Failed to apply changes restart_ecannot=You are not allowed to restart BIND diff --git a/bind8/records-lib.pl b/bind8/records-lib.pl index 6f57e03a1..80142f391 100755 --- a/bind8/records-lib.pl +++ b/bind8/records-lib.pl @@ -15,7 +15,17 @@ if ($origin ne ".") { } $file = &absolute_path($_[0]); local $rootfile = $_[4] ? $file : &make_chroot($file); -open(FILE, $rootfile); +if (&is_raw_format_records($rootfile)) { + # Convert from raw format first + &has_command("named-compilezone") || + &error("Zone file $rootfile is in raw format, but the ". + "named-compilezone command is not installed"); + &open_execute_command(FILE, "named-compilezone -f raw -F text -o - $origin $rootfile", 1, 1); + } +else { + # Can read text format records directly + open(FILE, $rootfile); + } $lnum = 0; local ($gotsoa, $aftersoa); while($line = ) { @@ -288,6 +298,7 @@ return @rv; sub create_record { local $fn = &make_chroot(&absolute_path($_[0])); +&is_raw_format_records($fn) && &error("Raw format zone files cannot be edited"); local $lref = &read_file_lines($fn); push(@$lref, &make_record(@_[1..$#_])); &flush_file_lines($fn); @@ -298,6 +309,7 @@ push(@$lref, &make_record(@_[1..$#_])); sub modify_record { local $fn = &make_chroot(&absolute_path($_[0])); +&is_raw_format_records($fn) && &error("Raw format zone files cannot be edited"); local $lref = &read_file_lines($fn); local $lines = $_[1]->{'eline'} - $_[1]->{'line'} + 1; splice(@$lref, $_[1]->{'line'}, $lines, &make_record(@_[2..$#_])); @@ -309,6 +321,7 @@ splice(@$lref, $_[1]->{'line'}, $lines, &make_record(@_[2..$#_])); sub delete_record { local $fn = &make_chroot(&absolute_path($_[0])); +&is_raw_format_records($fn) && &error("Raw format zone files cannot be edited"); local $lref = &read_file_lines($fn); local $lines = $_[1]->{'eline'} - $_[1]->{'line'} + 1; splice(@$lref, $_[1]->{'line'}, $lines); @@ -905,5 +918,17 @@ sub get_dnskey_rrset return @rv; } +# is_raw_format_records(file) +# Checks if a zone file is in BIND's new raw or text format +sub is_raw_format_records +{ +my ($file) = @_; +open(RAW, $file); +my $buf; +read(RAW, $buf, 3); +close(RAW); +return $buf eq "\0\0\0"; +} + 1; diff --git a/bind8/view_text.cgi b/bind8/view_text.cgi index 1c0756e15..b89c7f693 100755 --- a/bind8/view_text.cgi +++ b/bind8/view_text.cgi @@ -13,16 +13,22 @@ $access{'file'} || &error($text{'text_ecannot'}); &ui_print_header($file, $text{'text_title2'}, "", undef, undef, undef, undef, &restart_links($zone)); -print &text('text_desc2', "$file"),"

      \n"; - -$text = &read_file_contents(&make_chroot($file)); -if ($text) { - print &ui_table_start(undef, "width=100%", 2); - print &ui_table_row(undef, "

      ".&html_escape($text)."
      ", 2); - print &ui_table_end(); +if (&is_raw_format_records(&make_chroot($file))) { + print "$text{'text_rawformat'}

      \n"; } else { - print "$text{'text_none'}

      \n"; + print &text('text_desc2', "$file"),"

      \n"; + + $text = &read_file_contents(&make_chroot($file)); + if ($text) { + print &ui_table_start(undef, "width=100%", 2); + print &ui_table_row(undef, + "

      ".&html_escape($text)."
      ", 2); + print &ui_table_end(); + } + else { + print "$text{'text_none'}

      \n"; + } } &ui_print_footer(($tv eq "master" ? "edit_master.cgi" : From 4b4702e038898a1c56023ee5f227684237f4b305 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 13 Dec 2013 09:22:47 -0800 Subject: [PATCH 12/19] Add missing my --- file/file-lib.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file/file-lib.pl b/file/file-lib.pl index bf6749645..60a0c93fb 100755 --- a/file/file-lib.pl +++ b/file/file-lib.pl @@ -477,7 +477,7 @@ if ($userconfig{'nocharset'} || $config{'nocharset'}) { print "Content-type: $type\n\n"; } else { - $charset = &get_charset(); + my $charset = &get_charset(); print "Content-type: $type; charset=$charset\n\n"; } } From 9042999c197899ad1bf7cdce6063ae43c513b0ae Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 13 Dec 2013 22:05:29 -0800 Subject: [PATCH 13/19] Escape error message --- apache/manual_save.cgi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apache/manual_save.cgi b/apache/manual_save.cgi index 89450cf1c..42a73dc3d 100755 --- a/apache/manual_save.cgi +++ b/apache/manual_save.cgi @@ -69,7 +69,8 @@ if ($config{'test_manual'}) { $err = &test_config(); if ($err) { ©_source_dest($temp, $file); - &error(&text('manual_etest', "

      $err
      ")); + &error(&text('manual_etest', + "
      ".&html_escape($err)."
      ")); } } unlink($temp); From 13c7c5accc09aa5441a551cb96eb7a1d3763a8e0 Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Sun, 15 Dec 2013 00:51:19 +0800 Subject: [PATCH 14/19] Malaysian translation update --- apache/lang/ms_MY | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/apache/lang/ms_MY b/apache/lang/ms_MY index 67a0e529b..8868dcfed 100644 --- a/apache/lang/ms_MY +++ b/apache/lang/ms_MY @@ -607,12 +607,52 @@ mod_apachessl_ecacheport=Ralat pada Nombor port atau fail soket mod_apachessl_ecacherundir=Hilang direktori dimana gcache dijalankan dalam mod_apachessl_ecdnfile=Hilang fail terhadap pelanggan DN yang diperiksa mod_apachessl_eramdomfileb=Bait mestilah integer +mod_apachessl_eramdomfilef=Fail/Soket untuk beban beberapa rawak hilang mod_apachessl_esesstimeout=Masa dalam saat mestilah integer mod_apachessl_exportcert=Sijil pelanggan eksport dan rantaian sijil di belakang mereka untuk CGIs +mod_apachessl_forcessl=Paksa capaian SSL/notSSL? +mod_apachessl_notssl=Nafikan capaian SSL +mod_apachessl_nov2=Nyah-aktifkan SSL versi 2 +mod_apachessl_ramdomfile=Fail/Soket untuk beban beberapa rawak +mod_apachessl_ramdomfilee=Soket +mod_apachessl_ramdomfilef=Fail +mod_apachessl_sesstimeout=Masa dalam saat yang kunci sesi akan dicache +mod_auth_auth=Pengesahan fail teks +mod_auth_basic_dbm=Pangkalan data DBM +mod_auth_basic_file=Fail teks +mod_auth_dbm_auth=Pengesahan fail DBM +mod_auth_dbm_default=Format lalai DBM +mod_auth_dbm_egfile=Nama fail grup DBM tidak sah +mod_auth_dbm_eufile=Nama fail pengguna DBM tidak sah +mod_auth_dbm_gfile=Fail grup DBM +mod_auth_dbm_gtype=Jenis grup pangkalan data DBM +mod_auth_dbm_type=Jenis pangkalan data DBM +mod_auth_dbm_ufile=Fail pengguna DBM +mod_auth_egfile=Nama fail teks grup tidak sah +mod_auth_eufile=Nama fail teks pengguna tidak sah +mod_auth_gedit=Sunting grup +mod_auth_gfile=Fail teks grup +mod_auth_uedit=Sunting pengguna +mod_auth_ufile=Fail teks pengguna +mod_autoindex_asc=Menaik +mod_autoindex_date=Tarikh +mod_autoindex_default=Lalai +mod_autoindex_desc=Penerangan +mod_autoindex_descend=Menurun +mod_autoindex_name=Nama +mod_autoindex_size=Saiz +mod_autoindex_sort=Indeks direktori disusun mengikut +mod_band_all=Semua +mod_band_bandwidth=Had jalur lebar klien +mod_band_bw=Had (bait/saat) +mod_band_client=Untuk klien +mod_band_ebw='$1' bukanlah had jalur lebar yang sah mod_band_ent=IP atau domain mod_band_size=Saiz fail maksimum mod_cern_meta_default=Lalai mod_cern_meta_default2=Lalai +mod_cgi_default=Lalai +mod_cgi_none=Tiada mod_env_clear=Bersihkan mod_env_default=Lalai mod_env_evalue='$1' bukanlah nilai pembolehubah yang sah @@ -667,6 +707,7 @@ mod_mime_clangs=Bahasa kandungan mod_mime_default=Lalai mod_mime_deflang=Fail bahasa lalai mod_mime_enc=Pengekodan +mod_mime_lang=Bahasa mod_mime_magic_none=Tiada mod_mime_none=Tiada mod_mime_type=Jenis @@ -677,6 +718,7 @@ mod_php_value_header=Nilai mod_proxy_all=Semua mod_proxy_default=Lalai mod_proxy_domain=Domain +mod_ssl_default=Lalai mod_ssl_proto=Protokol SSL mod_ssl_req=Diperlukan mod_userdir_default=Lalai From 764bad68f380eaeb2fb4b446cb8522b88b55e10b Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Sun, 15 Dec 2013 01:20:48 +0800 Subject: [PATCH 15/19] fix typo that cause error --- dhcpd/index.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dhcpd/index.cgi b/dhcpd/index.cgi index 4f5eed16a..8f97785c7 100755 --- a/dhcpd/index.cgi +++ b/dhcpd/index.cgi @@ -445,7 +445,7 @@ if ($config{'dhcpd_version'} >= 3 && $access{'zones'}) { @zones = sort { $a->{'values'}->[0] <=> $b->{'values'}->[0] } @zones; if (@zones) { # display zones - print &ui_link("edit_zones.cgi?new=1",$text{'index_addzone'})."  "\n" if $access{'c_sub'}; + print &ui_link("edit_zones.cgi?new=1",$text{'index_addzone'})."  \n" if $access{'c_sub'}; foreach $z (@zones) { # print "ZONE: $z->{'value'}
      "; push(@zlinks, "edit_zones.cgi?idx=$z->{'index'}"); @@ -464,7 +464,7 @@ if ($config{'dhcpd_version'} >= 3 && $access{'zones'}) { else { print "$text{'index_nozones'}

      \n"; } - print &ui_link("edit_zones.cgi?new=1",$text{'index_addzone'})."  "\n" if $access{'c_sub'}; + print &ui_link("edit_zones.cgi?new=1",$text{'index_addzone'})."  \n" if $access{'c_sub'}; print &ui_hr(); } From 59a52bc675de897bf8b7ae42f8ec5a60c3307916 Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Mon, 16 Dec 2013 00:14:30 +0800 Subject: [PATCH 16/19] wrong print, should be variable --- dhcpd/index.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dhcpd/index.cgi b/dhcpd/index.cgi index 8f97785c7..186669a78 100755 --- a/dhcpd/index.cgi +++ b/dhcpd/index.cgi @@ -72,7 +72,7 @@ if ($st[7] != $config{'dhcpd_size'} || $st[9] != $config{'dhcpd_mtime'}) { # Create lookup type HTML # XXX change text, add to lookup_* -print ui_select("match", undef, [ [0,$text{'index_match0'},"selected"], +$matches = ui_select("match", undef, [ [0,$text{'index_match0'},"selected"], [1,$text{'index_match1'},""], [2,$text{'index_match2'},""] ]); From 76aba63a335c9816cd5d1cf6218ec9938742c61c Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Mon, 16 Dec 2013 01:21:42 +0800 Subject: [PATCH 17/19] ui-lib conversion dhcpd/edit_subnet.cgi - not finish yet --- dhcpd/edit_subnet.cgi | 98 ++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/dhcpd/edit_subnet.cgi b/dhcpd/edit_subnet.cgi index e08ab9691..5dff24ddb 100755 --- a/dhcpd/edit_subnet.cgi +++ b/dhcpd/edit_subnet.cgi @@ -35,56 +35,54 @@ foreach $s (&find("shared-network", $conf)) { } } -print "

      \n"; -print "\n"; -print "\n"; -print "\n"; -print "
      $text{'esub_tabhdr'}
      \n"; +print &ui_form_start("save_subnet.cgi", "post"); +print &ui_hidden("ret",$in{'ret'}); +print &ui_table_start($text{'esub_tabhdr'}, "width=100%", 4); -print "\n"; -printf "\n", - $sub ? &html_escape($sub->{'comment'}) : ""; +print "\n"; +print ""; +print ""; -print "\n"; -printf "\n", - $sub ? $sub->{'values'}->[0] : ""; +print "\n"; +print ""; -print "\n"; -printf "\n", - $sub ? $sub->{'values'}->[2] : ""; +print "\n"; +print ""; +print ""; @range = $sub ? &find("range", $sub->{'members'}) : (); -print "\n"; +print "\n"; if (!defined($in{'ret'})) { - print "\n"; - print "\n"; + print "\n"; + print "\n"; } else { - print "{'index'}>\n"; - print "\n"; + print ""; + print "\n"; } &display_params($sconf, "subnet"); @@ -112,8 +110,8 @@ foreach $s (&find("subnet", $mems)) { @host = sort { $a->{'values'}->[0] cmp $b->{'values'}->[0] } @host; # @group = sort { @{$a->{'members'}} <=> @{$b->{'members'}} } @group; -print "\n"; -print "\n"; +print "\n"; print "\n"; -print "
      $text{'esub_desc'}
      $text{'esub_desc'}"; +print &ui_textbox("desc", ( $sub ? &html_escape($sub->{'comment'}) : "" ), 60); +print "
      $text{'esub_naddr'}
      $text{'esub_naddr'}"; +print &ui_textbox("network", ( $sub ? $sub->{'values'}->[0] : "" ), 25); +print "$text{'esub_nmask'}
      $text{'esub_nmask'}"; +print &ui_textbox("netmask", ( $sub ? $sub->{'values'}->[2] : "" ), 25); +print "
      $text{'esub_arange'} \n"; +print "
      $text{'esub_arange'}\n"; for($i=0; $i<=@range; $i++) { $r = $range[$i]; - local $dyn = ($r->{'values'}->[0] eq "dynamic-bootp"); - printf " - \n", - $r->{'values'}->[$dyn]; - printf " \n", - $r->{'values'}->[$dyn+1]; - printf "\n", - $dyn ? "checked" : ""; - print "$text{'esub_dbooptpq'}
      \n"; + my $dyn = ($r->{'values'}->[0] eq "dynamic-bootp"); + print &ui_textbox("range_low_".$i, $r->{'values'}->[$dyn], 15); + print " - "; + print &ui_textbox("range_hi_".$i, $r->{'values'}->[$dyn+1], 15); + print " "; + print &ui_checkbox("range_dyn_".$i, 1, $text{'esub_dbooptpq'}, ($dyn ? 1 : 0 ) ); } -print "
      $text{'esub_shnet'}
      $text{'esub_shnet'}"; + my @shn; + push(@shn, [ "", "<$text{'esub_none'}>", ( $s_parent ? "" : "selected" ) ]); + foreach $s (&find("shared-network", $conf)) { + push(@shn, [ $s->{'index'}, ( &can('rw', \%access, $s) ? $s->{'values'}->[0] : "" ), ( $s eq $s_parent ? "" : "selected" ) ]); + } + print &ui_select("parent", undef, \@shn); + print "
         
      ".&ui_hidden("parent",$s_parent->{'index'})."  
      $text{'esub_hosts'}
      $text{'esub_hosts'}$text{'esub_groups'}{'index'},$sub->{'index'}\" type=hidden>\n"; + print &ui_hidden("hosts","$h->{'index'},$sub->{'index'}"); + #print "{'index'},$sub->{'index'}\" type=hidden>\n"; } } # inaccessible groups in this subnet foreach $g (@group) { if (!&can('r', \%access, $g) && $insubn{$g} eq $sub->{'index'}) { - print "{'index'},$sub->{'index'}\" type=hidden>\n"; + print &ui_hidden("groups","$g->{'index'},$sub->{'index'}"); + #print "{'index'},$sub->{'index'}\" type=hidden>\n"; } } } -print "
      \n"; -print "\n"; +print &ui_table_end(); +print &ui_hidden("sidx", $in{'sidx'}); + if (!$in{'new'}) { # Show buttons for existing subnet - print "\n"; + print &ui_hidden("idx", $in{'idx'}); print "\n"; print "\n" if &can('rw', \%access, $sub); @@ -180,7 +181,7 @@ if (!$in{'new'}) { } else { # Show create button for new subnet - print "\n"; + print &ui_hidden("new", "1"); print "\n"; } @@ -205,7 +206,8 @@ if ($config{'dhcpd_version'} >= 3 && !$in{'new'}) { "$text{'esub_pooladd'}
      \n"; } -print "\n"; +print &ui_form_end(); + if ($in{'ret'} eq "shared") { &ui_print_footer("edit_shared.cgi?idx=$in{'sidx'}", $text{'esub_retshar'}); } From 8f6e9cec967c122da82db08a8fa57ca9a92d4f49 Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Mon, 16 Dec 2013 03:26:08 +0800 Subject: [PATCH 18/19] ui-lib conversion dhcpd/edit_shared.cgi - not finish yet --- dhcpd/edit_shared.cgi | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/dhcpd/edit_shared.cgi b/dhcpd/edit_shared.cgi index 295e48013..bfa5018f0 100755 --- a/dhcpd/edit_shared.cgi +++ b/dhcpd/edit_shared.cgi @@ -23,23 +23,23 @@ else { # display &ui_print_header(undef, $in{'new'} ? $text{'esh_crheader'} : $text{'esh_eheader'}, ""); +print &ui_form_start("save_shared.cgi", "post"); +print &ui_table_start($text{'esh_tabhdr'}, "width=100%", 4); -print "
      \n"; -print "
      \n"; -print "\n"; -print "
      $text{'esh_tabhdr'}
      \n"; +print "\n"; +print ""; +print ""; -print "\n"; -printf "\n", - $sha ? &html_escape($sha->{'comment'}) : ""; - -print "\n"; -printf "\n", - $sha ? $sha->{'values'}->[0] : ""; +print "\n"; +print ""; &display_params($sconf, "shared-network"); -print "
      $text{'esh_desc'}"; +print &ui_textbox("desc", ( $sha ? &html_escape($sha->{'comment'}) : "" ), 60); +print "
      $text{'esh_desc'}
      $text{'esh_netname'}
      $text{'esh_netname'}"; +print &ui_textbox("name", ( $sha ? $sha->{'values'}->[0] : "" ), 15); +print "
      \n"; +print "\n"; -print "
      \n"; foreach $h (&find("host", $conf)) { push(@host, $h) if &can('r', \%access, $h); } @@ -129,7 +129,8 @@ if (!$in{'new'}) { } print "
      \n"; +print &ui_table_end(); + if (!$in{'new'}) { print "\n"; print "\n"; @@ -178,6 +179,6 @@ if ($config{'dhcpd_version'} >= 3 && !$in{'new'}) { "$text{'esub_pooladd'}
      \n"; } -print "\n"; +print &ui_form_end(); &ui_print_footer("", $text{'esh_return'}); From aab3382878654a77100b44a411d71c5ef448e9df Mon Sep 17 00:00:00 2001 From: Nawawi Jamili Date: Mon, 16 Dec 2013 03:26:38 +0800 Subject: [PATCH 19/19] ui-lib conversion dhcpd --- dhcpd/dhcpd-lib.pl | 17 +++++++----- dhcpd/edit_subnet.cgi | 61 ++++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/dhcpd/dhcpd-lib.pl b/dhcpd/dhcpd-lib.pl index ddbf0c7cd..d5845bce7 100755 --- a/dhcpd/dhcpd-lib.pl +++ b/dhcpd/dhcpd-lib.pl @@ -302,14 +302,17 @@ sub opt_input { local($v, $rv); $v = &find($_[1], $_[2]); -$rv = "\n", - $v ? $v->{'value'} : ""; +$rv .= &ui_radio($_[1]."_def", ( $v ? 0 : 1 ), [ [ 1, $_[3] ], [ 0, " " ] ]); +$rv .= &ui_textbox($_[1], ( $v ? $v->{'value'} : "" ), $_[4])." ".$_[5]; +$rv .= ""; +#$rv .= sprintf " $_[3]\n", +# $v ? "" : "checked"; +#$rv .= sprintf " ", +# $v ? "checked" : ""; +#$rv .= sprintf " $_[5]\n", +# $v ? $v->{'value'} : ""; return $rv; } diff --git a/dhcpd/edit_subnet.cgi b/dhcpd/edit_subnet.cgi index 5dff24ddb..59b05c72f 100755 --- a/dhcpd/edit_subnet.cgi +++ b/dhcpd/edit_subnet.cgi @@ -111,30 +111,28 @@ foreach $s (&find("subnet", $mems)) { # @group = sort { @{$a->{'members'}} <=> @{$b->{'members'}} } @group; print "\n"; -print "\n"; +print &ui_select("hosts", undef, \@esub_hosts_sel, 3, 1); +print "\n"; print "\n"; -print "\n"; +print &ui_select("groups", undef, \@esub_groups_sel, 3, 1); +print "\n"; if (!$in{'new'}) { # inaccessible hosts in this subnet @@ -160,29 +158,29 @@ if (!$in{'new'}) { # Show buttons for existing subnet print &ui_hidden("idx", $in{'idx'}); print "
      $_[0] 30 ? " colspan=3>\n" : ">\n"; -$rv .= sprintf " $_[3]\n", - $v ? "" : "checked"; -$rv .= sprintf " ", - $v ? "checked" : ""; -$rv .= sprintf " $_[5]
      $text{'esub_hosts'}"; +my @esub_hosts_sel; foreach $h (@host) { next if !&can('r', \%access, $h); - printf "\n", - $h->{'index'}, $insubn{$h}, - (!$in{'new'}) && $insubn{$h} eq $sub->{'index'} ? "selected" : "", - $h->{'values'}->[0]; + push(@esub_hosts_sel, [$h->{'index'}.",".$insubn{$h}, $h->{'values'}->[0], ( (!$in{'new'}) && $insubn{$h} eq $sub->{'index'} ? "selected" : "" ) ] ); } -print "$text{'esub_groups'}"; +my @esub_groups_sel; foreach $g (@group) { - local $gm = 0; + my $gm = 0; next if !&can('r', \%access, $g); foreach $h (@{$g->{'members'}}) { if ($h->{'name'} eq "host") { $gm++; } } - printf "\n", - $g->{'index'}, $insubn{$g}, - (!$in{'new'}) && $insubn{$g} eq $sub->{'index'} ? "selected" : "", - &group_name($gm, $g); + push(@esub_groups_sel, [$g->{'index'}.",".$insubn{$g}, &group_name($gm, $g), ( (!$in{'new'}) && $insubn{$g} eq $sub->{'index'} ? "selected" : "" ) ] ); } -print "
      \n"; - print "\n" - if &can('rw', \%access, $sub); - print "\n"; + print ""; + print ""; if ($access{'r_leases'}) { - print "\n"; + print ""; } - print "\n" if &can('rw', \%access, $sub, 1); + print ""; print "
      "; + print &ui_submit($text{'save'}) if &can('rw', \%access, $sub); + print ""; + print &ui_submit( (&can('rw', \%access, $sub) ? $text{'butt_eco'} : $text{'butt_vco'} ), "options"); + print ""; + print &ui_submit($text{'butt_leases'},"leases"); + print ""; + print &ui_submit($text{'delete'}, "delete") if &can('rw', \%access, $sub, 1); + print "
      \n"; - print "$text{'index_addhst'}  \n" - if &can('rw', \%access, $sub); - print "$text{'index_addhstg'}

      \n" - if &can('rw', \%access, $sub); + print &ui_link("edit_host.cgi?new=1&sidx=$in{'sidx'}&uidx=$in{'idx'}&ret=subnet", $text{'index_addhst'})."  " if &can('rw', \%access, $sub); + print &ui_link("edit_group.cgi?new=1&sidx=$in{'sidx'}&uidx=$in{'idx'}&ret=subnet", $text{'index_addhstg'}) if &can('rw', \%access, $sub); } else { # Show create button for new subnet print &ui_hidden("new", "1"); - print "\n"; + print "
      "; + print &ui_submit($text{'create'}); } if ($config{'dhcpd_version'} >= 3 && !$in{'new'}) { @@ -202,12 +200,11 @@ if ($config{'dhcpd_version'} >= 3 && !$in{'new'}) { else { &icons_table(\@links, \@titles, \@icons, 5); } - print "", - "$text{'esub_pooladd'}
      \n"; + print &ui_link("edit_pool.cgi?uidx=$in{'idx'}&sidx=$in{'sidx'}&new=1",$text{'esub_pooladd'}); } print &ui_form_end(); - +print "
      "; if ($in{'ret'} eq "shared") { &ui_print_footer("edit_shared.cgi?idx=$in{'sidx'}", $text{'esub_retshar'}); }