summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2004-06-08 06:23:23 +0000
committerdas <das@FreeBSD.org>2004-06-08 06:23:23 +0000
commit86ee9527d490f97d0806c5e07ccae773320cae16 (patch)
tree0297c4442e33677adbc86b664e351ae5caab6d85
parent9372d79f045ec7eb096615035a212fb555034516 (diff)
downloadFreeBSD-src-86ee9527d490f97d0806c5e07ccae773320cae16.zip
FreeBSD-src-86ee9527d490f97d0806c5e07ccae773320cae16.tar.gz
In fts_build(), if we try to chdir and fail (e.g. due to lack of search
permission), try to continue in FTS_DONTCHDIR mode. Of course this won't work for long paths, but we can't descend more than one pathname component beyond the directory anyway if we lack search permission. Here is a transcript demonstrating the change, where oldls is ls(1) linked with the old fts(3): das@VARK:~> mkdir t && touch t/{a,b,c} && chmod u-x t das@VARK:~> oldls t a b c das@VARK:~> oldls -l t das@VARK:~> \ls t a b c das@VARK:~> \ls -l t ls: a: Permission denied ls: b: Permission denied ls: c: Permission denied I had forgotten about this patch until bde reminded me. He reports using it without problems for over a year. PR: 45723
-rw-r--r--lib/libc/gen/fts-compat.c2
-rw-r--r--lib/libc/gen/fts.c2
2 files changed, 0 insertions, 4 deletions
diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c
index 0c56880..48f9e0b 100644
--- a/lib/libc/gen/fts-compat.c
+++ b/lib/libc/gen/fts-compat.c
@@ -710,8 +710,6 @@ fts_build(sp, type)
cur->fts_flags |= FTS_DONTCHDIR;
descend = 0;
cderrno = errno;
- (void)closedir(dirp);
- dirp = NULL;
} else
descend = 1;
} else
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
index 0c56880..48f9e0b 100644
--- a/lib/libc/gen/fts.c
+++ b/lib/libc/gen/fts.c
@@ -710,8 +710,6 @@ fts_build(sp, type)
cur->fts_flags |= FTS_DONTCHDIR;
descend = 0;
cderrno = errno;
- (void)closedir(dirp);
- dirp = NULL;
} else
descend = 1;
} else
OpenPOWER on IntegriCloud