summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2011-03-16 07:18:40 +0000
committerMatthias Radestock <matthias@rabbitmq.com>2011-03-16 07:18:40 +0000
commit11681ae6031b69432626e7d92a699b07dd021c95 (patch)
treedbcca575b7fbb7e904444b5704d0860998ed1a93
parent0e03d63fa6b9236744374041738f9c59182be325 (diff)
downloadrabbitmq-server-11681ae6031b69432626e7d92a699b07dd021c95.tar.gz
cosmetic
-rw-r--r--src/rabbit_auth_backend_internal.erl24
-rw-r--r--src/rabbit_auth_mechanism_cr_demo.erl12
-rw-r--r--src/rabbit_auth_mechanism_plain.erl5
3 files changed, 16 insertions, 25 deletions
diff --git a/src/rabbit_auth_backend_internal.erl b/src/rabbit_auth_backend_internal.erl
index 3d005845..f70813d1 100644
--- a/src/rabbit_auth_backend_internal.erl
+++ b/src/rabbit_auth_backend_internal.erl
@@ -85,10 +85,9 @@ check_user_login(Username, []) ->
internal_check_user_login(Username, fun(_) -> true end);
check_user_login(Username, [{password, Password}]) ->
internal_check_user_login(
- Username,
- fun(#internal_user{password_hash = Hash}) ->
- check_password(Password, Hash)
- end);
+ Username, fun(#internal_user{password_hash = Hash}) ->
+ check_password(Password, Hash)
+ end);
check_user_login(Username, AuthProps) ->
exit({unknown_auth_props, Username, AuthProps}).
@@ -131,12 +130,11 @@ check_resource_access(#user{username = Username},
[] ->
false;
[#user_permission{permission = P}] ->
- PermRegexp =
- case element(permission_index(Permission), P) of
- %% <<"^$">> breaks Emacs' erlang mode
- <<"">> -> <<$^, $$>>;
- RE -> RE
- end,
+ PermRegexp = case element(permission_index(Permission), P) of
+ %% <<"^$">> breaks Emacs' erlang mode
+ <<"">> -> <<$^, $$>>;
+ RE -> RE
+ end,
case re:run(Name, PermRegexp, [{capture, none}]) of
match -> true;
nomatch -> false
@@ -221,11 +219,9 @@ salted_md5(Salt, Cleartext) ->
Salted = <<Salt/binary, Cleartext/binary>>,
erlang:md5(Salted).
-set_admin(Username) ->
- set_admin(Username, true).
+set_admin(Username) -> set_admin(Username, true).
-clear_admin(Username) ->
- set_admin(Username, false).
+clear_admin(Username) -> set_admin(Username, false).
set_admin(Username, IsAdmin) ->
R = update_user(Username, fun(User) ->
diff --git a/src/rabbit_auth_mechanism_cr_demo.erl b/src/rabbit_auth_mechanism_cr_demo.erl
index 77aa34ea..acbb6e48 100644
--- a/src/rabbit_auth_mechanism_cr_demo.erl
+++ b/src/rabbit_auth_mechanism_cr_demo.erl
@@ -53,10 +53,8 @@ handle_response(Response, State = #state{username = undefined}) ->
{challenge, <<"Please tell me your password">>,
State#state{username = Response}};
-handle_response(Response, #state{username = Username}) ->
- case Response of
- <<"My password is ", Password/binary>> ->
- rabbit_access_control:check_user_pass_login(Username, Password);
- _ ->
- {protocol_error, "Invalid response '~s'", [Response]}
- end.
+handle_response(<<"My password is ", Password/binary>>,
+ #state{username = Username}) ->
+ rabbit_access_control:check_user_pass_login(Username, Password);
+handle_response(Response, _State) ->
+ {protocol_error, "Invalid response '~s'", [Response]}.
diff --git a/src/rabbit_auth_mechanism_plain.erl b/src/rabbit_auth_mechanism_plain.erl
index e2f9bff9..2448acb6 100644
--- a/src/rabbit_auth_mechanism_plain.erl
+++ b/src/rabbit_auth_mechanism_plain.erl
@@ -65,15 +65,12 @@ extract_user_pass(Response) ->
end.
extract_elem(<<0:8, Rest/binary>>) ->
- Count = next_null_pos(Rest),
+ Count = next_null_pos(Rest, 0),
<<Elem:Count/binary, Rest1/binary>> = Rest,
{ok, Elem, Rest1};
extract_elem(_) ->
error.
-next_null_pos(Bin) ->
- next_null_pos(Bin, 0).
-
next_null_pos(<<>>, Count) -> Count;
next_null_pos(<<0:8, _Rest/binary>>, Count) -> Count;
next_null_pos(<<_:8, Rest/binary>>, Count) -> next_null_pos(Rest, Count + 1).