Commit Graph

5563 Commits

Author SHA1 Message Date
Roy Marples
584b52db33 control: Fix hangup for non privsep builds
Fix related to #262.
2023-11-12 11:30:26 +00:00
Roy Marples
6baf4df467 Release dhcpcd-10.0.5 2023-11-10 14:25:12 +00:00
Roy Marples
3941274074 privsep: Note that unveil(2) is not needed
As we are in a chroot.
https://www.mail-archive.com/misc@openbsd.org/msg171664.html
2023-11-10 12:02:19 +00:00
Roy Marples
4bb0c8ff02 privsep: Allow dup3 on Linux
It seems some libc will really call dup3 rather than dup2.
Another fix for #260.
2023-11-10 11:04:22 +00:00
Roy Marples
1064814667 dev: Don't fail to start if we cannot open the dev plugin path
We accidently returned stdin fd in this case - return -1 instead.
2023-11-10 11:04:22 +00:00
Roy Marples
c32c88b642 dhcpcd: Close fork_fd on hangup
Closing it early results in zero length reads in some situations.
Logging that we forked via the launcher process also make more sense
and allows us to use log* functions.

While here, handle error condtions better by forcing a return
rather than handling an invalid state.

Fixes #260.
2023-11-10 11:04:22 +00:00
Roy Marples
2913df520a configure: guard config.h with #ifdef CONFIG_H
Rename CONFIG_H guard in defs.h to DEFS_H
This avoids a redeclaration issue on DragonFly.
2023-11-08 10:10:35 +00:00
Roy Marples
2d07224f97 IPv4LL: Don't start if already started
It's just pointless noise.
A follow-on fix for #255.
2023-10-23 15:25:13 +00:00
Roy Marples
d408e74bdc DHCP: re-enter DISCOVER phase if server doesn't reply to our REQUEST
Use the reboot timeout as per the initial DISCOVER timeout.

Fixes #255
2023-10-23 15:24:00 +00:00
Roy Marples
e8b6541979 Expose memset_s on FreeBSD 2023-10-23 15:39:20 +01:00
Roy Marples
47f4bf4188 Fix tests or #252. 2023-10-23 15:31:02 +01:00
Roy Marples
65190fa017 compat: test for memset_explicit, explicit_bzero and memset_s
These won't be optimised away by the compiler and our arc4random
compat function should use them *if* available.
If none are then a warning will be emitted to say it's potentially insecure.

Hopefully only uclibc users will see this message.

Fixes #252.
2023-10-23 15:28:40 +01:00
Roy Marples
beace2c04c Improve comment about capturing script output. 2023-10-20 06:53:20 +00:00
Roy Marples
3cb2426565 Release dhcpcd-10.0.4 2023-10-19 12:15:31 +01:00
Roy Marples
9c20aab025 dhcpcd: Improve script status handling 2023-10-19 12:06:33 +01:00
Roy Marples
fd2e62e72d privsep: Allow dup2 with SECCOMP 2023-10-19 11:34:30 +01:00
Roy Marples
ac4a70dc89 privsep: Notify processes when dhcpcd has daemonised
This allows us to dup stdout and stderr onto stdin which is
guaranteed to be dupped to /dev/null.
This in turn avoids SIGPIPE when the privileged proccess launches
the script and it wants to write to stdout/stderr or stupidly
read from stdin.
2023-10-19 11:14:57 +01:00
Fabrice Fontaine
57070736a5
compat/arc4random.c: use memset instead of explicit_bzero (#252)
Use memset instead of explicit_bzero to avoid the following build
failure with uclibc-ng since version 10.0.3 and
837d09e34c:

/home/fabrice/buildroot/output/host/lib/gcc/arm-buildroot-linux-uclibcgnueabi/12.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: ../compat/arc4random.o: in function `_rs_stir_if_needed':
arc4random.c:(.text+0x8cc): undefined reference to `explicit_bzero'

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2023-10-16 18:03:41 +01:00
Oleg Lyovin
52f1b730a8
privsep: allow __NR_clock_gettime32 syscall (#254)
musl libc doesn't have __NR_clock_gettime definition,
but has __NR_clock_gettime32. clock_gettime implementation
fallbacks to 32-bit version if 64-bit is not supported by the kernel.

Signed-off-by: Oleg Lyovin <ovlevin@sberdevices.ru>
2023-10-16 17:59:00 +01:00
Oleg Lyovin
6ada94b856
privsep: allow __NR_mmap2 syscall (#253)
The issue occured while compiled by musl toolchain:

    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = ?
    +++ killed by SIGSYS +++

This patchs allows seccomp to make __NR_mmap2 syscall.

Signed-off-by: Oleg Lyovin <ovlevin@sberdevices.ru>
2023-10-12 17:47:05 +01:00
Roy Marples
b976d55ebd dhcpcd: freopen of stdin/stdout may change the fd
So use dup2 instead.
2023-10-09 14:03:37 +01:00
Roy Marples
617a3ae207 privsep: Log script exit status. 2023-10-09 12:20:08 +01:00
Roy Marples
45fb8fd8dd Release dhcpcd-10.0.3 2023-10-06 09:27:53 +01:00
Roy Marples
d287090496 DHCP6: Set all requested addrs as not stale when starting discovery
Hopefully fixes #249.
2023-10-04 17:38:08 +01:00
Roy Marples
6b22ccb2ae doc: mention using --with-openssl
Fixes #225
2023-10-04 13:47:57 +01:00
Roy Marples
3c36bfc83d IPv6: Be explicit that lifetime zero means no longer a default router
Fixes #244
2023-10-04 13:38:44 +01:00
Roy Marples
500cd81362 options: introduce the uri option as opposed to a string
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.
2023-10-04 13:08:20 +01:00
Roy Marples
0b9d882529 options: andsf6 is DHCPv6, not DHCP 2023-10-02 11:01:39 +01:00
Roy Marples
dc96a61d14 Cast a compile warning away 2023-10-02 10:54:36 +01:00
Tobias Heider
cd34035851
compat: use OpenSSL RAND_priv_bytes() for entropy (#248)
* 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.
2023-09-29 08:57:41 +01:00
Christian Tomahogh
f2bc729e55
Send correct amount of used buffer for prefix exclude option (#250)
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.
2023-09-29 00:04:37 +01:00
Roy Marples
dcaf729bca Guard against handling many SIGTERM/SIGINT.
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.
2023-09-25 10:34:12 +01:00
Petr Gotthard
8ac0147364
Use a local variable instead of the optind (#86)
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>
2023-09-25 10:00:27 +01:00
Tobias Heider
8e316164a8
Support libcrypto for hmac and sha256 (#223)
* 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.
2023-09-25 09:49:00 +01:00
Ido Rosen
e0923934fc
Fix some grammar in README.md 2023-09-11 22:16:26 -07:00
Ido Rosen
4a3be174e4 Clarify persistent wording to address confusion.
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
2023-09-08 23:41:45 -07:00
Ido Rosen
9aece11fb7 Ignore VSCode .vscode and macOS .DS_Store files 2023-09-08 23:02:35 -07:00
Tobias Heider
837d09e34c
compat: update arc4random() to newer chacha20 based version from OpenBSD (#227)
* 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.
2023-09-04 14:53:44 +01:00
Tobias Heider
da3c493d2c
ci: execute tests after successful build (#243) 2023-09-04 14:53:10 +01:00
Roy Marples
1e1268d2de linux: fix wireless roaming
Fixes #228.
2023-08-22 15:12:21 +01:00
Roy Marples
e30adeb939 privsep: Fix a FD leak when processes exit
Add commentary to say they are closed on receipt of SIGCHLD.
2023-08-22 12:59:23 +00:00
Tobias Heider
1bd8fc7d4b
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.
2023-08-15 17:06:48 +01:00
Tobias Heider
f798bf23af
dhcpcd: Fix off-by-one overflow when read() writes full BUFSIZ (#236) 2023-08-12 20:59:21 +01:00
Tobias Heider
df3e2a1642
Add CI builds for Ubuntu, OpenBSD, FreeBSD and NetBSD (#229) 2023-08-04 18:00:26 +01:00
Petr Menšík
b7b7b656f8
Do not crash on dhcpcd test run (#231)
Check if state->bpf is allocated before attempting to write there.
2023-08-04 17:45:25 +01:00
Roy Marples
43c4b1b572 Fix --enable-secomp 2023-07-20 10:48:37 +01:00
Roy Marples
8b65e2d6c7 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.
2023-07-20 10:33:51 +01:00
Roy Marples
d2fbde99cf Release dhcpcd-10.0.2 2023-07-19 14:34:04 +01:00
Roy Marples
4523393a82 Fix compile warning with rb.c sync 2023-07-19 13:46:08 +01:00
Tobias Heider
ca67bd26f5
compat sync (#226)
* 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
2023-07-19 13:29:48 +01:00