libpurple/protocols/jabber/auth_cyrus.c

changeset 40103
0d8e52078bc7
parent 38358
30ba44276e74
child 40358
e6fe6fc1f516
--- a/libpurple/protocols/jabber/auth_cyrus.c	Mon Oct 28 22:41:37 2019 -0400
+++ b/libpurple/protocols/jabber/auth_cyrus.c	Sun Oct 27 14:28:20 2019 -0400
@@ -402,11 +402,22 @@
 jabber_cyrus_start(JabberStream *js, PurpleXmlNode *mechanisms,
                    PurpleXmlNode **reply, char **error)
 {
-	PurpleXmlNode *mechnode;
+	PurpleXmlNode *mechnode, *hostname;
 	JabberSaslState ret;
 
 	js->sasl_mechs = g_string_new("");
 	js->sasl_password = g_strdup(purple_connection_get_password(js->gc));
+	/* XEP-0233 says we should grab the hostname for Kerberos v5, but there
+	 * is no claim about other SASL mechanisms. Fortunately, most don't
+	 * care what we use, so just use the domainpart. */
+	hostname = purple_xmlnode_get_child_with_namespace(
+	        mechanisms, "hostname", NS_XMPP_SERVER_REGISTRATION);
+	if (hostname) {
+		js->serverFQDN = purple_xmlnode_get_data(hostname);
+	}
+	if (js->serverFQDN == NULL) {
+		js->serverFQDN = g_strdup(js->user->domain);
+	}
 
 	for(mechnode = purple_xmlnode_get_child(mechanisms, "mechanism"); mechnode;
 			mechnode = purple_xmlnode_get_next_twin(mechnode))

mercurial