Detect libcrypto in configure script. Only fall back
to using libcrypto when /usr libs are allowed and no
other compatible implementation is available or when
--with-openssl is passed explicitly.
Make sure libcrypto and libmd are never linked at the
same time.
Add OpenSSL based SHA256 and HMAC compat shims in
compat/crypt_openssl. Depeding on version and build flags,
libcrypto ships with a compatible SHA256 API in
"openssl/sha.h". OpenSSL 3 has deprecated the SHA API,
so if it is not detected we fall back to an EVP_DIGEST
based version.
Because the API might still be in use in OpenSSL internally,
the compatibility wrappers have a dhcpcd_ prefix to avoid
symbol conflicts.
* Add sha256 tests based on the existing hmac-md5 tests.
When persistent is not specified, dhcpcd de-configures the interface at exit.
However, the default dhcpcd.conf example provided enables the option.
See https://github.com/NetworkConfiguration/dhcpcd/discussions/140
Tobias Heider [Tue, 15 Aug 2023 16:06:48 +0000 (18:06 +0200)]
privsep: fix strlcpy overflow in psp_ifname (#239)
When running our Ubuntu tests with libc6 and strlcpy overflow checks
enabled we found that the wrong size is passed to strlcpy resulting
in a crash because of an overflow.
Roy Marples [Thu, 20 Jul 2023 09:32:26 +0000 (10:32 +0100)]
privsep: Allow diabling of SECCOMP on Linux
This allows a POSIX resource limited sandbox to be used at least
with privilege separation, which is better than just disabling
privilege separation entirely for when SECCOMP stops working due to
libc/kernel changes.
Roy Marples [Wed, 19 Jul 2023 11:42:49 +0000 (12:42 +0100)]
privsep: Send only what we have put in the buffer to script env
Rather then sending the whole buffer size.
If there is an error writing the last option, it may not be
NUL terminated correctly causing an assert.
Even so, we should not write the failed option to the environment
either as it would be a false positive for an empty option.
Roy Marples [Tue, 23 May 2023 21:14:57 +0000 (22:14 +0100)]
Linux: Improve learning IPv6 address flags
Rather than matching addresses during netlink message processing,
extract the local, address and flag parts.
Once done, then match local and address to the address we are
looking for and if equal apply the flags.
Roy Marples [Wed, 26 Apr 2023 13:15:07 +0000 (14:15 +0100)]
BSD: When we get RTM_NEWADDR the interface must have IFF_UP.
This is apparently historic behaviour.
It's not always mirrored in RTM_IFINFO either so we need to
replicate the behaviour if we had got it earlier.
This fixes dhcpcd requiring at least something to set the interface
up before starting on OpenBSD.
Other BSD are less impacted because it's a lot harder to get into
this state as we have more control over setting the IPv6 LL address.
Roy Marples [Thu, 20 Apr 2023 11:00:32 +0000 (12:00 +0100)]
chore: update build system to publish signed github releases
We rely on the GitHub CLI tools to do this.
We publish the compressed source tarball and a detached PGP
signature for it.
We add the SHA256 checksum of the tarball as a note on the release.
Automatic links to the changes are also given.
Roy Marples [Tue, 7 Feb 2023 18:25:45 +0000 (18:25 +0000)]
DHCP6: Request OPTION_NTP_SERVER to mirror DHCP
RFC 5908 deprecates OPTION_SNTP_SERVERS.
However we can support both at the same time as our scripts
will uniqify the results if there are stupidly any duplicates.
Roy Marples [Fri, 6 Jan 2023 11:14:45 +0000 (11:14 +0000)]
privsep: Try sending error if we cannot send the message.
There is an error sending a reply from an INET6 sysctl RT dump
on FreeBSD-14 using the dhcpcd-9 branch.
It seems to be related to capsicum and doesn't happen on FreeBSD-13.
We should handle the error gracefully and allow dhcpcd to try to
contuinue regardless.
xvuko [Thu, 5 Jan 2023 09:02:52 +0000 (10:02 +0100)]
dhcp: Fix classless link local static routes (#161)
Detecting host routes based on address comparison is not needed in
classless routes as /32 mask can be explicitly used. This detecting
mechanism did cause issues when gateway was set to 0.0.0.0 (link local
routes).
Laszlo Toth [Fri, 23 Dec 2022 13:31:43 +0000 (08:31 -0500)]
arp: ignore invalid ARP probes according to RFC5227 (#145)
Some network devices can send probes where the source address in the frame
does not match the sender in the ARP request, due to firmware bugs or
crafted packets.
Without verification this can cause to fail the defense, so we lose the
address, then request a new one. This might lead to the DHCP address pool
being exhausted and all sorts of problems like frequent IP changes.
A real life example is that some Cisco devices can send ARP probes in bursts,
where the frame's source address is clearly invalid, so hosts running dhcpcd
release addresses frequently, e.g., Raspberry Pis.
Example output:
"invalid ARP probe, sender hw address mismatch (00:be:75:xx:xx:xx, 00:00:00:yy:yy:yy)"
RFC5227, Section 1.1 describes that the two addresses must match in case
of ARP probes, so add the extra check and log a warning if we receive an
invalid packet like that.
Roy Marples [Fri, 2 Sep 2022 11:54:25 +0000 (12:54 +0100)]
privsep: Don't find processes we just asked to stop
We could rebind a lease, get a NAK and enter DISCOVER.
We need to restart the BPF in the middle as the BPF filter could
change.
As such, add a started flag to each privsep process and when
searching for a process by id only find started ones.
If we ask them to stop then the started flag is removed.
Fixes errors about writing to stopping processes an unknown
processes exiting.