Commit Graph

5600 Commits

Author SHA1 Message Date
Roy Marples
66811c7b9b Merge branch 'master' into manager_only 2024-06-15 14:09:31 +01:00
Roy Marples
127c0b77a8 configure: add --enable-ntp
It just uncomments the option to request ntp_servers in dhcpcd.conf.
Fixes #331.
2024-06-15 14:02:30 +01:00
Roy Marples
a15ba1987c Release dhcpcd-10.0.8 2024-05-24 17:01:54 +01:00
Roy Marples
486175335c Fix compile for builds without ARP 2024-05-24 15:54:40 +00:00
Roy Marples
e7f139d3be configure: fix the closefrom test
Fixes #327.
2024-05-24 13:23:37 +01:00
Roy Marples
906675d41e Spell ADVERTISEMENT correctly.
Fixes #326
2024-05-24 12:59:32 +01:00
Roy Marples
3067b38dc8 Release dhcpcd-10.0.7 2024-05-24 11:41:54 +01:00
Roy Marples
6149af646b DHCP: use request_time, fallback_time and ipv4ll_time
Rather than reboot time.

This allows reboot time of zero to skip the using old leases
while still allowing REQUESTs to gracefully fallback to DISCOVER.

request_time has a default of 180 seconds to mirror the DHCPv6
equivalent.
fallback_time and ipv4_ll time have a default of 5 seconds
to mirror the default reboot time.

Fixes #325 and affects #255.
2024-05-24 10:30:29 +00:00
Roy Marples
8dc7f72c63 DHCP6: Wait for IRT to elapse before requesting advertisments
RFC 8415 15 and 18.2.1 list this as a MUST.

Fixes #317.
2024-05-17 22:12:26 +00:00
Benjamin Drung
6fd656fb5b hooks/30-hostname: Exit with 0 if setting hostname is not needed
If the hostname is already set before dhcpcd is started, `need_hostname`
will hit the "No old hostname" case and will call `false` to return 1.
`set_hostname` will return with the same return value. Then
`30-hostname` will exit with the same exit value:

```
dhcpcd-10.0.6 starting
dev: loaded udev
DUID 00:03:00:01:3c:97:0e:e9:32:3c
enp0s25: IAID 0e:e9:32:3c
enp0s25: soliciting a DHCP lease
enp0s25: offered 192.168.3.61 from 192.168.1.7
enp0s25: ignoring offer of 192.168.3.61 from 192.168.1.8
enp0s25: probing address 192.168.3.61/20
enp0s25: leased 192.168.3.61 for 3600 seconds
enp0s25: adding route to 192.168.0.0/20
enp0s25: adding default route via 192.168.1.1
script_status: /usr/lib/dhcpcd/dhcpcd-run-hooks: WEXITSTATUS 1
exiting due to oneshot
dhcpcd exited
```

Return with value 0 in case setting the hostname is not needed.

Bug-Ubuntu: https://launchpad.net/bugs/2064926
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2024-05-13 16:19:40 +01:00
Roy Marples
dfb0dc2577 DHCPv6: Don't re-INFORM if the RA changes
RFC 8415 21.23
If the Reply to an Information-request message does not contain this
option, the client MUST behave as if the option with the value
IRT_DEFAULT was provided.

So we should not be influenced by only the RA changing the pl/vl
times of it's addresses.
2024-05-04 23:33:11 +01:00
Roy Marples
40c99e59aa privsep: Reduce fd use
On start close all FD's above stderr.
Close some fd's we don't need in processes spawned from priv.
Ensure we init some FD's to -1 to ensure we don't close stdin.
If DEBUG_FD is defined, we log FD's opened by pid.
Audit process FD usage and document it so I don't forget it.

Fixes #316.
2024-05-04 12:38:49 +01:00
Roy Marples
6a6c13f46d Add compat support for closefrom cribbed from libbsd
We had compat support in older dhcpcd but we want it faster
when linux supports faster, because, you know, fast.
2024-05-04 12:38:49 +01:00
Roy Marples
5dd6ee1437 dhcpcd: Only drop/release address family specified when given
Fixes #311
2024-04-27 11:12:29 +00:00
Colin McInnes
ad41d26a26 Fix time_offset to be int to match RFC-2132
https://datatracker.ietf.org/doc/html/rfc2132#section-3.4

time_offset (dhcp v4 option 2) should be int32, not uint32, as it can
indicate a time offset east (positive) or west (negative) of zero
meridian.
2024-04-27 12:01:54 +01:00
Roy Marples
0fbd29b0b9 hooks: stop wpa_supplicant on STOPPED
Taken from Void Linux package
2024-04-13 11:16:58 +01:00
Roy Marples
9d2e7e74fd linux: modern kernels can create stable private addresses
Just improve the comment.
Closes #301
2024-04-08 09:31:08 +01:00
Taoyu Li
faa3f54eba Respect IPV6_PREFERRED_ONLY flag on DHS_NONE state
Current IPv6_PREFERRED_ONLY (option 108) handling code is only effective
when current state is DHS_DISCOVER and DHS_REBOOT. However, when we
receive multiple ACKs upon our REQUEST, the first ACK will trigger the
use_v6only code path and dhcp_drop() us into DHS_NONE state, as a result
the option 108 on the second ACK won't be handled correctly and we'll
bind to the lease instead.

This patch fixes the issue by adding DHS_NONE as a state to respect
option 108 as well.
2024-04-02 10:07:39 +01:00
Roy Marples
9f8bb1fc12 compat: stub out _rs_forkhandler for compat/arc4random.c
We need to keep the fd open at fork, but we retained the code to
handle a fork.

The original update to chacha avoided this by guarding the call
but left the code alive which produced an unused function warning
on the GitHub Ubuntu runner.
This update fixes that.
2024-04-02 09:55:18 +01:00
Roy Marples
0ab1dfa54e DHCP6: Remove leading space from delegated_dhcp6_prefix 2024-03-28 16:50:32 +00:00
Daniel Goertzen
f1cf924ad6
add RFC4191 support (#297)
* add RFC4191 support

- handles route information options from RAs.
- refactor `sa_fromprefix()` to expose lower level functionality
- refactor `ipv6nd_rtprefix()` to be usable outside of `struct ra` context

* changes as requested by RM

- mostly minor/cosmetic changes
- functional change: "no longer a default router" warning moved to capture changes from routeinfo options

* simplify routeinfo_find/new
2024-03-09 01:27:57 +00:00
Lloyd Parkes
457f21c112
Define the Azure Endpoint and other site-specific options (#299)
Added the azureendpoint site-specific option as an ipaddress
definition to make it easier for Azure VMs using dhcpcd to get their
WireServer endpoint address.

Added binhex definitions for all otherwise undefined site-specific
options so that site-specific hooks can use them.
2024-02-25 12:21:12 +00:00
Petr Menšík
727c78f503
Move dhcp(v4) packet size check earlier (#295)
dhcp_handlebootp handled zero sized packets correctly, but
dhcp_redirect_dhcp did not have such protection. Move size check before
both of them. Size when called from dhcp_packet is checked by
is_packet_udp_bootp call. Only dhcp_recvmsg needs earlier checking to be
added.

Fixes #283
2024-02-16 16:15:35 +00:00
Roy Marples
8ab7ca1eb4 DHCP: DECLINE address on ARP defend failure
Also, drop the lease.
This should get us a new address from the DHCP server when we
re-enter DISCOVER to avoid looping on the same address and fail
again.
2023-12-24 12:07:25 +00:00
Roy Marples
2b2906df11 dhcpcd: Only starts in manager mode
A process per interface has been removed as it's very
challenging to get fully working in a multihomed setup.
Privsep makes this even more apparent.

First pass, more code to be removed I hope but this is a good
starting point.
2023-12-23 23:06:00 +00:00
pradeep-brightsign
e65e82a58d
dhcpcd: Add support for arp persist defence (#273)
RFC 5227 recommends 3 ways to deal with address conflict detection.
a) Stop everything.
b) Defend and then stop on fail - this is what dhcpcd currently does.
c) Notify and carry on.

The current change implements the option c. A new option arp_persistdefence
has been added and when this is enabled, the a defence is attempted upon a
conflict and when that fails, an error is logged on every other conflict
within the DEFEND_INTERVAL and the current IP address is retained.

Fixes #272
2023-12-21 10:26:09 +00:00
Roy Marples
1c8ae59836 Release dhcpcd-10.0.6 2023-12-18 15:39:51 +00:00
Roy Marples
01de6f23d3 DHCP6: For Prefix Delegation, the - interface means no assignment
- is an invalid interface name.
So we take this to mean don't assign the Delegated Prefix to
any interfaces.
The reject route for the Delegated Prefix is still installed.

Fixes #270
2023-12-18 12:22:13 +00:00
Roy Marples
c7a142affe DHCP6: Improve logging when changing IA type
Changing from PD to IA or IA to PD can result in a diagnostic
when there is no address to confirm AND we haven't loaded
a lease.
This improves the check and no more Success errors should
be reported.
2023-12-18 12:15:10 +00:00
Roy Marples
411e6539fd Fully configure an interface when being activated.
We need the full configuration - for example dhcpcd.conf
might have environment options for the hooks for the interface
being activated.

Because we now guard against starting protocols with IF_ACTIVE_USER
this is safe.

Fixes #257.
2023-12-14 22:56:00 +00:00
Roy Marples
0a0bbfe74e Fix year 2023-12-12 07:13:29 +00:00
Roy Marples
e337bd7ce4 Document that limiting address protocol can affect signalling dhcpcd
Fixes #264
2023-12-10 08:27:30 +00:00
Roy Marples
6788608eb0 Fix an unused var warning for capsicum for prior 2023-11-13 16:05:04 +00:00
Roy Marples
8d12632c67 Fix privsep builds for prior. 2023-11-13 15:54:50 +00:00
Roy Marples
ea53344a24 dhcpcd: Remove stdio callback and detach on daemonise
For some reason, the stdio callback is extremely flaky on
*some* Linux based distributions making it very hard to debug some
things.
Removing it is fine because we now enforce that we have file descriptors
for stdin, stdout and stdrr on launch and dup them to /dev/null on daemonise.

It's also interesting to see behavioural differences between
some socketpair implementations that emit a HANGUP and some don't.

As such, we now close the fork socket on daemonise once more AND
in the fork_cb depending on if we hangup or read zero first.

Fixes #262
2023-11-13 10:29:58 +00:00
Roy Marples
3b4c71859c control: Abort control recv path on hangup
This fixes a crash when we try and re-use it in another function.
2023-11-13 10:24:15 +00:00
Roy Marples
21d020b00e dhcpcd: Detach from launcher before stopping root process
This fixes non privsep builds where the launcher reports dhcpcd
hungup. Unsure why this happens, but it should not be a problem.

While here, shutdown has no effect on non STREAM sockets and
remove the silly error logging in fork_cb that we read an
error. We already printed the error so this makes no sense.

Hopefully fixes #262.
2023-11-12 12:16:53 +00:00
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