diff options
author | Sebastian Lackner | 2019-01-14 02:49:11 +0100 |
---|---|---|
committer | rfjakob | 2019-01-14 21:27:28 +0100 |
commit | 92110628ee5f48b0106b32090854fcc61d6bca20 (patch) | |
tree | 9469e338a693fb56beea79c961d367771f13346c /internal/syscallcompat | |
parent | 0345cc08307c01da635ea5546952a584480c9a93 (diff) |
syscallcompat: Drop Fchownat emulation on macOS.
Diffstat (limited to 'internal/syscallcompat')
-rw-r--r-- | internal/syscallcompat/emulate.go | 20 | ||||
-rw-r--r-- | internal/syscallcompat/emulate_test.go | 4 | ||||
-rw-r--r-- | internal/syscallcompat/sys_common.go | 10 | ||||
-rw-r--r-- | internal/syscallcompat/sys_darwin.go | 4 | ||||
-rw-r--r-- | internal/syscallcompat/sys_linux.go | 10 |
5 files changed, 10 insertions, 38 deletions
diff --git a/internal/syscallcompat/emulate.go b/internal/syscallcompat/emulate.go index 8a538fb..dc8cf6d 100644 --- a/internal/syscallcompat/emulate.go +++ b/internal/syscallcompat/emulate.go @@ -30,26 +30,6 @@ func emulateMknodat(dirfd int, path string, mode uint32, dev int) error { return syscall.Mknod(path, mode, dev) } -// emulateFchownat emulates the syscall for platforms that don't have it -// in the kernel (darwin). -func emulateFchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { - if !filepath.IsAbs(path) { - chdirMutex.Lock() - defer chdirMutex.Unlock() - cwd, err := syscall.Open(".", syscall.O_RDONLY, 0) - if err != nil { - return err - } - defer syscall.Close(cwd) - err = syscall.Fchdir(dirfd) - if err != nil { - return err - } - defer syscall.Fchdir(cwd) - } - return syscall.Lchown(path, uid, gid) -} - // emulateSymlinkat emulates the syscall for platforms that don't have it // in the kernel (darwin). func emulateSymlinkat(oldpath string, newdirfd int, newpath string) (err error) { diff --git a/internal/syscallcompat/emulate_test.go b/internal/syscallcompat/emulate_test.go index 3f23d91..6fe5f3e 100644 --- a/internal/syscallcompat/emulate_test.go +++ b/internal/syscallcompat/emulate_test.go @@ -29,10 +29,6 @@ func TestEmulateMknodat(t *testing.T) { } } -func TestEmulateFchownat(t *testing.T) { - t.Skipf("TODO") -} - // symlinkCheckMode looks if the mode bits in "st" say that this is a symlink. // Calls t.Fatal() if not. func symlinkCheckMode(t *testing.T, st syscall.Stat_t) { diff --git a/internal/syscallcompat/sys_common.go b/internal/syscallcompat/sys_common.go index 75d2509..9514830 100644 --- a/internal/syscallcompat/sys_common.go +++ b/internal/syscallcompat/sys_common.go @@ -72,6 +72,16 @@ func Unlinkat(dirfd int, path string, flags int) (err error) { return unix.Unlinkat(dirfd, path, flags) } +// Fchownat syscall. +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + // Why would we ever want to call this without AT_SYMLINK_NOFOLLOW? + if flags&unix.AT_SYMLINK_NOFOLLOW == 0 { + tlog.Warn.Printf("Fchownat: adding missing AT_SYMLINK_NOFOLLOW flag") + flags |= unix.AT_SYMLINK_NOFOLLOW + } + return unix.Fchownat(dirfd, path, uid, gid, flags) +} + // Linkat exists both in Linux and in MacOS 10.10+. func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { return unix.Linkat(olddirfd, oldpath, newdirfd, newpath, flags) diff --git a/internal/syscallcompat/sys_darwin.go b/internal/syscallcompat/sys_darwin.go index 89d93e7..be85fee 100644 --- a/internal/syscallcompat/sys_darwin.go +++ b/internal/syscallcompat/sys_darwin.go @@ -102,10 +102,6 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { return unix.Fchmodat(dirfd, path, mode, flags) } -func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { - return emulateFchownat(dirfd, path, uid, gid, flags) -} - func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { return emulateSymlinkat(oldpath, newdirfd, newpath) } diff --git a/internal/syscallcompat/sys_linux.go b/internal/syscallcompat/sys_linux.go index 28a7149..cacec6a 100644 --- a/internal/syscallcompat/sys_linux.go +++ b/internal/syscallcompat/sys_linux.go @@ -154,16 +154,6 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { return syscall.Chmod(procPath, mode) } -// Fchownat syscall. -func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { - // Why would we ever want to call this without AT_SYMLINK_NOFOLLOW? - if flags&unix.AT_SYMLINK_NOFOLLOW == 0 { - tlog.Warn.Printf("Fchownat: adding missing AT_SYMLINK_NOFOLLOW flag") - flags |= unix.AT_SYMLINK_NOFOLLOW - } - return syscall.Fchownat(dirfd, path, uid, gid, flags) -} - // Symlinkat syscall. func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { return unix.Symlinkat(oldpath, newdirfd, newpath) |