bin/58504: /etc/periodic/daily/100.clean-disks traverses non-local file systems

Lars Eggert larse at
Fri Oct 24 16:50:27 PDT 2003

>Number:         58504
>Category:       bin
>Synopsis:       /etc/periodic/daily/100.clean-disks traverses non-local file systems
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 24 16:50:24 PDT 2003
>Originator:     Lars Eggert
>Release:        FreeBSD 5.1-CURRENT i386
System: FreeBSD 5.1-CURRENT FreeBSD 5.1-CURRENT #0: Fri Oct 24 13:47:51 PDT 2003 root at i386

The find(1) command in /etc/periodic/daily/100.clean-disks traverses
non-local and read-only file systems, despite a carefully crafted
argument string that tries to avoid this.

This bug is probably due to a deficiency in find(1). When called with
"-delete", find(1) switches to depth-first traversal, according to the
man page:

             Delete found files and/or directories. Always returns
             true. This executes from the current working directory as
             find recurses down the tree. It will not attempt to
             delete a filename with a ``/'' character in its pathname
             relative to ``.'' for security reasons. Depth-first
             traversal processing is implied by this option.

However, in depth-first traversal mode, the "-prune" switch has no
effect, causing traversal of non-local and read-only file systems.
Again, from the find(1) man page:

             This primary always evaluates to true. It causes find to
             not descend into the current file. Note, the -prune
             primary has no effect if the -d option was specified.

("-d" is a synonym for "-depth")

Removing "-delete" causes correct behavior, and non-local and
read-only file systems are not traversed. Obviously, this is not a
work around, because no files will be deleted, but it proves the
point of the argument.

Run /etc/periodic/daily/100.clean-disks with read-only or non-local
file systems present.

This seems to fix it, but doesn't support $daily_clean_disks_verbose yet.

Index: 100.clean-disks
RCS file: /home/xbone/CVSROOT/FreeBSD-CURRENT-etc/periodic/daily/100.clean-disks,v
retrieving revision
diff -u -r1.1.1.1 100.clean-disks
--- 100.clean-disks	21 Sep 2002 00:26:56 -0000
+++ 100.clean-disks	24 Oct 2003 23:42:23 -0000
@@ -42,7 +42,7 @@
 	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
-		\( $args \) -atime +$daily_clean_disks_days -delete $print |
+		\( $args \) -atime +$daily_clean_disks_days -print0 | xargs -0 rm -v |
 		tee /dev/stderr | wc -l)
 	    [ -z "$print" ] && rc=0
 	    [ $rc -gt 1 ] && rc=1



More information about the freebsd-bugs mailing list