diff --git a/src/mod_pubsub/node_hometree.erl b/src/mod_pubsub/node_hometree.erl index 7c16a2303..c45448787 100644 --- a/src/mod_pubsub/node_hometree.erl +++ b/src/mod_pubsub/node_hometree.erl @@ -200,16 +200,15 @@ features() -> %% node_default:check_create_user_permission(Host, ServerHost, Node, ParentNode, Owner, Access).'''

create_node_permission(Host, ServerHost, Node, _ParentNode, Owner, Access) -> LOwner = jlib:short_prepd_jid(Owner), - {User, Server, _Resource} = LOwner, Allowed = case LOwner of - {undefined, Host, undefined} -> - true; % pubsub service always allowed + {undefined, BHost, undefined} -> + list_to_binary(Host) == BHost; % pubsub service always allowed _ -> {LU, LS, LR} = LOwner, case acl:match_rule(ServerHost, Access, exmpp_jid:make(LU, LS, LR)) of allow -> case node_to_path(Node) of - [<<"home">>, Server, User | _] -> true; + [<<"home">>, LS, LU | _] -> true; _ -> false end; _ -> diff --git a/src/mod_pubsub/node_hometree_odbc.erl b/src/mod_pubsub/node_hometree_odbc.erl index 759131ccb..c07d089b7 100644 --- a/src/mod_pubsub/node_hometree_odbc.erl +++ b/src/mod_pubsub/node_hometree_odbc.erl @@ -205,16 +205,15 @@ features() -> %% node_default:check_create_user_permission(Host, ServerHost, Node, ParentNode, Owner, Access).'''

create_node_permission(Host, ServerHost, Node, _ParentNode, Owner, Access) -> LOwner = jlib:short_prepd_jid(Owner), - {User, Server, _Resource} = LOwner, Allowed = case LOwner of - {undefined, Host, undefined} -> - true; % pubsub service always allowed + {undefined, BHost, undefined} -> + list_to_binary(Host) == BHost; % pubsub service always allowed _ -> {LU, LS, LR} = LOwner, case acl:match_rule(ServerHost, Access, exmpp_jid:make(LU, LS, LR)) of allow -> case node_to_path(Node) of - ["home", Server, User | _] -> true; + [<<"home">>, LS, LU | _] -> true; _ -> false end; _ -> diff --git a/src/mod_pubsub/nodetree_tree.erl b/src/mod_pubsub/nodetree_tree.erl index 6bdf81d3c..6c6329482 100644 --- a/src/mod_pubsub/nodetree_tree.erl +++ b/src/mod_pubsub/nodetree_tree.erl @@ -214,8 +214,9 @@ create_node(Host, Node, Type, Owner, Options, Parents) -> case Parents of [] -> true; [Parent | _] -> + BHost = list_to_binary(Host), case mnesia:read({pubsub_node, {Host, Parent}}) of - [#pubsub_node{owners = [{undefined, Host, undefined}]}] -> true; + [#pubsub_node{owners = [{undefined, BHost, undefined}]}] -> true; [#pubsub_node{owners = Owners}] -> lists:member(BJID, Owners); _ -> false end; diff --git a/src/mod_pubsub/nodetree_tree_odbc.erl b/src/mod_pubsub/nodetree_tree_odbc.erl index 53c5918ae..6f037c2c1 100644 --- a/src/mod_pubsub/nodetree_tree_odbc.erl +++ b/src/mod_pubsub/nodetree_tree_odbc.erl @@ -212,28 +212,30 @@ create_node(Host, Node, Type, Owner, Options, Parents) -> BJID = jlib:short_prepd_bare_jid(Owner), case nodeid(Host, Node) of {error, 'item_not_found'} -> - ParentExists = case Host of - {_, _, _} -> + ParentExists = case Host of + {_, _, _} -> %% This is special case for PEP handling %% PEP does not uses hierarchy true; _ -> - case Parents of - [] -> true; - [Parent | _] -> - case nodeid(Host, Parent) of - {result, PNodeId} -> - case nodeowners(PNodeId) of - [{[], Host, []}] -> true; - Owners -> lists:member(BJID, Owners) - end; - _ -> - false - end; - _ -> - false + case Parents of + [] -> + true; + [Parent | _] -> + case nodeid(Host, Parent) of + {result, PNodeId} -> + BHost = list_to_binary(Host), + case nodeowners(PNodeId) of + [{undefined, BHost, undefined}] -> true; + Owners -> lists:member(BJID, Owners) + end; + _ -> + false + end; + _ -> + false end - end, + end, case ParentExists of true -> case set_node(#pubsub_node{