There are several long-standing bugs relating to unreadable directories. The following tests were run on FreeBSD 12-stable, but I have also reproduced them using a build of libarchive's master branch (also on FreeBSD) by adding test cases (these are included in the pull request which I will shortly attach to this issue)
- (Reported in 2014 on FreeBSD): if you try and archive "." when the parent directory is not readable, or archive any path where the last-but-one component is searchable but not readable, a completely spurious but fatal error is generated at the end of the traversal, due to an attempt to open ".." for reading.
install -d -m 311 lock; mkdir lock/dir1; touch lock/dir1/f1
tar cvf /dev/null -C lock/dir1 .
output is
a .
a ./f1
tar: .: Unable to continue traversing directory tree: Permission denied
- If the current directory is not readable (but is searchable), then archiving any readable subdirectory fails completely with an inexplicable error:
install -d -m 311 lock; mkdir lock/dir1; touch lock/dir1/f1
tar cvf /dev/null -C lock dir1/.
output is
tar: .: Cannot stat: Bad file descriptor
I have fixes for these, though I do not know if my test cases are sufficiently portable for you. I will post a pull request shortly.
There are several long-standing bugs relating to unreadable directories. The following tests were run on FreeBSD 12-stable, but I have also reproduced them using a build of libarchive's master branch (also on FreeBSD) by adding test cases (these are included in the pull request which I will shortly attach to this issue)
output is
output is
I have fixes for these, though I do not know if my test cases are sufficiently portable for you. I will post a pull request shortly.