privacy_set in ejabberdctl error

Hello,
I'm trying to set privacy list through ejabberdctl, i use command:

ejabberdctl privacy_set testuser domain.com "<query xmlns='jabber:iq:privacy'><list name='blocked'><item type='jid' value='user2@domain.com' action='allow' order='1'></item></list></query>"

but I get result:

Problem 'error {badmatch,
                   {error,
                       {xmlelement,"error",
                           [{"code","501"},{"type","cancel"}],
                           [{xmlelement,"feature-not-implemented",
                                [{"xmlns",
                                  "urn:ietf:params:xml:ns:xmpp-stanzas"}],
                                []}]}}}' occurred executing the command.
Stacktrace: [{mod_admin_extra,privacy_set,3},
             {ejabberd_ctl,call_command,3},
             {ejabberd_ctl,try_call_command,3},
             {ejabberd_ctl,process2,3},
             {ejabberd_ctl,process,1},
             {rpc,'-handle_call_call/6-fun-0-',5}]

What i have do wrong ?

Thanks.

I think the problem is in

I think the problem is in spaces in the shell. I don't know how you can provide a parameter in the shell that has arguments. Any idea?

Instead of ejabberdctl, I installed ejabberd_xmlrpc, the xmlrpc erlang library, and then created the file priset.py with this content:

import xmlrpclib

server_url = 'http://127.0.0.1:4560'
server = xmlrpclib.ServerProxy(server_url)

def ejabberdctl(command, data):
    fn = getattr(server, command)
    return fn(data)

result = ejabberdctl('privacy_set', {'user':'badlop', 'host':'localhost', 'xmlquery':"<query xmlns=
'jabber:iq:privacy'><list name='blocked'><item type='jid' value='user2@domain.com' action=
'allow' order='1'></item></list></query>"})

print result

This gets a correct result, and the list is set correctly.

$ python priset.py                                                            
{'res': 0}

Thanks for your reply. I

Thanks for your reply.
I tested your code and have the same issue, still i get 500 internal server error ;/
I have ejabberd 2.1.6, maybe there is some error ?

Hi guys, I have exactly the

Hi guys,

I have exactly the same problem with ejabberd 2.1.8, Can you tell me how can I solve this problem?? Thanks.

The purpose of me is to clear the privacy list of "public", so I use the below command:

ejabberdctl privacy_set 22 hzs-t61-elou "<query xmlns='jabber:iq:privacy'><list name='public'></list></query>"

But error was observed at ejabberd log:

=INFO REPORT==== 2011-09-15 14:39:57 ===

D(<0.478.0>:ejabberd_commands:314) : Executing command mod_admin_extra:privacy_set with Args=["66",
                                                                                              "hzs-t61-elou",
                                                                                              "<query xmlns='jabber:iq:privacy'><list name='public'></list></query>"]

=ERROR REPORT==== 2011-09-15 14:39:57 ===
{xmlrpc_http,156,
{ejabberd_xmlrpc,handler,
{'EXIT',
{{badmatch,
{error,
{xmlelement,"error",
[{"code","501"},{"type","cancel"}],
[{xmlelement,"feature-not-implemented",
[{"xmlns",
"urn:ietf:params:xml:ns:xmpp-stanzas"}],
[]}]}}},
[{mod_admin_extra,privacy_set,3},
{ejabberd_xmlrpc,do_command,6},
{ejabberd_xmlrpc,try_do_command,6},
{xmlrpc_http,eval_payload,6},
{tcp_serv,start_session,3},
{proc_lib,init_p,5}]}}}}

Can you tell me how I can resolve the problem? thanks.

The solution mentioned

The solution mentioned above:

{hosts, ["mydomain.com"]}.
If there was only this entry, i've get error.

So, a have change this to:
{hosts, ["localhost"]}.

And yours script works! But i can't connect to server in my domain.

So, a changed to:
{hosts, ["localhost", "mydomain.com"]}.

could resolve the problem, I presume this is a bug of ejabberd. Had this been fixed? in which version?

If your users login to

If your users login to accounts of the domain "mydomain.com", and you send XMLRPC queries to the domain "localhost", then obviously you need to have both domains in the Hosts option.

With your's code i

With your's code i get:

python pritest.py
Traceback (most recent call last):
  File "pritest.py", line 10, in <module>
    result = ejabberdctl('privacy_set', {'user':'1', 'host':'localhost', 'xmlquery':"<query xmlns='jabber:iq:privacy'><list name='blocked'><item type='jid' value='user2@domain.com' action='allow' order='1'></item></list></query>"})
  File "pritest.py", line 8, in ejabberdctl
    return fn(data)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1243, in request
    headers
xmlrpclib.ProtocolError: <ProtocolError for 127.0.0.1:4560/RPC2: 500 Internal Server Error>

and in ejabberd.log:

D(<0.705.0>:ejabberd_commands:314) : Executing command mod_admin_extra:privacy_set with Args=["1",
                                                                                              "localhost",
                                                                                              "<query xmlns='jabber:iq:privacy'><list name='blocked'><item type='jid' value='user2@domain.com' action='allow' order='1'></item></list></query>"]

=ERROR REPORT==== 2011-06-07 09:14:53 ===
{xmlrpc_http,153,
    {ejabberd_xmlrpc,handler,
        {'EXIT',
            {{badmatch,
                 {error,
                     {xmlelement,"error",
                         [{"code","501"},{"type","cancel"}],
                         [{xmlelement,"feature-not-implemented",
                              [{"xmlns",
                                "urn:ietf:params:xml:ns:xmpp-stanzas"}],
                              []}]}}},
             [{mod_admin_extra,privacy_set,3},
              {ejabberd_xmlrpc,do_command,6},
              {ejabberd_xmlrpc,try_do_command,6},
              {xmlrpc_http,eval_payload,6},
              {tcp_serv,start_session,3},
              {proc_lib,init_p_do_apply,3}]}}}}

Please help, i really need it...

I get your same error when I

I get your same error when I remove mod_privacy of my ejabberd.cfg

Do you have mod_privacy enabled in ejabberd.cfg ?

Also, check in WebAdmin -> Nodes -> your node -> Modules, if mod_privacy is enabled.

Do you see any error when ejabberd starts?

More ideas: if you changed a lot of times ejabberd.cfg, or experimented a otwith privacy lists, you can try this: put the default ejabberd.cfg and change it only to add xmlrpc. Also delete the Mnesia spool files, and crete new accounts.

Yes!! Works, but i think i've

Yes!! Works, but i think i've found bug :)
Problem was line i ejabberd.cfg:
{hosts, ["mydomain.com"]}.
If there was only this entry, i've get error.

So, a have change this to:
{hosts, ["localhost"]}.

And yours script works! But i can't connect to server in my domain.

So, a changed to:
{hosts, ["localhost", "mydomain.com"]}.

And everything works fine, script, privacy_set and connection to server.
In my opinion something is wrong with this, it should work with any "hosts" configuration.

rysi3k wrote: In my opinion

rysi3k wrote:

In my opinion something is wrong with this, it should work with any "hosts" configuration.

Ah, right. I've found the bug in mod_admin_extra.erl, fixed it and committed to SVN.

Please update and check it works correctly now.

Ok, svn version works great

Ok, svn version works great :)

Hmmm I've found some problem

Hmmm I've found some problem with this.
I used your's script to make privacy list and set it default and active, but on try to set active it returns error:

Traceback (most recent call last):
  File "pritest.py", line 11, in <module>
    result = ejabberdctl('privacy_set', {'user':'43824', 'host':'domain.eu', 'xmlquery':"<query xmlns='jabber:iq:privacy'><active name='blocked'/></query>"})
  File "pritest.py", line 8, in ejabberdctl
    return fn(data)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1243, in request
    headers
xmlrpclib.ProtocolError: <ProtocolError for 127.0.0.1:4560/RPC2: 500 Internal Server Error>

In pritest.py I have:

import xmlrpclib

server_url = 'http://127.0.0.1:4560'
server = xmlrpclib.ServerProxy(server_url)

def ejabberdctl(command, data):
    fn = getattr(server, command)
    return fn(data)

result = ejabberdctl('privacy_set', {'user':'43824', 'host':'domain.eu', 'xmlquery':"<query xmlns='jabber:iq:privacy'><list name='blocked'><item type='jid' value='44108@domain.eu' action='deny' order='1'></item></list></query>"})
result = ejabberdctl('privacy_set', {'user':'43824', 'host':'domain.eu', 'xmlquery':"<query xmlns='jabber:iq:privacy'><active name='blocked'/></query>"})
result = ejabberdctl('privacy_set', {'user':'43824', 'host':'domain.eu', 'xmlquery':"<query xmlns='jabber:iq:privacy'><default name='blocked'/></query>"})

print result

Whats wrong?

Your second call says

Your second call says something about: active. mod_admin_extra didn't support that. I've updated it in SVN, and now it should work. Update SVN and try again.

Maybe you're seeing a problem

Maybe you're seeing a problem related to this: http://www.ejabberd.im/node/4739
Check my comment there.

Syndicate content