Attached is a patch file for jsm/authreg.c that enables one to alter the
behavior of jabberd 1.4 when someone logs in with a username/resource
combination that already has an active session. Currently the existing
session is kicked and the new one logs in. With this patch, one can add the
<first-session-priority/> tag to the jsm section of jabber.xml and the
behavior is reversed. That is, the first session is allowed to continue and
the second one is not allowed to log in. I would appreciate comments on this
implementation. It may well be that there are better ways to do this. One bug
that seems to exist in this version is that the second client is not informed
of the login failure, but instead just sits there until it times out. I'm not
quite sure how to correct that. Thanks.
Wes Morgan
50a51
> session sessn;
53c54
< xmlnode x;
---
> xmlnode x, session_priority;
70,72c71,85
< }else if(!js_mapi_call(si, e_AUTH, p, user, NULL)){
< if(jpacket_subtype(p) == JPACKET__GET)
< { /* if it's a type="get" for auth, everybody mods it and we result and return it */
---
> }else{
> /* get existing session data (if any) */
> sessn = js_session_primary(user);
> if(sessn != NULL)
> {
> session_priority = xmlnode_get_tag(si->config,"first-session-priority");
> if(session_priority != NULL)
> {
> jutil_error(p->x, TERROR_AUTH);
> }
> log_debug(ZONE,"user %s is currently online",user->user);
> }
> if(!js_mapi_call(si, e_AUTH, p, user, NULL)){
> if(jpacket_subtype(p) == JPACKET__GET)
> { /* if it's a type="get" for auth, everybody mods it and we result and return it */
76c89
< }else{ /* type="set" that didn't get handled used to be a problem, but now auth_plain passes on failed checks so it might be normal */
---
> }else{ /* type="set" that didn't get handled used to be a problem, but now auth_plain passes on failed checks so it might be normal */
78c91,92
< }
---
> }
> }