summaryrefslogtreecommitdiff
path: root/src/rabbit_runtime_parameters.erl
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-04-08 16:00:55 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-04-08 16:00:55 +0100
commit6f8a4ef1ba794b2005dcdccb600c9fa1c621130c (patch)
treecda350d3bb58d95b49c40c8663949a6d19b3cf94 /src/rabbit_runtime_parameters.erl
parent2f16bf43db30da94a1f3115bd19e12c3b4f196ea (diff)
downloadrabbitmq-server-6f8a4ef1ba794b2005dcdccb600c9fa1c621130c.tar.gz
Allow parameter validation to know about the user making the change.
Diffstat (limited to 'src/rabbit_runtime_parameters.erl')
-rw-r--r--src/rabbit_runtime_parameters.erl35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/rabbit_runtime_parameters.erl b/src/rabbit_runtime_parameters.erl
index ba6b9538..7307330b 100644
--- a/src/rabbit_runtime_parameters.erl
+++ b/src/rabbit_runtime_parameters.erl
@@ -18,7 +18,7 @@
-include("rabbit.hrl").
--export([parse_set/4, set/4, set_any/4, clear/3, clear_any/3, list/0, list/1,
+-export([parse_set/5, set/5, set_any/5, clear/3, clear_any/3, list/0, list/1,
list_component/1, list/2, list_formatted/1, lookup/3,
value/3, value/4, info_keys/0]).
@@ -30,12 +30,12 @@
-type(ok_or_error_string() :: 'ok' | {'error_string', string()}).
--spec(parse_set/4 :: (rabbit_types:vhost(), binary(), binary(), string())
- -> ok_or_error_string()).
--spec(set/4 :: (rabbit_types:vhost(), binary(), binary(), term())
- -> ok_or_error_string()).
--spec(set_any/4 :: (rabbit_types:vhost(), binary(), binary(), term())
- -> ok_or_error_string()).
+-spec(parse_set/5 :: (rabbit_types:vhost(), binary(), binary(), string(),
+ rabbit_types:user() | 'none') -> ok_or_error_string()).
+-spec(set/5 :: (rabbit_types:vhost(), binary(), binary(), term(),
+ rabbit_types:user() | 'none') -> ok_or_error_string()).
+-spec(set_any/5 :: (rabbit_types:vhost(), binary(), binary(), term(),
+ rabbit_types:user() | 'none') -> ok_or_error_string()).
-spec(set_global/2 :: (atom(), term()) -> 'ok').
-spec(clear/3 :: (rabbit_types:vhost(), binary(), binary())
-> ok_or_error_string()).
@@ -65,19 +65,19 @@
%%---------------------------------------------------------------------------
-parse_set(_, <<"policy">>, _, _) ->
+parse_set(_, <<"policy">>, _, _, _) ->
{error_string, "policies may not be set using this method"};
-parse_set(VHost, Component, Name, String) ->
+parse_set(VHost, Component, Name, String, User) ->
case rabbit_misc:json_decode(String) of
{ok, JSON} -> set(VHost, Component, Name,
- rabbit_misc:json_to_term(JSON));
+ rabbit_misc:json_to_term(JSON), User);
error -> {error_string, "JSON decoding error"}
end.
-set(_, <<"policy">>, _, _) ->
+set(_, <<"policy">>, _, _, _) ->
{error_string, "policies may not be set using this method"};
-set(VHost, Component, Name, Term) ->
- set_any(VHost, Component, Name, Term).
+set(VHost, Component, Name, Term, User) ->
+ set_any(VHost, Component, Name, Term, User).
set_global(Name, Term) ->
mnesia_update(Name, Term),
@@ -86,16 +86,17 @@ set_global(Name, Term) ->
format_error(L) ->
{error_string, rabbit_misc:format_many([{"Validation failed~n", []} | L])}.
-set_any(VHost, Component, Name, Term) ->
- case set_any0(VHost, Component, Name, Term) of
+set_any(VHost, Component, Name, Term, User) ->
+ case set_any0(VHost, Component, Name, Term, User) of
ok -> ok;
{errors, L} -> format_error(L)
end.
-set_any0(VHost, Component, Name, Term) ->
+set_any0(VHost, Component, Name, Term, User) ->
case lookup_component(Component) of
{ok, Mod} ->
- case flatten_errors(Mod:validate(VHost, Component, Name, Term)) of
+ case flatten_errors(
+ Mod:validate(VHost, Component, Name, Term, User)) of
ok ->
case mnesia_update(VHost, Component, Name, Term) of
{old, Term} -> ok;