From owner-freebsd-standards@FreeBSD.ORG Sun Feb 5 09:43:59 2006 Return-Path: X-Original-To: freebsd-standards@FreeBSD.org Delivered-To: freebsd-standards@FreeBSD.org Received: by hub.freebsd.org (Postfix, from userid 1035) id 31E1516A422; Sun, 5 Feb 2006 09:43:59 +0000 (GMT) Date: Sun, 5 Feb 2006 09:43:59 +0000 From: Xin LI To: freebsd-standards@FreeBSD.org Message-ID: <20060205094359.GA16091@hub.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="a8Wt8u1KmwUX3Y2C" Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Cc: delphij@FreeBSD.org Subject: Exit if working directory is not accessible: a find(1) bug or feature? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Feb 2006 09:43:59 -0000 --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Dear folks, I have recently found a find(1) feature (or bug) that, it would exit immediately if the working directory is not accessible. HOW TO REPEAT: [su to root] cd /tmp mkdir find_testcase chmod 700 find_testcase cd find_testcase [su to your user, e.g. su delphij] Now that we have an non-accessible working directory (/tmp/find_testcase). Any attempt of find would fail with: find: .: Permission Denied This was caused by line 157-158 of find/main.c, which was inherted from 4.4BSD. This behavior also exists in CentOS 3.5, OpenBSD 3.8 and Solaris 8. It seems that the purpose of the code was to conform the POSIX statement that: "-exec ... The current directory for the invocation of utility_name shall be the same as the current directory when the find utility was started. ..." However, it looks somewhat confusing that find(1) refuse to work even if no -exec is specified. So, should we consider this as a feature (add some comments in the BUGS section), or it's a bug that should be fixed? Cheers, --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch-find.1" Index: find.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/find/find.1,v retrieving revision 1.73 diff -u -r1.73 find.1 --- find.1 14 Jun 2005 11:50:51 -0000 1.73 +++ find.1 5 Feb 2006 09:27:17 -0000 @@ -934,3 +934,6 @@ primaries are actually global options (as documented above). They should probably be replaced by options which look like options. +.Pp +.Nm +will exit immediately if the working directory is not accessible. --a8Wt8u1KmwUX3Y2C--