ejabberd with smack: how to successfully create leaf node inside collection node

Hi,

A registered user created a collection node on my ejabberd server using smack library and following config:

PubSubManager psMgr = new PubSubManager(conn, "pubsub.mydomain");

ConfigureForm CForm = new ConfigureForm(DataForm.Type.submit);
CForm.setAccessModel(AccessModel.open);          //anyone can access
CForm.setDeliverPayloads(true);                 //allow payloads with notif
CForm.setNotifyDelete(true);                      //notify subscribers when nodeis deleted
CForm.setPersistentItems(true);                  //save published items in storage @ server
CForm.setPresenceBasedDelivery(false);          //notify subscribers even when they are offline
CForm.setPublishModel(PublishModel.open);       //only publishers (owner) can post items to this node
CForm.setNodeType(NodeType.collection);
CForm.setChildrenAssociationPolicy(ChildrenAssociationPolicy.all);
CForm.setChildrenMax(65536);

psMgr.createNode("/collection_node", lCForm);

..this collection node is created fine. Note that the children association policy is 'all'.

Now, if a different user registered on the same server, tries to create a leaf node inside this collection node (as shown below), the server returns 'forbidden - auth' error.

ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
form.setNodeType(NodeType.leaf);
form.setCollection("/collection_node");
psMgr.createNode("/collection_node/leaf_node", form);

I have these plugins enabled in my ejabberd server for the pubsub module ["collections", "dag", "flat", "hometree", "pep"].

Can anyone please suggest why should the leaf node creation fail even after the collection node has granted 'all' to associate child nodes with itself.

smack version is: 4.1.2
ejabberd version: (for some weird reason shows): 0.0 . [However, the server was installed from source code available on (https://github.com/processone/ejabberd/archive/master.zip) in Nov-2015 with erlang installed at the same time (OTP 17.1). So should be pretty much latest unless i screwed up something during installation.]

When i set nodetree attribute

When i set nodetree attribute in mod_pubsub to "dag" and default plugin to "dag", and if I try to create a collection or a leaf node, then the server returns with internal-server-error

The following is what is logged as the error. Even if i delete all pubsub related data in mnesia (rm var/lib/ejabberd/pubsub_index.DCD, pubsub_index.DCL, pubsub_item.DAT, pubsub_node.DCD, pubsub_node.DCL) and start afresh with nodetree and default plugin to "dag", i still get the same error.

2015-11-29 08:54:40.880 [error] <0.15643.0>@mod_pubsub:transaction_retry:4180 transaction return internal error: {aborted,{function_clause,[{mod_pubsub,'-get_node_subs_by_depth/3-lc$^0/1-0-',[{'EXIT',{{badmatch,[{pubsub_node,{<<"pubsub.mydomain">>,<<"collection_node">>},5,[],<<"dag">>,[{<<"1478525555">>,<<""mydomain">>,<<>>}],[{publish_model,open},{presence_based_delivery,false},{persist_items,true},{notify_delete,true},{deliver_payloads,true},{access_model,open},{node_type,leaf},{notify_config,false},{notify_retract,true},{purge_offline,false},{max_items,10},{subscribe,true},{roster_groups_allowed,[]},{notification_type,headline},{max_payload_size,60000},{send_last_published_item,on_sub_and_presence},{deliver_notifications,true}]}]},[{nodetree_dag,traversal_helper,6,[{file,"src/nodetree_dag.erl"},{line,203}]},{mod_pubsub,tree_call,3,[{file,"src/mod_pubsub.erl"},{line,4081}]},{mod_pubsub,get_node_subs_by_depth,3,[{file,"src/mod_pubsub.erl"},{line,3402}]},{mod_pubsub,'-create_node/7-fun-2-',7,[{file,"src/mod_pubsub.erl"},{line,1850}]},{mnesia_tm,apply_fun,3,[{file,"mnesia_tm.erl"},{line,833}]},{mnesia_tm,execute_transaction,5,[{file,"mnesia_tm.erl"},{line,813}]},{mod_pubsub,transaction_retry,6,[{file,"src/mod_pubsub.erl"},{line,4160}]},{mod_pubsub,create_node,7,[{file,"src/mod_pubsub.erl"},{line,1871}]}]}}],[{file,"src/mod_pubsub.erl"},{line,3403}]},{mod_pubsub,'-create_node/7-fun-2-',7,[{file,"src/mod_pubsub.erl"},{line,1850}]},{mnesia_tm,apply_fun,3,[{file,"mnesia_tm.erl"},{line,833}]},{mnesia_tm,execute_transaction,5,[{file,"mnesia_tm.erl"},{line,813}]},{mod_pubsub,transaction_retry,6,[{file,"src/mod_pubsub.erl"},{line,4160}]},{mod_pubsub,create_node,7,[{file,"src/mod_pubsub.erl"},{line,1871}]},{mod_pubsub,do_route,7,[{file,"src/mod_pubsub.erl"},{line,985}]},{mod_pubsub,handle_info,2,[{file,"src/mod_pubsub.erl"},{line,859}]}]}}

I also can't create nodes

I also can't create nodes whether on virtual or dag nodetree. I tried deleting database. I'm getting the following in error log:

[error] <0.844.0>@mod_pubsub:transaction_retry:4236 transaction return internal error: {'EXIT',{{badmatch,[<<"localhost">>]},[{mod_pubsub,serverhost,1,[{file,"src/mod_pubsub.erl"},{line,4012}]},{mod_pubsub,tree,1,[{file,"src/mod_pubsub.erl"},{line,4016}]},{mod_pubsub,tree_call,3,[{file,"src/mod_pubsub.erl"},{line,4131}]},{mod_pubsub,'-transaction/4-fun-0-',3,[{file,"src/mod_pubsub.erl"},{line,4183}]},{mnesia_tm,non_transaction,5,[{file,"mnesia_tm.erl"},{line,737}]},{mod_pubsub,transaction_retry,6,[{file,"src/mod_pubsub.erl"},{line,4210}]},{mod_pubsub,publish_item,7,[{file,"src/mod_pubsub.erl"},{line,2193}]},{mod_pubsub,iq_sm,3,[{file,"src/mod_pubsub.erl"},{line,1206}]}]}}
2016-03-08 16:29:05.070 [error] <0.844.0>@mod_pubsub:transaction_retry:4239 transaction return internal error: {atomic,{'EXIT',{{badmatch,[<<"localhost">>]},[{mod_pubsub,serverhost,1,[{file,"src/mod_pubsub.erl"},{line,4012}]},{mod_pubsub,tree,1,[{file,"src/mod_pubsub.erl"},{line,4016}]},{mod_pubsub,tree_call,3,[{file,"src/mod_pubsub.erl"},{line,4131}]},{mod_pubsub,'-create_node/7-fun-2-',7,[{file,"src/mod_pubsub.erl"},{line,1845}]},{mnesia_tm,apply_fun,3,[{file,"mnesia_tm.erl"},{line,833}]},{mnesia_tm,execute_transaction,5,[{file,"mnesia_tm.erl"},{line,808}]},{mod_pubsub,transaction_retry,6,[{file,"src/mod_pubsub.erl"},{line,4210}]},{mod_pubsub,create_node,7,[{file,"src/mod_pubsub.erl"},{line,1870}]}]}}}

Hi, Below are few

Hi,

Below are few suggestions which might be helpful.
My guess is if you are building as-is from the source, the nodes that are being created are 'flat' nodes. This is because 'flat' is defined to be the standard node type. In mod_pubsub try changing

-define(STDNODE, <<"flat">>).

to

-define(STDNODE, <<"hometree">>).

and then recompile.

Also, as far as I know, dag is no more maintained. I could be wrong about this.
Hope this helps.

-Prasad

Syndicate content