Currently we don't attempt to validate a uri given, aside from
not allowing any space characters within.
If the option is `array uri` then the first two bytes are the
length of the uri in network order and the rest is a uri element.
The uri's are space separated for the variable because space is not
allowed within the uri.
This allows us to implement RFC 8572, Secure Zero Touch Provisioning.
* compat: use OpenSSL RAND_priv_bytes() for entropy
Use OpenSSL random number generator to seed arc4random() if available,
if it fails fall back to /dev/urandom.
* tests: link eloop-bench against LDADD lib
arc4random might depend on libcrypto so we need to link it.
The payload of the prefix exclude option was correctly created
but the amount of bytes to send in the DHCPv6 request was
always set to 0 which resulted in an invalid prefix exclude option
This patch fixes this behavior by calculating the correct amount
of bytes to send.
Privsep has a mini-eloop for reading data from other processes.
This mini-eloop processes signals as well so we can reap children.
During teardown we don't want to process SIGTERM or SIGINT again,
as that could trigger memory issues.
Hopefully fixes#247.
The optind get overwritten by reload_config(), so the reconf_reboot()
used a wrong argument count.
Signed-off-by: Petr Gotthard <petr.gotthard@centrum.cz>
* compat: Add OpenSSL libcrypto compatibility layer
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.
* compat: update arc4random() to newer chacha20 based version from OpenBSD
* arc4random: keep fd after first call to arc4random
privsep + chroot doesn't allow us to reopen /dev/urandom in
an unpriviledged process so we open the fd once and then
hold onto it.
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.
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.
* compat: sync pidfile.c with netbsd v1.16
- fix typos in word "otherwise".
- s/sucess/success/ in comment.
* compat: sync rb.c with netbsd v1.16
- fix typos in word "successfully", mainly s/succesfully/successfully/.
- toolify
* compat: sync strlcpy.c with openbsd v1.16
- I am retiring my old email address; replace it with my OpenBSD one.
* compat: sync arc4random_uniform.c with openbsd v1.3
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.
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.
Fixes#201 and maybe #149.
Just to silence GNU make.
This makes development slightly harder on BSDs, just have to
do a `make clean` when changing configuration options.
Fixes#197.
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.