Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Jan 21, 2021
1 parent 8539b01 commit 3001350
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
1 change: 0 additions & 1 deletion pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,6 @@ func (c *Client) parseFileInfo(raw string) (*eosclient.FileInfo, error) {
}
}
}

fi, err := c.mapToFileInfo(kv)
if err != nil {
return nil, err
Expand Down
25 changes: 16 additions & 9 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ func (fs *eosfs) createShadowHome(ctx context.Context) error {

shadowFolders := []string{fs.conf.ShareFolder}
for _, sf := range shadowFolders {
err = fs.c.CreateDir(ctx, uid, gid, path.Join(home, sf))
err = fs.createUserDir(ctx, u, path.Join(home, sf))
if err != nil {
return err
}
Expand Down Expand Up @@ -1312,14 +1312,14 @@ func (fs *eosfs) convertToFileReference(ctx context.Context, eosFileInfo *eoscli

// permissionSet returns the permission set for the current user
func (fs *eosfs) permissionSet(ctx context.Context, eosFileInfo *eosclient.FileInfo, owner *userpb.UserId) *provider.ResourcePermissions {
u, ok := user.ContextGetUserID(ctx)
if !ok {
u, ok := user.ContextGetUser(ctx)
if !ok || owner == nil || u.Id == nil {
return &provider.ResourcePermissions{
// no permissions
}
}

if u.OpaqueId == owner.OpaqueId && u.Idp == owner.Idp {
if u.Id.OpaqueId == owner.OpaqueId && u.Id.Idp == owner.Idp {
return &provider.ResourcePermissions{
// owner has all permissions
AddGrant: true,
Expand All @@ -1343,10 +1343,17 @@ func (fs *eosfs) permissionSet(ctx context.Context, eosFileInfo *eosclient.FileI
}
}

uid, gid, err := fs.getUserUIDAndGID(ctx, u)
if err != nil {
return &provider.ResourcePermissions{
// no permissions
}
}

var perm string
var rp *provider.ResourcePermissions
var rp provider.ResourcePermissions
for _, e := range eosFileInfo.SysACL.Entries {
if e.Qualifier == u.OpaqueId {
if e.Qualifier == uid || e.Qualifier == gid {
perm = e.Permissions
}
}
Expand Down Expand Up @@ -1391,7 +1398,7 @@ func (fs *eosfs) permissionSet(ctx context.Context, eosFileInfo *eosclient.FileI
rp.GetQuota = true
}

return rp
return &rp
}

func (fs *eosfs) convert(ctx context.Context, eosFileInfo *eosclient.FileInfo) (*provider.ResourceInfo, error) {
Expand All @@ -1407,8 +1414,8 @@ func (fs *eosfs) convert(ctx context.Context, eosFileInfo *eosclient.FileInfo) (

owner, err := fs.getUserIDGateway(ctx, strconv.FormatUint(eosFileInfo.UID, 10))
if err != nil {
log := appctx.GetLogger(ctx)
log.Warn().Uint64("uid", eosFileInfo.UID).Msg("could not lookup userid, leaving empty")
sublog := appctx.GetLogger(ctx).With().Logger()
sublog.Warn().Uint64("uid", eosFileInfo.UID).Msg("could not lookup userid, leaving empty")
owner = &userpb.UserId{}
}

Expand Down

0 comments on commit 3001350

Please sign in to comment.