10 days agoRespect DHCPv6 for prior master
Roy Marples [Tue, 9 Aug 2022 16:56:44 +0000 (17:56 +0100)]
Respect DHCPv6 for prior

10 days agoAmend prior so that NTP servers are removed if the option vanishes
Roy Marples [Tue, 9 Aug 2022 16:32:49 +0000 (17:32 +0100)]
Amend prior so that NTP servers are removed if the option vanishes

10 days agohooks: Support timesyncd
Roy Marples [Tue, 9 Aug 2022 16:26:37 +0000 (17:26 +0100)]
hooks: Support timesyncd

Fixes #106

11 days agoinet6: Support RFC 4862 5.5.3.e in regards to Valid Lifetime
Roy Marples [Mon, 8 Aug 2022 15:47:55 +0000 (16:47 +0100)]
inet6: Support RFC 4862 5.5.3.e in regards to Valid Lifetime

      1.  If the received Valid Lifetime is greater than 2 hours or
          greater than RemainingLifetime, set the valid lifetime of the
          corresponding address to the advertised Valid Lifetime.

      2.  If RemainingLifetime is less than or equal to 2 hours, ignore
          the Prefix Information option with regards to the valid

      3.  Otherwise, reset the valid lifetime of the corresponding
          address to 2 hours.

3 weeks agooptions: Ensure that we correctly read auth tokens.
Roy Marples [Fri, 29 Jul 2022 07:00:09 +0000 (08:00 +0100)]
options: Ensure that we correctly read auth tokens.

3 weeks agodhcpcd-run-hooks.8: its and not it's for posessive.
Roy Marples [Fri, 29 Jul 2022 06:22:59 +0000 (07:22 +0100)]
dhcpcd-run-hooks.8: its and not it's for posessive.

Thanks to perkelix.
Fixes #110.

3 weeks agoAlways skip hooks ending in ~ (#113)
Adam Dinwoodie [Fri, 29 Jul 2022 06:14:41 +0000 (07:14 +0100)]
Always skip hooks ending in ~ (#113)

dhcpcd-run-hooks is intended to skip hooks with filenames ending in `~`,
but the test only works if `$skip_hooks` is defined and not empty.
Refactor the test such that files ending in `~` are always skipped, as
appears to be the intent of this code.

2 months agoDHCP: Fill chaddr if hwlen really is 16 bytes
Roy Marples [Thu, 2 Jun 2022 05:36:18 +0000 (06:36 +0100)]
DHCP: Fill chaddr if hwlen really is 16 bytes

This isn't normally a problem as ethernet is 6 bytes in length.
Spotted by Steve Noonan.

3 months agoLinux: Use netlink to workout address flags
Roy Marples [Wed, 20 Apr 2022 16:51:53 +0000 (17:51 +0100)]
Linux: Use netlink to workout address flags

There seems to be a race with netlink announcing the address vs
it's availability via /proc.
Fixes #76.

4 months agoadd support for loongarch64 (#93)
Wu Xiaotian [Thu, 31 Mar 2022 22:46:20 +0000 (06:46 +0800)]
add support for loongarch64 (#93)

5 months agoduid: Disable use of machine UUID by default.
Roy Marples [Sat, 12 Mar 2022 11:15:09 +0000 (11:15 +0000)]
duid: Disable use of machine UUID by default.

Fixes #89.

5 months agohooks: Use command -v rather than type
Roy Marples [Thu, 24 Feb 2022 12:53:02 +0000 (12:53 +0000)]
hooks: Use command -v rather than type

command -v is now required by POSIX, type is technically an extension.

5 months agoBump dates for prior
Roy Marples [Thu, 24 Feb 2022 06:34:10 +0000 (06:34 +0000)]
Bump dates for prior

5 months agoFixes manual page typos found by Lintian
Martin-Éric Racine [Thu, 24 Feb 2022 06:28:21 +0000 (06:28 +0000)]
Fixes manual page typos found by Lintian

9 months agodhcpcd.8: remove reference to 02-dump hook script
Roy Marples [Sat, 13 Nov 2021 14:10:31 +0000 (14:10 +0000)]
dhcpcd.8: remove reference to 02-dump hook script

This hook script was removed a while ago.
Fixes #72.

9 months agoAdd epair(4) to the ignored interface types list (#73)
Ben Woods [Sat, 13 Nov 2021 13:53:58 +0000 (21:53 +0800)]
Add epair(4) to the ignored interface types list (#73)

The FreeBSD epair(4) interface type can be thought of as a virtual patch cable.
The epair interfaces come in pairs, with network traffic being passed between the 2 pairs.
The basic intent is to provide connectivity between two virtual network stack instances.
This interface type does not typically require an IP address, as it is passing traffic
between other virtual networks/interfaces which obtain their own IP address.
Therefore, add this interface type to the list that will be ignored by dhcpcd.

9 months agoprivsep: Only set RLIMIT_NOFILES for supported platforms
Roy Marples [Fri, 12 Nov 2021 14:24:11 +0000 (14:24 +0000)]
privsep: Only set RLIMIT_NOFILES for supported platforms

Basically only for NetBSD, DragonFlyBSD, kqueue or epoll platforms.
All others will use poll(2) and return EINVAL if nfds > RLIMIT_NOFILES.

Trying to work out our nfs limit relies on already listening to
all FD's which may not be the case and was problematic.
Luckily all platforms aside from Solaris have new file creation
sandboxed away aside from accept(2) so this should still be safe.

9 months agosrc/privsep-linux.c: Add support of Synopsys ARC64 architecture (#66)
Veronika Kremneva [Wed, 27 Oct 2021 19:53:22 +0000 (22:53 +0300)]
src/privsep-linux.c: Add support of Synopsys ARC64 architecture (#66)

Signed-off-by: Veronika Kremneva <kremneva@synopsys.com>
9 months agoprivsep: and again on OpenBSD
Roy Marples [Wed, 20 Oct 2021 10:21:38 +0000 (11:21 +0100)]
privsep: and again on OpenBSD

9 months agoprivsep: Fix compile on Dragonfly BSD
Roy Marples [Wed, 20 Oct 2021 09:23:19 +0000 (10:23 +0100)]
privsep: Fix compile on Dragonfly BSD

10 months agoREADME.md: Remove non existant man page links.
Roy Marples [Mon, 18 Oct 2021 14:25:35 +0000 (15:25 +0100)]
README.md: Remove non existant man page links.

They have not been online for sometime and are unlikely to return.
While here, correct the commit log location.

Fixes #39

10 months agoDHCP: Set INFORM state only when we are about to inform
Roy Marples [Thu, 14 Oct 2021 05:31:11 +0000 (06:31 +0100)]
DHCP: Set INFORM state only when we are about to inform

As we may not find an address right away.
While here, tidy up and comment code about deriving the address
when none is specified for inform and static setups.

10 months agoDHCP: Fix infinite INFORM messages
Kaelan Mikowicz [Thu, 14 Oct 2021 05:14:45 +0000 (22:14 -0700)]
DHCP: Fix infinite INFORM messages

When an address is configured on the interface, do not send an
INFORM message if the interface is already bound.

Fixes #48

10 months agoprivsep: Fix getting interface VLANID on BSD (#58)
Philip Paeps [Tue, 12 Oct 2021 08:07:28 +0000 (16:07 +0800)]
privsep: Fix getting interface VLANID on BSD (#58)

Include relevant headers for the definition of SIOCGETVLAN.  This fixes
DHCPv6 Prefix Delegation where a prefix is delegated to several VLAN
interfaces on the same physical interface.

10 months agoDHCP6: Don't spam the log when a RA repeatedly triggers an INFORM
Roy Marples [Fri, 1 Oct 2021 15:25:53 +0000 (16:25 +0100)]
DHCP6: Don't spam the log when a RA repeatedly triggers an INFORM

This can occur if the RA reduces the prefix times in accordance
with it's own lifetimes for example.
dhcpcd only checks if the RA contents have changed to trigger a

As such, only log about new INFORMs.

Fixes #46.

11 months agoprivsep: Enforce proper alignment of serialized struct cmsghdr
Marian Cingel [Tue, 31 Aug 2021 12:33:20 +0000 (13:33 +0100)]
privsep: Enforce proper alignment of serialized struct cmsghdr

Fixes #43.

11 months agoDHCP6: Only send FQDN for SOLICIT, REQUEST, RENEW, or REBIND messages.
Roy Marples [Tue, 31 Aug 2021 09:57:44 +0000 (10:57 +0100)]
DHCP6: Only send FQDN for SOLICIT, REQUEST, RENEW, or REBIND messages.

As per RFC 4704 section 5.
Fixes #44.

11 months agoFix rt_cmp_dest() for equivalent network prefixes with different netmasks. (#52)
Stefan Sperling [Tue, 31 Aug 2021 09:31:15 +0000 (11:31 +0200)]
Fix rt_cmp_dest() for equivalent network prefixes with different netmasks. (#52)

When rt_add() decides that it must delete+add a route in order to change
the routing table entry, a wrong RB tree lookup result can throw it off
the rails. In the case observed, a static /64 prefix was deleted from
vlan1 while dhcpcd intended to delete its reject route bound to lo0.

Given two routes in the table, the loopback reject route installed by
dhcpd for my /48 prefix, and a cloning route for a /64 prefix on vlan1:

2001:db8::/48 ::1         UGR        0        0 32768    56 lo0
2001:db8::/64 2001:db8::1 UCn        1        2     -     4 vlan1

When searching the OS routing table dhcpcd attempts to tell routes apart
based only on the masked destination address. In the above case the masked
destinations look identical. The only difference is the length of the netmask.
The function rt_cmp_dest() didn't detect this and returned the /64 route
while dhcpcd was in fact searching for the /48 route.

This patch fixes the lookup by running rt_cmp_netmask() if the masked
destination comparison via sa_cmp() leaves us with a tie. With this change
dhcpcd deletes the /48 route as intended, and leaves the /64 route alone.

I had to move the rt_cmp_dest() function down since it needs to use the
static helper function rt_cmp_netmask(), which happened to be defined
just below rt_cmp_dest().

Why am I using an overlapping static prefix? The answer is that my ISP
assigns a static /48 prefix but won't route IPv6 unless my router sends
a DHCPv6 request when it connects via PPPoE. I configure static IPv6 subnets
on LAN interfaces and have configured dhcpcd to obtain a /48 prefix lease
without setting addresses on any internal interfaces.
My dhcpcd.conf contains:
  option rapid_commit
  require dhcp_server_identifier
  script ""
  allowinterfaces pppoe0
  interface pppoe0
    ia_pd 1 /2001:db8::/48

This problem was found on OpenBSD, in case that matters for reproduction
of the issue.

11 months agoUpdate man pages for default metric changes (#51)
Peter Fabinski [Tue, 31 Aug 2021 09:29:25 +0000 (05:29 -0400)]
Update man pages for default metric changes (#51)

* Update man pages for metric changes in 3547ed19

* Make metric man changes additive

11 months agoFix parsing of hex/octal escapes in strings (#42)
Craig McQueen [Fri, 20 Aug 2021 07:57:18 +0000 (17:57 +1000)]
Fix parsing of hex/octal escapes in strings (#42)

12 months agoMerge pull request #38 from concatime/posix-shell
Roy Marples [Tue, 20 Jul 2021 10:06:32 +0000 (11:06 +0100)]
Merge pull request #38 from concatime/posix-shell

configure: test -a|o is not POSIX

13 months agoBuild as dhcpcd-9.99 now we have a dhcpcd-9 branch.
Roy Marples [Mon, 19 Jul 2021 20:25:45 +0000 (21:25 +0100)]
Build as dhcpcd-9.99 now we have a dhcpcd-9 branch.

13 months agoIPv4LL: Don't remove statically assigned addresses
Roy Marples [Mon, 19 Jul 2021 20:22:44 +0000 (21:22 +0100)]
IPv4LL: Don't remove statically assigned addresses

Fixes #37.

While here, don't open a DHCP port for static addresses either
when not in manager mode.

15 months agoconfigure: test -a|o is not POSIX
Issam E. Maghni [Tue, 4 May 2021 16:33:02 +0000 (12:33 -0400)]
configure: test -a|o is not POSIX

17 months agoFreeBSD: Finish EVFILT_PROCDESC implementation.
Roy Marples [Thu, 18 Mar 2021 12:14:54 +0000 (12:14 +0000)]
FreeBSD: Finish EVFILT_PROCDESC implementation.

17 months agoFix more new eloop fallout.
Roy Marples [Wed, 17 Mar 2021 20:16:20 +0000 (20:16 +0000)]
Fix more new eloop fallout.

17 months agoprivsep: Implement pdfork(2) for capsicum(4)
Roy Marples [Wed, 17 Mar 2021 20:13:02 +0000 (20:13 +0000)]
privsep: Implement pdfork(2) for capsicum(4)

Capsicum does not allow waitpid(2).
As such we need to use pdfork(2) and watch for the descriptor to

17 months agoprivsep: Fix FreeBSD for prior
Roy Marples [Wed, 17 Mar 2021 15:19:27 +0000 (15:19 +0000)]
privsep: Fix FreeBSD for prior

17 months agoprivsep: Fix Linux support for prior
Roy Marples [Wed, 17 Mar 2021 15:12:22 +0000 (15:12 +0000)]
privsep: Fix Linux support for prior

17 months agoprivsep: Remove debug from prior
Roy Marples [Wed, 17 Mar 2021 15:11:53 +0000 (15:11 +0000)]
privsep: Remove debug from prior

17 months agoprivsep: Implement some process management
Roy Marples [Wed, 17 Mar 2021 15:03:52 +0000 (15:03 +0000)]
privsep: Implement some process management

This also allows us to wait until all processes have exited to
avoid a fast restart which complains addresses are in use.

17 months agoprivsep: Don't close control proxy on hangup
Roy Marples [Wed, 17 Mar 2021 14:23:55 +0000 (14:23 +0000)]
privsep: Don't close control proxy on hangup

Instead wait for it to be closed by the master process for a
clean shtudown.

17 months agocontrol: Fix working with new eloop
Roy Marples [Wed, 10 Mar 2021 13:09:39 +0000 (13:09 +0000)]
control: Fix working with new eloop

17 months agosrc/privsep-linux.c: add support for m68k (#29)
Fabrice Fontaine [Mon, 8 Mar 2021 10:05:16 +0000 (11:05 +0100)]
src/privsep-linux.c: add support for m68k (#29)

Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
17 months agoREADME.md: remove dead reference to phabricator
Roy Marples [Mon, 8 Mar 2021 09:43:50 +0000 (09:43 +0000)]
README.md: remove dead reference to phabricator

17 months agocontrol: Cannot write with hangup
Roy Marples [Sat, 20 Feb 2021 16:25:05 +0000 (16:25 +0000)]
control: Cannot write with hangup

18 months agoeloop: delete events from kqueue/epoll directly
Roy Marples [Tue, 16 Feb 2021 16:43:18 +0000 (16:43 +0000)]
eloop: delete events from kqueue/epoll directly

Rather than relying on close(2) being called.
Whilst a bit less performant with many open/close, there is also
no guarantee that close(2) will actually be called as
shutdown(2) could be used instead.

18 months agolog a diagnostic here
Roy Marples [Tue, 16 Feb 2021 16:40:35 +0000 (16:40 +0000)]
log a diagnostic here

18 months agocontrol: Don't log error deleting fds from eloop.
Roy Marples [Tue, 9 Feb 2021 11:36:07 +0000 (11:36 +0000)]
control: Don't log error deleting fds from eloop.

They might not be added as they are inactive and its just noise
as no operation is done anymore even for kqueue or epoll.

18 months agoBSD: Find the correct interface for tunneled routes
Roy Marples [Tue, 9 Feb 2021 10:11:54 +0000 (10:11 +0000)]
BSD: Find the correct interface for tunneled routes

Should disard a harmless diagnostic.

18 months agocontrol: GC control deletion
Roy Marples [Mon, 8 Feb 2021 19:25:08 +0000 (19:25 +0000)]
control: GC control deletion

Just free it entirely.

18 months agosrc/privsep-linux.c: add support for arc (#28)
Fabrice Fontaine [Mon, 8 Feb 2021 06:23:54 +0000 (07:23 +0100)]
src/privsep-linux.c: add support for arc (#28)

Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?

It should be noted that AUDIT_ARCH_{ARCOMPACT,ARCV2} is only defined
since kernel 5.2 and

Detection of arc compact and arc v2 have been "copy/pasted" from

 - http://autobuild.buildroot.org/results/d29083700a80dd647621eed06faeeae03f0587d3

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18 months agosrc/privsep-linux.c: add support for or1k (#27)
Fabrice Fontaine [Sun, 7 Feb 2021 08:43:14 +0000 (09:43 +0100)]
src/privsep-linux.c: add support for or1k (#27)

Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?

It should be noted that AUDIT_ARCH_OPENRISC is defined since kernel 3.7:

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18 months agoForce TOP as we know which directory we are in.
Roy Marples [Fri, 5 Feb 2021 22:41:16 +0000 (22:41 +0000)]
Force TOP as we know which directory we are in.

18 months agocontrol fd can be both read and write.
Roy Marples [Fri, 5 Feb 2021 21:56:40 +0000 (21:56 +0000)]
control fd can be both read and write.

18 months agosrc/privsep-linux: fix build on sparc (#26)
Fabrice Fontaine [Fri, 5 Feb 2021 08:25:12 +0000 (09:25 +0100)]
src/privsep-linux: fix build on sparc (#26)

Fix the following build failure:

privsep-linux.c:203: warning: "AUDIT_ARCH_SPARC64" redefined
  203 | #    define AUDIT_ARCH_SPARC64
In file included from privsep-linux.c:35:
/srv/storage/autobuild/run/instance-0/output-1/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/linux/audit.h:392: note: this is the location of the previous definition
In file included from privsep-linux.c:36:
privsep-linux.c:215:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?
      |                                      ^~~~~~~~~~~~~~~~~~

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18 months agosrc/privsep-linux.c: add support for sh (#25)
Fabrice Fontaine [Fri, 5 Feb 2021 08:05:54 +0000 (09:05 +0100)]
src/privsep-linux.c: add support for sh (#25)

Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?

It should be noted that AUDIT_ARCH_{SH,SHEL,SH64,SHEL64} are defined at
least since kernel 3.7 and

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18 months agoFix tests
Roy Marples [Wed, 3 Feb 2021 20:52:01 +0000 (20:52 +0000)]
Fix tests

18 months agoRename Privileged Actioneer to Privileged Proxy
Roy Marples [Tue, 2 Feb 2021 17:09:25 +0000 (17:09 +0000)]
Rename Privileged Actioneer to Privileged Proxy

Sadly actioneer is not a real word.

18 months agoRename Master to Manager
Roy Marples [Tue, 2 Feb 2021 16:54:09 +0000 (16:54 +0000)]
Rename Master to Manager

18 months agoFix prior for epoll.
Roy Marples [Tue, 2 Feb 2021 15:10:20 +0000 (15:10 +0000)]
Fix prior for epoll.

18 months agoeloop: Make the API more like native poll/kqueue/epoll
Roy Marples [Tue, 2 Feb 2021 14:41:54 +0000 (14:41 +0000)]
eloop: Make the API more like native poll/kqueue/epoll

Just have the one callback, but return an abstracted event mask
to work out if we can read/write have something else.
Log diagnostics if the event mask is unexpected.

While here add more logging if we fail to register an event to

18 months agoAdd __NR_pselect6_time64 to priory
Roy Marples [Sun, 31 Jan 2021 21:12:26 +0000 (21:12 +0000)]
Add __NR_pselect6_time64 to priory

18 months agoLinux: allow pselect(2) to work in SECCOMP
Roy Marples [Sun, 31 Jan 2021 21:07:43 +0000 (21:07 +0000)]
Linux: allow pselect(2) to work in SECCOMP

The default is ppoll(2), but we still allow epoll(7) so
allowing pselect(2) makes perfect sense and allows the user
to pick the polling mechanism they want.

18 months ago src/privsep-linux.c: add support for microblaze (#24)
Fabrice Fontaine [Sun, 31 Jan 2021 20:57:40 +0000 (21:57 +0100)]
 src/privsep-linux.c: add support for microblaze (#24)

Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?

It should be noted that AUDIT_ARCH_MICROBLAZE is only defined since
kernel 3.18 and

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18 months agoA belated welcome to 2021
Roy Marples [Sun, 31 Jan 2021 10:33:21 +0000 (10:33 +0000)]
A belated welcome to 2021

18 months ago src/privsep-linux.c: add support for nios2 (#23)
Fabrice Fontaine [Sun, 31 Jan 2021 10:12:21 +0000 (11:12 +0100)]
 src/privsep-linux.c: add support for nios2 (#23)

Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?

It should be noted that AUDIT_ARCH_NIOS2 is only defined since kernel
5.2 and

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18 months agoTypo with prior
Roy Marples [Sun, 31 Jan 2021 10:08:11 +0000 (10:08 +0000)]
Typo with prior

18 months agoLinux: Add support for NDS32BE SECCOMP
Roy Marples [Sun, 31 Jan 2021 07:37:03 +0000 (07:37 +0000)]
Linux: Add support for NDS32BE SECCOMP

18 months ago src/privsep-linux.c: add support for xtensa (#22)
Fabrice Fontaine [Sun, 31 Jan 2021 02:35:10 +0000 (03:35 +0100)]
 src/privsep-linux.c: add support for xtensa (#22)

Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?

It should be noted that AUDIT_ARCH_XTENSA is only defined since kernel
5.0 and

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18 months agoimport-src: Improve target so we don't create empty files
Roy Marples [Sat, 30 Jan 2021 12:21:15 +0000 (12:21 +0000)]
import-src: Improve target so we don't create empty files

18 months agoimport-src: adjust build target so all .in files are pre-built
Roy Marples [Sat, 30 Jan 2021 11:46:06 +0000 (11:46 +0000)]
import-src: adjust build target so all .in files are pre-built

While here, if we cannot find ypbind to work out how the hook script
should be configured, guess according to OS.

18 months agosrc/privsep-linux.c: add support for nds32 (#21)
Fabrice Fontaine [Sat, 30 Jan 2021 11:10:08 +0000 (12:10 +0100)]
src/privsep-linux.c: add support for nds32 (#21)

Fix the following build failure:

privsep-linux.c:206:4: error: #error "Platform does not support seccomp filter yet"
 #  error "Platform does not support seccomp filter yet"
In file included from privsep-linux.c:36:
privsep-linux.c:213:38: error: 'SECCOMP_AUDIT_ARCH' undeclared here (not in a function); did you mean 'SECCOMP_ALLOW_ARG'?

It should be noted that AUDIT_ARCH_NDS32 is only defined since kernel
5.2 and

 - http://autobuild.buildroot.org/results/af8ba07ea0c12ab8cd24d528ef98db05521f3d36

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18 months agoeloop: optimise the pselect code so it's not a wrapper for ppoll
Roy Marples [Sat, 30 Jan 2021 11:04:53 +0000 (11:04 +0000)]
eloop: optimise the pselect code so it's not a wrapper for ppoll

This makes the code smaller yet and also use less memory then ppoll!
Still, the API blows chunks and we still have arbitary fd limits
which we'll realistically never hit.
Also, some BSD's note potential issues with select on the same fd
across processes so ppoll is still the winner.

18 months agoeloop: Default to using ppoll(2) again.
Roy Marples [Sat, 30 Jan 2021 01:37:15 +0000 (01:37 +0000)]
eloop: Default to using ppoll(2) again.

Even though we now have fully working kqueue(2) and epoll(7)
with our privsep code, ppoll(2) is faster and smaller for our

This time though, we will keep the code here as it's fully working
and while fixing kqueue we also fixed other bugs in dhcpcd as a result
so it's not time wasted at all.

18 months agoeloop: Fix logic error with epoll reading test
Roy Marples [Fri, 29 Jan 2021 22:10:21 +0000 (01:10 +0300)]
eloop: Fix logic error with epoll reading test

18 months agoeloop: Always free the pollfd buffer when clearing events
Roy Marples [Fri, 29 Jan 2021 11:13:43 +0000 (11:13 +0000)]
eloop: Always free the pollfd buffer when clearing events

And set the flag to re-create it before the next run.
This allows us to always ensure it's small if the prior run
used more signals and fds.

18 months agoeloop: fix a memory leak when clearing events
Roy Marples [Fri, 29 Jan 2021 06:48:17 +0000 (06:48 +0000)]
eloop: fix a memory leak when clearing events

18 months agoWhitespace
Roy Marples [Fri, 29 Jan 2021 06:46:39 +0000 (06:46 +0000)]

18 months agoeloop: fixup a compile warning
Roy Marples [Thu, 28 Jan 2021 23:25:26 +0000 (23:25 +0000)]
eloop: fixup a compile warning

18 months agoBSD: Plug a memory leak
Roy Marples [Thu, 28 Jan 2021 23:24:49 +0000 (23:24 +0000)]
BSD: Plug a memory leak

18 months agoLinux: Implement epoll(7) for eloop (again)
Roy Marples [Thu, 28 Jan 2021 17:26:20 +0000 (17:26 +0000)]
Linux: Implement epoll(7) for eloop (again)

eloop allows for O(1) processing of active fd's.
The problems with the prior implementation have now been fixed.

18 months agocontrol: Don't log the write db didn't exist when freeing it.
Roy Marples [Thu, 28 Jan 2021 17:26:08 +0000 (17:26 +0000)]
control: Don't log the write db didn't exist when freeing it.

18 months agoprivsep: Restore the poll maxfd + 1 for state engine
Roy Marples [Thu, 28 Jan 2021 13:17:57 +0000 (13:17 +0000)]
privsep: Restore the poll maxfd + 1 for state engine

It wasn't fixed, it was using kqueue so avoided!

18 months agoDragonFly: cast away more kqueue compile warnings
Roy Marples [Thu, 28 Jan 2021 12:51:47 +0000 (12:51 +0000)]
DragonFly: cast away more kqueue compile warnings

18 months agoFreeBSD: cast away some kqueue warnings
Roy Marples [Thu, 28 Jan 2021 12:39:07 +0000 (12:39 +0000)]
FreeBSD: cast away some kqueue warnings

NetBSD uses size_t, FreeBSD uses int for changelist length.

18 months agoprivsep: Don't add 1 to max fd open when limiting resources
Roy Marples [Thu, 28 Jan 2021 12:13:45 +0000 (12:13 +0000)]
privsep: Don't add 1 to max fd open when limiting resources

It shoud no longer be needed for OpenBSD, Linux and Solaris.

18 months agoOpenBSD: Fix kqueue detection and one error.
Roy Marples [Thu, 28 Jan 2021 12:13:24 +0000 (12:13 +0000)]
OpenBSD: Fix kqueue detection and one error.

18 months agoBSD: Implement kqueue(2) for eloop (again)
Roy Marples [Thu, 28 Jan 2021 11:54:05 +0000 (11:54 +0000)]
BSD: Implement kqueue(2) for eloop (again)

kqueue allows for O(1) processing of active fd's an a more
robust signal handling method without the need to use global
variables to avoid calling functions during signal delivery.

The problems with the prior implemenation have now been fixed.

18 months agoprivsep: move setting signals to after clearing eloop
Roy Marples [Wed, 27 Jan 2021 14:11:52 +0000 (14:11 +0000)]
privsep: move setting signals to after clearing eloop

18 months agoWhitespace
Roy Marples [Wed, 27 Jan 2021 13:45:34 +0000 (13:45 +0000)]

18 months agoprivsep: Ensure BPF listener pid is logged in debug
Roy Marples [Wed, 27 Jan 2021 13:37:31 +0000 (13:37 +0000)]
privsep: Ensure BPF listener pid is logged in debug

This mirrors the inet listener.

18 months agocontrol: log an error if we fail to remove the write callback
Roy Marples [Wed, 27 Jan 2021 13:33:52 +0000 (13:33 +0000)]
control: log an error if we fail to remove the write callback

18 months agoWhitespace
Roy Marples [Wed, 27 Jan 2021 13:31:51 +0000 (13:31 +0000)]

18 months agocontrol: unlink privileged socket when shutting down without privsep
Roy Marples [Tue, 26 Jan 2021 17:37:29 +0000 (17:37 +0000)]
control: unlink privileged socket when shutting down without privsep

Otherwise we have a connection refused when dhcpcd starts again
as it sees the stale socket file.

18 months agoLinux: fix a memory leak when dhcpcd exits or the log is reopened
Roy Marples [Sun, 24 Jan 2021 22:53:20 +0000 (22:53 +0000)]
Linux: fix a memory leak when dhcpcd exits or the log is reopened

18 months agoeloop: Allow eloop to process all fds returned from poll(2)
Roy Marples [Sun, 24 Jan 2021 22:22:25 +0000 (22:22 +0000)]
eloop: Allow eloop to process all fds returned from poll(2)

We do this by ensuring the events list or pollfd struct storage
is not modified during the revent processing.
An event with a fd of -1 means it's been deleted and one without
a pollfd struct reference has been newly added.
This also allows us to count down the number of fd's that
returned a revent so we can break the loop early if possible.

This is a really minor optimisation that at best only applies if
more than one revent is returned via poll(2).
In the case on dhcpcd on NetBSD with privsep, the number of
fd's is really low. And on other platforms or without privsep it's
low also (just not as low).
It's only when you run dhcpcd per interface that the number
of fd's starts to creep upwards as you then need one per address
dhcpcd is monitoring (as well as the ARP listener per IPv4 address
for non NetBSD).

However, I use eloop in other code where this could be a good saving
and dhcpcd is where the master version of this lives!

19 months agoscript: Use rt_proto_add to ensure no duplicate interfaces on OpenBSD
Roy Marples [Mon, 18 Jan 2021 11:31:05 +0000 (11:31 +0000)]
script: Use rt_proto_add to ensure no duplicate interfaces on OpenBSD

OpenBSD allows matching priorities, so we need to take the interfaces
in the order given to ensure uniqueness.

19 months agoRelease dhcpcd-9.4.0 dhcpcd-9.4.0
Roy Marples [Mon, 28 Dec 2020 12:59:20 +0000 (12:59 +0000)]
Release dhcpcd-9.4.0

19 months agoscript: ignore inactive interfaces for ordering
Roy Marples [Mon, 28 Dec 2020 01:59:57 +0000 (01:59 +0000)]
script: ignore inactive interfaces for ordering