From 0c50ef0f1dbe64534a0eeee1df1cbb2b576767ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 18 Feb 2022 15:47:15 +0000 Subject: [PATCH] only root nodes may have an owner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- pkg/storage/utils/decomposedfs/grants.go | 10 +- .../utils/decomposedfs/lookup/lookup.go | 7 +- pkg/storage/utils/decomposedfs/node/node.go | 175 ++++++++++-------- .../utils/decomposedfs/node/node_test.go | 8 +- .../utils/decomposedfs/node/permissions.go | 41 +--- pkg/storage/utils/decomposedfs/revisions.go | 3 - pkg/storage/utils/decomposedfs/spaces.go | 73 ++++---- .../utils/decomposedfs/testhelpers/helpers.go | 2 +- pkg/storage/utils/decomposedfs/tree/tree.go | 38 +--- pkg/storage/utils/decomposedfs/upload.go | 12 +- .../grpc/gateway_storageprovider_test.go | 15 +- tests/integration/grpc/grpc_suite_test.go | 2 +- 12 files changed, 159 insertions(+), 227 deletions(-) diff --git a/pkg/storage/utils/decomposedfs/grants.go b/pkg/storage/utils/decomposedfs/grants.go index c57f6f87ac3..40e6199500d 100644 --- a/pkg/storage/utils/decomposedfs/grants.go +++ b/pkg/storage/utils/decomposedfs/grants.go @@ -56,16 +56,12 @@ func (fs *Decomposedfs) AddGrant(ctx context.Context, ref *provider.Reference, g return err } - owner, err := node.Owner() - if err != nil { - return err - } - + owner := node.Owner() // If the owner is empty and there are no grantees then we are dealing with a just created project space. // In this case we don't need to check for permissions and just add the grant since this will be the project // manager. // When the owner is empty but grants are set then we do want to check the grants. - if !(len(grantees) == 0 && owner.OpaqueId == "") { + if !(len(grantees) == 0 && (owner == nil || owner.OpaqueId == "")) { ok, err := fs.p.HasPermission(ctx, node, func(rp *provider.ResourcePermissions) bool { // TODO remove AddGrant or UpdateGrant grant from CS3 api, redundant? tracked in https://github.com/cs3org/cs3apis/issues/92 return rp.AddGrant || rp.UpdateGrant @@ -91,7 +87,7 @@ func (fs *Decomposedfs) AddGrant(ctx context.Context, ref *provider.Reference, g // when a grant is added to a space, do not add a new space under "shares" if spaceGrant := ctx.Value(utils.SpaceGrant); spaceGrant == nil { - err := fs.createStorageSpace(ctx, spaceTypeShare, node.ID) + err := fs.linkStorageSpaceType(ctx, spaceTypeShare, node.ID) if err != nil { return err } diff --git a/pkg/storage/utils/decomposedfs/lookup/lookup.go b/pkg/storage/utils/decomposedfs/lookup/lookup.go index 1ed4482ba82..38032a1acd6 100644 --- a/pkg/storage/utils/decomposedfs/lookup/lookup.go +++ b/pkg/storage/utils/decomposedfs/lookup/lookup.go @@ -74,12 +74,7 @@ func (lu *Lookup) NodeFromID(ctx context.Context, id *provider.ResourceId) (n *n // The Resource references the root of a space return lu.NodeFromSpaceID(ctx, id) } - n, err = node.ReadNode(ctx, lu, id.StorageId, id.OpaqueId) - if err != nil { - return nil, err - } - - return n, n.FindStorageSpaceRoot() + return node.ReadNode(ctx, lu, id.StorageId, id.OpaqueId) } // Pathify segments the beginning of a string into depth segments of width length diff --git a/pkg/storage/utils/decomposedfs/node/node.go b/pkg/storage/utils/decomposedfs/node/node.go index 69298f0d2ee..c66be444b34 100644 --- a/pkg/storage/utils/decomposedfs/node/node.go +++ b/pkg/storage/utils/decomposedfs/node/node.go @@ -112,14 +112,14 @@ func New(spaceID, id, parentID, name string, blobsize int64, blobID string, owne // ChangeOwner sets the owner of n to newOwner func (n *Node) ChangeOwner(new *userpb.UserId) (err error) { - nodePath := n.InternalPath() - n.owner = new + rootNodePath := n.SpaceRoot.InternalPath() + n.SpaceRoot.owner = new var attribs = map[string]string{xattrs.OwnerIDAttr: new.OpaqueId, xattrs.OwnerIDPAttr: new.Idp, xattrs.OwnerTypeAttr: utils.UserTypeToString(new.Type)} - if err := xattrs.SetMultiple(nodePath, attribs); err != nil { + if err := xattrs.SetMultiple(rootNodePath, attribs); err != nil { return err } @@ -158,7 +158,7 @@ func (n *Node) GetMetadata(key string) (val string, err error) { } // WriteAllNodeMetadata writes the Node metadata to disk -func (n *Node) WriteAllNodeMetadata(owner *userpb.UserId) (err error) { +func (n *Node) WriteAllNodeMetadata() (err error) { attribs := make(map[string]string) attribs[xattrs.ParentidAttr] = n.ParentID @@ -167,55 +167,64 @@ func (n *Node) WriteAllNodeMetadata(owner *userpb.UserId) (err error) { attribs[xattrs.BlobsizeAttr] = strconv.FormatInt(n.Blobsize, 10) nodePath := n.InternalPath() - attribs[xattrs.OwnerIDAttr] = "" - attribs[xattrs.OwnerIDPAttr] = "" - attribs[xattrs.OwnerTypeAttr] = "" + return xattrs.SetMultiple(nodePath, attribs) +} - if owner != nil { - attribs[xattrs.OwnerIDAttr] = owner.OpaqueId - attribs[xattrs.OwnerIDPAttr] = owner.Idp - attribs[xattrs.OwnerTypeAttr] = utils.UserTypeToString(owner.Type) +func (n *Node) WriteOwner(owner *userpb.UserId) error { + attribs := map[string]string{ + xattrs.OwnerIDAttr: owner.OpaqueId, + xattrs.OwnerIDPAttr: owner.Idp, + xattrs.OwnerTypeAttr: utils.UserTypeToString(owner.Type), } - if err := xattrs.SetMultiple(nodePath, attribs); err != nil { - return err - } - return + nodeRootPath := n.SpaceRoot.InternalPath() + return xattrs.SetMultiple(nodeRootPath, attribs) + } // ReadNode creates a new instance from an id and checks if it exists func ReadNode(ctx context.Context, lu PathLookup, spaceID, nodeID string) (n *Node, err error) { - n = &Node{ + + // read space root + r := &Node{ SpaceID: spaceID, lu: lu, - ID: nodeID, + ID: spaceID, } - - nodePath := n.InternalPath() - - // lookup parent id in extended attributes - var attr string - attr, err = xattrs.Get(nodePath, xattrs.ParentidAttr) + r.SpaceRoot = r + r.owner, err = r.readOwner() switch { - case err == nil: - n.ParentID = attr - case xattrs.IsAttrUnset(err): - return nil, errtypes.InternalError(err.Error()) case xattrs.IsNotExist(err): - return n, nil // swallow not found, the node defaults to exists = false - default: - return nil, errtypes.InternalError(err.Error()) + return r, nil + case err != nil: + return nil, err } + r.Exists = true // check if this is a space root - if _, err = xattrs.Get(nodePath, xattrs.SpaceNameAttr); err == nil { - n.SpaceRoot = n + if spaceID == nodeID { + return r, nil + } + + // read node + n = &Node{ + SpaceID: spaceID, + lu: lu, + ID: nodeID, + SpaceRoot: r, } + + nodePath := n.InternalPath() + + var attr string // lookup name in extended attributes if attr, err = xattrs.Get(nodePath, xattrs.NameAttr); err == nil { n.Name = attr } else { return } + + n.Exists = true + // lookup blobID in extended attributes if attr, err = xattrs.Get(nodePath, xattrs.BlobIDAttr); err == nil { n.BlobID = attr @@ -230,6 +239,40 @@ func ReadNode(ctx context.Context, lu PathLookup, spaceID, nodeID string) (n *No return } + // lookup parent id in extended attributes + attr, err = xattrs.Get(nodePath, xattrs.ParentidAttr) + switch { + case err == nil: + n.ParentID = attr + case xattrs.IsAttrUnset(err): + return nil, errtypes.InternalError(err.Error()) + case xattrs.IsNotExist(err): + return n, nil // swallow not found, the node defaults to exists = false + default: + return nil, errtypes.InternalError(err.Error()) + } + + // TODO why do we stat the parent? to determine if the current node is in the trash we would need to traverse all parents... + // we need to traverse all parents for permissions anyway ... + // - we can compare to space root owner with the current user + // - we can compare the share permissions on the root for spaces, which would work for managers + // - for non managers / owners we need to traverse all path segments because an intermediate node might have been shared + // - if we want to support negative acls we need to traverse the path for all users (but the owner) + // for trashed items we need to check all parents + // - one of them might have the trash suffix ... + // - options: + // - move deleted nodes in a trash folder that is still part of the tree (aka freedesktop org trash spec) + // - shares should still be removed, which requires traversing all trashed children ... and it should be undoable ... + // - what if a trashed file is restored? will child items be accessible by a share? + // - compare paths of trash root items and the trashed file? + // - to determine the relative path of a file we would need to traverse all intermediate nodes anyway + // - recursively mark all children as trashed ... async ... it is ok when that is not synchronous + // - how do we pick up if an error occurs? write a journal somewhere? activity log / delta? + // - stat requests will not pick up trashed items at all + // - recursively move all children into the trash folder? + // - no need to write an additional trash entry + // - can be made more robust with a journal + // - same recursion mechanism can be used to purge items? sth we still need to do _, err = os.Stat(n.ParentInternalPath()) if err != nil { if os.IsNotExist(err) { @@ -238,9 +281,6 @@ func ReadNode(ctx context.Context, lu PathLookup, spaceID, nodeID string) (n *No return nil, err } - // FIXME always set SpaceRoot? what about shares? - - n.Exists = true return } @@ -333,59 +373,58 @@ func (n *Node) Parent() (p *Node, err error) { return } -// Owner returns the cached owner id or reads it from the extended attributes -// TODO can be private as only the AsResourceInfo uses it -func (n *Node) Owner() (*userpb.UserId, error) { - if n.owner != nil { - return n.owner, nil - } +func (n *Node) Owner() *userpb.UserId { + return n.SpaceRoot.owner +} + +// readOwner reads the owner from the extended attributes of the space root +// in case either owner id or owner idp are unset we return an error and an empty owner object +func (n *Node) readOwner() (*userpb.UserId, error) { owner := &userpb.UserId{} - // FIXME ... do we return the owner of the reference or the owner of the target? - // we don't really know the owner of the target ... and as the reference may point anywhere we cannot really find out - // but what are the permissions? all? none? the gateway has to fill in? - // TODO what if this is a reference? - nodePath := n.InternalPath() + rootNodePath := n.SpaceRoot.InternalPath() // lookup parent id in extended attributes var attr string var err error // lookup ID in extended attributes - attr, err = xattrs.Get(nodePath, xattrs.OwnerIDAttr) + attr, err = xattrs.Get(rootNodePath, xattrs.OwnerIDAttr) switch { case err == nil: owner.OpaqueId = attr - case xattrs.IsAttrUnset(err), xattrs.IsNotExist(err): - fallthrough + case xattrs.IsAttrUnset(err): + err = nil default: return nil, err } // lookup IDP in extended attributes - attr, err = xattrs.Get(nodePath, xattrs.OwnerIDPAttr) + attr, err = xattrs.Get(rootNodePath, xattrs.OwnerIDPAttr) switch { case err == nil: owner.Idp = attr case xattrs.IsAttrUnset(err), xattrs.IsNotExist(err): - fallthrough + err = nil default: return nil, err } // lookup type in extended attributes - attr, err = xattrs.Get(nodePath, xattrs.OwnerTypeAttr) + attr, err = xattrs.Get(rootNodePath, xattrs.OwnerTypeAttr) switch { case err == nil: owner.Type = utils.UserTypeMap(attr) case xattrs.IsAttrUnset(err), xattrs.IsNotExist(err): - fallthrough - default: - // TODO the user type defaults to invalid, which is the case err = nil + default: + return nil, err } - n.owner = owner - return n.owner, err + // owner is an optional property + if owner.Idp == "" && owner.OpaqueId == "" { + return nil, nil + } + return owner, nil } // PermissionSet returns the permission set for the current user @@ -396,7 +435,7 @@ func (n *Node) PermissionSet(ctx context.Context) provider.ResourcePermissions { appctx.GetLogger(ctx).Debug().Interface("node", n).Msg("no user in context, returning default permissions") return NoPermissions() } - if o, _ := n.Owner(); utils.UserEqual(u.Id, o) { + if utils.UserEqual(u.Id, n.SpaceRoot.Owner()) { return OwnerPermissions() } // read the permissions for the current user from the acls of the current node @@ -566,6 +605,7 @@ func (n *Node) AsResourceInfo(ctx context.Context, rp *provider.ResourcePermissi Size: uint64(n.Blobsize), Target: target, PermissionSet: rp, + Owner: n.Owner(), } if nodeType == provider.ResourceType_RESOURCE_TYPE_CONTAINER { @@ -578,10 +618,6 @@ func (n *Node) AsResourceInfo(ctx context.Context, rp *provider.ResourcePermissi } } - if ri.Owner, err = n.Owner(); err != nil { - sublog.Debug().Err(err).Msg("could not determine owner") - } - // TODO make etag of files use fileid and checksum var tmTime time.Time @@ -828,20 +864,7 @@ func (n *Node) UnsetTempEtag() (err error) { // ReadUserPermissions will assemble the permissions for the current user on the given node without parent nodes func (n *Node) ReadUserPermissions(ctx context.Context, u *userpb.User) (ap provider.ResourcePermissions, err error) { // check if the current user is the owner - o, err := n.Owner() - if err != nil { - // TODO check if a parent folder has the owner set? - appctx.GetLogger(ctx).Error().Err(err).Str("node", n.ID).Msg("could not determine owner, returning default permissions") - return NoPermissions(), err - } - if o.OpaqueId == "" { - // this happens for root nodes and project spaces in the storage. the extended attributes are set to emptystring to indicate: no owner - // for project spaces we need to go over the grants and check the granted permissions - if n.ID == RootID { - return NoOwnerPermissions(), nil - } - } - if utils.UserEqual(u.Id, o) { + if utils.UserEqual(u.Id, n.Owner()) { appctx.GetLogger(ctx).Debug().Str("node", n.ID).Msg("user is owner, returning owner permissions") return OwnerPermissions(), nil } diff --git a/pkg/storage/utils/decomposedfs/node/node_test.go b/pkg/storage/utils/decomposedfs/node/node_test.go index 9c422d11a4a..d8befdc85e9 100644 --- a/pkg/storage/utils/decomposedfs/node/node_test.go +++ b/pkg/storage/utils/decomposedfs/node/node_test.go @@ -22,7 +22,6 @@ import ( "encoding/json" "time" - userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" "github.com/cs3org/reva/pkg/storage/utils/decomposedfs/node" helpers "github.com/cs3org/reva/pkg/storage/utils/decomposedfs/testhelpers" @@ -91,13 +90,8 @@ var _ = Describe("Node", func() { n.Name = "TestName" n.BlobID = "TestBlobID" n.Blobsize = int64(blobsize) - owner := &userpb.UserId{ - Idp: "testidp", - OpaqueId: "testuserid", - Type: userpb.UserType_USER_TYPE_PRIMARY, - } - err = n.WriteAllNodeMetadata(owner) + err = n.WriteAllNodeMetadata() Expect(err).ToNot(HaveOccurred()) n2, err := env.Lookup.NodeFromResource(env.Ctx, ref) Expect(err).ToNot(HaveOccurred()) diff --git a/pkg/storage/utils/decomposedfs/node/permissions.go b/pkg/storage/utils/decomposedfs/node/permissions.go index 1d089f71dc7..b70124c74ea 100644 --- a/pkg/storage/utils/decomposedfs/node/permissions.go +++ b/pkg/storage/utils/decomposedfs/node/permissions.go @@ -100,21 +100,9 @@ func (p *Permissions) AssemblePermissions(ctx context.Context, n *Node) (ap prov appctx.GetLogger(ctx).Debug().Interface("node", n.ID).Msg("no user in context, returning default permissions") return NoPermissions(), nil } + // check if the current user is the owner - o, err := n.Owner() - if err != nil { - // TODO check if a parent folder has the owner set? - appctx.GetLogger(ctx).Error().Err(err).Interface("node", n.ID).Msg("could not determine owner, returning default permissions") - return NoPermissions(), err - } - if o.OpaqueId == "" { - // this happens for root nodes and project spaces in the storage. the extended attributes are set to emptystring to indicate: no owner - // for project spaces we need to go over the grants and check the granted permissions - if n.ID == RootID { - return NoOwnerPermissions(), nil - } - } - if utils.UserEqual(u.Id, o) { + if utils.UserEqual(u.Id, n.Owner()) { lp, err := n.lu.Path(ctx, n) if err == nil && lp == n.lu.ShareFolder() { return ShareFolderPermissions(), nil @@ -187,9 +175,11 @@ func (p *Permissions) HasPermission(ctx context.Context, n *Node, check func(*pr } // determine root - if err = n.FindStorageSpaceRoot(); err != nil { - return false, err - } + /* + if err = n.FindStorageSpaceRoot(); err != nil { + return false, err + } + */ // for an efficient group lookup convert the list of groups to a map // groups are just strings ... groupnames ... or group ids ??? AAARGH !!! @@ -269,22 +259,7 @@ func (p *Permissions) getUserAndPermissions(ctx context.Context, n *Node) (*user return nil, &perms } // check if the current user is the owner - o, err := n.Owner() - if err != nil { - appctx.GetLogger(ctx).Error().Err(err).Interface("node", n.ID).Msg("could not determine owner, returning default permissions") - perms := NoPermissions() - return nil, &perms - } - if o.OpaqueId == "" { - // this happens for root nodes and project spaces in the storage. the extended attributes are set to emptystring to indicate: no owner - // for project spaces we need to go over the grants and check the granted permissions - if n.ID != RootID { - return u, nil - } - perms := NoOwnerPermissions() - return nil, &perms - } - if utils.UserEqual(u.Id, o) { + if utils.UserEqual(u.Id, n.Owner()) { appctx.GetLogger(ctx).Debug().Str("node", n.ID).Msg("user is owner, returning owner permissions") perms := OwnerPermissions() return u, &perms diff --git a/pkg/storage/utils/decomposedfs/revisions.go b/pkg/storage/utils/decomposedfs/revisions.go index 34ee6c0ee22..912122566d4 100644 --- a/pkg/storage/utils/decomposedfs/revisions.go +++ b/pkg/storage/utils/decomposedfs/revisions.go @@ -161,9 +161,6 @@ func (fs *Decomposedfs) RestoreRevision(ctx context.Context, ref *provider.Refer err = errtypes.NotFound(filepath.Join(n.ParentID, n.Name)) return err } - if err := n.FindStorageSpaceRoot(); err != nil { - return err - } ok, err := fs.p.HasPermission(ctx, n, func(rp *provider.ResourcePermissions) bool { return rp.RestoreFileVersion diff --git a/pkg/storage/utils/decomposedfs/spaces.go b/pkg/storage/utils/decomposedfs/spaces.go index 074e65f471a..5284de64fc0 100644 --- a/pkg/storage/utils/decomposedfs/spaces.go +++ b/pkg/storage/utils/decomposedfs/spaces.go @@ -92,9 +92,14 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr return nil, errors.Wrap(err, "decomposedfs: error creating node") } - if err := root.WriteAllNodeMetadata(req.GetOwner().GetId()); err != nil { + if err := root.WriteAllNodeMetadata(); err != nil { return nil, err } + if req.GetOwner() != nil && req.GetOwner().GetId() != nil { + if err := root.WriteOwner(req.GetOwner().GetId()); err != nil { + return nil, err + } + } // always enable propagation on the storage space root // mark the space root node as the end of propagation @@ -103,21 +108,7 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr return nil, err } - u, ok := ctxpkg.ContextGetUser(ctx) - if !ok { - return nil, fmt.Errorf("decomposedfs: spaces: contextual user not found") - } - - ownerID := u.Id - if req.Type == spaceTypeProject { - ownerID = &userv1beta1.UserId{} - } - - if err := root.ChangeOwner(ownerID); err != nil { - return nil, err - } - - err = fs.createStorageSpace(ctx, req.Type, root.ID) + err = fs.linkStorageSpaceType(ctx, req.Type, root.ID) if err != nil { return nil, err } @@ -138,21 +129,24 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr ctx = context.WithValue(ctx, utils.SpaceGrant, struct{}{}) - if err := fs.AddGrant(ctx, &provider.Reference{ - ResourceId: &provider.ResourceId{ - StorageId: spaceID, - OpaqueId: spaceID, - }, - }, &provider.Grant{ - Grantee: &provider.Grantee{ - Type: provider.GranteeType_GRANTEE_TYPE_USER, - Id: &provider.Grantee_UserId{ - UserId: u.Id, + if req.Type != spaceTypePersonal { + u := ctxpkg.ContextMustGetUser(ctx) + if err := fs.AddGrant(ctx, &provider.Reference{ + ResourceId: &provider.ResourceId{ + StorageId: spaceID, + OpaqueId: spaceID, }, - }, - Permissions: ocsconv.NewManagerRole().CS3ResourcePermissions(), - }); err != nil { - return nil, err + }, &provider.Grant{ + Grantee: &provider.Grantee{ + Type: provider.GranteeType_GRANTEE_TYPE_USER, + Id: &provider.Grantee_UserId{ + UserId: u.Id, + }, + }, + Permissions: ocsconv.NewManagerRole().CS3ResourcePermissions(), + }); err != nil { + return nil, err + } } space, err := fs.storageSpaceFromNode(ctx, root, req.Type, root.InternalPath(), false) @@ -265,6 +259,10 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide appctx.GetLogger(ctx).Error().Err(err).Str("id", nodeID).Msg("could not read node") return nil, err } + if !n.Exists { + // return empty list + return spaces, nil + } space, err := fs.storageSpaceFromNode(ctx, n, spaceTypeAny, n.InternalPath(), canListAllSpaces) if err != nil { return nil, err @@ -567,14 +565,13 @@ func (fs *Decomposedfs) DeleteStorageSpace(ctx context.Context, req *provider.De return os.Symlink(trashPath, np) } -func (fs *Decomposedfs) createStorageSpace(ctx context.Context, spaceType string, spaceID string) error { +func (fs *Decomposedfs) linkStorageSpaceType(ctx context.Context, spaceType string, spaceID string) error { // create space type dir if err := os.MkdirAll(filepath.Join(fs.o.Root, "spacetypes", spaceType), 0700); err != nil { return err } - // we can reuse the node id as the space id - // TODO pathify spaceid + // link space in spacetypes err := os.Symlink("../../spaces/"+lookup.Pathify(spaceID, 1, 2)+"/nodes/"+lookup.Pathify(spaceID, 4, 2), filepath.Join(fs.o.Root, "spacetypes", spaceType, spaceID)) if err != nil { if isAlreadyExists(err) { @@ -611,11 +608,7 @@ func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node, } } - owner, err := n.Owner() - if err != nil { - return nil, err - } - + var err error // TODO apply more filters var sname string if sname, err = n.GetMetadata(xattrs.SpaceNameAttr); err != nil { @@ -689,9 +682,9 @@ func (fs *Decomposedfs) storageSpaceFromNode(ctx context.Context, n *node.Node, } } - if spaceType != spaceTypeProject && owner.OpaqueId != "" { + if n.Owner() != nil && n.Owner().OpaqueId != "" { space.Owner = &userv1beta1.User{ // FIXME only return a UserID, not a full blown user object - Id: owner, + Id: n.Owner(), } } diff --git a/pkg/storage/utils/decomposedfs/testhelpers/helpers.go b/pkg/storage/utils/decomposedfs/testhelpers/helpers.go index 11e2f74c960..c278531efb2 100644 --- a/pkg/storage/utils/decomposedfs/testhelpers/helpers.go +++ b/pkg/storage/utils/decomposedfs/testhelpers/helpers.go @@ -157,7 +157,7 @@ func (t *TestEnv) CreateTestFile(name, blobID, parentID, spaceID string, blobSiz if err != nil { return nil, err } - err = n.WriteAllNodeMetadata(t.Owner.Id) + err = n.WriteAllNodeMetadata() if err != nil { return nil, err } diff --git a/pkg/storage/utils/decomposedfs/tree/tree.go b/pkg/storage/utils/decomposedfs/tree/tree.go index d68e4898208..83babc01580 100644 --- a/pkg/storage/utils/decomposedfs/tree/tree.go +++ b/pkg/storage/utils/decomposedfs/tree/tree.go @@ -239,19 +239,7 @@ func (t *Tree) CreateDir(ctx context.Context, n *node.Node) (err error) { n.ID = uuid.New().String() } - // who will become the owner? the owner of the parent node, not the current user - var p *node.Node - p, err = n.Parent() - if err != nil { - return - } - var owner *userpb.UserId - owner, err = p.Owner() - if err != nil { - return - } - - err = t.createNode(n, owner) + err = t.createNode(n) if err != nil { return } @@ -520,21 +508,6 @@ func (t *Tree) RestoreRecycleItemFunc(ctx context.Context, spaceid, key, trashPa } } - // the new node will inherit the permissions of its parent - p, err := targetNode.Parent() - if err != nil { - return err - } - - po, err := p.Owner() - if err != nil { - return err - } - - if err := recycleNode.ChangeOwner(po); err != nil { - return err - } - targetNode.Exists = true // update name attribute if err := recycleNode.SetMetadata(xattrs.NameAttr, targetNode.Name); err != nil { @@ -602,11 +575,6 @@ func (t *Tree) Propagate(ctx context.Context, n *node.Node) (err error) { } // is propagation enabled for the parent node? - - // look up space root from the trashed node - if err = n.FindStorageSpaceRoot(); err != nil { - return - } root := n.SpaceRoot // use a sync time and don't rely on the mtime of the current node, as the stat might not change when a rename happened too quickly @@ -785,14 +753,14 @@ func (t *Tree) DeleteBlob(key string) error { } // TODO check if node exists? -func (t *Tree) createNode(n *node.Node, owner *userpb.UserId) (err error) { +func (t *Tree) createNode(n *node.Node) (err error) { // create a directory node nodePath := n.InternalPath() if err = os.MkdirAll(nodePath, 0700); err != nil { return errors.Wrap(err, "Decomposedfs: error creating node") } - return n.WriteAllNodeMetadata(owner) + return n.WriteAllNodeMetadata() } // readTrashLink returns nodeID and timestamp diff --git a/pkg/storage/utils/decomposedfs/upload.go b/pkg/storage/utils/decomposedfs/upload.go index 349f01ebd9c..8c6334203ba 100644 --- a/pkg/storage/utils/decomposedfs/upload.go +++ b/pkg/storage/utils/decomposedfs/upload.go @@ -243,10 +243,6 @@ func (fs *Decomposedfs) NewUpload(ctx context.Context, info tusd.FileInfo) (uplo } usr := ctxpkg.ContextMustGetUser(ctx) - owner, err := p.Owner() - if err != nil { - return nil, errors.Wrap(err, "Decomposedfs: error determining owner") - } var spaceRoot string if info.Storage != nil { if spaceRoot, ok = info.Storage["SpaceRoot"]; !ok { @@ -270,9 +266,6 @@ func (fs *Decomposedfs) NewUpload(ctx context.Context, info tusd.FileInfo) (uplo "UserType": utils.UserTypeToString(usr.Id.Type), "UserName": usr.Username, - "OwnerIdp": owner.Idp, - "OwnerId": owner.OpaqueId, - "LogLevel": log.GetLevel().String(), } // Create binary file in the upload folder with no content @@ -607,10 +600,7 @@ func (upload *fileUpload) FinishUpload(ctx context.Context) (err error) { tryWritingChecksum(&sublog, n, "adler32", adler32h) // who will become the owner? the owner of the parent actually ... not the currently logged in user - err = n.WriteAllNodeMetadata(&userpb.UserId{ - Idp: upload.info.Storage["OwnerIdp"], - OpaqueId: upload.info.Storage["OwnerId"], - }) + err = n.WriteAllNodeMetadata() if err != nil { return errors.Wrap(err, "Decomposedfs: could not write metadata") } diff --git a/tests/integration/grpc/gateway_storageprovider_test.go b/tests/integration/grpc/gateway_storageprovider_test.go index 07bd12ecc3d..75bac57b4cc 100644 --- a/tests/integration/grpc/gateway_storageprovider_test.go +++ b/tests/integration/grpc/gateway_storageprovider_test.go @@ -30,7 +30,6 @@ import ( userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" storagep "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" - typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" "github.com/cs3org/reva/pkg/auth/scope" ctxpkg "github.com/cs3org/reva/pkg/ctx" "github.com/cs3org/reva/pkg/rgrpc/todo/pool" @@ -285,14 +284,16 @@ var _ = Describe("gateway", func() { It("places new spaces in the correct shard", func() { createRes, err := serviceClient.CreateStorageSpace(ctx, &storagep.CreateStorageSpaceRequest{ - Opaque: &typesv1beta1.Opaque{ - Map: map[string]*typesv1beta1.OpaqueEntry{ - "path": { - Decoder: "plain", - Value: []byte("/projects"), + /* + Opaque: &typesv1beta1.Opaque{ + Map: map[string]*typesv1beta1.OpaqueEntry{ + "path": { + Decoder: "plain", + Value: []byte("/projects"), + }, }, }, - }, + */ Owner: user, Type: "project", Name: "o - project", diff --git a/tests/integration/grpc/grpc_suite_test.go b/tests/integration/grpc/grpc_suite_test.go index 042725da660..0bbb451cc0a 100644 --- a/tests/integration/grpc/grpc_suite_test.go +++ b/tests/integration/grpc/grpc_suite_test.go @@ -58,7 +58,7 @@ type Revad struct { Cleanup cleanupFunc // Function to kill the process and cleanup the temp. root. If the given parameter is true the files will be kept to make debugging failures easier. } -// stardRevads takes a list of revad configuration files plus a map of +// startRevads takes a list of revad configuration files plus a map of // variables that need to be substituted in them and starts them. // // A unique port is assigned to each spawned instance.