From owner-freebsd-bugs@FreeBSD.ORG Tue Dec 20 15:00:15 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 472C416A41F for ; Tue, 20 Dec 2005 15:00:15 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id A59AC43D64 for ; Tue, 20 Dec 2005 15:00:13 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id jBKF0DUt012976 for ; Tue, 20 Dec 2005 15:00:13 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id jBKF0Dh7012973; Tue, 20 Dec 2005 15:00:13 GMT (envelope-from gnats) Resent-Date: Tue, 20 Dec 2005 15:00:13 GMT Resent-Message-Id: <200512201500.jBKF0Dh7012973@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Anatoli Klassen Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3631816A41F for ; Tue, 20 Dec 2005 14:54:19 +0000 (GMT) (envelope-from dev@26th.net) Received: from 26th.net (26th.net [217.79.183.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id B1AE243D49 for ; Tue, 20 Dec 2005 14:54:18 +0000 (GMT) (envelope-from dev@26th.net) Received: by 26th.net (Postfix, from userid 1001) id 1B52D1DA14; Tue, 20 Dec 2005 15:54:17 +0100 (CET) Message-Id: <20051220145417.1B52D1DA14@26th.net> Date: Tue, 20 Dec 2005 15:54:17 +0100 (CET) From: Anatoli Klassen To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/90687: [patch] side effect of -delete option of find(1) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Anatoli Klassen List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2005 15:00:15 -0000 >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: