Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Feb 2006 09:43:59 +0000
From:      Xin LI <delphij@freebsd.org>
To:        freebsd-standards@FreeBSD.org
Cc:        delphij@FreeBSD.org
Subject:   Exit if working directory is not accessible: a find(1) bug or feature?
Message-ID:  <20060205094359.GA16091@hub.freebsd.org>

index | next in thread | raw e-mail

[-- Attachment #1 --]
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,

[-- Attachment #2 --]
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.
help

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