From 8286bc011f80fc6bde7d1072f293d095b669c068 Mon Sep 17 00:00:00 2001 From: Jesse Geens Date: Wed, 23 Oct 2024 10:17:05 +0200 Subject: [PATCH] Make AddACL only recursive when it is passed a directory --- pkg/eosclient/eosgrpc/eosgrpc.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index f171511a17..9aead112dc 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -259,6 +259,13 @@ func (c *Client) AddACL(ctx context.Context, auth, rootAuth eosclient.Authorizat log := appctx.GetLogger(ctx) log.Info().Str("func", "AddACL").Str("uid,gid", auth.Role.UID+","+auth.Role.GID).Str("path", path).Msg("") + // First, we need to figure out if the path is a directory + // to know whether our request should be recursive + fileInfo, err := c.GetFileInfoByPath(ctx, auth, path) + if err != nil { + return err + } + // Init a new NSRequest rq, err := c.initNSRequest(ctx, rootAuth, "") if err != nil { @@ -272,7 +279,7 @@ func (c *Client) AddACL(ctx context.Context, auth, rootAuth eosclient.Authorizat msg := new(erpc.NSRequest_AclRequest) msg.Cmd = erpc.NSRequest_AclRequest_ACL_COMMAND(erpc.NSRequest_AclRequest_ACL_COMMAND_value["MODIFY"]) msg.Type = erpc.NSRequest_AclRequest_ACL_TYPE(erpc.NSRequest_AclRequest_ACL_TYPE_value["SYS_ACL"]) - msg.Recursive = true + msg.Recursive = fileInfo.IsDir msg.Rule = a.CitrineSerialize() msg.Id = new(erpc.MDId) @@ -302,6 +309,13 @@ func (c *Client) RemoveACL(ctx context.Context, auth, rootAuth eosclient.Authori log := appctx.GetLogger(ctx) log.Info().Str("func", "RemoveACL").Str("uid,gid", auth.Role.UID+","+auth.Role.GID).Str("path", path).Msg("") + // First, we need to figure out if the path is a directory + // to know whether our request should be recursive + fileInfo, err := c.GetFileInfoByPath(ctx, auth, path) + if err != nil { + return err + } + acls, err := c.getACLForPath(ctx, auth, path) if err != nil { return err @@ -319,7 +333,7 @@ func (c *Client) RemoveACL(ctx context.Context, auth, rootAuth eosclient.Authori msg := new(erpc.NSRequest_AclRequest) msg.Cmd = erpc.NSRequest_AclRequest_ACL_COMMAND(erpc.NSRequest_AclRequest_ACL_COMMAND_value["MODIFY"]) msg.Type = erpc.NSRequest_AclRequest_ACL_TYPE(erpc.NSRequest_AclRequest_ACL_TYPE_value["SYS_ACL"]) - msg.Recursive = true + msg.Recursive = fileInfo.IsDir msg.Rule = sysACL msg.Id = new(erpc.MDId)