Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs related to unreadable directories. #1167

Merged
merged 2 commits into from
Mar 30, 2019
Merged

Fix bugs related to unreadable directories. #1167

merged 2 commits into from
Mar 30, 2019

Conversation

RhodiumToad
Copy link
Contributor

  1. Don't try to open ".." for reading as part of the process of
    ascending out of an initially specified directory; it's wrong, and if
    the directory is not readable it causes a spurious error.

  2. If opening "." initially for reading fails, then open it for
    execute instead, if O_EXEC exists. This avoids spurious and unhelpful
    failures when the current directory is not readable.

Add test cases for the above.

At least the first of these issues is ancient; it was reported against
FreeBSD in 2014.

References issue #1166

1. Don't try to open ".." for reading as part of the process of
ascending out of an initially specified directory; it's wrong, and if
the directory is not readable it causes a spurious error.

2. If opening "." initially for reading fails, then open it for
execute instead, if O_EXEC exists. This avoids spurious and unhelpful
failures when the current directory is not readable.

Add test cases for the above.

At least the first of these issues is ancient; it was reported against
FreeBSD in 2014.
@mmatuska
Copy link
Member

The test segfaults on Mac OS X.

@RhodiumToad
Copy link
Contributor Author

I'm guessing that OS X lacks O_EXEC and therefore has no way to open the current directory when it is unreadable. Can you confirm that?

If a platform lacks O_EXEC and we get a failure when starting the
traverse from within an unreadable directory, then don't score that as
a failure, since with the current code it can never succeed. But if
O_EXEC exists, the failure still counts.
@RhodiumToad
Copy link
Contributor Author

The two osx:mojave test failures are from your broken CI script.

The autotools/freebsd12 failure looks spurious to me.

@mmatuska mmatuska merged commit b62b6b5 into libarchive:master Mar 30, 2019
@mmatuska
Copy link
Member

The test now fails on Solaris-like platforms (OmniOS). The manpage for open(2) says:

   O_EXEC

       If set, indicates that the file should be opened for execute
       permission.  This option is only valid for regular files, an error
       will be returned if it is not.

@RhodiumToad
Copy link
Contributor Author

On OmniOS you need to use O_SEARCH everywhere I've used O_EXEC (in the actual code, not just the test). Likewise, on Linux it should be using O_PATH. This probably means adding platform-specific configuration stuff. Since I do not have any interest in either OmniOS or Linux, I will leave that ball in your court.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants