Skip to content

Commit

Permalink
eosfs: getattr tricks to get sys attrs while keeping authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrizio Furano committed Nov 28, 2023
1 parent 4caa25c commit 1038d17
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,18 @@ func (fs *eosfs) UnsetArbitraryMetadata(ctx context.Context, ref *provider.Refer
}

func (fs *eosfs) getLockPayloads(ctx context.Context, auth eosclient.Authorization, path string) (string, string, error) {
data, err := fs.c.GetAttr(ctx, auth, "sys."+LockPayloadKey, path)

// sys attributes want root auth, buddy
rootauth, err := fs.getRootAuth(ctx)
if err != nil {
return nil, err
}
data, err := fs.c.GetAttr(ctx, rootauth, "sys."+LockPayloadKey, path)
if err != nil {
return "", "", err
}

eoslock, err := fs.c.GetAttr(ctx, auth, "sys."+EosLockKey, path)
eoslock, err := fs.c.GetAttr(ctx, rootauth, "sys."+EosLockKey, path)
if err != nil {
return "", "", err
}
Expand Down Expand Up @@ -1177,6 +1183,17 @@ func (fs *eosfs) ListGrants(ctx context.Context, ref *provider.Reference) ([]*pr
return nil, err
}

// This is invoked just to see if it fails, I know, it's ugly
_, err = fs.c.GetAttrs(ctx, auth, fn)
if err != nil {
return nil, err
}

// Now we get the real info, I know, it's ugly
auth, err = fs.getRootAuth(ctx)
if err != nil {
return nil, err
}
attrs, err := fs.c.GetAttrs(ctx, auth, fn)
if err != nil {
return nil, err
Expand Down Expand Up @@ -1276,7 +1293,7 @@ func (fs *eosfs) getMDShareFolder(ctx context.Context, p string, mdKeys []string
}

// lightweight accounts don't have share folders, so we're passing an empty string as path
auth, err := fs.getUserAuth(ctx, u, "")
auth, err := fs.getRootAuth(ctx, u, "")
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 1038d17

Please sign in to comment.