25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-30 16:36:29 +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>
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;
_ ->

View File

@ -205,16 +205,15 @@ features() ->
%% node_default:check_create_user_permission(Host, ServerHost, Node, ParentNode, Owner, Access).'''</p>
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;
_ ->

View File

@ -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;

View File

@ -219,12 +219,14 @@ create_node(Host, Node, Type, Owner, Options, Parents) ->
true;
_ ->
case Parents of
[] -> true;
[] ->
true;
[Parent | _] ->
case nodeid(Host, Parent) of
{result, PNodeId} ->
BHost = list_to_binary(Host),
case nodeowners(PNodeId) of
[{[], Host, []}] -> true;
[{undefined, BHost, undefined}] -> true;
Owners -> lists:member(BJID, Owners)
end;
_ ->