Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squid - Allow "all" ACL in Do Not Cache, add some hints to GUI, remove useless remount code #438

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions www/pfSense-pkg-squid/files/usr/local/pkg/squid.inc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ function squid_check_ca_hashes() {
}
}
if ($cert_count < 10) {
conf_mount_rw();
// create ca-root hashes from ca-root-nss package
log_error("[squid] Creating root certificate bundle hashes from the Mozilla Project...");
$cas = file(SQUID_LOCALBASE . '/share/certs/ca-root-nss.crt');
Expand Down Expand Up @@ -361,9 +360,7 @@ fi

EOD;

conf_mount_rw();
write_rcfile($rc);
conf_mount_ro();
}

/* Start sqp_monitor.sh watchdog script */
Expand Down Expand Up @@ -946,7 +943,8 @@ function squid_validate_cache($post, &$input_errors) {
if (strpos($host, '.') === 0) {
$host = substr($host, 1);
}
if (!is_ipaddr($host) && !is_domain($host)) {
// Allow "all" ACL as special case to disable any cache access
if (!is_ipaddr($host) && !is_domain($host) && $host != "all") {
$input_errors[] = "The host '$host' is not a valid IP or hostname.";
}
}
Expand Down Expand Up @@ -1467,13 +1465,20 @@ EOD;

$donotcache = sq_text_area_decode($settings['donotcache']);
if (!empty($donotcache)) {
file_put_contents(SQUID_ACLDIR . '/donotcache.acl', $donotcache);
$conf .= 'acl donotcache dstdomain "' . SQUID_ACLDIR . "/donotcache.acl\"\n";
$conf .= "cache deny donotcache\n";
// Allow "all" ACL as special case to disable any cache access
if ($donotcache == "all") {
$conf .= "cache deny all\n";
} else {
file_put_contents(SQUID_ACLDIR . '/donotcache.acl', $donotcache);
$conf .= 'acl donotcache dstdomain "' . SQUID_ACLDIR . "/donotcache.acl\"\n";
$conf .= "cache deny donotcache\n";
}
} elseif (file_exists(SQUID_ACLDIR . '/donotcache.acl')) {
unlink(SQUID_ACLDIR . '/donotcache.acl');
}
$conf .= "cache allow all\n";
if ($donotcache != "all") {
$conf .= "cache allow all\n";
}

return $conf.$refresh_conf;
}
Expand Down Expand Up @@ -2010,8 +2015,6 @@ function squid_resync($via_rpc = "no") {
return;
}

conf_mount_rw();

// Fix user/group entry permissions
squid_fixup_user();

Expand Down Expand Up @@ -2049,7 +2052,6 @@ function squid_resync($via_rpc = "no") {
// restart Squid if enabled and reconfigure filter
squid_restart_services();
filter_configure();
conf_mount_ro();
}

/*
Expand Down Expand Up @@ -2426,4 +2428,4 @@ function squid_list_ssl_ca() {
}
}
return $prvca_list;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,8 @@ fi

EOD;

conf_mount_rw();
log_error("[squid] Creating 'clamd.sh' rc script.");
write_rcfile($rc);
conf_mount_ro();
}

/* Create c-icap.sh rc script */
Expand All @@ -713,15 +711,14 @@ fi
sleep 5
/bin/rm -f {$cicap_pipe}
EOF;
conf_mount_rw();

log_error("[squid] Creating '{$c_icap_rcfile}' rc script.");
write_rcfile(array(
"file" => "{$c_icap_rcfile}",
"start" => "{$cicap_start_cmd}",
"stop" => "{$cicap_stop_cmd}"
)
);
conf_mount_ro();
}

/* (Re)start antivirus services if AV features are enabled */
Expand Down
4 changes: 3 additions & 1 deletion www/pfSense-pkg-squid/files/usr/local/pkg/squid_cache.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@
<description>
<![CDATA[
Enter domain(s) and/or IP address(es) that should never be cached.
<span class="text-info">Put each entry on a separate line.</span>
<span class="text-info">Put each entry on a separate line.</span><br/>
Hint: To deny any access to cached objects, use <code>all</code>.
To match subdomains, prefix a domain with <code>.</code>
]]>
</description>
<type>textarea</type>
Expand Down