diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-12-28 23:36:13 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-12-28 23:36:13 -0800 |
| commit | 03c7447ad6705c2b0d2e79400f0d55c9b5237668 (patch) | |
| tree | 835e0502c81464efbe2cd36691310d063fbabf52 /weed/command | |
| parent | a8af1e3f5feee959c4281b5439a08eb2ffbc3ee3 (diff) | |
| download | seaweedfs-03c7447ad6705c2b0d2e79400f0d55c9b5237668.tar.xz seaweedfs-03c7447ad6705c2b0d2e79400f0d55c9b5237668.zip | |
set mount point to existing permissions
fix https://github.com/chrislusf/seaweedfs/issues/806
Diffstat (limited to 'weed/command')
| -rw-r--r-- | weed/command/mount_std.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index e238fafbf..9ab21010e 100644 --- a/weed/command/mount_std.go +++ b/weed/command/mount_std.go @@ -4,7 +4,10 @@ package command import ( "fmt" + "os" + "os/user" "runtime" + "strconv" "strings" "time" @@ -28,6 +31,24 @@ func runMount(cmd *Command, args []string) bool { 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) c, err := fuse.Mount( @@ -77,6 +98,9 @@ func runMount(cmd *Command, args []string) bool { DataCenter: *mountOptions.dataCenter, DirListingLimit: *mountOptions.dirListingLimit, EntryCacheTtl: 3 * time.Second, + MountUid: uid, + MountGid: gid, + MountMode: mountMode, })) if err != nil { fuse.Unmount(*mountOptions.dir) |
