From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org, kostja.osipov@gmail.com
Subject: [Tarantool-patches] [PATCH 1/3] access: fix invalid error type for not found user
Date: Tue, 5 Nov 2019 17:59:50 +0300 [thread overview]
Message-ID: <428837a3e85ef7a36ac842891794e137f17f20e8.1572965692.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1572965692.git.v.shpilevoy@tarantool.org>
Box.session.su() raised 'SystemError' when a user was not found
due to a too long user name. That was obviously wrong, because
SystemError is always something related to libraries (standard,
curl, etc), and it has an errno code.
Now a ClientError is raised.
---
src/box/schema.cc | 5 ++---
src/box/user.cc | 5 +++--
test/box/access.result | 3 ++-
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/box/schema.cc b/src/box/schema.cc
index 9767207e0..fab7544f2 100644
--- a/src/box/schema.cc
+++ b/src/box/schema.cc
@@ -311,9 +311,8 @@ schema_find_id(uint32_t system_space_id, uint32_t index_id,
const char *name, uint32_t len, uint32_t *object_id)
{
if (len > BOX_NAME_MAX) {
- diag_set(SystemError,
- "name length %d is greater than BOX_NAME_MAX", len);
- return -1;
+ *object_id = BOX_ID_NIL;
+ return 0;
}
struct space *space = space_cache_find(system_space_id);
if (space == NULL)
diff --git a/src/box/user.cc b/src/box/user.cc
index 03b4b2e3b..15c40f90d 100644
--- a/src/box/user.cc
+++ b/src/box/user.cc
@@ -521,8 +521,9 @@ user_find_by_name(const char *name, uint32_t len)
if (schema_find_id(BOX_USER_ID, 2, name, len, &uid) != 0)
return NULL;
struct user *user = user_by_id(uid);
- if (user == NULL || user->def->type != SC_USER) {
- diag_set(ClientError, ER_NO_SUCH_USER, tt_cstr(name, len));
+ if (user == NULL || user->def->type != SC_USER || uid == BOX_ID_NIL) {
+ diag_set(ClientError, ER_NO_SUCH_USER,
+ tt_cstr(name, MIN(BOX_INVALID_NAME_MAX, len)));
return NULL;
}
return user;
diff --git a/test/box/access.result b/test/box/access.result
index dc339038d..05e2f4147 100644
--- a/test/box/access.result
+++ b/test/box/access.result
@@ -248,7 +248,8 @@ session.su('does not exist')
-- allowed name.
session.su(string.rep('a', 66000))
---
-- error: name length 66000 is greater than BOX_NAME_MAX
+- error: User 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is
+ not found
...
--------------------------------------------------------------------------------
-- Check if identifiers obey the common constraints
--
2.21.0 (Apple Git-122.2)
next prev parent reply other threads:[~2019-11-05 14:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-05 14:59 [Tarantool-patches] [PATCH 0/3] Replication status errno Vladislav Shpilevoy
2019-11-05 14:59 ` Vladislav Shpilevoy [this message]
2019-11-05 18:15 ` [Tarantool-patches] [PATCH 1/3] access: fix invalid error type for not found user Konstantin Osipov
2019-11-06 14:48 ` Vladislav Shpilevoy
2019-11-05 14:59 ` [Tarantool-patches] [PATCH 2/3] error: move errno into an error object Vladislav Shpilevoy
2019-11-05 18:18 ` Konstantin Osipov
2019-11-06 14:49 ` Vladislav Shpilevoy
2019-11-05 14:59 ` [Tarantool-patches] [PATCH 3/3] replication: show errno in replication info Vladislav Shpilevoy
2019-11-05 18:18 ` Konstantin Osipov
2019-11-05 18:13 ` [Tarantool-patches] [PATCH 0/3] Replication status errno Konstantin Osipov
2019-11-21 17:38 ` Kirill Yukhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=428837a3e85ef7a36ac842891794e137f17f20e8.1572965692.git.v.shpilevoy@tarantool.org \
--to=v.shpilevoy@tarantool.org \
--cc=kostja.osipov@gmail.com \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 1/3] access: fix invalid error type for not found user' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox