aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend
diff options
context:
space:
mode:
authorSebastian Lackner2019-01-12 21:24:48 +0100
committerSebastian Lackner2019-01-12 21:24:50 +0100
commit99e8b6d288b1551947faec669b6af65331441471 (patch)
tree12201af74281d35cf764eb0d4aa5fdc8bb8b63c2 /internal/fusefrontend
parentefc280330c68dc5cbf605921f6c840a54d5841bb (diff)
fusefrontend: Preserve SUID/SGID/sticky-bits in openWriteOnlyFile and Rmdir.
Fixes https://github.com/rfjakob/gocryptfs/issues/336 and https://github.com/rfjakob/gocryptfs/issues/337.
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r--internal/fusefrontend/fs.go2
-rw-r--r--internal/fusefrontend/fs_dir.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index c4b1a01..eb14335 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -192,7 +192,7 @@ func (fs *FS) openWriteOnlyFile(dirfd int, cName string, newFlags int) (*File, f
return nil, fuse.ToStatus(err)
}
// The cast to uint32 fixes a build failure on Darwin, where st.Mode is uint16.
- perms := uint32(st.Mode & 0777)
+ perms := uint32(st.Mode)
// Verify that we don't have read permissions
if perms&0400 != 0 {
tlog.Warn.Printf("openWriteOnlyFile: unexpected permissions %#o, returning EPERM", perms)
diff --git a/internal/fusefrontend/fs_dir.go b/internal/fusefrontend/fs_dir.go
index 880f271..a017050 100644
--- a/internal/fusefrontend/fs_dir.go
+++ b/internal/fusefrontend/fs_dir.go
@@ -163,7 +163,7 @@ func (fs *FS) Rmdir(relPath string, context *fuse.Context) (code fuse.Status) {
return fuse.ToStatus(err)
}
// This cast is needed on Darwin, where st.Mode is uint16.
- origMode := uint32(st.Mode & 0777)
+ origMode := uint32(st.Mode)
err = syscallcompat.Fchmodat(parentDirFd, cName, origMode|0700, unix.AT_SYMLINK_NOFOLLOW)
if err != nil {
tlog.Debug.Printf("Rmdir: Fchmodat failed: %v", err)