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

fix create_node_permission using binary() instead of string()

This commit is contained in:
Christophe Romain 2010-05-17 12:52:43 +02:00
parent f32b394a96
commit 4409c49494
4 changed files with 27 additions and 26 deletions

View File

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

View File

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

View File

@ -214,8 +214,9 @@ create_node(Host, Node, Type, Owner, Options, Parents) ->
case Parents of case Parents of
[] -> true; [] -> true;
[Parent | _] -> [Parent | _] ->
BHost = list_to_binary(Host),
case mnesia:read({pubsub_node, {Host, Parent}}) of 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); [#pubsub_node{owners = Owners}] -> lists:member(BJID, Owners);
_ -> false _ -> false
end; end;

View File

@ -212,28 +212,30 @@ create_node(Host, Node, Type, Owner, Options, Parents) ->
BJID = jlib:short_prepd_bare_jid(Owner), BJID = jlib:short_prepd_bare_jid(Owner),
case nodeid(Host, Node) of case nodeid(Host, Node) of
{error, 'item_not_found'} -> {error, 'item_not_found'} ->
ParentExists = case Host of ParentExists = case Host of
{_, _, _} -> {_, _, _} ->
%% This is special case for PEP handling %% This is special case for PEP handling
%% PEP does not uses hierarchy %% PEP does not uses hierarchy
true; true;
_ -> _ ->
case Parents of case Parents of
[] -> true; [] ->
[Parent | _] -> true;
case nodeid(Host, Parent) of [Parent | _] ->
{result, PNodeId} -> case nodeid(Host, Parent) of
case nodeowners(PNodeId) of {result, PNodeId} ->
[{[], Host, []}] -> true; BHost = list_to_binary(Host),
Owners -> lists:member(BJID, Owners) case nodeowners(PNodeId) of
end; [{undefined, BHost, undefined}] -> true;
_ -> Owners -> lists:member(BJID, Owners)
false end;
end; _ ->
_ -> false
false end;
_ ->
false
end end
end, end,
case ParentExists of case ParentExists of
true -> true ->
case set_node(#pubsub_node{ case set_node(#pubsub_node{