From 596f04c575f215f26d46293af75e21ab2cae2885 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 3 Oct 2015 00:40:29 +0200 Subject: Do not loop when trying to chown inaccessible directory and log some debug info Some whacky issue with screwed filesystem/permissions reported at https://forum.pfsense.org/index.php?topic=100167.msg559007#msg559007 - cannot get any meaningful info from the guy there. --- config/squid3/34/squid.inc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'config/squid3/34/squid.inc') diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index 654aeb3c..ae367d3a 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -91,18 +91,22 @@ function squid_chown_recursive($dir, $user, $group) { chown($dir, $user); chgrp($dir, $group); - $handle = opendir($dir) ; - while (($item = readdir($handle)) !== false) { - if (!empty($item) && ($item != ".") && ($item != "..")) { - $path = "{$dir}/{$item}"; - // Recurse unless it's the cache dir, that is slow and rarely necessary. - if (is_dir($path) && (basename($dir) != "cache")) { - squid_chown_recursive($path, $user, $group); - } elseif (is_file($path)) { - chown($path, $user); - chgrp($path, $group); + $handle = opendir($dir); + if ($handle) { + while (($item = readdir($handle)) !== false) { + if (!empty($item) && ($item != ".") && ($item != "..")) { + $path = "{$dir}/{$item}"; + // Recurse unless it's the cache dir, that is slow and rarely necessary. + if (is_dir($path) && (basename($dir) != "cache")) { + squid_chown_recursive($path, $user, $group); + } elseif (is_file($path)) { + chown($path, $user); + chgrp($path, $group); + } } } + } else { + log_error(gettext("Squid squid_chown_recursive call failed; permissions not set for directory: {$dir}")); } } -- cgit v1.2.3