aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend
diff options
context:
space:
mode:
authorSebastian Lackner2019-01-12 21:19:23 +0100
committerSebastian Lackner2019-01-12 21:20:16 +0100
commit1fbe7798cf879d80cfbd755b05bdadae24bc5519 (patch)
tree43fdd12317feaebd3fa8d318ba09a9fce60d2d1f /internal/fusefrontend
parenta525e33eaa59c6561653a5fc40e5c4d5a9a3184b (diff)
fusefrontend: -allow_other: Use MknodatUser in Mknod FUSE call.
Instead of manually adjusting the user and mode after creating the device file, adjust effective permissions and let the kernel deal with it. Related to https://github.com/rfjakob/gocryptfs/issues/338.
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r--internal/fusefrontend/fs.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index 2c6ac5a..9637acf 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -319,6 +319,10 @@ func (fs *FS) Mknod(path string, mode uint32, dev uint32, context *fuse.Context)
return fuse.ToStatus(err)
}
defer syscall.Close(dirfd)
+ // Make sure context is nil if we don't want to preserve the owner
+ if !fs.args.PreserveOwner {
+ context = nil
+ }
// Create ".name" file to store long file name (except in PlaintextNames mode)
if !fs.args.PlaintextNames && nametransform.IsLongContent(cName) {
err = fs.nameTransform.WriteLongNameAt(dirfd, cName, path)
@@ -326,26 +330,15 @@ func (fs *FS) Mknod(path string, mode uint32, dev uint32, context *fuse.Context)
return fuse.ToStatus(err)
}
// Create "gocryptfs.longfile." device node
- err = syscallcompat.Mknodat(dirfd, cName, mode, int(dev))
+ err = syscallcompat.MknodatUser(dirfd, cName, mode, int(dev), context)
if err != nil {
nametransform.DeleteLongNameAt(dirfd, cName)
}
} else {
// Create regular device node
- err = syscallcompat.Mknodat(dirfd, cName, mode, int(dev))
- }
- if err != nil {
- return fuse.ToStatus(err)
- }
- // Set owner
- if fs.args.PreserveOwner {
- err = syscallcompat.Fchownat(dirfd, cName, int(context.Owner.Uid),
- int(context.Owner.Gid), unix.AT_SYMLINK_NOFOLLOW)
- if err != nil {
- tlog.Warn.Printf("Mknod: Fchownat failed: %v", err)
- }
+ err = syscallcompat.MknodatUser(dirfd, cName, mode, int(dev), context)
}
- return fuse.OK
+ return fuse.ToStatus(err)
}
// Truncate - FUSE call. Truncates a file.