]> granicus.if.org Git - ejabberd/commitdiff
Use mnesia calls instead of ets for Acl and Access tables (#1206)
authorBadlop <badlop@process-one.net>
Mon, 19 Sep 2016 09:54:46 +0000 (11:54 +0200)
committerBadlop <badlop@process-one.net>
Mon, 19 Sep 2016 09:56:22 +0000 (11:56 +0200)
src/acl.erl
src/ejabberd_web_admin.erl
src/mod_configure.erl

index d3f9afe38ad8df545677b99c7522f92c897f052e..14439ce7a76b7e33a74ba7adbbcce8f90fde713e 100644 (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
index 6583fb445f70c7b71917aa712b79de1cfd2a2452..184f9775b23c3bf608d395219cb7f8d356ae2f93 100644 (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
index d0e0166a49c56cfd07bd6ba159b5b8790cf11689..03779d027abca4535ee2551ff3c27f56f6abfe2d 100644 (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'},