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.
This commit is contained in:
Sebastian Lackner 2019-01-12 21:24:48 +01:00
parent efc280330c
commit 99e8b6d288
2 changed files with 2 additions and 2 deletions

View File

@ -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)

View File

@ -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)