set mount point to existing permissions
fix https://github.com/chrislusf/seaweedfs/issues/806
This commit is contained in:
@@ -4,7 +4,10 @@ package command
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -28,6 +31,24 @@ func runMount(cmd *Command, args []string) bool {
|
|||||||
|
|
||||||
fuse.Unmount(*mountOptions.dir)
|
fuse.Unmount(*mountOptions.dir)
|
||||||
|
|
||||||
|
// detect mount folder mode
|
||||||
|
mountMode := os.ModeDir | 0755
|
||||||
|
if fileInfo, err := os.Stat(*mountOptions.dir); err == nil {
|
||||||
|
mountMode = os.ModeDir | fileInfo.Mode()
|
||||||
|
println(*mountOptions.dir, "mount mode", mountMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// detect current user
|
||||||
|
uid, gid := uint32(0), uint32(0)
|
||||||
|
if u, err := user.Current(); err == nil {
|
||||||
|
if parsedId, pe := strconv.ParseUint(u.Uid, 10, 32); pe == nil {
|
||||||
|
uid = uint32(parsedId)
|
||||||
|
}
|
||||||
|
if parsedId, pe := strconv.ParseUint(u.Gid, 10, 32); pe == nil {
|
||||||
|
gid = uint32(parsedId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
util.SetupProfiling(*mountCpuProfile, *mountMemProfile)
|
util.SetupProfiling(*mountCpuProfile, *mountMemProfile)
|
||||||
|
|
||||||
c, err := fuse.Mount(
|
c, err := fuse.Mount(
|
||||||
@@ -77,6 +98,9 @@ func runMount(cmd *Command, args []string) bool {
|
|||||||
DataCenter: *mountOptions.dataCenter,
|
DataCenter: *mountOptions.dataCenter,
|
||||||
DirListingLimit: *mountOptions.dirListingLimit,
|
DirListingLimit: *mountOptions.dirListingLimit,
|
||||||
EntryCacheTtl: 3 * time.Second,
|
EntryCacheTtl: 3 * time.Second,
|
||||||
|
MountUid: uid,
|
||||||
|
MountGid: gid,
|
||||||
|
MountMode: mountMode,
|
||||||
}))
|
}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fuse.Unmount(*mountOptions.dir)
|
fuse.Unmount(*mountOptions.dir)
|
||||||
|
|||||||
@@ -34,8 +34,10 @@ func (dir *Dir) Attr(context context.Context, attr *fuse.Attr) error {
|
|||||||
// https://github.com/bazil/fuse/issues/196
|
// https://github.com/bazil/fuse/issues/196
|
||||||
attr.Valid = time.Second
|
attr.Valid = time.Second
|
||||||
|
|
||||||
if dir.Path == "/" {
|
if dir.Path == dir.wfs.option.FilerMountRootPath {
|
||||||
attr.Mode = os.ModeDir | 0777
|
attr.Uid = dir.wfs.option.MountUid
|
||||||
|
attr.Gid = dir.wfs.option.MountGid
|
||||||
|
attr.Mode = dir.wfs.option.MountMode
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -26,6 +27,10 @@ type Option struct {
|
|||||||
DataCenter string
|
DataCenter string
|
||||||
DirListingLimit int
|
DirListingLimit int
|
||||||
EntryCacheTtl time.Duration
|
EntryCacheTtl time.Duration
|
||||||
|
|
||||||
|
MountUid uint32
|
||||||
|
MountGid uint32
|
||||||
|
MountMode os.FileMode
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = fs.FS(&WFS{})
|
var _ = fs.FS(&WFS{})
|
||||||
|
|||||||
Reference in New Issue
Block a user