Ensure that HTTP and ICP restrictions are created after ACLs in the config file.
---- Changes since 1.390 ----
The httpd_accel family of directives are no longer shown when using Squid versions 2.6 and above (as they have been deprecated).
+Directives that refer to ACLs like http_access are no longer re-positioned in the configuration file unless necessary.
else {
# update or create
@vals = ( $in{'action'} );
- foreach $y (split(/\0/, $in{'yes'})) { push(@vals, $y); }
- foreach $n (split(/\0/, $in{'no'})) { push(@vals, "!$n"); }
+ foreach $y (split(/\0/, $in{'yes'})) {
+ push(@vals, $y);
+ $used{$y}++;
+ }
+ foreach $n (split(/\0/, $in{'no'})) {
+ push(@vals, "!$n");
+ $used{$n}++;
+ }
$newhttp = { 'name' => 'http_access', 'values' => \@vals };
if ($http) { splice(@https, &indexof($http, @https), 1, $newhttp); }
else { push(@https, $newhttp); }
}
-&save_directive($conf, "http_access", \@https, "acl");
+
+# Find the last referenced ACL
+@acls = grep { $used{$_->{'values'}->[0]} } &find_config("acl", $conf);
+$lastacl = @acls ? $acls[$#acls] : undef;
+
+&save_directive($conf, "http_access", \@https, $lastacl);
&flush_file_lines();
&unlock_file($config{'squid_conf'});
&webmin_log($in{'delete'} ? 'delete' : $http ? 'modify' : 'create', "http");
else {
# update or create
@vals = ( $in{'action'} );
- foreach $y (split(/\0/, $in{'yes'})) { push(@vals, $y); }
- foreach $n (split(/\0/, $in{'no'})) { push(@vals, "!$n"); }
+ foreach $y (split(/\0/, $in{'yes'})) {
+ push(@vals, $y);
+ $used{$y}++;
+ }
+ foreach $n (split(/\0/, $in{'no'})) {
+ push(@vals, "!$n");
+ $used{$n}++;
+ }
$newicp = { 'name' => 'icp_access', 'values' => \@vals };
if ($icp) { splice(@icps, &indexof($icp, @icps), 1, $newicp); }
else { push(@icps, $newicp); }
}
-&save_directive($conf, "icp_access", \@icps, "acl");
+
+# Find the last referenced ACL
+@acls = grep { $used{$_->{'values'}->[0]} } &find_config("acl", $conf);
+$lastacl = @acls ? $acls[$#acls] : undef;
+
+&save_directive($conf, "icp_access", \@icps, $lastacl);
&flush_file_lines();
&unlock_file($config{'squid_conf'});
&webmin_log($in{'delete'} ? 'delete' : $icp ? 'modify' : 'create', "icp");
if ($i >= @oldv) {
# a new directive is being added..
$nl = &directive_line($newv[$i]);
- local @after = $_[3] ? &find_config($_[3], $_[0]) : ( );
+ local @after = ref($_[3]) ? ( $_[3] ) :
+ $_[3] ? &find_config($_[3], $_[0]) : ( );
local $after = @after ? @after[$#after] : undef;
local @comment = &find_config($_[1], $_[0], 3);
local $comment = @comment ? $comment[$#comment] : undef;
else {
# updating some directive
$nl = &directive_line($newv[$i]);
- local @after = $_[3] ? &find_config($_[3], $_[0]) : ( );
+ local @after = ref($_[3]) ? ( $_[3] ) :
+ $_[3] ? &find_config($_[3], $_[0]) : ( );
local $after = @after ? @after[$#after] : undef;
if ($after && $oldv[$i]->{'line'} < $after->{'line'}) {
# Need to move it after some directive