#include <limits.h>
#include <ctype.h>
#include <libcitadel.h>
+#include <expat.h>
#include "citadel.h"
#include "server.h"
#include "citserver.h"
#include "internet_addressing.h"
#include "md5.h"
#include "ctdl_module.h"
-
-#ifdef HAVE_EXPAT
-#include <expat.h>
#include "serv_xmpp.h"
struct xmpp_event *xmpp_queue = NULL;
/* If we're not logged in yet, offer SASL as our feature set */
xmpp_output_auth_mechs();
- /* Also offer non-SASL authentication
- cprintf("<auth xmlns=\"http://jabber.org/features/iq-auth\"/>"); */
+ /* Also offer non-SASL authentication */
+ cprintf("<auth xmlns=\"http://jabber.org/features/iq-auth\"/>");
}
/* Offer binding and sessions as part of our feature set */
if (XMPP->chardata_len > 0) {
safestrncpy(XMPP->iq_client_resource, XMPP->chardata,
sizeof XMPP->iq_client_resource);
+ striplt(XMPP->iq_client_resource);
+ }
+ }
+
+ if (!strcasecmp(el, "username")) { /* NON SASL ONLY */
+ if (XMPP->chardata_len > 0) {
+ safestrncpy(XMPP->iq_client_username, XMPP->chardata,
+ sizeof XMPP->iq_client_username);
+ striplt(XMPP->iq_client_username);
+ }
+ }
+
+ if (!strcasecmp(el, "password")) { /* NON SASL ONLY */
+ if (XMPP->chardata_len > 0) {
+ safestrncpy(XMPP->iq_client_password, XMPP->chardata,
+ sizeof XMPP->iq_client_password);
+ striplt(XMPP->iq_client_password);
}
}
}
}
+ /*
+ * Non SASL authentication
+ */
+ else if (
+ (!strcasecmp(XMPP->iq_type, "set"))
+ && (!strcasecmp(XMPP->iq_query_xmlns, "jabber:iq:auth:query"))
+ ) {
+
+ jabber_non_sasl_authenticate(
+ XMPP->iq_id,
+ XMPP->iq_client_username,
+ XMPP->iq_client_password,
+ XMPP->iq_client_resource
+ );
+ }
+
/*
* If this <iq> stanza was a "bind" attempt, process it ...
*/
const char *CitadelServiceXMPP="XMPP";
-#endif /* HAVE_EXPAT */
-
CTDL_MODULE_INIT(jabber)
{
-#ifdef HAVE_EXPAT
if (!threading) {
CtdlRegisterServiceHook(config.c_xmpp_c2s_port,
NULL,
CtdlRegisterSessionHook(xmpp_logout_hook, EVT_LOGOUT);
CtdlRegisterSessionHook(xmpp_login_hook, EVT_UNSTEALTH);
CtdlRegisterSessionHook(xmpp_logout_hook, EVT_STEALTH);
- #else
- lprintf(CTDL_INFO, "This server is missing the Expat XML parser. Jabber service will be disabled.\n");
-#endif
}
/* return our Subversion id for the Log */