pidgin/pidgin

ed2b25ccdf2c
Parents 770040cb6000
Children b6896c389190
Add a field in IRC where users can explicitly set the SASL login name

Testing Done:
Tested by setting the SASL login name and connecting with an alternative nickname. Also tested the fallback behavior in case SASL login name isn't set, but the user wants to login with SASL anyway.

Bugs closed: PIDGIN-15451

Reviewed at https://reviews.imfreedom.org/r/1388/
--- a/libpurple/protocols/irc/irc.c Thu Apr 21 20:19:21 2022 -0500
+++ b/libpurple/protocols/irc/irc.c Thu Apr 21 20:20:12 2022 -0500
@@ -1099,6 +1099,9 @@
option = purple_account_option_bool_new(_("Authenticate with SASL"), "sasl", FALSE);
prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
+ option = purple_account_option_string_new(_("SASL login name"), "saslname", "");
+ prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
+
option = purple_account_option_bool_new(
_("Allow plaintext SASL auth over unencrypted connection"),
"auth_plain_in_clear", FALSE);
--- a/libpurple/protocols/irc/msgs.c Thu Apr 21 20:19:21 2022 -0500
+++ b/libpurple/protocols/irc/msgs.c Thu Apr 21 20:20:12 2022 -0500
@@ -1454,10 +1454,20 @@
{
struct irc_conn *irc = ctx;
PurpleConnection *gc = purple_account_get_connection(irc->account);
+ const char *saslname =
+ purple_account_get_string(irc->account, "saslname", NULL);
+
+ if(saslname == NULL || *saslname == '\0') {
+ saslname = purple_account_get_string(irc->account, "realname", "");
+ }
+
+ if(saslname == NULL || *saslname == '\0') {
+ saslname = purple_connection_get_display_name(gc);
+ }
switch(id) {
case SASL_CB_AUTHNAME:
- *res = purple_connection_get_display_name(gc);
+ *res = saslname;
break;
case SASL_CB_USER:
*res = "";