@@ -383,7 +383,7 @@ type javaConf struct {
383383 SuperFS bool `json:"superFs,omitempty"`
384384}
385385
386- func getOrCreate (name , user , group , superuser , supergroup string , conf javaConf , f func () * fs.FileSystem ) int64 {
386+ func getOrCreate (name , user , groups , superuser , supergroup string , conf javaConf , f func () * fs.FileSystem ) int64 {
387387 fslock .Lock ()
388388 defer fslock .Unlock ()
389389 ws := activefs [name ]
@@ -406,18 +406,18 @@ func getOrCreate(name, user, group, superuser, supergroup string, conf javaConf,
406406 case "mysql" , "postgres" , "sqlite3" :
407407 m .mask = 0x7FFFFFFF // limit generated uid to int32
408408 }
409- logger .Infof ("JuiceFileSystem created for user:%s group :%s" , user , group )
409+ logger .Infof ("JuiceFileSystem created for user:%s groups :%s" , user , groups )
410410 }
411411 w := & wrapper {jfs , name , nil , m , user , superuser , supergroup , conf }
412412 if _ , ok := superuserChangedCb [name ]; ! ok {
413413 jfs .Meta ().OnReload (func (format * meta.Format ) {
414414 kerb .loadConf (name , format .KerbConf , jfs )
415- updateAllCtx (name , user , group )
415+ updateAllCtx (name , user , groups )
416416 })
417417 superuserChangedCb [name ] = struct {}{}
418418 }
419419 activefs [name ] = append (ws , w )
420- updateAllCtx (name , user , group )
420+ updateAllCtx (name , user , groups )
421421 nextFsHandle = nextFsHandle + 1
422422 handlers [nextFsHandle ] = w
423423 return nextFsHandle
@@ -832,7 +832,14 @@ func updateCtx(w *wrapper, groups []string) {
832832 if w .isSuperuser (w .user , groups ) {
833833 w .ctx = meta .NewContext (uint32 (os .Getpid ()), 0 , []uint32 {0 })
834834 } else {
835- w .ctx = meta .NewContext (uint32 (os .Getpid ()), w .lookupUid (w .user ), w .lookupGids (groups ))
835+ var gids []uint32
836+ if w .ctx != nil {
837+ gids = w .ctx .Gids ()
838+ }
839+ if len (groups ) > 0 {
840+ gids = w .lookupGids (groups )
841+ }
842+ w .ctx = meta .NewContext (uint32 (os .Getpid ()), w .lookupUid (w .user ), gids )
836843 }
837844}
838845
0 commit comments