Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Dec 2005 15:54:17 +0100 (CET)
From:      Anatoli Klassen <anatoli@aksoft.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/90687: [patch] side effect of -delete option of find(1) 
Message-ID:  <20051220145417.1B52D1DA14@26th.net>
Resent-Message-ID: <200512201500.jBKF0Dh7012973@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         90687
>Category:       bin
>Synopsis:       [patch] side effect of -delete option of find(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 20 15:00:12 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Anatoli Klassen
>Release:        FreeBSD 5.4-RELEASE-p6 i386
>Organization:
>Environment:
System: FreeBSD mercury.26th.net 5.4-RELEASE-p6 FreeBSD 5.4-RELEASE-p6 #0: Wed Jul 27 12:58:07 CEST 2005 root@mercury.26th.net:/usr/obj/usr/src/sys/MERCURY i386

>Description:
	If -delete option is used it cancel -L option silently.
	So find does something different as it does with just -print option.
	The result could be deleting of all symbolic links instead of broken ones only even
	if user has already validated this with previous -print run.

>How-To-Repeat:
	Create a file, symbolic link to it and a broken symbolic link:
	touch a && ln -s a b && ln -s c d

	Now detect all broken links:
	find -L . -type l
	- works fine, shows that "d" is broken.

	Then try to delete the broken links
	find -L . -type l -delete
	- all links are deleted, not only broken ones.

>Fix:

A patch to remove the side effect. It does not allow to delete the broken links because
there is once more check in the code with comment "sanity check", but at least it will
show error message and not delete correct links.

--- /usr/src/usr.bin/find/function.c	Thu Jul 29 05:33:55 2004
+++ find/function.c	Tue Dec 20 14:16:56 2005
@@ -453,8 +453,6 @@
 {
 
 	ftsoptions &= ~FTS_NOSTAT;	/* no optimise */
-	ftsoptions |= FTS_PHYSICAL;	/* disable -follow */
-	ftsoptions &= ~FTS_LOGICAL;	/* disable -follow */
 	isoutput = 1;			/* possible output */
 	isdepth = 1;			/* -depth implied */
 
To delete the links really one can use "find -L . -type l -print0 | xargs -0 rm"

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051220145417.1B52D1DA14>