diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-common/irc/fe-sasl.c | 29 | ||||
-rw-r--r-- | src/fe-text/gui-printtext.c | 3 | ||||
-rw-r--r-- | src/fe-text/statusbar-config.c | 2 | ||||
-rw-r--r-- | src/irc/core/irc-servers.h | 1 | ||||
-rw-r--r-- | src/irc/core/sasl.c | 7 | ||||
-rw-r--r-- | src/perl/irc/Irc.xs | 1 |
6 files changed, 41 insertions, 2 deletions
diff --git a/src/fe-common/irc/fe-sasl.c b/src/fe-common/irc/fe-sasl.c index 331b38b0..fc8105fc 100644 --- a/src/fe-common/irc/fe-sasl.c +++ b/src/fe-common/irc/fe-sasl.c @@ -1,7 +1,7 @@ /* fe-sasl.c : irssi - Copyright (C) 2015 The Lemon Man + Copyright (C) 2015-2017 The Lemon Man This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,11 @@ #include "module-formats.h" #include "signals.h" #include "levels.h" +#include "misc.h" +#include "sasl.h" + +#include "irc-servers.h" +#include "settings.h" #include "printtext.h" @@ -35,14 +40,36 @@ static void sig_sasl_failure(IRC_SERVER_REC *server, const char *reason) printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_SASL_ERROR, reason); } +static void sig_cap_end(IRC_SERVER_REC *server) +{ + /* The negotiation has now been terminated, if we didn't manage to + * authenticate successfully with the server just disconnect. */ + if (!server->sasl_success && + server->connrec->sasl_mechanism != SASL_MECHANISM_NONE && + settings_get_bool("sasl_disconnect_on_failure")) { + /* We can't use server_disconnect() here because we'd end up + * freeing the 'server' object and be guilty of a slew of UaF. */ + server->connection_lost = TRUE; + /* By setting connection_lost we make sure the communication is + * halted and when the control goes back to irc_parse_incoming + * the server object is safely destroyed. */ + signal_stop(); + } + +} + void fe_sasl_init(void) { + settings_add_bool("server", "sasl_disconnect_on_failure", TRUE); + signal_add("server sasl success", (SIGNAL_FUNC) sig_sasl_success); signal_add("server sasl failure", (SIGNAL_FUNC) sig_sasl_failure); + signal_add_first("server cap end", (SIGNAL_FUNC) sig_cap_end); } void fe_sasl_deinit(void) { signal_remove("server sasl success", (SIGNAL_FUNC) sig_sasl_success); signal_remove("server sasl failure", (SIGNAL_FUNC) sig_sasl_failure); + signal_remove("server cap end", (SIGNAL_FUNC) sig_cap_end); } diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c index 775e6044..a07451fa 100644 --- a/src/fe-text/gui-printtext.c +++ b/src/fe-text/gui-printtext.c @@ -169,7 +169,8 @@ static void get_colors(int flags, int *fg, int *bg, int *attr) if (*bg >= 0) { *bg = mirc_colors[*bg % 100]; flags &= ~GUI_PRINT_FLAG_COLOR_24_BG; - if (settings_get_bool("mirc_blink_fix")) { + /* ignore mirc color 99 = -1 (reset) */ + if (*bg != -1 && settings_get_bool("mirc_blink_fix")) { if (*bg < 16) /* ansi bit flip :-( */ *bg = (*bg&8) | (*bg&4)>>2 | (*bg&2) | (*bg&1)<<2; *bg = term_color256map[*bg&0xff] & 7; diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c index a47a709e..48f4aa61 100644 --- a/src/fe-text/statusbar-config.c +++ b/src/fe-text/statusbar-config.c @@ -194,6 +194,8 @@ static void statusbar_read_group(CONFIG_NODE *node) STATUSBAR_GROUP_REC *group; GSList *tmp; + g_return_if_fail(is_node_list(node)); + group = statusbar_group_find(node->key); if (group == NULL) { group = statusbar_group_create(node->key); diff --git a/src/irc/core/irc-servers.h b/src/irc/core/irc-servers.h index bb100f86..09f3f81d 100644 --- a/src/irc/core/irc-servers.h +++ b/src/irc/core/irc-servers.h @@ -68,6 +68,7 @@ struct _IRC_SERVER_REC { unsigned int motd_got:1; /* We've received MOTD */ unsigned int isupport_sent:1; /* Server has sent us an isupport reply */ unsigned int cap_complete:1; /* We've done the initial CAP negotiation */ + unsigned int sasl_success:1; /* Did we authenticate successfully ? */ int max_kicks_in_cmd; /* max. number of people to kick with one /KICK command */ int max_modes_in_cmd; /* max. number of mode changes in one /MODE command */ diff --git a/src/irc/core/sasl.c b/src/irc/core/sasl.c index a1c16cdd..1021bea4 100644 --- a/src/irc/core/sasl.c +++ b/src/irc/core/sasl.c @@ -48,6 +48,7 @@ static gboolean sasl_timeout(IRC_SERVER_REC *server) cap_finish_negotiation(server); server->sasl_timeout = 0; + server->sasl_success = FALSE; signal_emit("server sasl failure", 2, server, "The authentication timed out"); @@ -84,6 +85,8 @@ static void sasl_fail(IRC_SERVER_REC *server, const char *data, const char *from params = event_get_params(data, 2, NULL, &error); + server->sasl_success = FALSE; + signal_emit("server sasl failure", 2, server, error); /* Terminate the negotiation */ @@ -99,6 +102,8 @@ static void sasl_already(IRC_SERVER_REC *server, const char *data, const char *f server->sasl_timeout = 0; } + server->sasl_success = TRUE; + signal_emit("server sasl success", 1, server); /* We're already authenticated, do nothing */ @@ -112,6 +117,8 @@ static void sasl_success(IRC_SERVER_REC *server, const char *data, const char *f server->sasl_timeout = 0; } + server->sasl_success = TRUE; + signal_emit("server sasl success", 1, server); /* The authentication succeeded, time to finish the CAP negotiation */ diff --git a/src/perl/irc/Irc.xs b/src/perl/irc/Irc.xs index 8b3b0c45..41690010 100644 --- a/src/perl/irc/Irc.xs +++ b/src/perl/irc/Irc.xs @@ -32,6 +32,7 @@ static void perl_irc_server_fill_hash(HV *hv, IRC_SERVER_REC *server) (void) hv_store(hv, "isupport_sent", 13, newSViv(server->isupport_sent), 0); (void) hv_store(hv, "cap_complete", 12, newSViv(server->cap_complete), 0); + (void) hv_store(hv, "sasl_success", 12, newSViv(server->sasl_success), 0); av = newAV(); for (tmp = server->cap_supported; tmp != NULL; tmp = tmp->next) |