summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin von Gagern <Martin.vGagern@gmx.net>2009-08-26 11:20:02 +0200
committerJames Youngman <jay@gnu.org>2010-04-06 22:48:39 +0100
commit20171febf2f583d83e1de0d447fa11d3e30f0ba0 (patch)
tree2f2e3d4ce49ed316d3b275c0600763c3ccb03954
parent969f7feed34a7ac3682d354eda6a66d80336711a (diff)
downloadfindutils-20171febf2f583d83e1de0d447fa11d3e30f0ba0.tar.gz
Bug #27213: avoid failed assertions for non-executable directories.
Addresses Savannah bug #27213 - https://savannah.gnu.org/bugs/?27213 This used to fail in recent releases: 1. mkdir -p foo/bar 2. chmod a-x foo 3. find foo 4. find foo -ls Now it will print error messages for the denied permission on foo, but will not abort completely, and in 3. will even print the name foo/bar, while it won't do so in 4., as the -ls predicate requires stat information. For now, 4. will print two identical error message. This should get fixed some day.
-rw-r--r--build-aux/.cvsignore1
-rw-r--r--build-aux/.gitignore1
-rw-r--r--find/ftsfind.c19
-rw-r--r--find/util.c11
4 files changed, 27 insertions, 5 deletions
diff --git a/build-aux/.cvsignore b/build-aux/.cvsignore
index f5e817b..35d182e 100644
--- a/build-aux/.cvsignore
+++ b/build-aux/.cvsignore
@@ -18,3 +18,4 @@ c++defs.h
useless-if-before-free
vc-list-files
update-copyright
+unused-parameter.h
diff --git a/build-aux/.gitignore b/build-aux/.gitignore
index 7ced4ed..be5fe6e 100644
--- a/build-aux/.gitignore
+++ b/build-aux/.gitignore
@@ -17,3 +17,4 @@ compile
/useless-if-before-free
/vc-list-files
/update-copyright
+/unused-parameter.h
diff --git a/find/ftsfind.c b/find/ftsfind.c
index 5e9187d..9eb9541 100644
--- a/find/ftsfind.c
+++ b/find/ftsfind.c
@@ -459,6 +459,23 @@ consider_visiting (FTS *p, FTSENT *ent)
error_severity (1);
return;
}
+ else
+ {
+ error(0, ent->fts_errno, "%s",
+ safely_quote_err_filename(0, ent->fts_path));
+ error_severity(1);
+ /* Continue despite the error, as file name without stat info
+ * might be better than not even processing the file name. This
+ * can lead to repeated error messages later on, though, if a
+ * predicate requires stat information.
+ *
+ * Not printing an error message here would be even more wrong,
+ * though, as this could cause the contents of a directory to be
+ * silently ignored, as the directory wouldn't be identified as
+ * such.
+ */
+ }
+
}
}
@@ -467,7 +484,7 @@ consider_visiting (FTS *p, FTSENT *ent)
|| ent->fts_info == FTS_NS /* e.g. symlink loop */)
{
assert (!state.have_stat);
- assert (ent->fts_info == FTS_NSOK || state.type != 0);
+ assert (ent->fts_info == FTS_NSOK || state.type == 0);
mode = state.type;
}
else
diff --git a/find/util.c b/find/util.c
index f415560..5259652 100644
--- a/find/util.c
+++ b/find/util.c
@@ -216,6 +216,9 @@ get_statinfo (const char *pathname, const char *name, struct stat *p)
{
if (!options.ignore_readdir_race || (errno != ENOENT) )
{
+ /* FIXME: this error message might repeat the one from
+ * the FTS_NS case in consider_visiting. How to avoid this?
+ */
error (0, errno, "%s",
safely_quote_err_filename (0, pathname));
state.exit_status = 1;
@@ -272,6 +275,10 @@ get_info (const char *pathname,
int result = get_statinfo (pathname, state.rel_pathname, p);
if (result != 0)
{
+ return -1; /* failure. */
+ }
+ else
+ {
/* Verify some postconditions. We can't check st_mode for
non-zero-ness because of Savannah bug #16378 (which is
that broken NFS servers can return st_mode==0). */
@@ -283,10 +290,6 @@ get_info (const char *pathname,
{
assert (p->st_ino);
}
- return -1; /* failure. */
- }
- else
- {
return 0; /* success. */
}
}