25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Use mnesia calls instead of ets for Acl and Access tables (#1206)

This commit is contained in:
Badlop 2016-09-19 11:54:46 +02:00
parent 662b6f1020
commit da291d804c
3 changed files with 11 additions and 11 deletions

View File

@ -449,9 +449,9 @@ access_matches(all, _Data, _Host) ->
access_matches(none, _Data, _Host) ->
deny;
access_matches(Name, Data, Host) when is_atom(Name) ->
GAccess = ets:lookup(access, {Name, global}),
GAccess = mnesia:dirty_read(access, {Name, global}),
LAccess =
if Host /= global -> ets:lookup(access, {Name, Host});
if Host /= global -> mnesia:dirty_read(access, {Name, Host});
true -> []
end,
case GAccess ++ LAccess of
@ -484,7 +484,7 @@ access_rules_matches([], _Data, _Host, Default) ->
Default.
get_aclspecs(ACL, Host) ->
ets:lookup(acl, {ACL, Host}) ++ ets:lookup(acl, {ACL, global}).
mnesia:dirty_read(acl, {ACL, Host}) ++ mnesia:dirty_read(acl, {ACL, global}).
is_regexp_match(String, RegExp) ->
case ejabberd_regexp:run(String, RegExp) of

View File

@ -747,7 +747,7 @@ process_admin(Host,
_ -> nothing
end,
ACLs = lists:keysort(2,
ets:select(acl,
mnesia:dirty_select(acl,
[{{acl, {'$1', Host}, '$2'}, [],
[{{acl, '$1', '$2'}}]}])),
{NumLines, ACLsP} = term_to_paragraph(ACLs, 80),
@ -784,7 +784,7 @@ process_admin(Host,
_ -> nothing
end,
ACLs = lists:keysort(2,
ets:select(acl,
mnesia:dirty_select(acl,
[{{acl, {'$1', Host}, '$2'}, [],
[{{acl, '$1', '$2'}}]}])),
make_xhtml((?H1GL((?T(<<"Access Control Lists">>)),
@ -849,7 +849,7 @@ process_admin(Host,
end;
_ -> nothing
end,
Access = ets:select(access,
Access = mnesia:dirty_select(access,
[{{access, {'$1', Host}, '$2'}, [],
[{{access, '$1', '$2'}}]}]),
{NumLines, AccessP} = term_to_paragraph(lists:keysort(2,Access), 80),
@ -883,7 +883,7 @@ process_admin(Host,
end;
_ -> nothing
end,
AccessRules = ets:select(access,
AccessRules = mnesia:dirty_select(access,
[{{access, {'$1', Host}, '$2'}, [],
[{{access, '$1', '$2'}}]}]),
make_xhtml((?H1GL((?T(<<"Access Rules">>)),
@ -1153,7 +1153,7 @@ term_to_paragraph(T, Cols) ->
term_to_id(T) -> jlib:encode_base64((term_to_binary(T))).
acl_parse_query(Host, Query) ->
ACLs = ets:select(acl,
ACLs = mnesia:dirty_select(acl,
[{{acl, {'$1', Host}, '$2'}, [],
[{{acl, '$1', '$2'}}]}]),
case lists:keysearch(<<"submit">>, 1, Query) of
@ -1267,7 +1267,7 @@ access_rules_to_xhtml(AccessRules, Lang) ->
<<"Add New">>)])])]))]).
access_parse_query(Host, Query) ->
AccessRules = ets:select(access,
AccessRules = mnesia:dirty_select(access,
[{{access, {'$1', Host}, '$2'}, [],
[{{access, '$1', '$2'}}]}]),
case lists:keysearch(<<"addnew">>, 1, Query) of

View File

@ -1337,7 +1337,7 @@ get_form(Host, [<<"config">>, <<"acls">>], Lang) ->
[{xmlcdata, S}]}
end,
str:tokens(iolist_to_binary(io_lib:format("~p.",
[ets:select(acl,
[mnesia:dirty_select(acl,
[{{acl,
{'$1',
'$2'},
@ -1372,7 +1372,7 @@ get_form(Host, [<<"config">>, <<"access">>], Lang) ->
[{xmlcdata, S}]}
end,
str:tokens(iolist_to_binary(io_lib:format("~p.",
[ets:select(access,
[mnesia:dirty_select(access,
[{{access,
{'$1',
'$2'},