diff options
author | Jakob Unterwurzacher | 2017-11-30 19:09:24 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2017-11-30 19:10:21 +0100 |
commit | 22282aefe6f4da0257ea8f568aa4369ad15ce5f9 (patch) | |
tree | 7021f334527a93e70b3237e6bc43d6fbb739392a /internal/syscallcompat/emulate.go | |
parent | bd79a8cd0d0da041ed24178492a4bca786fddd9b (diff) |
syscallcompat: add tests for emulated syscalls
Also fix the bug in emulateFchmodat that was found by the tests.
Diffstat (limited to 'internal/syscallcompat/emulate.go')
-rw-r--r-- | internal/syscallcompat/emulate.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/syscallcompat/emulate.go b/internal/syscallcompat/emulate.go index 6cb0ea0..59d0ea5 100644 --- a/internal/syscallcompat/emulate.go +++ b/internal/syscallcompat/emulate.go @@ -135,6 +135,16 @@ func emulateFchmodat(dirfd int, path string, mode uint32, flags int) (err error) return err } defer syscall.Fchdir(cwd) + // We also don't have Lchmod, so emulate it (poorly). + if flags&unix.AT_SYMLINK_NOFOLLOW > 0 { + fi, err := os.Lstat(path) + if err != nil { + return err + } + if fi.Mode()&os.ModeSymlink > 0 { + return nil + } + } return syscall.Chmod(path, mode) } |