From 1038d17e508003a8dc0e0b0d9900bb1ddb3a796a Mon Sep 17 00:00:00 2001 From: Fabrizio Furano Date: Tue, 28 Nov 2023 09:46:05 +0100 Subject: [PATCH] eosfs: getattr tricks to get sys attrs while keeping authorization --- pkg/storage/utils/eosfs/eosfs.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 7ebe3dce114..45c0af66dbb 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -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 } @@ -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 @@ -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 }