diff options
author | Jakob Unterwurzacher | 2016-06-08 00:17:18 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2016-06-08 00:32:44 +0200 |
commit | 5da292828c3a58254560bb47d700186ff8c3ca9c (patch) | |
tree | 9a128cbefb86fe3f80fc0bfcf4bc6d8b4163a00e /tests | |
parent | f58a8d8740364467ee9e3cf20cec8d47c4e59ad8 (diff) |
fusefrontend: fix chown on dangling symlinks
We (actually, go-fuse) used to call Chown() instead of Lchown()
which meant that the operation would fail on dangling symlinks.
Fix this by calling os.Lchown() ourself. Also add a test case
for this.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration_tests/main_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/integration_tests/main_test.go b/tests/integration_tests/main_test.go index b6cb8ca..17f9d9d 100644 --- a/tests/integration_tests/main_test.go +++ b/tests/integration_tests/main_test.go @@ -437,3 +437,19 @@ func TestLongNames(t *testing.T) { t.Errorf("Leftover files, cnt1=%d cnt2=%d", cnt1, cnt2) } } + +func TestLchown(t *testing.T) { + name := test_helpers.DefaultPlainDir + "symlink" + err := os.Symlink("/target/does/not/exist", name) + if err != nil { + t.Fatal(err) + } + err = os.Chown(name, os.Getuid(), os.Getgid()) + if err == nil { + t.Error("Chown on dangling symlink should fail") + } + err = os.Lchown(name, os.Getuid(), os.Getgid()) + if err != nil { + t.Error(err) + } +} |