From 1f6ad5ccd829be38c030a636fe3c8426db9b04fe Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 24 Nov 2020 12:45:27 +0300 Subject: [PATCH] [#201] morph/eacl: Return error if container eACL is not set Signed-off-by: Leonard Lyubich --- pkg/morph/client/container/wrapper/eacl.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/morph/client/container/wrapper/eacl.go b/pkg/morph/client/container/wrapper/eacl.go index d8bad938..3b843034 100644 --- a/pkg/morph/client/container/wrapper/eacl.go +++ b/pkg/morph/client/container/wrapper/eacl.go @@ -7,6 +7,8 @@ import ( "github.com/pkg/errors" ) +var errEACLNotFound = errors.New("extended ACL table is not set for this container") + // GetEACL reads the extended ACL table from NeoFS system // through Container contract call. func (w *Wrapper) GetEACL(cid *container.ID) (*eacl.Table, []byte, error) { @@ -27,13 +29,21 @@ func (w *Wrapper) GetEACL(cid *container.ID) (*eacl.Table, []byte, error) { return nil, nil, err } + // Client may not return errors if the table is missing, so check this case additionally. + // The absence of a signature in the response can be taken as an eACL absence criterion, + // since unsigned table cannot be approved in the storage by design. + sig := rpcAnswer.Signature() + if len(sig) == 0 { + return nil, nil, errEACLNotFound + } + table := eacl.NewTable() if err = table.Unmarshal(rpcAnswer.EACL()); err != nil { // use other major version if there any return nil, nil, err } - return table, rpcAnswer.Signature(), nil + return table, sig, nil } // PutEACL saves the extended ACL table in NeoFS system