diff options
author | doktornotor <notordoktor@gmail.com> | 2015-09-30 15:24:26 +0200 |
---|---|---|
committer | doktornotor <notordoktor@gmail.com> | 2015-09-30 15:24:26 +0200 |
commit | b27ad1190a1a6360a9b61c488a9843f66d42125d (patch) | |
tree | ccef525ce4a8a04f31369fa273136be1f8145c3c /config/squid3/34 | |
parent | 49050e47642d7fbfdbd286dfec149ef74b83f179 (diff) | |
download | pfsense-packages-b27ad1190a1a6360a9b61c488a9843f66d42125d.tar.gz pfsense-packages-b27ad1190a1a6360a9b61c488a9843f66d42125d.tar.bz2 pfsense-packages-b27ad1190a1a6360a9b61c488a9843f66d42125d.zip |
Do not leave orphaned cache dirs if harddisk_cache_location changed
The old cache dir will ONLY get deleted when located under /var/squid/ to prevent nasty accidents.
Diffstat (limited to 'config/squid3/34')
-rwxr-xr-x | config/squid3/34/squid_cache.xml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/config/squid3/34/squid_cache.xml b/config/squid3/34/squid_cache.xml index a5e73f80..2045005c 100755 --- a/config/squid3/34/squid_cache.xml +++ b/config/squid3/34/squid_cache.xml @@ -403,10 +403,40 @@ <encoding>base64</encoding> </field> </fields> + <custom_php_command_before_form> + <![CDATA[ + global $oldcachedir; + // do not leave orphaned cachedirs if harddisk_cache_location changed + if ($_POST['harddisk_cache_location'] != $config['installedpackages']['squidcache']['config'][0]['harddisk_cache_location']) { + $oldcachedir = $config['installedpackages']['squidcache']['config'][0]['harddisk_cache_location']; + $cachedir_changed = true; + } + ]]> + </custom_php_command_before_form> <custom_php_validation_command> squid_validate_cache($_POST, $input_errors); </custom_php_validation_command> <custom_php_resync_config_command> + <![CDATA[ + if ($cachedir_changed) { + // only delete directories under sane paths automatically + if (substr($oldcachedir, 0, 11) === "/var/squid/") { + log_error("Deleting Squid cache dir '{$oldcachedir}' since 'Hard Disk Cache Location' changed to '{$_POST['harddisk_cache_location']}'."); + // cannot nuke disk cache while Squid is running + squid_stop_monitor(); + if (is_service_running('squid')) { + stop_service("squid"); + } + rename($oldcachedir, "{$oldcachedir}.old"); + mwexec_bg("/bin/rm -rf {$oldcachedir}.old"); + // new cachedir will be created on squid_resync() below which calls squid_dash_z() + // also the services will get restarted there + } else { + log_error("'Hard Disk Cache Location' changed to '{$_POST['harddisk_cache_location']}'."); + log_error("Will NOT delete Squid cache dir '{$oldcachedir}' since it is not located under /var/squid. Delete manually if required."); + } + } squid_resync(); + ]]> </custom_php_resync_config_command> </packagegui> |