fritzy / SleekXMPP

Python 2.6+/3.1+ XMPP Library
http://groups.google.com/group/sleekxmpp-discussion
Other
1.1k stars 299 forks source link

xep_0009 (jabber_rpc), ACL control error #93

Closed ThomasChiroux closed 12 years ago

ThomasChiroux commented 13 years ago

Hi, I had some problem while using ACLs in develop: raceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/sleekxmpp/plugins/xep_0009/remote.py", line 586, in _on_jabber_rpc_method_call if ACL.check(rules, iq['from'], pmethod): File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/sleekxmpp/plugins/xep_0009/remote.py", line 117, in check policy = cls._check(rule, jid, resource) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/sleekxmpp/plugins/xep_0009/remote.py", line 124, in _check if cls._match(jid, rule[1]) and cls._match(resource, rule[2]): File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/sleekxmpp/plugins/xep_0009/remote.py", line 151, in _match token_index = value.find(token, position) TypeError: 'NoneType' object is not callable

It appears that 'value' was not string when matching jid to rule[1](jid was not a string ?)

So, i've patched sleekxmpp/plugins/xep_0009/remote.py :

changed line 150 from : token_index = value.find(token, position) to: token_index = str(value).find(token, position)

dannmartens commented 13 years ago

Looking at the beginning of the call chain: ACL.check(rules, iq['from'], pmethod), I wonder whether in your case the IQ has a 'from'.

I am assuming that the type of iq['from'] is string.

If iq['from'] is None, I would prefer to fix this issue in a different way. I could add a check which denies access immediately if there is no valid 'from'.

fritzy commented 13 years ago

That's interesting... why wouldn't the iq have a from unless it is one you generated locally?

dannmartens commented 13 years ago

I'm just backtracking the traceback: at line 150, value appears to be None.

Still, a test would be appropriate, here. Stay tuned.

correl commented 12 years ago

I ran into this issue today. The error is misleading; value is not None, it's a JID object. Casting it to a string works since it converts it to a string containing the full JID. I'm submitting a pull request with my fix.

edit: pull request: https://github.com/fritzy/SleekXMPP/pull/122