diff --git a/squid/edit_authparam.cgi b/squid/edit_authparam.cgi index f01a94a3e..cdb3075a3 100755 --- a/squid/edit_authparam.cgi +++ b/squid/edit_authparam.cgi @@ -2,199 +2,136 @@ # edit_authparam.cgi # A form for editing authentication programs +use strict; +use warnings; +our (%text, %in, %access, $squid_version, %config, $auth_program); require './squid-lib.pl'; $access{'authparam'} || &error($text{'authparam_ecannot'}); &ui_print_header(undef, $text{'authparam_title'}, "", "edit_authparam", 0, 0, 0, &restart_button()); -$conf = &get_config(); +my $conf = &get_config(); -print "
\n"; + +print &ui_table_hr(); + +my $taa = &find_value("authenticate_ip_ttl", $conf); +my @ta = split(/\s+/,$taa); +print &ui_table_row($text{'eprogs_aittl'}, + &ui_radio("b_aittl_def", @ta ? 0 : 1, + [ [ 1, $text{'default'} ], + [ 0, &time_fields("b_aittl", 6, $ta[0], $ta[1]) ] ])); + +print &ui_table_end(); +print &ui_form_end([ [ undef, $text{'buttsave'} ] ]); &ui_print_footer("", $text{'eprogs_return'}); diff --git a/squid/lang/en b/squid/lang/en index 7087fe45f..5776e451c 100644 --- a/squid/lang/en +++ b/squid/lang/en @@ -642,6 +642,7 @@ sprog_emsg6='$1' is not a valid column width sprog_emsg7=No DNS servers entered sprog_emsg8='$1' is not a valid IP address sprog_emsg9='$1' is not a valid cache time +sprog_emsg10='$1' is not a valid TTL suser_ftsu=Failed to save user suser_emsg1=Invalid or missing username diff --git a/squid/save_authparam.cgi b/squid/save_authparam.cgi index a30314834..49408a53a 100755 --- a/squid/save_authparam.cgi +++ b/squid/save_authparam.cgi @@ -2,22 +2,27 @@ # save_authparam.cgi # Save authentication program options +use strict; +use warnings; +our (%text, %in, %access, $squid_version, %config, $auth_program, + $auth_database, $module_root_directory, $module_config_directory); require './squid-lib.pl'; $access{'authparam'} || &error($text{'authparam_ecannot'}); &ReadParse(); &lock_file($config{'squid_conf'}); -$conf = &get_config(); +my $conf = &get_config(); &error_setup($text{'authparam_err'}); if ($squid_version >= 2.5) { - local @auth = &find_config("auth_param", $conf); + my @auth = &find_config("auth_param", $conf); # Save basic authentication options if ($in{'b_auth_mode'} == 0) { &save_auth(\@auth, "basic", "program"); } elsif ($in{'b_auth_mode'} == 2) { - &system_logged("cp $module_root_directory/squid-auth.pl $module_config_directory"); + ©_source_dest("$module_root_directory/squid-auth.pl", + "$module_config_directory/squid-auth.pl"); &save_auth(\@auth, "basic", "program", "$auth_program $auth_database"); &system_logged("chmod a+rx $auth_program $auth_database"); } @@ -38,7 +43,7 @@ if ($squid_version >= 2.5) { } else { $in{'b_ttl'} =~ /^\d+$/ || - &error(&text('sprog_emsg6', $in{'b_ttl'})); + &error(&text('sprog_emsg10', $in{'b_ttl'})); &save_auth(\@auth, "basic", "credentialsttl", $in{'b_ttl'}." ".$in{'b_ttl_u'}); } @@ -49,14 +54,17 @@ if ($squid_version >= 2.5) { &save_auth(\@auth, "basic", "realm", $in{'b_realm'}); } if ($in{'b_aittl_def'}) { - &save_directive($conf, "authenticate_ip_ttl",[ ]); - }else{ - $in{'b_aittl'} =~ /^\d+$/ ||&error(&text('sprog_emsg6', $in{'b_aittl'})); - @baittl[0]= $in{'b_aittl'}." ".$in{'b_aittl_u'}; - &save_directive($conf, "authenticate_ip_ttl", - [ { 'name' => 'authenticate_ip_ttl', - 'values' => \@baittl }]); - } + &save_directive($conf, "authenticate_ip_ttl",[ ]); + } + else { + $in{'b_aittl'} =~ /^\d+$/ || + &error(&text('sprog_emsg10', $in{'b_aittl'})); + my @baittl= ( $in{'b_aittl'}." ".$in{'b_aittl_u'} ); + &save_directive($conf, "authenticate_ip_ttl", + [ { 'name' => 'authenticate_ip_ttl', + 'values' => \@baittl }]); + } + # Save digest authentication options if ($in{'d_auth_mode'} == 0) { &save_auth(\@auth, "digest", "program"); @@ -122,7 +130,8 @@ elsif ($squid_version >= 2) { &save_directive($conf, "authenticate_program", [ ]); } elsif ($in{'auth_mode'} == 2) { - &system_logged("cp $module_root_directory/squid-auth.pl $module_config_directory"); + ©_source_dest("$module_root_directory/squid-auth.pl", + "$module_config_directory/squid-auth.pl"); &save_directive($conf, "authenticate_program", [ { 'name' => 'authenticate_program', 'values' => [ "$auth_program $auth_database" ] } ]); @@ -163,8 +172,8 @@ return $_[0] =~ /^\d+$/ ? undef : &text('sprog_emsg5',$_[0]); # save_auth(&auth, type, name, [value]) sub save_auth { -local ($old) = grep { $_->{'values'}->[0] eq $_[1] && - $_->{'values'}->[1] eq $_[2] } @{$_[0]}; +my ($old) = grep { $_->{'values'}->[0] eq $_[1] && + $_->{'values'}->[1] eq $_[2] } @{$_[0]}; if ($old && @_ > 3) { # Replace value $old->{'values'} = [ $_[1], $_[2], $_[3] ];