[PATCH] fts(3): allow FTS_LOGICAL without FTS_NOCHDIR

Jilles Tjoelker jilles at stack.nl
Fri Jan 1 21:25:36 UTC 2010


fts(3) currently automatically enables FTS_NOCHDIR if FTS_LOGICAL (-L in
various utilities) is used, according to a comment because symlinks are
too hard. However, the effect of fts_instr=FTS_FOLLOW seems quite
similar to FTS_LOGICAL in chdir mode. Using one more bit in fts_flags, I
made FTS_LOGICAL work with chdir.

This has several advantages:
* it runs faster
* it eliminates the PATH_MAX restriction on deep directory trees
* find -L ... -type l -delete can be made to work without ugliness
  (although it is of course still insecure if run over directory trees
  where untrusted users have write access)

Question: why are the values for fts_flags in the public header file
fts.h, even though they are supposedly private?

In case the mailing list eats the patch, it is also available here:
http://www.stack.nl/~jilles/unix/fts-logical-chdir.patch

-- 
Jilles Tjoelker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fts-logical-chdir.patch
Type: text/x-diff
Size: 3983 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20100101/2ee0812a/fts-logical-chdir.bin


More information about the freebsd-hackers mailing list