summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-09-07 13:10:25 +0100
committerSimon MacMullen <simon@rabbitmq.com>2012-09-07 13:10:25 +0100
commit55c32ad3b6cb2755b524de72594a378b87884057 (patch)
treed52f2ae1006a38ab660a9cf5fcbdf7ddcebddcbf /src
parentd5adfd080b4693d1c666034fdacc1f101cc6996f (diff)
downloadrabbitmq-server-git-55c32ad3b6cb2755b524de72594a378b87884057.tar.gz
Add a backdoor to allow the direct client to set a trusted user-id. Yes, this is ugly, but the diff is small.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_channel.erl19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 69fe0edca3..23a80cf100 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -459,11 +459,15 @@ check_write_permitted(Resource, #ch{user = User}) ->
check_read_permitted(Resource, #ch{user = User}) ->
check_resource_access(User, Resource, read).
-check_user_id_header(#'P_basic'{user_id = undefined}, _) ->
- ok;
-check_user_id_header(#'P_basic'{user_id = Username},
+check_user_id_header(Props = #'P_basic'{user_id = undefined}, _) ->
+ Props;
+%% We rely on the fact that the codec can't express this. So we must
+%% be talking to the direct client, which can do anything anyway.
+check_user_id_header(Props = #'P_basic'{user_id = {trust, Username}}, _) ->
+ Props#'P_basic'{user_id = Username};
+check_user_id_header(Props = #'P_basic'{user_id = Username},
#ch{user = #user{username = Username}}) ->
- ok;
+ Props;
check_user_id_header(#'P_basic'{user_id = Claimed},
#ch{user = #user{username = Actual}}) ->
precondition_failed(
@@ -608,8 +612,11 @@ handle_method(#'basic.publish'{exchange = ExchangeNameBin,
check_internal_exchange(Exchange),
%% We decode the content's properties here because we're almost
%% certain to want to look at delivery-mode and priority.
- DecodedContent = rabbit_binary_parser:ensure_content_decoded(Content),
- check_user_id_header(DecodedContent#content.properties, State),
+ DecodedContent0 = rabbit_binary_parser:ensure_content_decoded(Content),
+ DecodedContent =
+ DecodedContent0#content{
+ properties = check_user_id_header(
+ DecodedContent0#content.properties, State)},
{MsgSeqNo, State1} =
case {TxStatus, ConfirmEnabled} of
{none, false} -> {undefined, State};