Val Lorentz [Fri, 19 Apr 2024 21:00:20 +0000 (23:00 +0200)]
Fix channel symbol returned by RPL_NAMREPLY for secret channels
References:
- https://modern.ircdocs.horse/#rplnamreply-353
- https://datatracker.ietf.org/doc/html/rfc2812#page-47
- (RFC 1459 is irrelevant here, as
https://datatracker.ietf.org/doc/html/rfc1459#page-51 uses a different
format)
Alexander Barton [Sat, 13 Apr 2024 17:43:54 +0000 (19:43 +0200)]
Don't abort startup when setgid/setuid() fails with EINVAL
Both setgid(2) as well as setuid(2) can fail with EINVAL in addition to
EPERM, their manual pages state "EINVAL: The user/group ID specified in
uid/gid is not valid in this user namespace ".
So not only treat EPERM as an "acceptable error" and continue with
logging the error, but do the same for EINVAL.
This was triggered by the Void Linux xbps-uunshare(1) tool used for
building "XBPS source packages" and reported by luca in #ngircd. Thanks!
Wait for the "ERROR :Closing connection" message sent by ngIRCd when
handling the QUIT command, do not wait for "Connection closed" which is
actually output by the telnet(1) command and is implementation
dependant! For example, on Haiku OS, this is not always(!) echoed (the
command seems to hang sometimes?) which results in unpredictable
failures in the test suite ...
- Try to only search for processes of the current user.
- Prefer using pgrep (in addition to pidof) when available.
- Streamline system overrides.
- Get rid of HEAD_FLAGS: all systems so far support "-1".
- Use "ps -o pid,comm" as the default, which is POSIX.1.
- Use "sort -r" to hopefully get the newest (=highest) PID, which is the
case on older systems not using randomized PIDs at least.
Revert "testsuite: Pass -nameopt to openssl s_client."
Although this is a nice looking solution, it is not that portable: for
example, the "openssl s_client" command of LibreSSL 3.8.2 on OpenBSD 7.4
does not support it.
So let's revert back to the "uglier" but working variant ...
Alexander Barton [Thu, 28 Mar 2024 09:16:44 +0000 (10:16 +0100)]
Try to set file descriptor limit to its maximum and show info on startup
The number of possible parallel connections is limited by the process
file descriptor limit (among other things). Therefore try to upgrade the
current "soft" limit to its "hard" maximum (but limit it to 100000), and
show an information or even warning, wenn still less than the configured
"MaxConnections" setting.
Please note that ngIRCd and its linked libraries (like PAM) need file
descriptors not only for incoming and outgoing IRC connections, but for
reading files and inter-process communication, too! Therefore the actual
connection limit is _less_ than the file descriptor limit!
This introduces the new MAX_FD_LIMIT (100000) #define.
S2S-TLS/GnuTLS: Fix handling of certificate information for incoming connections
Show proper certificate information for incoming connections, too, and
not "peer did not present a certificate", regardless if the client sent
a certificate or not.
This change is for GnuTLS and similar to what was implemented in commit
for OpenSSL in "S2S-TLS/OpenSSL: Fix handling of certificate information
for incoming connections".
S2S-TLS/GnuTLS: Update SSL code for GnuTLS certificate reloading
Without this, the S2S-TLS-Patch not even compiles with GnuTLS because
of the "new" GnuTLS certificate reload support implemented in commit eead4a63 ("x509_cred_slot").
This includes simplifying cb_connserver_login_ssl() a bit, we do not
have to code for invalid state which was ruled out by an assert() and
therefore can get rid of the goto altogether (and don't log the same
error twice with different messages).
S2S-TLS/OpenSSL: Postpone verification of TLS session right before server handshake
The verify callback in OpenSSL is called pretty early, and at that time
it is not possible yet to check which connection it belongs to, and some
connections may have relaxed requirements.
So always return success in the Verify_openssl() callback, and postpone
validation of the TLS session until starting the server handshake in
cb_connserver_login_ssl(), when we know which server this connection
belongs to and which options (like "SSLVerify") are in effect.
The code doing this was already present in cb_connserver_login_ssl(),
but this patch adds a more prominent comment to the function.
S2S-TLS/OpenSSL: Fix handling of certificate information for incoming connections
Show proper certificate information for incoming connections, too, and
not "peer did not present a certificate", regardless if the client sent
a certificate or not.
And free the client certificate structure "peer_cert" on incoming
connections as well!
S2S-TLS/OpenSSL: Always setup host name verification
Setup host name verification even when the "SSLVerify" option is
disabled, because even then the peer can present a valid certificate and
validation would always(!) fail because of the missing host name
verification setup.
Christoph Biedl [Sun, 2 Nov 2014 13:48:34 +0000 (14:48 +0100)]
Support for server certificate validation on server links [S2S-TLS]
This patch provides code to validate the server certificate in
server links, defeating nasty man-in-the-middle attacks on server
links.
Features:
- Check whether the certificate is signed by a trusted certificate
authority (CA).
- Check the host name, including wildcard certificates and Subject
Alternative Names.
- Optionally check against a certificate revocation list (CRL).
- Implementation for both OpenSSL and GnuTLS linkage.
Left for another day:
- Parameterize the TLS parameter of an outbound connection. Currently,
it's hardcoded to disable all versions before TLSv1.1.
- Using certificate as CA-certificate. They work for GnuTLS only but
perhaps this should rather raise an error there, too.
- Optional OCSP checking.
- Checking client certificates. Code is there but this first needs some
consideration about the use cases. This could replace all other
authentication methods, for both client-server and server-server
connections.
This patch is based on a patch by Florian Westphal from 2009, which
implemented this for OpenSSL only:
From: Florian Westphal <fw@strlen.de>
Date: Mon, 18 May 2009 00:29:02 +0200
Subject: SSL/TLS: Add initial certificate support to OpenSSL backend
Commit message modified by Alex Barton.
Closes #120, "Server links using TLS/SSL need certificate validation".
Supersedes PR #8, "Options for verifying and requiring SSL client
certificates", which had (incomplete?) code for OpenSSL, no GnuTLS.
Alexander Barton [Sat, 23 Mar 2024 19:15:16 +0000 (20:15 +0100)]
Streamline README.md & INSTALL.md files
- Tweak some paragraphs and bring others more in line with texts on the
homepage ...
- Try to not duplicate information:
- Configuration is explained in doc/QuickStart.md;
- command line parameters are already better described in the
ngircd(8) manual page.
- Move all pointers to documentation to the README.md file, which is
directly shown in GitHub when browsing the repository, for example.
Alexander Barton [Sun, 17 Mar 2024 14:55:39 +0000 (15:55 +0100)]
METATADA: Fix unsetting "cloakhost"
Correctly re-generate the "cloaked hostname" when removing the
"cloakhost" using an empty string by passing down NULL instead of the
empty string, which results in protocol violations (for example on
WHOIS).
The default value for the -nameopt option changed in OpenSSL 3.2 from
`oneline' to `utf8'. The `oneline' option also included a space around
the fields which is not the case for `utf8'. This means that
CN = my.first.domain.tld
changed to
CN=my.first.domain.tld
and is now longer recognized, leading to test failure.
This can be fixed by either going back to `oneline' or keeping `utf8'
and adding additionally `space_eq'. Anoter way would be to teach the
expect that the space is optional.
Add explicit -nameopt option with `utf8,space_eq' which is understood by
by OpenSSL 3.2 and earlier to make explicit. Remove the wildcard.
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Alexander Barton [Tue, 23 Jan 2024 21:25:28 +0000 (22:25 +0100)]
Debian package: Enable the [SSL] section
This makes sense because the package is build with SSL support enabled,
and we set and enable "CAFile" in commit ae9cfade -- which results in an
error when this is not in an enabled(!) [SSL] section ...
Alexander Barton [Sun, 21 Jan 2024 19:10:42 +0000 (20:10 +0100)]
Migrate info from INSTALL.md into doc/QuickStart.md
Move most information regarding configuring ngIRCd into the
doc/QuickStart.md document, only describe building and installing ngIRCd
in the INSTALL.md file. Don't duplicate content!
Alexander Barton [Sun, 21 Jan 2024 18:41:39 +0000 (19:41 +0100)]
Use a default "IncludeDir" only when no config file was specified
No longer use a default built-in value for the "IncludeDir" directive
when a configuration file was explicitly specified on the command line
using "--config"/"-f": This way no default include directory is scanned
when a possibly non-default configuration file is used which
(intentionally) did not specify an "IncludeDir" directive.
With this patch you now can use "-f /dev/null" for checking all built-in
defaults, regardless of any local configuration files in the default
drop-in directory (which would have been read in until this change).
Alexander Barton [Sat, 20 Jan 2024 22:07:25 +0000 (23:07 +0100)]
Make the description of the "Info" option more precise
The "Info" option in the "[Global]" section is optional (so comment it
out in the sample configuration file) and set to the server software
name and its version when not set (so add this information to the sample
configuration file and the ngircd.conf(5) manual page).
Alexander Barton [Sat, 20 Jan 2024 22:04:32 +0000 (23:04 +0100)]
Deduce a server name when not set in the configuration
The server "Name" in the "[Global]" section of the configuration file is
optional now: When not set (or empty), ngIRCd now tries to deduce a
valid IRC server name from the local host name ("node name"), possibly
adding a ".host" extension when the host name does not contain a dot
(".") which is required in an IRC server name ("ID").
This new behaviour, with all configuration parameters now being
optional, allows running ngIRCd without any configuration file at all.
Alexander Barton [Sat, 20 Jan 2024 15:14:01 +0000 (16:14 +0100)]
Explicitly test for the empty string in Channel_UserHasMode()
Basically this is unnecessary, as Channel_UserModes() always returns a
valid pointer and strchr() can deal with an empty (NULL-terminated)
string perfectly fine, bit it makes the code a bit more obvious and
silences the following warning:
In function ‘Channel_UserHasMode’,
inlined from ‘Channel_Kick’ at channel.c:384:7:
channel.c:784:16: warning: ‘strchr’ reading 1 or more bytes from a region
of size 0 [-Wstringop-overread]
784 | return strchr(Channel_UserModes(Chan, Client), Mode) != NULL;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This was seen with "gcc (Debian 12.2.0-14) 12.2.0" at least.
Alexander Barton [Fri, 19 Jan 2024 21:07:38 +0000 (22:07 +0100)]
Update included Debian package configuration
- Rewrite using current dh_make.
- Standards-Version: 4.6.2.
- No longer build 3 different packages; only build "ngircd" which now
includes support for IDENT, PAM (disabled in the ngircd.conf installed
by the package), SSL (OpenSSL), ZLib and IPv6.
- Update package description accordingly.
- No longer install a SysV init file, only install ngircd.service unit.
Alexander Barton [Fri, 19 Jan 2024 15:55:23 +0000 (16:55 +0100)]
Use -Werror when testing for -Wno-format-truncation
Clang does not know the -Wno-format-truncation option of (current) GCC,
but accepts unknown -W... options (exit core 0) but issues a warning
message on every invocation. So for example on macOS, where Clang is
used as "gcc", a new warning message was shown for every file to
compile, since we enabled -Wno-format-truncation in commit 1d527eaf:
Clang no longer acceps unknown -W... options by enabling -Werror, which
this patch adds to the CFLAGS while testing for -Wno-format-truncation,
which fixes this issue.
Alexander Barton [Thu, 18 Jan 2024 21:41:39 +0000 (22:41 +0100)]
Annotate "fall through" cases to silence warnings
Add a "/* fall through */" annotation to "case" statements which
actually should "fall through" to silences GCC warning like this:
hash.c: In function ‘jenkins_hash’:
hash.c:110:27: warning: this statement may fall through
[-Wimplicit-fallthrough=]
110 | case 12: c+=((UINT32)k[11])<<24;
| ~^~~~~~~~~~~~~~~~~~~~~
Alexander Barton [Thu, 18 Jan 2024 21:39:10 +0000 (22:39 +0100)]
Disable GCC -Wformat-truncation when suported
Pass -Wno-format-truncation when this is supported by GCC so silence
warnings like this:
conf.c: In function ‘Read_Config’:
conf.c:985:60: warning: ‘snprintf’ output may be truncated before
the last format character [-Wformat-truncation=]
985 | snprintf(file, sizeof(file), "%s/%s",
| ^
conf.c:985:25: note: ‘snprintf’ output 2 or more bytes (assuming 257)
into a destination of size 256
985 | snprintf(file, sizeof(file), "%s/%s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
986 | Conf_IncludeDir, entry->d_name);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The warning is correct, but this is basically why we use snprintf() in
the first place.
Alexander Barton [Tue, 16 Jan 2024 16:33:54 +0000 (17:33 +0100)]
autogen.sh: Prefere automake 1.11 over other releases
GNU automake 1.11 is the last release supporting "de-ANSI-fication"
using the included ansi2knr tool. And becuase we _want_ to support old
K&R platforms, we try hard to use this release of automake when
available to generate our build system.
Alexander Barton [Mon, 15 Jan 2024 21:14:15 +0000 (22:14 +0100)]
Autodetect support for IPv6 by default
Until now, IPv6 support was disabled by default, which seems a bit
outdated in 2024. Note: You still can pass "--enable-ipv6" or
"--disable-ipv6" to the ./configure script to forcefully activate or
deactivate IPv6 support.
Alexander Barton [Mon, 15 Jan 2024 20:12:10 +0000 (21:12 +0100)]
Do IDENT requests even when DNS lookups are disabled
Without this patch, disabling DNS in the configuration disabled IDENT
lookups as well (for no good reason).
This patch allows enabling/disabling DNS lookups and IDENT requests
completely separately and enhances the messages sent to the client when
"NoticeBeforeRegistration" is enabled, too.
Channel Admins are not allowed to set Channel Owner status!
This was reported back in April 2021, thanks Sarah!
Subject: NGIRCD bug report
Date: April 28 2021, 14:30:08 MESZ
To: alex@barton.de
Hello,
I am writing to you to report a bug in ngircd.
In any give channel, if an user is with mode +a (admin), he/she can
sets mode +/-q(owner) to any other user. This is not inline with the
documentation.
I've looked into the code irc-mode.c, apparently an if block is
missing. Below are the code snippets that I believe fixes the bug.
Allow SSL client-only configurations without keys/certificates
You don't need to configure certificates/keys as long as you don't
configure SSL-enabled listening ports.
This can make sense when you want to only link your local daemon to an
uplink server using SSL and only have clients on your local host or in
you fully trusted network, where SSL is not required.
Respect "SSLConnect" option for incoming connections
Don't accept incoming plain-text ("non SSL") server connections for
servers configured with "SSLConnect" enabled.
If "SSLConnect" is not set for an incoming connection the server still
accepts both plain-text and encrypted connections.
This change prevents an authenticated client-server being able to force
the server-server to send its password on a plain-text connection when
SSL/TLS was intended.