diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-08-26 13:36:58 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-08-26 13:36:58 +0100 |
| commit | 5c9ab05610bfa8b315973c89fe375d760ac5feef (patch) | |
| tree | 77ac5fbd1b79275cb4e07d252d6529e829c27828 /src | |
| parent | 31acae72aa8ecca63fecb8cf1ac28c8f516b33cc (diff) | |
| download | rabbitmq-server-git-5c9ab05610bfa8b315973c89fe375d760ac5feef.tar.gz | |
move treating 'amq\.*' specially to inner case
The Permission argument to check_resource_access is not
a #permission{}. It is an atom naming which permission we want
(configure, read or write).
To treat 'amq.*' resources differently, the check needs to be moved to
the inner case.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_access_control.erl | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl index 8d00f59124..1445c085b5 100644 --- a/src/rabbit_access_control.erl +++ b/src/rabbit_access_control.erl @@ -171,10 +171,6 @@ check_resource_access(Username, check_resource_access(Username, R#resource{name = <<"amq.default">>}, Permission); -check_resource_access(_Username, - #resource{name = <<"amq.gen",_/binary>>}, - #permission{scope = client}) -> - ok; check_resource_access(Username, R = #resource{virtual_host = VHostPath, name = Name}, Permission) -> @@ -184,14 +180,19 @@ check_resource_access(Username, [] -> false; [#user_permission{permission = P}] -> - 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 + case {Name, P} of + {<<"amq.",_/binary>>, #permission{scope = client}} -> + true; + _ -> + 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 + end end end, if Res -> ok; |
