Make cyrus-sasl required

Thu, 11 Aug 2022 21:56:21 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 11 Aug 2022 21:56:21 -0500
changeset 41488
95f59c2bc50d
parent 41487
86b6cbbee778
child 41489
8026339f5ace

Make cyrus-sasl required

Testing Done:
Compiled

Reviewed at https://reviews.imfreedom.org/r/1579/

libpurple/protocols/irc/irc.c file | annotate | diff | comparison | revisions
libpurple/protocols/irc/irc.h file | annotate | diff | comparison | revisions
libpurple/protocols/irc/msgs.c file | annotate | diff | comparison | revisions
libpurple/protocols/irc/parse.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/auth.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/auth.h file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/jabber.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/jabber.h file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/xmpp.c file | annotate | diff | comparison | revisions
meson.build file | annotate | diff | comparison | revisions
meson_options.txt file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/irc/irc.c	Thu Aug 11 21:26:10 2022 -0500
+++ b/libpurple/protocols/irc/irc.c	Thu Aug 11 21:56:21 2022 -0500
@@ -413,7 +413,6 @@
 	option = purple_account_option_bool_new(_("Use SSL"), "ssl", FALSE);
 	opts = g_list_append(opts, option);
 
-#ifdef HAVE_CYRUS_SASL
 	option = purple_account_option_bool_new(_("Authenticate with SASL"),
 	                                        "sasl", FALSE);
 	opts = g_list_append(opts, option);
@@ -422,7 +421,6 @@
 	                                          "unencrypted connection"),
 	                                        "auth_plain_in_clear", FALSE);
 	opts = g_list_append(opts, option);
-#endif
 
 	return opts;
 }
@@ -601,16 +599,12 @@
 	const char *nickname, *identname, *realname;
 	struct irc_conn *irc = purple_connection_get_protocol_data(gc);
 	const char *pass = purple_connection_get_password(gc);
-#ifdef HAVE_CYRUS_SASL
 	const gboolean use_sasl = purple_account_get_bool(irc->account, "sasl", FALSE);
-#endif
 
 	if (pass && *pass) {
-#ifdef HAVE_CYRUS_SASL
 		if (use_sasl)
 			buf = irc_format(irc, "vv:", "CAP", "REQ", "sasl");
-		else /* intended to fall through */
-#endif
+		else
 			buf = irc_format(irc, "v:", "PASS", pass);
 		if (irc_send(irc, buf) < 0) {
 			g_free(buf);
@@ -728,7 +722,6 @@
 	g_free(irc->mode_chars);
 	g_free(irc->reqnick);
 
-#ifdef HAVE_CYRUS_SASL
 	if (irc->sasl_conn) {
 		sasl_dispose(&irc->sasl_conn);
 		irc->sasl_conn = NULL;
@@ -736,7 +729,6 @@
 	g_free(irc->sasl_cb);
 	if(irc->sasl_mechs)
 		g_string_free(irc->sasl_mechs, TRUE);
-#endif
 
 
 	g_free(irc);
--- a/libpurple/protocols/irc/irc.h	Thu Aug 11 21:26:10 2022 -0500
+++ b/libpurple/protocols/irc/irc.h	Thu Aug 11 21:56:21 2022 -0500
@@ -26,9 +26,7 @@
 
 #include <config.h>
 
-#ifdef HAVE_CYRUS_SASL
 #include <sasl/sasl.h>
-#endif
 
 #include <purple.h>
 
@@ -97,13 +95,11 @@
 	char *mode_chars;
 	char *reqnick;
 	gboolean nickused;
-#ifdef HAVE_CYRUS_SASL
 	sasl_conn_t *sasl_conn;
 	const char *current_mech;
 	GString *sasl_mechs;
 	gboolean mech_works;
 	sasl_callback_t *sasl_cb;
-#endif
 };
 
 struct irc_buddy {
@@ -181,14 +177,12 @@
 void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_who(struct irc_conn *irc, const char *name, const char *from, char **args);
-#ifdef HAVE_CYRUS_SASL
 void irc_msg_cap(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_auth(struct irc_conn *irc, char *arg);
 void irc_msg_authenticate(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_authok(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_authtryagain(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_authfail(struct irc_conn *irc, const char *name, const char *from, char **args);
-#endif
 
 void irc_cmd_table_build(struct irc_conn *irc);
 
--- a/libpurple/protocols/irc/msgs.c	Thu Aug 11 21:26:10 2022 -0500
+++ b/libpurple/protocols/irc/msgs.c	Thu Aug 11 21:56:21 2022 -0500
@@ -35,9 +35,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#ifdef HAVE_CYRUS_SASL
 #include <sasl/sasl.h>
-#endif
 
 static char *irc_mask_nick(const char *mask);
 static char *irc_mask_userhost(const char *mask);
@@ -49,9 +47,7 @@
                                    const char *from, const char *to,
                                    const char *rawmsg, gboolean notice);
 
-#ifdef HAVE_CYRUS_SASL
 static void irc_sasl_finish(struct irc_conn *irc);
-#endif
 
 static char *irc_mask_nick(const char *mask)
 {
@@ -1464,7 +1460,6 @@
 	g_free(msg);
 }
 
-#ifdef HAVE_CYRUS_SASL
 static int
 irc_sasl_cb_secret(sasl_conn_t *conn, void *ctx, int id, sasl_secret_t **secret)
 {
@@ -1862,4 +1857,3 @@
 	irc_send(irc, buf);
 	g_free(buf);
 }
-#endif
--- a/libpurple/protocols/irc/parse.c	Thu Aug 11 21:26:10 2022 -0500
+++ b/libpurple/protocols/irc/parse.c	Thu Aug 11 21:56:21 2022 -0500
@@ -104,7 +104,6 @@
 	{ "501", "n:", 2, irc_msg_badmode },		/* Unknown mode flag		*/
 	{ "506", "nc:", 3, irc_msg_nosend },		/* Must identify to send	*/
 	{ "515", "nc:", 3, irc_msg_regonly },		/* Registration required	*/
-#ifdef HAVE_CYRUS_SASL
 	{ "903", "*", 0, irc_msg_authok},		/* SASL auth successful		*/
 	{ "904", "*", 0, irc_msg_authtryagain },	/* SASL auth failed, can recover*/
 	{ "905", "*", 0, irc_msg_authfail },		/* SASL auth failed		*/
@@ -112,7 +111,6 @@
 	{ "907", "*", 0, irc_msg_authfail },		/* SASL auth failed		*/
 	{ "cap", "vv:", 3, irc_msg_cap },		/* SASL capable			*/
 	{ "authenticate", ":", 1, irc_msg_authenticate }, /* SASL authenticate		*/
-#endif
 	{ "invite", "n:", 2, irc_msg_invite },		/* Invited			*/
 	{ "join", ":", 1, irc_msg_join },		/* Joined a channel		*/
 	{ "kick", "cn:", 3, irc_msg_kick },		/* KICK				*/
@@ -715,11 +713,9 @@
 		}
 		purple_connection_take_error(gc, error);
 		return;
-#ifdef HAVE_CYRUS_SASL
 	} else if (!strncmp(input, "AUTHENTICATE ", 13)) {
 		irc_msg_auth(irc, input + 13);
 		return;
-#endif
 	}
 
 	if (input[0] != ':' || (cur = strchr(input, ' ')) == NULL) {
--- a/libpurple/protocols/jabber/auth.c	Thu Aug 11 21:26:10 2022 -0500
+++ b/libpurple/protocols/jabber/auth.c	Thu Aug 11 21:56:21 2022 -0500
@@ -73,7 +73,6 @@
 		_("Server requires plaintext authentication over an unencrypted stream"));
 }
 
-#ifdef HAVE_CYRUS_SASL
 static void
 auth_old_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields)
 {
@@ -122,7 +121,6 @@
 	/* Disable the account as the user has cancelled connecting */
 	purple_account_set_enabled(purple_connection_get_account(gc), FALSE);
 }
-#endif
 
 void
 jabber_auth_start(JabberStream *js, PurpleXmlNode *packet)
@@ -366,17 +364,14 @@
 		js->user->resource = g_strdup("Home");
 	}
 
-#ifdef HAVE_CYRUS_SASL
-	/* If we have Cyrus SASL, then passwords will have been set
-	 * to OPTIONAL for this protocol. So, we need to do our own
-	 * password prompting here
+	/* With Cyrus SASL, passwords are optional for this protocol. So, we need to
+	 * do our own password prompting here
 	 */
 
 	if (!purple_connection_get_password(js->gc)) {
 		purple_account_request_password(account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc);
 		return;
 	}
-#endif
 	iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:auth");
 
 	query = purple_xmlnode_get_child(iq->node, "query");
@@ -519,9 +514,7 @@
 
 	jabber_auth_add_mech(jabber_auth_get_plain_mech());
 	jabber_auth_add_mech(jabber_auth_get_digest_md5_mech());
-#ifdef HAVE_CYRUS_SASL
 	jabber_auth_add_mech(jabber_auth_get_cyrus_mech());
-#endif
 #ifdef HAVE_WEBEX_TOKEN
 	jabber_auth_add_mech(jabber_auth_get_webex_token_mech());
 #endif
--- a/libpurple/protocols/jabber/auth.h	Thu Aug 11 21:26:10 2022 -0500
+++ b/libpurple/protocols/jabber/auth.h	Thu Aug 11 21:56:21 2022 -0500
@@ -56,9 +56,7 @@
 JabberSaslMech *jabber_auth_get_plain_mech(void);
 JabberSaslMech *jabber_auth_get_digest_md5_mech(void);
 JabberSaslMech **jabber_auth_get_scram_mechs(gint *count);
-#ifdef HAVE_CYRUS_SASL
 JabberSaslMech *jabber_auth_get_cyrus_mech(void);
-#endif
 JabberSaslMech *jabber_auth_get_webex_token_mech(void);
 
 void jabber_auth_add_mech(JabberSaslMech *);
--- a/libpurple/protocols/jabber/jabber.c	Thu Aug 11 21:26:10 2022 -0500
+++ b/libpurple/protocols/jabber/jabber.c	Thu Aug 11 21:56:21 2022 -0500
@@ -463,7 +463,6 @@
 
 	/* If we've got a security layer, we need to encode the data,
 	 * splitting it on the maximum buffer length negotiated */
-#ifdef HAVE_CYRUS_SASL
 	if (js->sasl_maxbuf>0) {
 		int pos = 0;
 
@@ -502,7 +501,6 @@
 		}
 		return;
 	}
-#endif
 
 	if (js->bosh)
 		jabber_bosh_connection_send(js->bosh, data);
@@ -618,7 +616,6 @@
 		}
 
 		purple_connection_update_last_received(gc);
-#ifdef HAVE_CYRUS_SASL
 		if (js->sasl_maxbuf > 0) {
 			const char *out;
 			unsigned int olen;
@@ -643,7 +640,6 @@
 			}
 			return G_SOURCE_CONTINUE;
 		}
-#endif
 		buf[len] = '\0';
 		purple_debug_misc("jabber", "Recv (%" G_GSSIZE_FORMAT "): %s", len,
 		                  buf);
@@ -1588,7 +1584,6 @@
 
 	if (js->auth_mech && js->auth_mech->dispose)
 		js->auth_mech->dispose(js);
-#ifdef HAVE_CYRUS_SASL
 	if(js->sasl)
 		sasl_dispose(&js->sasl);
 	if(js->sasl_mechs)
@@ -1597,7 +1592,6 @@
 	/* Note: _not_ g_free.  See auth_cyrus.c:jabber_sasl_cb_secret */
 	free(js->sasl_secret);
 	g_free(js->sasl_password);
-#endif
 	g_free(js->serverFQDN);
 	g_list_free_full(js->commands, (GDestroyNotify)jabber_adhoc_commands_free);
 	g_free(js->server_name);
@@ -3638,7 +3632,6 @@
 	const gchar *type = "pc"; /* default client type, if unknown or
 								unspecified */
 	const gchar *ui_name = NULL;
-#ifdef HAVE_CYRUS_SASL
 	/* We really really only want to do this once per process */
 	static gboolean sasl_initialized = FALSE;
 #ifdef _WIN32
@@ -3646,10 +3639,8 @@
 	gchar *sasldir;
 #endif
 	int ret;
-#endif
 
 	/* XXX - If any other plugin wants SASL this won't be good ... */
-#ifdef HAVE_CYRUS_SASL
 	if (!sasl_initialized) {
 		sasl_initialized = TRUE;
 #ifdef _WIN32
@@ -3667,7 +3658,6 @@
 		SetErrorMode(old_error_mode);
 #endif
 	}
-#endif
 
 	jabber_cmds = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, cmds_free_func);
 
--- a/libpurple/protocols/jabber/jabber.h	Thu Aug 11 21:26:10 2022 -0500
+++ b/libpurple/protocols/jabber/jabber.h	Thu Aug 11 21:56:21 2022 -0500
@@ -69,9 +69,7 @@
 #include "buddy.h"
 #include "bosh.h"
 
-#ifdef HAVE_CYRUS_SASL
 #include <sasl/sasl.h>
-#endif
 
 #define CAPS0115_NODE "https://pidgin.im/"
 
@@ -196,7 +194,6 @@
 
 	char *serverFQDN;
 
-#ifdef HAVE_CYRUS_SASL
 	sasl_conn_t *sasl;
 	sasl_callback_t *sasl_cb;
 	sasl_secret_t *sasl_secret;
@@ -208,7 +205,6 @@
 	GString *sasl_mechs;
 
 	gchar *sasl_password;
-#endif
 
 	gboolean unregistration;
 	PurpleAccountUnregistrationCb unregistration_cb;
--- a/libpurple/protocols/jabber/xmpp.c	Thu Aug 11 21:26:10 2022 -0500
+++ b/libpurple/protocols/jabber/xmpp.c	Thu Aug 11 21:56:21 2022 -0500
@@ -129,11 +129,8 @@
 	PurpleProtocolOptions options;
 
 	options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME |
-	          OPT_PROTO_MAIL_CHECK | OPT_PROTO_SLASH_COMMANDS_NATIVE;
-
-#ifdef HAVE_CYRUS_SASL
-	options |= OPT_PROTO_PASSWORD_OPTIONAL;
-#endif
+	          OPT_PROTO_MAIL_CHECK | OPT_PROTO_SLASH_COMMANDS_NATIVE |
+	          OPT_PROTO_PASSWORD_OPTIONAL;
 
 	return PURPLE_PROTOCOL(g_object_new(
 		XMPP_TYPE_PROTOCOL,
--- a/meson.build	Thu Aug 11 21:26:10 2022 -0500
+++ b/meson.build	Thu Aug 11 21:56:21 2022 -0500
@@ -577,8 +577,7 @@
 	conf.set('HAVE_' + func.to_upper(),
 	    compiler.has_function(func))
 endforeach
-sasl = dependency('libsasl2', version : '>= 2.0', required : get_option('cyrus-sasl'))
-conf.set('HAVE_CYRUS_SASL', sasl.found())
+sasl = dependency('libsasl2', version : '>= 2.0')
 
 #######################################################################
 # Check for external libzephyr
--- a/meson_options.txt	Thu Aug 11 21:26:10 2022 -0500
+++ b/meson_options.txt	Thu Aug 11 21:56:21 2022 -0500
@@ -40,9 +40,6 @@
 option('avahi', type : 'feature',
        description : 'compile with avahi (required for Bonjour support)')
 
-option('cyrus-sasl', type : 'feature',
-       description : 'enable Cyrus SASL support for XMPP/IRC')
-
 option('dynamic-prpls', type : 'string', value: 'all',
        description : 'specify which protocols to build dynamically')
 

mercurial