From owner-freebsd-hackers@FreeBSD.ORG Fri May 24 15:28:29 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BF6F5384 for ; Fri, 24 May 2013 15:28:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) by mx1.freebsd.org (Postfix) with ESMTP id 9E5BD90D for ; Fri, 24 May 2013 15:28:29 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id EB444B977; Fri, 24 May 2013 11:28:28 -0400 (EDT) From: John Baldwin To: Jilles Tjoelker Subject: Re: find -delete broken, or just used improperly? Date: Fri, 24 May 2013 09:46:29 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <20130520192316.GA32531@pix.net> <201305211106.39313.jhb@freebsd.org> <20130524102411.GA3984@stack.nl> In-Reply-To: <20130524102411.GA3984@stack.nl> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201305240946.29590.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 24 May 2013 11:28:29 -0400 (EDT) Cc: freebsd-hackers@freebsd.org, Kurt Lidl X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 May 2013 15:28:29 -0000 On Friday, May 24, 2013 6:24:11 am Jilles Tjoelker wrote: > On Tue, May 21, 2013 at 11:06:39AM -0400, John Baldwin wrote: > > On Monday, May 20, 2013 5:47:31 pm Jilles Tjoelker wrote: > > > The below patch allows deleting the pathname given to find itself: > > > > Index: usr.bin/find/function.c > > > =================================================================== > > > --- usr.bin/find/function.c (revision 250661) > > > +++ usr.bin/find/function.c (working copy) > > > @@ -442,7 +442,8 @@ > > > errx(1, "-delete: forbidden when symlinks are followed"); > > > > > > /* Potentially unsafe - do not accept relative paths whatsoever */ > > > - if (strchr(entry->fts_accpath, '/') != NULL) > > > + if (entry->fts_level > FTS_ROOTLEVEL && > > > + strchr(entry->fts_accpath, '/') != NULL) > > > errx(1, "-delete: %s: relative path potentially not safe", > > > entry->fts_accpath); > > > I'm curious, how would you instruct a patched find to avoid deleteing > > the /tmp/foo directory (e.g. if you wanted this to be a job that > > pruned empty dirs from /tmp/foo but never pruned the directory > > itself). Would -mindepth 1 do it? (Just asking. I have also found > > this message annoying but most of the jobs I have seen it on probably > > don't want to delete the root path, just descendants.) > > -mindepth 1 works, as does cd /tmp/foo && find . -... (-delete silently > ignores . and ..). Right, my only concern is that this fix will introduce a change in behavior that I think might be significant, so we should make sure to advertise it well in UPDATING, etc. -- John Baldwin