Skip to content

Commit 3a81b0c

Browse files
authored
Merge pull request #1971 from Exirel/core-sasl-fail
core: quit after SASL Auth failed
2 parents 92185b6 + 0557c43 commit 3a81b0c

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

sopel/coretasks.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,11 @@ def receive_cap_list(bot, trigger):
684684
if req.success:
685685
req.success(bot, req.prefix + trigger)
686686
if cap == 'sasl': # TODO why is this not done with bot.cap_req?
687-
receive_cap_ack_sasl(bot)
687+
try:
688+
receive_cap_ack_sasl(bot)
689+
except ConfigurationError as error:
690+
LOGGER.error(str(error))
691+
bot.quit('Wrong SASL configuration.')
688692

689693

690694
def receive_cap_ls_reply(bot, trigger):
@@ -852,6 +856,19 @@ def sasl_success(bot, trigger):
852856
bot.write(('CAP', 'END'))
853857

854858

859+
@plugin.event(events.ERR_SASLFAIL)
860+
@plugin.event(events.ERR_SASLTOOLONG)
861+
@plugin.event(events.ERR_SASLABORTED)
862+
@plugin.event(events.ERR_NICKLOCKED)
863+
@plugin.unblockable
864+
@plugin.thread(False)
865+
def sasl_fail(bot, trigger):
866+
"""SASL Auth Failed: log the error and quit."""
867+
LOGGER.error(
868+
'SASL Auth Failed; check your configuration: %s', str(trigger))
869+
bot.quit('SASL Auth Failed')
870+
871+
855872
@module.event(events.RPL_SASLMECHS)
856873
@module.unblockable
857874
def sasl_mechs(bot, trigger):
@@ -880,10 +897,13 @@ def sasl_mechs(bot, trigger):
880897
881898
See https://github.com/sopel-irc/sopel/issues/1780 for background
882899
"""
883-
raise ConfigurationError(
884-
"Configured SASL mechanism '{}' is not advertised by this server. "
885-
"Advertised values: {}"
886-
.format(mech, ', '.join(supported_mechs)))
900+
LOGGER.error(
901+
"Configured SASL mechanism '%s' is not advertised by this server. "
902+
"Advertised values: %s",
903+
mech,
904+
', '.join(supported_mechs),
905+
)
906+
bot.quit('Wrong SASL configuration.')
887907

888908

889909
def _get_sasl_pass_and_mech(bot):

0 commit comments

Comments
 (0)