From owner-freebsd-hackers@FreeBSD.ORG Mon May 20 19:23:23 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 9B93513A for ; Mon, 20 May 2013 19:23:23 +0000 (UTC) (envelope-from lidl@hydra.pix.net) Received: from hydra.pix.net (hydra.pix.net [IPv6:2001:470:e254::3c]) by mx1.freebsd.org (Postfix) with ESMTP id 6D360174F for ; Mon, 20 May 2013 19:23:23 +0000 (UTC) Received: from hydra.pix.net (localhost [127.0.0.1]) by hydra.pix.net (8.14.5/8.14.5) with ESMTP id r4KJNGXF032594 for ; Mon, 20 May 2013 15:23:16 -0400 (EDT) (envelope-from lidl@hydra.pix.net) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.97.8 at mail.pix.net Received: (from lidl@localhost) by hydra.pix.net (8.14.5/8.14.5/Submit) id r4KJNGnk032593 for freebsd-hackers@freebsd.org; Mon, 20 May 2013 15:23:16 -0400 (EDT) (envelope-from lidl) Date: Mon, 20 May 2013 15:23:16 -0400 From: Kurt Lidl To: freebsd-hackers@freebsd.org Subject: find -delete broken, or just used improperly? Message-ID: <20130520192316.GA32531@pix.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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: Mon, 20 May 2013 19:23:23 -0000 OK, maybe I'm missing something obvious, but... find(1) says: -delete 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. Following symlinks is incompatible with this option. However, it fails even when the path is absolute: bhyve9# mkdir /tmp/foo bhyve9# find /tmp/foo -empty -delete find: -delete: /tmp/foo: relative path potentially not safe Shouldn't this work? I ran into this during a build of stable/9 with WITHOUT_SHAREDOCS set, which ultimately triggers this bit of /usr/src/Makefile.inc1: .for dist in ${EXTRA_DISTRIBUTIONS} find ${DESTDIR}/${DISTDIR}/${dist} -empty -delete .endfor The actual observed failure is this: ===> etc/sendmail (distribute) cd /usr/src/etc/sendmail; make install -DNO_SUBDIR DESTDIR=/usr/obj/usr/src/release/dist/base SHARED=copies find //usr/obj/usr/src/release/dist/doc -empty -delete find: -delete: //usr/obj/usr/src/release/dist/doc: relative path potentially not safe *** [distributeworld] Error code 1 Stop in /usr/src. *** [distributeworld] Error code 1 Stop in /usr/src. *** [base.txz] Error code 1 Stop in /usr/src/release. *** [release] Error code 1 Stop in /usr/src/release. Thanks for any insight. -Kurt