From eb1f6029e31fb93717c2fe8cfc6bb3c669683095 Mon Sep 17 00:00:00 2001 From: Elliot Speck Date: Thu, 17 Dec 2020 15:53:17 +1100 Subject: [PATCH] Add --no-default-permissions flag based on latest fuse library. --- .gitmodules | 3 ++- api/api.go | 9 +++++---- api/common/config.go | 11 ++++++----- internal/dir.go | 2 +- internal/file.go | 2 +- internal/flags.go | 17 +++++++++++------ internal/goofys.go | 8 ++++---- internal/handles.go | 2 +- vendor/github.com/jacobsa/fuse | 2 +- 9 files changed, 32 insertions(+), 24 deletions(-) diff --git a/.gitmodules b/.gitmodules index e7526dbb..75c7eebc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -15,7 +15,8 @@ url = https://github.com/jtolds/gls [submodule "vendor/github.com/jacobsa/fuse"] path = vendor/github.com/jacobsa/fuse - url = https://github.com/kahing/fusego + url = https://github.com/jacobsa/fuse + branch = master [submodule "vendor/github.com/Azure/go-autorest"] path = vendor/github.com/Azure/go-autorest url = https://github.com/Azure/go-autorest/ diff --git a/api/api.go b/api/api.go index f8ce2e39..0f32409e 100644 --- a/api/api.go +++ b/api/api.go @@ -27,10 +27,11 @@ func Mount( } // Mount the file system. mountCfg := &fuse.MountConfig{ - FSName: bucketName, - Options: flags.MountOptions, - ErrorLogger: GetStdLogger(NewLogger("fuse"), logrus.ErrorLevel), - DisableWritebackCaching: true, + FSName: bucketName, + Options: flags.MountOptions, + ErrorLogger: GetStdLogger(NewLogger("fuse"), logrus.ErrorLevel), + DisableWritebackCaching: true, + DisableDefaultPermissions: flags.DisableDefaultPermissions, } if flags.DebugFuse { diff --git a/api/common/config.go b/api/common/config.go index e4f23ad5..3998f80c 100644 --- a/api/common/config.go +++ b/api/common/config.go @@ -45,11 +45,12 @@ type FlagStorage struct { Backend interface{} // Tuning - Cheap bool - ExplicitDir bool - StatCacheTTL time.Duration - TypeCacheTTL time.Duration - HTTPTimeout time.Duration + Cheap bool + ExplicitDir bool + StatCacheTTL time.Duration + TypeCacheTTL time.Duration + HTTPTimeout time.Duration + DisableDefaultPermissions bool // Debugging DebugFuse bool diff --git a/internal/dir.go b/internal/dir.go index 687674f0..64e838f2 100644 --- a/internal/dir.go +++ b/internal/dir.go @@ -899,7 +899,7 @@ func (parent *Inode) Unlink(name string) (err error) { } func (parent *Inode) Create( - name string, metadata fuseops.OpMetadata) (inode *Inode, fh *FileHandle) { + name string, metadata fuseops.OpContext) (inode *Inode, fh *FileHandle) { parent.logFuse("Create", name) diff --git a/internal/file.go b/internal/file.go index a2ccbaa7..33350dc0 100644 --- a/internal/file.go +++ b/internal/file.go @@ -71,7 +71,7 @@ const READAHEAD_CHUNK = uint32(20 * 1024 * 1024) // NewFileHandle returns a new file handle for the given `inode` triggered by fuse // operation with the given `opMetadata` -func NewFileHandle(inode *Inode, opMetadata fuseops.OpMetadata) *FileHandle { +func NewFileHandle(inode *Inode, opMetadata fuseops.OpContext) *FileHandle { tgid, err := GetTgid(opMetadata.Pid) if err != nil { log.Debugf( diff --git a/internal/flags.go b/internal/flags.go index f18633a8..e62a6e01 100644 --- a/internal/flags.go +++ b/internal/flags.go @@ -242,6 +242,10 @@ func NewApp() (app *cli.App) { Value: 30 * time.Second, Usage: "Set the timeout on HTTP requests to S3", }, + cli.BoolFlag{ + Name: "disable-default-permissions", + Usage: "Disable UNIX default_permissions flag on FUSE mount.", + }, ///////////////////////// // Debugging @@ -275,7 +279,7 @@ func NewApp() (app *cli.App) { flagCategories[f] = "aws" } - for _, f := range []string{"cheap", "no-implicit-dir", "stat-cache-ttl", "type-cache-ttl", "http-timeout"} { + for _, f := range []string{"cheap", "no-implicit-dir", "stat-cache-ttl", "type-cache-ttl", "http-timeout", "disable-default-permissions"} { flagCategories[f] = "tuning" } @@ -327,11 +331,12 @@ func PopulateFlags(c *cli.Context) (ret *FlagStorage) { Gid: uint32(c.Int("gid")), // Tuning, - Cheap: c.Bool("cheap"), - ExplicitDir: c.Bool("no-implicit-dir"), - StatCacheTTL: c.Duration("stat-cache-ttl"), - TypeCacheTTL: c.Duration("type-cache-ttl"), - HTTPTimeout: c.Duration("http-timeout"), + Cheap: c.Bool("cheap"), + ExplicitDir: c.Bool("no-implicit-dir"), + StatCacheTTL: c.Duration("stat-cache-ttl"), + TypeCacheTTL: c.Duration("type-cache-ttl"), + HTTPTimeout: c.Duration("http-timeout"), + DisableDefaultPermissions: c.Bool("disable-default-permissions"), // Common Backend Config Endpoint: c.String("endpoint"), diff --git a/internal/goofys.go b/internal/goofys.go index 9070fb54..ee18e321 100644 --- a/internal/goofys.go +++ b/internal/goofys.go @@ -880,7 +880,7 @@ func (fs *Goofys) OpenFile( in := fs.getInodeOrDie(op.Inode) fs.mu.RUnlock() - fh, err := in.OpenFile(op.Metadata) + fh, err := in.OpenFile(op.OpContext) if err != nil { return } @@ -953,10 +953,10 @@ func (fs *Goofys) FlushFile( // This check helps us with scenarios like https://github.com/kahing/goofys/issues/273 // Also see goofys_test.go:TestClientForkExec. if fh.Tgid != nil { - tgid, err := GetTgid(op.Metadata.Pid) + tgid, err := GetTgid(op.OpContext.Pid) if err != nil { fh.inode.logFuse("<-- FlushFile", - fmt.Sprintf("Failed to retrieve tgid from op.Metadata.Pid. FlushFileOp:%#v, err:%v", + fmt.Sprintf("Failed to retrieve tgid from op.OpContext.Pid. FlushFileOp:%#v, err:%v", op, err)) return fuse.EIO } @@ -1013,7 +1013,7 @@ func (fs *Goofys) CreateFile( parent := fs.getInodeOrDie(op.Parent) fs.mu.RUnlock() - inode, fh := parent.Create(op.Name, op.Metadata) + inode, fh := parent.Create(op.Name, op.OpContext) parent.mu.Lock() diff --git a/internal/handles.go b/internal/handles.go index 651faf69..d1afc5f6 100644 --- a/internal/handles.go +++ b/internal/handles.go @@ -494,7 +494,7 @@ func (inode *Inode) ListXattr() ([]string, error) { return xattrs, nil } -func (inode *Inode) OpenFile(metadata fuseops.OpMetadata) (fh *FileHandle, err error) { +func (inode *Inode) OpenFile(metadata fuseops.OpContext) (fh *FileHandle, err error) { inode.logFuse("OpenFile") inode.mu.Lock() diff --git a/vendor/github.com/jacobsa/fuse b/vendor/github.com/jacobsa/fuse index ca77844c..e0296dec 160000 --- a/vendor/github.com/jacobsa/fuse +++ b/vendor/github.com/jacobsa/fuse @@ -1 +1 @@ -Subproject commit ca77844c7bcca61167af9964208ec3f71ffdc7c8 +Subproject commit e0296dec955fa0cdbacac5beababf84945547253