Follow-up Comment #11, bugs #12044 (project findutils):

To recap what remains of our original discussion, we still have one candidate
left: -

To chdir() to a subdir, you
- stat("."); save dot_fd;
- st = lstat(file); if ISDIR {
chdir(file);
check stat(".") matches st inode and filesystem.
if not, fchdir(dot_fd) and retry.

Keep track of retry count. Retry at least once, but perhaps
only once.

This is substantially the same as the current implementation, except for the
fact that the "retry" takes the place of our existing check of the list of
mounted filesystems.  This looks like a promising approach.  

If the chdir() check actually failed because someone is trying to exploit the
very race condition that the check exists to detect, then the second cycle of
stat-chdir-stat (i.e. the first retry) will then notice that "foo" is now a
symbolic link.  This seems to me to be the right thing.

I have a small lingering concern that there may be tests in the predicate
list (-prune for example) which would have been true for the old "foo" but
now will be false for the new "foo".  Similarly the other way around; some
tests that were false may now be true.  Will it be necessary to re-do all the
predicates  on the command line which don't have side effects?

    _______________________________________________________

This item URL is:

  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=12044>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/



_______________________________________________
Bug-findutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-findutils

Reply via email to