diff options
author | Jakob Unterwurzacher | 2018-09-08 18:06:33 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2018-09-08 18:06:33 +0200 |
commit | 930c37e03d5ff80e7cdc9f0ca2cd35d80a06d5c0 (patch) | |
tree | 7294ff75cc9ebbc78c5d6fe57c20ca7e69d515d5 /tests | |
parent | 9ec9d0c49cfbdc9ceba10d7534b77e527c0a3cdc (diff) |
syscallcompat: use O_PATH in OpenDirNofollow
This fixes the "0100 directory" problem in reverse mode,
and should be slightly faster.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/reverse/correctness_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/reverse/correctness_test.go b/tests/reverse/correctness_test.go index 34b32ea..17c4cdd 100644 --- a/tests/reverse/correctness_test.go +++ b/tests/reverse/correctness_test.go @@ -207,3 +207,33 @@ func TestTooLongSymlink(t *testing.T) { err2.Err) } } + +// Test that we can traverse a directory with 0100 permissions +// (execute but no read). This used to be a problem as OpenDirNofollow opened +// all directory in the path with O_RDONLY. Now it uses O_PATH, which only needs +// the executable bit. +func Test0100Dir(t *testing.T) { + dir := dirA + "/" + t.Name() + err := os.Mkdir(dir, 0700) + if err != nil { + t.Fatal(err) + } + file := dir + "/hello" + err = ioutil.WriteFile(file, []byte("hello"), 0600) + if err != nil { + t.Fatal(err) + } + err = os.Chmod(dir, 0100) + if err != nil { + t.Fatal(err) + } + + fileReverse := dirC + "/" + t.Name() + "/hello" + fd, err := os.Open(fileReverse) + // Make sure the dir can be removed after the test is done + os.Chmod(dir, 0700) + if err != nil { + t.Fatal(err) + } + fd.Close() +} |