summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2014-01-12 07:10:26 -0500
committerTingPing <tingping@tingping.se>2014-01-12 07:10:26 -0500
commit0f0dabdcf46d6650addfc854a39eecfb49189c7f (patch)
tree93945296dfaded4ac875334acb5e9123a92ef0d8 /src
parenta817072e6fd208f6f26253d5fc18cc6dd0e09a17 (diff)
Support numeric 908
Diffstat (limited to 'src')
-rw-r--r--src/common/inbound.c49
-rw-r--r--src/common/proto-irc.c3
2 files changed, 32 insertions, 20 deletions
diff --git a/src/common/inbound.c b/src/common/inbound.c
index a157a347..d1c5b51a 100644
--- a/src/common/inbound.c
+++ b/src/common/inbound.c
@@ -1830,33 +1830,43 @@ static const char *sasl_mechanisms[] =
 };
 
 void
+inbound_sasl_supportedmechs (server *serv, char *list)
+{
+	int i;
+
+	if (serv->sasl_mech != MECH_EXTERNAL)
+	{
+		/* Use most secure one supported */
+		for (i = MECH_AES; i >= MECH_PLAIN; i--)
+		{
+			if (strstr (list, sasl_mechanisms[i]) != NULL)
+			{
+				serv->sasl_mech = i;
+				serv->retry_sasl = TRUE;
+				tcp_sendf (serv, "AUTHENTICATE %s\r\n", sasl_mechanisms[i]);
+				return;
+			}
+		}
+	}
+
+	/* Abort, none supported */
+	serv->sent_saslauth = TRUE;
+	tcp_sendf (serv, "AUTHENTICATE *\r\n");
+	return;
+}
+
+void
 inbound_sasl_authenticate (server *serv, char *data)
 {
 		ircnet *net = (ircnet*)serv->network;
 		char *user, *pass = NULL;
 		const char *mech = sasl_mechanisms[serv->sasl_mech];
-		int i;
 
-		/* Got a list of supported mechanisms */
+		/* Got a list of supported mechanisms from inspircd */
 		if (strchr (data, ',') != NULL)
 		{
-			if (serv->sasl_mech == MECH_EXTERNAL)
-				goto sasl_abort;
-
-			/* Use most secure one supported */
-			for (i = MECH_AES; i >= MECH_PLAIN; i--)
-			{
-				if (strstr (data, sasl_mechanisms[i]) != NULL)
-				{
-					serv->sasl_mech = i;
-					serv->retry_sasl = TRUE;
-					tcp_sendf (serv, "AUTHENTICATE %s\r\n", sasl_mechanisms[i]);
-					return;
-				}
-			}
-
-			/* Nothing we support */
-			goto sasl_abort;
+			inbound_sasl_supportedmechs (serv, data);
+			return;
 		}
 
 		if (net->user && !(net->flags & FLAG_USE_GLOBAL))
@@ -1882,7 +1892,6 @@ inbound_sasl_authenticate (server *serv, char *data)
 #endif
 		}
 
-sasl_abort:
 		if (pass == NULL)
 		{
 			/* something went wrong abort */
diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c
index 6d7c7fc1..2a4b3361 100644
--- a/src/common/proto-irc.c
+++ b/src/common/proto-irc.c
@@ -968,6 +968,9 @@ process_numeric (session * sess, int n,
 			tcp_send_len (serv, "CAP END\r\n", 9);
 		}
 		break;
+	case 908:	/* Supported SASL Mechs */
+		inbound_sasl_supportedmechs (serv, word_eol[3]+1);
+		break;
 
 	default: