diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/fusefrontend/args.go | 7 | ||||
-rw-r--r-- | internal/fusefrontend/fs.go | 3 | ||||
-rw-r--r-- | internal/fusefrontend_reverse/rfs.go | 9 |
3 files changed, 19 insertions, 0 deletions
diff --git a/internal/fusefrontend/args.go b/internal/fusefrontend/args.go index 5781db8..37f4463 100644 --- a/internal/fusefrontend/args.go +++ b/internal/fusefrontend/args.go @@ -1,6 +1,7 @@ package fusefrontend import ( + "github.com/hanwen/go-fuse/fuse" "github.com/rfjakob/gocryptfs/internal/cryptocore" ) @@ -16,6 +17,12 @@ type Args struct { // Should we chown a file after it has been created? // This only makes sense if (1) allow_other is set and (2) we run as root. PreserveOwner bool + // Should we force ownership to be presented with a given user and group? + // This only makes sense if allow_other is set. In *most* cases, it also + // only makes sense with PreserveOwner set, but can also make sense without + // PreserveOwner if the underlying filesystem acting as backing store + // enforces ownership itself. + ForceOwner *fuse.Owner // ConfigCustom is true when the user select a non-default config file // location. If it is false, reverse mode maps ".gocryptfs.reverse.conf" // to "gocryptfs.conf" in the plaintext dir. diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go index c589302..16707d6 100644 --- a/internal/fusefrontend/fs.go +++ b/internal/fusefrontend/fs.go @@ -77,6 +77,9 @@ func (fs *FS) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Stat target, _ := fs.Readlink(name, context) a.Size = uint64(len(target)) } + if fs.args.ForceOwner != nil { + a.Owner = *fs.args.ForceOwner + } return a, status } diff --git a/internal/fusefrontend_reverse/rfs.go b/internal/fusefrontend_reverse/rfs.go index 63384ac..3c84e15 100644 --- a/internal/fusefrontend_reverse/rfs.go +++ b/internal/fusefrontend_reverse/rfs.go @@ -115,6 +115,9 @@ func (rfs *ReverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr } var a fuse.Attr a.FromStat(&st) + if rfs.args.ForceOwner != nil { + a.Owner = *rfs.args.ForceOwner + } return &a, fuse.OK } // Handle virtual files (gocryptfs.diriv, *.name) @@ -136,6 +139,9 @@ func (rfs *ReverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr } var a fuse.Attr status = f.GetAttr(&a) + if rfs.args.ForceOwner != nil { + a.Owner = *rfs.args.ForceOwner + } return &a, status } // Decrypt path to "plaintext relative path" @@ -177,6 +183,9 @@ func (rfs *ReverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr a.Size = uint64(len(linkTarget)) } + if rfs.args.ForceOwner != nil { + a.Owner = *rfs.args.ForceOwner + } return &a, fuse.OK } |