From 0162392a28b75ccb6c3b26c26f2a83b5973a2d92 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 29 Nov 2017 12:54:34 +0100 Subject: fusefrontend: Use Fchmodat to implement Chmod --- internal/fusefrontend/fs.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'internal/fusefrontend') diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go index 002b4e1..c4035fa 100644 --- a/internal/fusefrontend/fs.go +++ b/internal/fusefrontend/fs.go @@ -239,13 +239,14 @@ func (fs *FS) Chmod(path string, mode uint32, context *fuse.Context) (code fuse. if fs.isFiltered(path) { return fuse.EPERM } - cPath, err := fs.getBackingPath(path) + dirfd, cName, err := fs.openBackingPath(path) if err != nil { return fuse.ToStatus(err) } + defer dirfd.Close() // os.Chmod goes through the "syscallMode" translation function that messes - // up the suid and sgid bits. So use syscall.Chmod directly. - err = syscall.Chmod(cPath, mode) + // up the suid and sgid bits. So use a syscall directly. + err = syscallcompat.Fchmodat(int(dirfd.Fd()), cName, mode, unix.AT_SYMLINK_NOFOLLOW) return fuse.ToStatus(err) } -- cgit v1.2.3