ejabberd - Comments for "Development of mod_register and mod_vcard" https://www.ejabberd.im/node/4127 en Modifications https://www.ejabberd.im/node/4127#comment-56466 <h3>1. Include username and "registered": patch applied</h3> <p>Thank you.</p> <h3>2. Is it worth to change a hook for unauthenticated user?</h3> <div class="quote-msg"> <div class="quote-author">Quote:</div> <p>Do you think that part about getting the From when the client is unathenticated is worth the effort to include in future releases? </p></div> <p>Yes, I believe that this is a very useful feature in some circumstances. For instance, if the client wishes to be able to determine if the account is available in the server without actually registering the new account yet. For instance, when the user in my client program changes their name, being able to check the availability of the XMPP account for that name is essential before confirming the new name in the application database. The user is not necessarily logged in at that time. The reason why I thought it an acceptable modification for the ejabberd code is the following clause from XEP-0077 (just before <noindex><a href="http://xmpp.org/extensions/xep-0077.html#example-3" title="http://xmpp.org/extensions/xep-0077.html#example-3" rel="nofollow" >http://xmpp.org/extensions/xep-0077.html#example-3</a></noindex>):</p> <div class="quote-msg"> <div class="quote-author">Quote:</div> <p>If the host determines (based on the 'from' address) that the entity is already registered, the IQ result that it sends in response to the IQ get MUST contain an empty element (indicating that the entity is already registered) ... </p></div> <p>I hope that you can accept this modification, but it is a shame that it cannot be included in the 2.1.x releases.</p> <h3>3. vCard XEP is ambiguous: I'll get a clarification</h3> <p>Yes, you are correct - I did interpret that sentence to include <strong>respectively</strong>. Also, yes, the specification is ambiguous as it stands. It will be useful to get clarification.</p> <h3>4. Other ways to find account registration: maybe with iq, presence or message</h3> <p>That is a useful suggestion. Thank you. If you do not accept the modification for a separate vCard error depending on whether the account exists or not then I will change my client code according to this method.</p> <p>Cheers, Mike.</p> Mon, 02 Aug 2010 10:05:53 +0000 PioneerMike comment 56466 at https://www.ejabberd.im Long reply https://www.ejabberd.im/node/4127#comment-56458 <p>I split my reply in four sections.</p> <h3>1. Include username and "registered": patch applied</h3> <div class="quote-msg"> <div class="quote-author"><em>PioneerMike</em> wrote:</div> <p> I have posted the full files (based on V2.1.4) to <noindex><a href="http://paste.jabbim.cz" title="http://paste.jabbim.cz" rel="nofollow" >http://paste.jabbim.cz</a></noindex> as follows: </p></div> <p>Great, I was able to download the files, get the differences and see your changes.</p> <div class="quote-msg"> <div class="quote-author"><em>PioneerMike</em> wrote:</div> <p> Regarding Register - yes, I do refer to that paragraph. </p></div> <p>Ok, and your changes work. I've simplified the code that includes the Username and the "registered" element, and included it in ejabberd 2.1.x and master branches.</p> <h3>2. Is it worth to change a hook for unauthenticated user?</h3> <p>You expect that the unauthenticated client may provide a From attribute. However, I have doubts about how many clients provide a From when they are unauthenticated yet:</p> <pre> +unauthenticated_iq_register(_Acc, Server, + #iq{type = Type, xmlns = ?NS_REGISTER} = IQ, + IP, From) -&gt; Address = case IP of {A, _Port} -&gt; A; _ -&gt; undefined end, - ResIQ = process_iq(jlib:make_jid("", "", ""), + FromJid = case Type of + get -&gt; jlib:string_to_jid(From); </pre><p> Another concern I have about that part is that it modifies an existing ejabberd hook to add the new argument From, so that change can't be included in the stable releases ejabberd 2.1.x. It can be included in future ejabberd 3.x releases.</p> <p>Do you think that part about getting the From when the client is unathenticated is worth the effort to include in future releases?</p> <h3>3. vCard XEP is ambiguous: I'll get a clarification</h3> <div class="quote-msg"> <div class="quote-author"><em>PioneerMike</em> wrote:</div> <p> Allowing the request of a vCard to respond differently if an account is registered or not </p></div> <p>Ok, I noticed that <noindex><a href="http://xmpp.org/extensions/xep-0054.html" title="http://xmpp.org/extensions/xep-0054.html" rel="nofollow" >http://xmpp.org/extensions/xep-0054.html</a></noindex> is ambiguous when it says:</p> <div class="quote-msg"> <div class="quote-author">Quote:</div> <p> If no vCard exists or the user does not exist, the server MUST return a stanza error, which SHOULD &lt;service-unavailable/&gt; or &lt;item-not-found/&gt;. </p></div> <p>You interpreted that sentence as if it had the word <strong>respectively</strong> in the end, like this:</p> <div class="quote-msg"> <div class="quote-author"><em>PioneerMike</em> wrote:</div> <p> If no vCard exists or the user does not exist, the server MUST return a stanza error, which SHOULD <strong>be</strong> &lt;service-unavailable/&gt; or &lt;item-not-found/&gt; <strong>, respectively</strong>. </p></div> <p>I'll contact the XEP author to get a clarification of how to interpret that sentence. If he agrees that each case should produce a different error, then I'll apply your patch.</p> <h3>4. Other ways to find account registration: maybe with iq, presence or message</h3> <p>For my purposes, I need this feature. Is there another way for a client application (which is already logged in) to check if another account exists?</p> <p>Maybe yes, I found in <noindex><a href="http://xmpp.org/rfcs/rfc3921.html#rfc.section.11.1" title="http://xmpp.org/rfcs/rfc3921.html#rfc.section.11.1" rel="nofollow" >http://xmpp.org/rfcs/rfc3921.html#rfc.section.11.1</a></noindex> this:</p> <div class="quote-msg"> <div class="quote-author">Quote:</div> <p> if the JID is of the form &lt;user@domain&gt; or &lt;user@domain/resource&gt; and the associated user account does not exist, the recipient's server (a) SHOULD silently ignore the stanza (i.e., neither deliver it nor return an error) if it is a presence stanza, (b) MUST return a &lt;service-unavailable/&gt; stanza error to the sender if it is an IQ stanza, and (c) SHOULD return a &lt;service-unavailable/&gt; stanza error to the sender if it is a message stanza. </p></div> <p>I made some quick test, maybe they give you some idea. I tried from account 'badlop' to query an existing account 'badlop2' and to an unexistent account 'user123123':</p> <pre> &lt;iq to='badlop2@localhost' type='get'&gt; &lt;query xmlns='jabber:iq:last'/&gt; &lt;iq&gt; &lt;iq from='badlop2@localhost' to='badlop@localhost/work' type='result'&gt; &lt;query seconds='9' xmlns='jabber:iq:last'/&gt; &lt;iq&gt; </pre><pre> &lt;iq to='user123123@localhost' type='get'&gt; &lt;query xmlns='jabber:iq:last'/&gt; &lt;iq&gt; &lt;iq from='user123123@localhost' to='badlop@localhost/work' type='error'&gt; &lt;query xmlns='jabber:iq:last'/&gt; &lt;error code='503' type='cancel'&gt; &lt;service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt; &lt;error&gt; &lt;iq&gt; </pre><p> And sending an empty message:</p> <pre> &lt;message to='badlop2@localhost'&gt;&lt;message&gt; </pre><pre> &lt;message to='user123123@localhost'&gt;&lt;message&gt; &lt;message from='user123123@localhost' to='badlop@localhost/work' type='error' xml:lang='es'&gt; &lt;error code='503' type='cancel'&gt; &lt;service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt; &lt;error&gt; &lt;message&gt; </pre> Wed, 28 Jul 2010 17:56:25 +0000 mfoss comment 56458 at https://www.ejabberd.im Full files provided https://www.ejabberd.im/node/4127#comment-56448 <p>Hi,</p> <p>Sorry for the delay in responding. I expected to receive an email if anyone posted to this thread. Sorry for the unreadable source code. I have posted the full files (based on V2.1.4) to <noindex><a href="http://paste.jabbim.cz" title="http://paste.jabbim.cz" rel="nofollow" >http://paste.jabbim.cz</a></noindex> as follows:</p> <p>ejabberd_c2s.erl #1 (lines 1 to 2079): <noindex><a href="http://paste.jabbim.cz/4746" title="http://paste.jabbim.cz/4746" rel="nofollow" >http://paste.jabbim.cz/4746</a></noindex><br /> ejabberd_c2s.erl #2 (lines 2080 to 2294): <noindex><a href="http://paste.jabbim.cz/4749" title="http://paste.jabbim.cz/4749" rel="nofollow" >http://paste.jabbim.cz/4749</a></noindex><br /> mod_register.erl: <noindex><a href="http://paste.jabbim.cz/4747" title="http://paste.jabbim.cz/4747" rel="nofollow" >http://paste.jabbim.cz/4747</a></noindex><br /> mod_vcard.erl: <noindex><a href="http://paste.jabbim.cz/4748" title="http://paste.jabbim.cz/4748" rel="nofollow" >http://paste.jabbim.cz/4748</a></noindex></p> <p>There seems to be a post limit, so ejabberd_c2s.erl is split into 2 different posts. Line 2080 on #1 is not complete.</p> <p>Regarding Register - yes, I do refer to that paragraph.</p> <p>Regarding your comment about security and abusing the system, a client is already able to determine if an account is registered by applying the Register modification I have submitted to you. Allowing the request of a vCard to respond differently if an account is registered or not is therefore no more of a security risk. It is a useful feature because my client application can request the vCard for an account when a user wishes to subscribe to presence notifications from another user's account and can provide a friendly message to indicate that the subscription request has been posted to the specified user account (and show the avatar) or it can show an error message to indicate that the user account does not exist. For my purposes, I need this feature. Is there another way for a client application (which is already logged in) to check if another account exists?</p> <p>Cheers, Mike.</p> Tue, 27 Jul 2010 12:19:20 +0000 PioneerMike comment 56448 at https://www.ejabberd.im Regarding Register, I guess https://www.ejabberd.im/node/4127#comment-56313 <p>Regarding Register, I guess you refer to the paragraph "If the host determines (based on the 'from' address) that the entity is already registered, ", and the example<br /> <noindex><a href="http://xmpp.org/extensions/xep-0077.html#example-3" title="http://xmpp.org/extensions/xep-0077.html#example-3" rel="nofollow" >http://xmpp.org/extensions/xep-0077.html#example-3</a></noindex></p> <p>I couldn't review your changes because it's almost unreadable.</p> <p>Please provide your changes in a way easy to apply:<br /> A) Either provide a patch (if you got ejabberd code from git, you can run "git diff origin/2.1.x &gt; registerfix.diff")<br /> B) Or the full modified files.</p> <p>If you don't have hosting, you can use <noindex><a href="http://paste.jabbim.cz/" title="http://paste.jabbim.cz/" rel="nofollow" >http://paste.jabbim.cz/</a></noindex> or similar sites, or email them to me. Remember to indicate what ejabberd version are those changes to apply (2.1.4 I imagine).</p> <p>Regarding Vcard, I agree with your bug report, but I propose a slightly different solution.</p> <p>You provide a different response depending if the account exists or not. That seems a nice feature. But this feature can be abused: it allows to know if an account is registered or not in the server. I'm writting your change to return the same IQ-error in both cases:</p> <pre> &lt;iq type='get' to='user666@localhost'&gt; &lt;vCard xmlns='vcard-temp'/&gt; &lt;iq&gt; &lt;iq from='user666@localhost' to='badlop@localhost/work' type='error'&gt; &lt;vCard xmlns='vcard-temp'/&gt; &lt;error type='cancel'&gt; &lt;item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt; &lt;/error&gt; &lt;iq&gt; </pre><pre> &lt;iq type='get' to='user_no_vcard@localhost'&gt; &lt;vCard xmlns='vcard-temp'/&gt; &lt;iq&gt; &lt;iq from='user_no_vcard@localhost' to='badlop@localhost/work' type='error'&gt; &lt;vCard xmlns='vcard-temp'/&gt; &lt;error type='cancel'&gt; &lt;item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt; &lt;/error&gt; &lt;iq&gt; </pre> Tue, 29 Jun 2010 11:35:00 +0000 mfoss comment 56313 at https://www.ejabberd.im