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:
parent
f32b394a96
commit
4409c49494
@ -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;
|
||||
_ ->
|
||||
|
@ -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;
|
||||
_ ->
|
||||
|
@ -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;
|
||||
|
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user