* ircutils: Fix incorrect log message on invalid STS policy
* STS: fix confusion over what a secure connection is
irclib computed 'secure_connection' when TLS is enabled and TLS certs
are checked; but ircutils used the value to parse STS policies, which
should only care about being TLS or not.
This commit fixes the incorrect parsing on unchecked-TLS, and triggers
a reconnect when a STS policy is encountered in this case, to force
TLS certs to be checked before storing the policy.
* Accept STS policies when reconnecting after getting it over cleartext
ircutils.parseStsPolicy() was passed self.driver.ssl which is the configured
value, even though the connection was forced to be TLS temporarily
* ci: Lower timeout
* Fix typo in test name
Co-authored-by: James Lu <james@overdrivenetworks.com>
---------
Co-authored-by: James Lu <james@overdrivenetworks.com>
`registry.Value.__call__()` is a wrapper around access to
`registry.Value.value`, that checks if the value was set before the latest
call to `registry.open_registry`; and updates the `value` if needed.
When accessing `registry.Value.value` directly, this cache can't be
invalidated, causing the old value to still be used, until the next call
to `registry.Value.__call__()`.
This commit reverts db7ef3f025
(though it keeps the year updates)
After discussion with several people, it seems better to mention
copyright owners explicitly. eg. https://reuse.software/faq/#vcs-copyright
explains the issue of using VCSs to track copyright.
As db7ef3f025 only replaced mentions
of my name with 'The Limnoria Contributors', this commit only needs
to undo that + add one person who contributed to setup.py.
When a driver's run() method crashes, supybot.drivers.run() marks it
as dead and sets its 'irc' attribute to None.
This would be fine for "normal" independent drivers (like Socket used
to be), because this driver would never be called again.
But now that we use select(), some other thread may hold a reference
to this driver in a select() call frame, and call the dead driver's
'_read()' method when there is data to be read from the socket.
There is already a safeguard in '_read()' in the case the socket could
be read from, but this safeguard was missing from _handleSocketError.
This caused the "live" driver's select() to crash, which propagagated
to its run(), which caused the driver to be marked as dead, etc.
Eventually, all drivers could die, and we end up with the dreadful
"Schedule is the only remaining driver, why do we continue to live?"
in an infinite loop.
Otherwise, if some IP addresses don't work (eg. all odd ones), the bot will
consecutively fail because it can't connect, then connect + get STS + reconnect,
then fail again, then connect + get STS, etc.
Fixes a regression in ecc2c32950 that caused
Socket.py to ignore the IP address entirely after computing it, and
to call getSocket() and connect() with the hostname instead.
So far Limnoria relied on detecting 'ERROR :closing link' (see doError
in src/irclib.py), but that's not a standard at all, and fails on
Oragono; so we need to do this to check we're disconnected.
Plus, parsing the argument of ERROR is awful in the first place.
setTimeout may be called as a supybot.drivers.poll callback,
which may by the access to supybot.drivers.poll() in _select;
so a crash in setTimeout will propage up to _run(), which would
cause a random driver to be killed because another one failed
and that's bad.
For example:
INFO 2020-05-27T18:40:18 supybot Received SIGHUP, reloading configuration.
ERROR 2020-05-27T18:40:19 supybot Uncaught exception in in drivers.run:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/supybot/drivers/__init__.py", line 104, in run
driver.run()
File "/usr/lib/python3/dist-packages/supybot/drivers/Socket.py", line 194, in run
self._select()
File "/usr/lib/python3/dist-packages/supybot/drivers/Socket.py", line 167, in _select
[], [], conf.supybot.drivers.poll())
File "/usr/lib/python3/dist-packages/supybot/registry.py", line 422, in __call__
self.set(_cache[self._name])
File "/usr/lib/python3/dist-packages/supybot/registry.py", line 476, in set
self.setValue(float(s))
File "/usr/lib/python3/dist-packages/supybot/registry.py", line 495, in setValue
super(PositiveFloat, self).setValue(v)
File "/usr/lib/python3/dist-packages/supybot/registry.py", line 482, in setValue
super(Float, self).setValue(float(v))
File "/usr/lib/python3/dist-packages/supybot/registry.py", line 385, in setValue
callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/supybot/drivers/Socket.py", line 305, in setTimeout
self.conn.settimeout(conf.supybot.drivers.poll())
OSError: [Errno 9] Bad file descriptor
ERROR 2020-05-27T18:40:19 supybot Exception id: 0x86ecf
INFO 2020-05-27T18:40:21 supybot Removing driver SocketDriver(Irc object for irchaven).
If on an insecure connection: reconnect.
If on a secure connect: store it and do nothing else.
For now, stored STS policies are not read when connecting to an
insecure server.
There's no reason to use it anymore instead of Socket.
It's already missing features compared to Socket, and I don't want to
maintain it anymore so it will keep getting worse.
The connect() method already adds it, so it was in the list twice
(added both by __init__() and connect()).
This caused _select() to call _read() twice on the same instance,
except there is usually nothing to read on the second call,
so it blocks for up to conf.supybot.drivers.poll().
Having it enabled by default would break existing bots just by
doing the update.
Let's just show a warning and give owners some time to update
their config, for the moment.