Skip to content

Commit 9236485

Browse files
committed
Use ClientOpcode in MCBP privilege checks
Change-Id: I3fc7ae153580885178603e5629469d75037318fe Reviewed-on: http://review.couchbase.org/100087 Tested-by: Build Bot <[email protected]> Reviewed-by: Paolo Cocchi <[email protected]>
1 parent 364c798 commit 9236485

File tree

3 files changed

+208
-172
lines changed

3 files changed

+208
-172
lines changed

daemon/mcbp_executors.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -779,14 +779,14 @@ void execute_client_request_packet(Cookie& cookie,
779779

780780
static McbpPrivilegeChains privilegeChains;
781781

782-
const auto opcode = request.opcode;
782+
const auto opcode = request.getClientOpcode();
783783
const auto res = privilegeChains.invoke(opcode, cookie);
784784
switch (res) {
785785
case cb::rbac::PrivilegeAccess::Fail:
786786
LOG_WARNING("{} {}: no access to command {}",
787787
c->getId(),
788788
c->getDescription(),
789-
to_string(cb::mcbp::ClientOpcode(opcode)));
789+
to_string(opcode));
790790
audit_command_access_failed(cookie);
791791

792792
if (c->remapErrorCode(ENGINE_EACCESS) == ENGINE_DISCONNECT) {
@@ -801,12 +801,11 @@ void execute_client_request_packet(Cookie& cookie,
801801
// The framing of the packet is valid...
802802
// Verify that the actual command is legal
803803
auto& bucket = cookie.getConnection().getBucket();
804-
auto result = bucket.validatorChains.invoke(request.getClientOpcode(),
805-
cookie);
804+
auto result = bucket.validatorChains.invoke(opcode, cookie);
806805
if (result != cb::mcbp::Status::Success) {
807806
std::string command;
808807
try {
809-
command = to_string(request.getClientOpcode());
808+
command = to_string(opcode);
810809
} catch (const std::exception&) {
811810
command = "unknown 0x" + cb::to_hex(request.opcode);
812811
}
@@ -824,7 +823,8 @@ void execute_client_request_packet(Cookie& cookie,
824823
return;
825824
}
826825

827-
handlers[opcode](cookie);
826+
handlers[std::underlying_type<cb::mcbp::ClientOpcode>::type(opcode)](
827+
cookie);
828828
}
829829
return;
830830
case cb::rbac::PrivilegeAccess::Stale:

0 commit comments

Comments
 (0)