Compiler flags that enable warnings were hidden behind the 'hardening'
option. This was a direct port of the previous autoconf config, but it
probably makes sense to always show them as they have no effect on
compiler's output (unlike hardening flags which distributors might want
to alter or disable completely).
Also remove -fwrapv (which is enabled by -fno-strict-overflow) and fix
all new warnings we've added (like VLAs in libgcrypt code, so it should
now be buildable with MSVC in case anyone wishes to do it).
Since tincd chdirs to its own configuration directory and only then
resolves relative paths passed as command-line arguments (like --config
and --pidfile), statements like these:
- fix authentication with socks5 proxies
- fix crash in forked process with exec proxy and empty node name
- refactor byte fiddling into structs
- add unit and integration tests
The README didn't really present the most relevant information to new
users at the start, it read more like a release notes file. This makes
it a more proper introduction to tinc.
Also add a quickstart guide as a Markdown file in the root of the source
tree, this will make it nicer on GitHub and GitLab, and might help users
that don't want to read the manual.
We could chown the build directory to our own user, but that's
relatively slow. Since we fully control the environment (relatively
speaking, we're still running on other's machines), the vulnerability
doesn't affect this particular use case.
connection_t: split compression_level/log_level into two fields
compression_level is reused as a place to store log_level when piping
logs to tincctl. Since it was being compared directly with a log level,
it felt like a wrong field is being used by mistake.
Wrap it in union to avoid wasting additional memory.
connection_t: allocate legacy context on first use
Since the new protocol is preferred if available, if both sides of the
connection are running modern versions of tinc, the old protocol may not
be used at all.
Use actual port in tincd logs / tinc get Port / invitations
If Port 0 option is used (which makes tincd bind to a port chosen
by the operating system), tinc and tincd used to print that value as
it is instead of whatever port was actually allocated.
After moving to meson, we've been using separate build directories
for each test flavor instead of running `git clean -dfx`, and the .nsi
used to create a Windows installer for the development release wasn't
updated to reflect this.
While the previous test suite ran fine in practice, it relied on
subtle differences in behavior of many UNIX tools, and thus needed GNU
Coreutils on many operating systems to work properly, and didn't work on
"pure" Windows at all.
A simple example would be how different versions of tail handle SIGPIPE
if you pipe its output into another process: GNU tail exits on SIGPIPE
since about 2017 (too lazy to look up the exact version, but this
changed recently), while most other tails continue reading the file and
piping the output into god knows where.
Since we need Python to run the new build system (meson) anyway, let's
use it for the test suite, and get rid of all other test dependencies.
It (currently) requires only the standard library of Python 3.6 or newer.
Unlike the original test suite, this one assigns node names and port
numbers randomly to support `meson test --repeat` (because meson can run
the same test multiple times in parallel, and this breaks with the old
approach).
Also remove old integration tests based on shell scripts.
Speed up the authentication protocol security tests.
The security test took 70 seconds, mainly because it consisted of
several subtests that each had to wait for a timeout to pass. Split it
into three tests; two for testing a MITM splicing connections between
tinc daemons using the legacy and SPTPS protocols, the remaining tests
are in a single shell script but now run in parallel.
SPTPS error messages should not always be logged, they are mostly
low-level details, and serious errors like failing to connect to a node
due to SPTPS issues will be logged by higher layers anyway, so move it
down to log level 3.
Guus Sliepen [Sun, 27 Mar 2022 18:58:44 +0000 (20:58 +0200)]
Don't put the --recursive option in .astylerc.
When calling astyle manually without wildcards in the filename(s),
astyle will refuse to work if the --recursive option is used. Remove it
from .astylerc and add the option to the command line when the "reformat"
build target is used.
Kirill Isakov [Sat, 12 Mar 2022 06:32:01 +0000 (12:32 +0600)]
Fix `make distcheck`
`make distcheck` builds and then calls both tinc and tincd with two options:
--version
--help
tincd behavior was changed by 28b7a53b6 to print usage information to
stderr, but automake expects to see a non-empty output from stdout, and
fails distcheck if it's empty.
Guus Sliepen [Sat, 22 Jan 2022 21:56:55 +0000 (22:56 +0100)]
Enable hardening flags at the end of the configure script.
Unfortunately some of the autoconf checks themselver trigger compiler
warnings when hardening is enabled and if -Werror is also enabled. Avoid
this by only enabling the hardening flags at the end of the configure
script.
Guus Sliepen [Sun, 16 Jan 2022 22:02:09 +0000 (23:02 +0100)]
Enable and fix many extra warnings supported by GCC and Clang.
This enables many extra warning options when hardening is enabled, and
fixes the definition of _FORTITY_SOURCE. -Wshadow is not (yet) enabled,
as this generates quite some warnings that are less trivial to fix.
Guus Sliepen [Sun, 16 Jan 2022 19:45:41 +0000 (20:45 +0100)]
Fix potential crash during failing PMTU discovery.
If we get PACKET_TOO_BIG responses when sending UDP packets, we lower the
maximum MTU we will probe accordingly. However, after enough of those
responses, maxmtu could drop below zero and wrap. Guard against that by
never dropping maxmtu below the minimum required MTU for UDP communication.
Kirill Isakov [Thu, 19 Aug 2021 08:36:02 +0000 (14:36 +0600)]
CI: improve sanitizer runs; minor cleanups.
- sanitizers now do the full test run, as in every other job.
- run all test flavors even if one of them fails.
- change big-endian cross build to little-endian MIPS.
Kirill Isakov [Tue, 17 Aug 2021 10:35:22 +0000 (16:35 +0600)]
Fix UBSAN warnings in linux/device.c.
linux/device.c:149:11: runtime error: implicit conversion from type 'ssize_t' (aka 'long') of value -1 (64-bit, signed) to type 'size_t' (aka 'unsigned long') changed the value to 18446744073709551615 (64-bit, unsigned)
#0 0x55e3cb851f84 in read_packet /home/runner/work/tinc/tinc/src/linux/device.c:149:11
#1 0x55e3cb7bb7fe in handle_device_data /home/runner/work/tinc/tinc/src/net_packet.c:1906:5
#2 0x55e3cb78e6e0 in event_loop /home/runner/work/tinc/tinc/src/event.c:353:5
#3 0x55e3cb7a6a90 in main_loop /home/runner/work/tinc/tinc/src/net.c:505:6
#4 0x55e3cb83d241 in main /home/runner/work/tinc/tinc/src/tincd.c:614:11
#5 0x7fec881950b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#6 0x55e3cb757dcd in _start (/home/runner/work/tinc/tinc/src/tincd+0x9adcd)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior linux/device.c:149:11 in
linux/device.c:163:23: runtime error: unsigned integer overflow: 18446744073709551615 + 10 cannot be represented in type 'unsigned long'
#0 0x55e3cb852253 in read_packet /home/runner/work/tinc/tinc/src/linux/device.c:163:23
#1 0x55e3cb7bb7fe in handle_device_data /home/runner/work/tinc/tinc/src/net_packet.c:1906:5
#2 0x55e3cb78e6e0 in event_loop /home/runner/work/tinc/tinc/src/event.c:353:5
#3 0x55e3cb7a6a90 in main_loop /home/runner/work/tinc/tinc/src/net.c:505:6
#4 0x55e3cb83d241 in main /home/runner/work/tinc/tinc/src/tincd.c:614:11
#5 0x7fec881950b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#6 0x55e3cb757dcd in _start (/home/runner/work/tinc/tinc/src/tincd+0x9adcd)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior linux/device.c:163:23 in
Kirill Isakov [Sun, 15 Aug 2021 12:43:14 +0000 (18:43 +0600)]
tincd on Windows: call srand() after main2()
On Windows, rand() was returning the same sequence on every service
execution, because srand() was initializing its state only for the
short-lived process.