diff options
author | Matthias Radestock <matthias@lshift.net> | 2009-01-22 13:28:50 +0000 |
---|---|---|
committer | Matthias Radestock <matthias@lshift.net> | 2009-01-22 13:28:50 +0000 |
commit | 414fcba01a9ef35404e79075acfcaa753ba695b3 (patch) | |
tree | a6858dd00f7710bca823c8693a886493ae5aec26 | |
parent | da4f1505b9bccdbcd2f0c712bc0cca3379c2aadd (diff) | |
download | rabbitmq-server-bug20173.tar.gz |
refactoringbug20173
-rw-r--r-- | src/rabbit_access_control.erl | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl index 357a294a..0d9632b5 100644 --- a/src/rabbit_access_control.erl +++ b/src/rabbit_access_control.erl @@ -307,34 +307,30 @@ clear_permissions(Username, VHostPath) -> list_vhost_permissions(VHostPath) -> [{Username, ConfigurationPerm, MessagingPerm} || - #user_permission{user_vhost = #user_vhost{username = Username}, - permission = #permission{ - configuration = ConfigurationPerm, - messaging = MessagingPerm}} <- - %% TODO: use dirty ops instead - rabbit_misc:execute_mnesia_transaction( - rabbit_misc:with_vhost( - VHostPath, - fun () -> mnesia:match_object( - #user_permission{user_vhost = #user_vhost{ - username = '_', - virtual_host = VHostPath}, - permission = '_'}) - end))]. + {Username, _, ConfigurationPerm, MessagingPerm} <- + list_permissions(rabbit_misc:with_vhost( + VHostPath, match_user_vhost('_', VHostPath)))]. list_user_permissions(Username) -> [{VHostPath, ConfigurationPerm, MessagingPerm} || - #user_permission{user_vhost = #user_vhost{virtual_host = VHostPath}, + {_, VHostPath, ConfigurationPerm, MessagingPerm} <- + list_permissions(rabbit_misc:with_user( + Username, match_user_vhost(Username, '_')))]. + +list_permissions(QueryThunk) -> + [{Username, VHostPath, ConfigurationPerm, MessagingPerm} || + #user_permission{user_vhost = #user_vhost{username = Username, + virtual_host = VHostPath}, permission = #permission{ configuration = ConfigurationPerm, messaging = MessagingPerm}} <- %% TODO: use dirty ops instead - rabbit_misc:execute_mnesia_transaction( - rabbit_misc:with_user( - Username, - fun () -> mnesia:match_object( - #user_permission{user_vhost = #user_vhost{ - username = Username, - virtual_host = '_'}, - permission = '_'}) - end))]. + rabbit_misc:execute_mnesia_transaction(QueryThunk)]. + +match_user_vhost(Username, VHostPath) -> + fun () -> mnesia:match_object( + #user_permission{user_vhost = #user_vhost{ + username = Username, + virtual_host = VHostPath}, + permission = '_'}) + end. |