[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] [PATCH] Fix Savannah bug #15384, find misbehaves whe
From: |
James Youngman |
Subject: |
[Findutils-patches] [PATCH] Fix Savannah bug #15384, find misbehaves when parent directory is not readable. 2007-12-02 James Youngman <address@hidden> |
Date: |
Sun, 2 Dec 2007 22:11:42 +0000 |
---
NEWS | 5 +++++
find/find.c | 16 ++++++++++++----
find/testsuite/Makefile.am | 2 ++
find/testsuite/find.posix/parent.exp | 7 +++++++
find/testsuite/find.posix/parent.xo | 1 +
5 files changed, 27 insertions(+), 4 deletions(-)
create mode 100644 find/testsuite/find.posix/parent.exp
create mode 100644 find/testsuite/find.posix/parent.xo
diff --git a/NEWS b/NEWS
index 4191bbd..9225889 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
* Major changes in release 4.3.12-CVS
+** Bug Fixes
+
+#15384: Find misbehaves when parent directory is not readable.
+
+
* Major changes in release 4.3.11, 2007-12-02
** Functional changes
diff --git a/find/find.c b/find/find.c
index bc6f8e9..6a3976a 100644
--- a/find/find.c
+++ b/find/find.c
@@ -879,10 +879,18 @@ safely_chdir(const char *dest,
options.open_nofollow_available = false;
#endif
if (options.open_nofollow_available)
- result = safely_chdir_nofollow(dest, direction, statbuf_dest,
symlink_follow_option, did_stat);
- else
- result = safely_chdir_lstat(dest, direction, statbuf_dest,
symlink_follow_option, did_stat);
- return result;
+ {
+ result = safely_chdir_nofollow(dest, direction, statbuf_dest,
+ symlink_follow_option, did_stat);
+ if (SafeChdirOK == result)
+ return result;
+ }
+ /* Even if O_NOFOLLOW is available, we may need to use the alternative
+ * method, since parent of the start point may be executable but not
+ * readable.
+ */
+ return safely_chdir_lstat(dest, direction, statbuf_dest,
+ symlink_follow_option, did_stat);
}
diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am
index e73e520..3712f0c 100644
--- a/find/testsuite/Makefile.am
+++ b/find/testsuite/Makefile.am
@@ -81,6 +81,7 @@ find.posix/depth1.xo \
find.posix/sizes.xo \
find.posix/name.xo \
find.posix/nameslash.xo \
+find.posix/parent.xo \
find.posix/perm-X.xo \
find.posix/perm-vanilla.xo \
find.posix/posixnot.xo \
@@ -138,6 +139,7 @@ find.gnu/mindepth-badarg.exp \
find.gnu/name-opt.exp \
find.gnu/name-period.exp \
find.gnu/name-slash.exp \
+find.posix/parent.exp \
find.gnu/path.exp \
find.gnu/print_stdout.exp \
find.gnu/print0.exp \
diff --git a/find/testsuite/find.posix/parent.exp
b/find/testsuite/find.posix/parent.exp
new file mode 100644
index 0000000..1cdca3b
--- /dev/null
+++ b/find/testsuite/find.posix/parent.exp
@@ -0,0 +1,7 @@
+# test for handling of unreadable parent directory
+exec rm -rf tmp
+exec mkdir tmp tmp/dir
+exec chmod a-rw tmp
+find_start p {tmp/dir}
+exec chmod u+rw tmp
+exec rm -rf tmp
diff --git a/find/testsuite/find.posix/parent.xo
b/find/testsuite/find.posix/parent.xo
new file mode 100644
index 0000000..2dc4706
--- /dev/null
+++ b/find/testsuite/find.posix/parent.xo
@@ -0,0 +1 @@
+tmp/dir
--
1.5.3.6
- [Findutils-patches] [PATCH] Fix Savannah bug #15384, find misbehaves when parent directory is not readable. 2007-12-02 James Youngman <address@hidden>,
James Youngman <=