Control: tags -1 patch
Patch against 1:3.2.4~rc1-3.5, based on Nicholas Bamber's 2011 patch and
reworked, because find has no --path or --prune options: the pruning is
built as
\( -path 'A' -o -path 'A/*' -o -path 'B' -o -path 'B/*' \) -prune -o
in front of the existing expression. Each entry matches the directory and
everything below it, which matters when a mount point inside a pruned
directory (Docker's overlay mounts under /var/lib/docker, for example) is
handed to find as a starting point of its own.
The new tigerrc setting Tiger_FSScan_PruneDirs is a pipe-separated list of
find -path patterns and defaults to empty, so the scan is unchanged unless
it is set. The stale TODO in find_files that described this feature is
removed.
Tested with a small tree: plain paths, paths with a trailing slash and
globs such as /home/*/.cache are all pruned, and with the setting empty
find's output is byte-identical to before.
Andrei Trimbitas
--- a/scripts/find_files
+++ b/scripts/find_files
@@ -17,6 +17,9 @@
#
# find_files - 06/14/93
#
+# 10/04/2026 atrimbitas Skip the directories listed in
Tiger_FSScan_PruneDirs,
+# based on a patch from Nicholas Bamber (Debian bug #610785)
+#
# 02/26/2010 fgclaramonte Properly remove the temporary mountlist file
# generated by the script
#
@@ -43,14 +46,7 @@
#
#-----------------------------------------------------------------------------
# TODO:
-# - There is not currently a way for admins to have find _not_ go through
-# directories that might be too big or should not be reviewed, consider
-# using the -prune option (in combination with the defined FINEPRUNEOPT
-# in configuration) like this:
-# -a \! -name NAME -prune -a \! -name "*REGEXP*" -prune
-#
-# - Alternative, allow the admin to restrict the depth of the test using
-# -maxdepth
+# - Allow the admin to restrict the depth of the test using -maxdepth
#
#-----------------------------------------------------------------------------
#
@@ -269,6 +265,24 @@
rw=rw
[ "x$Tiger_FSScan_ReadOnly" = 'xY' ] && rw=
+# Directories the admin does not want scanned (pipe-separated find -path
patterns)
+pruneopt=
+if [ -n "$Tiger_FSScan_PruneDirs" ]; then
+ saveIFS=$IFS
+ IFS='|'
+ set -f
+ for prunedir in $Tiger_FSScan_PruneDirs
+ do
+ # Match the directory and anything below it: a mount point inside a
+ # pruned directory is a starting point of its own for find
+ [ -n "$pruneopt" ] && pruneopt="$pruneopt -o"
+ pruneopt="$pruneopt -path '${prunedir%/}' -o -path '${prunedir%/}/*'"
+ done
+ set +f
+ IFS=$saveIFS
+ pruneopt="\( $pruneopt \) -prune -o"
+fi
+
{
if [ ! -n "$FINDXDEV" ]; then
echo "$FINDPRUNE"
@@ -303,13 +317,13 @@
# Do not change these variable names
otherfile="${outfile}.other.$counter"
-# echo "$FIND x $findpruneopt $findopt -print" 1>&2
+# echo "$FIND x $findpruneopt $pruneopt $findopt -print" 1>&2
for mountpt in $disklist
do
# Not sure why we're cd'ing to /, but it breaks all relative paths
# being used in the find options. Commented out --mlk
# cd /
- eval nice -5 $FIND "$mountpt" $findpruneopt $findopt -print 2>/dev/null
+ eval nice -5 $FIND "$mountpt" $findpruneopt $pruneopt $findopt -print
2>/dev/null
done | nice -6 $output 2>&1 |
sed -e '/No such file/s/^.*:[[:space:]]\(.*\):[[:space:]].*$/\1/' |
while read symlink ; do
--- a/tigerrc
+++ b/tigerrc
@@ -325,6 +325,11 @@
#
Tiger_FSScan_ReadOnly=N
#
+# Directories the file system scan should skip, pipe-separated.
+# Each entry is a find -path pattern, e.g. '/srv/backups|/home/*/.cache'
+#
+Tiger_FSScan_PruneDirs=''
+#
# List of dot files commonly found in user home directories. These
# will be checked by check_accounts for proper access permissions.
#