Skip to content

Commit

Permalink
MB-3479 - Use binary protocol AUTH_ERROR on null bucket access
Browse files Browse the repository at this point in the history
When the client tries to do operations on the so-called "NULL bucket",
instead of returning a binary protocol response ENOMEM, respond with
the PROTOCOL_BINARY_RESPONSE_AUTH_ERROR result code.

Change-Id: I0efed77c4dbc2782fad1d8638a7ec7fe42313e21
Reviewed-on: http://review.membase.org/6267
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
  • Loading branch information
steveyen authored and alk committed May 16, 2011
1 parent 1222513 commit 142396c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
7 changes: 7 additions & 0 deletions cproxy.c
Expand Up @@ -1968,6 +1968,13 @@ void upstream_error_msg(conn *uc, char *ascii_msg,
binary_status = PROTOCOL_BINARY_RESPONSE_EINTERNAL; binary_status = PROTOCOL_BINARY_RESPONSE_EINTERNAL;
} }


pthread_mutex_lock(&ptd->proxy->proxy_lock);
if (ptd->proxy->name != NULL &&
strcmp(ptd->proxy->name, NULL_BUCKET) == 0) {
binary_status = PROTOCOL_BINARY_RESPONSE_AUTH_ERROR;
}
pthread_mutex_unlock(&ptd->proxy->proxy_lock);

write_bin_error(uc, binary_status, 0); write_bin_error(uc, binary_status, 0);


update_event(uc, EV_WRITE | EV_PERSIST); update_event(uc, EV_WRITE | EV_PERSIST);
Expand Down
20 changes: 10 additions & 10 deletions t/moxi_multitenancy.py
Expand Up @@ -61,17 +61,17 @@ def testNullBucket(self):
"""Test null bucket""" """Test null bucket"""
self.client_connect() self.client_connect()


get_oom = self.packRes(memcacheConstants.CMD_GETK, get_err = self.packRes(memcacheConstants.CMD_GETK,
status=memcacheConstants.ERR_ENOMEM, status=memcacheConstants.ERR_AUTH_ERROR,
val="Out of memory") val="Auth failure")


get_req = self.packReq(memcacheConstants.CMD_GETK, key='keyNotThere0') get_req = self.packReq(memcacheConstants.CMD_GETK, key='keyNotThere0')
self.client_send(get_req) self.client_send(get_req)
self.client_recv(get_oom) self.client_recv(get_err)


get_req = self.packReq(memcacheConstants.CMD_GETK, key='keyNotThere0') get_req = self.packReq(memcacheConstants.CMD_GETK, key='keyNotThere0')
self.client_send(get_req) self.client_send(get_req)
self.client_recv(get_oom) self.client_recv(get_err)


self.assertTrue(self.mock_quiet()) self.assertTrue(self.mock_quiet())


Expand All @@ -82,15 +82,15 @@ def testNullBucketSet(self):
set_req = self.packReq(memcacheConstants.CMD_SET, key='simpleSet', set_req = self.packReq(memcacheConstants.CMD_SET, key='simpleSet',
extraHeader=struct.pack(memcacheConstants.SET_PKT_FMT, 0, 0), extraHeader=struct.pack(memcacheConstants.SET_PKT_FMT, 0, 0),
val='123') val='123')
set_oom = self.packRes(memcacheConstants.CMD_SET, set_err = self.packRes(memcacheConstants.CMD_SET,
status=memcacheConstants.ERR_ENOMEM, status=memcacheConstants.ERR_AUTH_ERROR,
val="Out of memory") val="Auth failure")


self.client_send(set_req) self.client_send(set_req)
self.client_recv(set_oom) self.client_recv(set_err)


self.client_send(set_req) self.client_send(set_req)
self.client_recv(set_oom) self.client_recv(set_err)


self.assertTrue(self.mock_quiet()) self.assertTrue(self.mock_quiet())


Expand Down

0 comments on commit 142396c

Please sign in to comment.