Commit Graph

31 Commits (1f800bcf69a1238520afd16223d491da6d3f17d8)

Author SHA1 Message Date
C. McEnroe df1e561378 Handle tags without values
Otherwise a tag with no value would cause a segfault trying to
unescape the NULL tag pointer. This shouldn't happen for the server
tags we parse, but clients could send @+draft/reply with no value.
2021-08-15 12:24:15 -04:00
C. McEnroe a585b1b073 Silence maybe uninitialized warning
Wouldn't happen anyway since configPath will always return at least
one path.
2021-08-09 20:12:44 -04:00
Klemens Nanni ae332f6e8d Perform TLS handshake after final pledge
ircConnect() yields a connected TCP socket after which "inet dns" is
no longer needed.

Possibly having loaded private key material, it seems a tad more
comforting to speak TLS *after* dropping any network capabilities
(except for socket read/write to the IRC host, of course).

Instead of moving the final pledge into irc.c:ircConnect() and thus
complicating the code around pledge across two C modules, simply
stub out an mnemonic ircHandshake() and call that explicitly.

This restores behaviour gained with
981ebc4 "Remove explicit tls_handshake(3) from ircConnect" which
was reverted for other reasons.
2021-07-13 15:21:57 -04:00
Klemens Nanni ae64d277b8 Explicitly clear TLS secrets afer handshake
No need to keep them at runtime;  do so unconditionally for the sake of
simplicity.

Declare TLS config globally so ircConnect() can clear it and declare
both client and config statically as they are not used outside the irc.c
module.
2021-07-13 15:17:35 -04:00
Klemens Nanni 40b3f52aaf Revert "Remove explicit tls_handshake(3) from ircConnect"
This reverts commit 981ebc4f12.

This broke `-o' to print the server certificate;  without explicit
handshake there will be no tls_read(3) in this short code path.
2021-07-13 15:17:22 -04:00
C. McEnroe 981ebc4f12 Remove explicit tls_handshake(3) from ircConnect
The first call to ircFormat, which calls tls_write(3) in turn, will
perform the handshake anyway. This way the handshake happens after
the final pledge(2) call.
2021-06-25 11:50:14 -04:00
C. McEnroe a0cc519829 Move setting CLOEXEC on socket to ircConnect 2021-06-25 11:50:14 -04:00
Klemens Nanni 2b7f62dbd4 Handle EINTR from connect(2) gracefully
Resizing the window early on may return early due to SIGWINCH.
Continue asynchronously in that case instead of exiting.
2021-06-21 17:58:28 -04:00
Klemens Nanni 585039fb6e Use "secure" libtls ciphers
d3e90b6 'Use libtls "compat" ciphers' from 2018 fell back to "compat"
ciphers to support irc.mozilla.org which now yields NXDOMAIN.

All modern networks (should) support secure ciphers, so drop the
hopefully unneeded list of less secure ciphers by avoiding
tls_config_set_ciphers(3) and therefore sticking to the "secure" aka.
"default" set of ciphers in libtls.

A quick check shows that almost all of the big/known IRC networks
support TLS1.3 already;  those who do not at least comply with
SSL_CTX_set_cipher_list(3)'s "HIGH" set as can be tested like this:

	echo \
	  irc.hackint.org \
	  irc.tilde.chat \
	  irc.libera.chat \
	  irc.efnet.nl \
	  irc.oftc.net |
	xargs -tn1 \
	openssl s_client -quiet -cipher HIGH -no_ign_eof -port 6697 -host
2021-06-20 20:25:56 -04:00
C. McEnroe b3631a7e32 Handle TLS_WANNT_POLL{IN,OUT} from tls_handshake(3)
For blocking sockets it should be retried immediately.
2021-06-20 16:48:53 -04:00
C. McEnroe 0b4004c202 Only explicitly load the default CA file on OpenBSD 2021-06-10 15:23:33 -04:00
Klemens Nanni 171a56ee2d Hoist loading default root certificates into ircConfig()
tls_connect_socket(3) in ircConnect() does that by default already
unless tls_config_set_ca_file(3) was used.

Loading CA certificates before connecting makes no practical difference
except on OpenBSD where this allows for tighter unveil und pledge setups
now that all required (TLS related) file I/O is finished by the time
ircConnect() gets to do network I/O.

In case of the hidden `-!' insecure flag which is implied by `-o' to
print server certificates and exit, loading root certificates is not
required at all;  likewise, using explicit self signed server
certificates will not involve certificate authorities either, hence load
them only if needed.
2021-06-10 14:44:35 -04:00
C. McEnroe c6cd90c2dd Print chain to stdout with -o 2021-01-10 18:00:41 -05:00
C. McEnroe e42b3aa08e Add -o and -t options to trust self-signed certificates 2021-01-09 19:11:57 -05:00
C. McEnroe 8190d76086 Use a static buffer for base directory paths 2020-08-21 16:49:10 -04:00
C. McEnroe d9a0364cb4 Use configPath to load TLS cert/priv 2020-08-20 14:56:13 -04:00
C. McEnroe 814c36223a Say "OpenSSL" in additional permission notices
LibreSSL is "a modified version of that library".
2020-08-04 12:19:14 -04:00
C. McEnroe 5873d8b5a7 Remove tls_close error handling
It seems that sometimes tls_close returns non-zero but tls_error returns
a null string... We're exiting anyway, so just ignore it.
2020-07-23 14:20:29 -04:00
C. McEnroe 94fb9798c5 Bump ParamCap to 254
Apparently IRCds have decided that the 15-parameter limit doesn't matter
anymore. 254 is the maximum number of single-byte parameters (following
a single-byte command) which fit in a 512-byte CR-LF-terminated line.
When everyone decides that the 512-byte line length limit doesn't matter
either, I will delete my software and people can use some JavaScript
garbage instead.

This makes struct Message 2080 bytes, but there's only ever one or two
of them around at once. Avoid passing it by value to handle.
2020-06-24 13:36:24 -04:00
C. McEnroe 721c3a9ee6 Add additional permission for linking with LibreSSL
https://www.gnu.org/licenses/gpl-faq.en.html#GPLIncompatibleLibs
2020-06-08 17:48:07 -04:00
multiplexd 460207440b Use the correct hostname in error message
Previously, the remote host to which catgirl(1) is connecting was used
in error reporting instead of the local bind address if the latter could
not be resolved.
2020-02-17 23:07:29 -05:00
C. McEnroe b20be7cbad Various small cleanups
Haven't really gone through ui.c yet.
2020-02-16 23:05:43 -05:00
C. McEnroe 700b5d5870 Replace small integers in size_t with uint 2020-02-15 22:19:55 -05:00
C. McEnroe 0a772ff139 Explicitly close the TLS connection
Just to be nice.
2020-02-13 01:01:23 -05:00
multiplexd 1e544ce482 Implement source address selection
This commit adds a '-S' command line option and a "bind"
configuration file option to specify the source address to bind to when
connecting to the IRC server.
2020-02-13 00:05:52 +00:00
C. McEnroe 8b3bf897c2 Search for cert and priv in config dirs 2020-02-06 02:21:04 -05:00
C. McEnroe d57df09511 Align word wrapping with tab character
Also fixes handling whitespace directly after control codes.
2020-02-04 19:50:23 -05:00
C. McEnroe 052cd2ed26 Remove style string macros 2020-02-02 03:34:05 -05:00
C. McEnroe e5363bcae0 Implement the beginnings of UI
It takes so much code to do anything in curses...
2020-02-01 19:37:55 -05:00
C. McEnroe 2b3a8bfb9c Add -v flag 2020-02-01 02:26:35 -05:00
C. McEnroe 8431602363 Blindly implement login flow 2020-02-01 01:18:01 -05:00