diff options
author | Waqas Hussain <waqas20@gmail.com> | 2010-07-03 18:11:28 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2010-07-03 18:11:28 +0500 |
commit | b45ab38e21d7c915975a69e52bd565e6cdb75e66 (patch) | |
tree | f69201438d1595dcc2c49fa01fd1f474feeee35d /net | |
parent | afd2f3da8a34282e02e744cd1b13c62e66d613ae (diff) | |
download | prosody-b45ab38e21d7c915975a69e52bd565e6cdb75e66.tar.gz prosody-b45ab38e21d7c915975a69e52bd565e6cdb75e66.zip |
xmppcomponent_listener: Don't validate to/from on non-stanzas, fixes component auth.
Diffstat (limited to 'net')
-rw-r--r-- | net/xmppcomponent_listener.lua | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/net/xmppcomponent_listener.lua b/net/xmppcomponent_listener.lua index 2d6d7de8..2bf77fb6 100644 --- a/net/xmppcomponent_listener.lua +++ b/net/xmppcomponent_listener.lua @@ -99,26 +99,28 @@ function stream_callbacks.handlestanza(session, stanza) if not stanza.attr.xmlns and stanza.name == "handshake" then stanza.attr.xmlns = xmlns_component; end - local from = stanza.attr.from; - if from then - if session.component_validate_from then - local _, domain = jid_split(stanza.attr.from); - if domain ~= session.host then - -- Return error - session:close{ - condition = "invalid-from"; - text = "Component tried to send from address <"..tostring(from) - .."> which is not in domain <"..tostring(session.host)..">"; - }; - return; + if not stanza.attr.xmlns or stanza.attr.xmlns == "jabber:client" then + local from = stanza.attr.from; + if from then + if session.component_validate_from then + local _, domain = jid_split(stanza.attr.from); + if domain ~= session.host then + -- Return error + session:close{ + condition = "invalid-from"; + text = "Component tried to send from address <"..tostring(from) + .."> which is not in domain <"..tostring(session.host)..">"; + }; + return; + end end - end - else + else stanza.attr.from = session.host; - end - if not stanza.attr.to then - session.send(st.error_reply(stanza, "modify", "bad-request", "Components MUST specify a 'to' address on stanzas")); - return; + end + if not stanza.attr.to then + session.send(st.error_reply(stanza, "modify", "bad-request", "Components MUST specify a 'to' address on stanzas")); + return; + end end return core_process_stanza(session, stanza); end |