Roy Marples [Sat, 25 Jul 2020 13:22:18 +0000 (14:22 +0100)]
options: open an address socket to detect if inet6 is available
This should silence dhcpcd warnings if IPv6 is compiled out.
Do the same for IPv4, although that's highly unlikely as
it's kind of required for some interface ioctls.
Roy Marples [Tue, 30 Jun 2020 20:33:24 +0000 (21:33 +0100)]
dhcpcd: Turn off stderr logging rather than closing stderr
And only turn it off when stderr is a tty.
A better approach might to open an fd just to log to and
redirect stdout/stderr to /dev/null alongside stdin at program
start, but that's more code.
Roy Marples [Mon, 29 Jun 2020 10:54:29 +0000 (11:54 +0100)]
options: rework prior to use macros
Can't use DHCPCD_MASTER because a config option sets it - duh.
This allows us to use a different config option which makes little
sense in options but makes sense in the code.
Roy Marples [Tue, 23 Jun 2020 10:31:25 +0000 (11:31 +0100)]
Linux: redefine NLA_ALIGNTO as 4U
This removes the last of the alignment issues reported by clang
in the linux driver for dhcpcd.
Upstream has no interest in fixing this and local testing
shows it works fine on all platforms I have.
Roy Marples [Mon, 22 Jun 2020 20:56:16 +0000 (21:56 +0100)]
Linux: keep the generic netlink socket around to get ssid with privsep
While here, improve our reading of netlink(7) and terminate on either
ERROR or DONE. If neither are in the message, read again unless it's
the link receiving socket.
Also, only callback if this is the sequence number expected.
Ismael Luceno [Sun, 21 Jun 2020 14:06:14 +0000 (15:06 +0100)]
Libc implementations are allowed to require the explicit inclusion of
either <sys/types.h> (where it should be defined) or <sys/stat.h>
(prototypes requiring it) to expose mode_t.
Without that it fails to be exposed in musl libc, and potentially other
implementations.
Roy Marples [Mon, 15 Jun 2020 14:51:17 +0000 (15:51 +0100)]
DHCP6: Use sla setting when calculating delegated prefix length
This is fine as we have a limited list of interfaces we're
delegating to so we know all the numbers.
This fixes an issue where an interface index could exceed 8 bits.
Roy Marples [Mon, 15 Jun 2020 08:49:34 +0000 (09:49 +0100)]
BSD: Mark routes as static only from static config
Rather than if genered by an address.
This allows RA prefix routes without an address to be non static,
so you could derive whether a route came from something autoconf
or not.
Roy Marples [Thu, 11 Jun 2020 10:35:20 +0000 (11:35 +0100)]
udev: disable for non Linux systems
On FreeBSD udev, the function udev_device_new_from_subsystem_sysname
exists but is not implemented.
As such it breaks our device initialisation detection.
Disabled by default, but can be enabled with ./configure --with-udev
Roy Marples [Wed, 10 Jun 2020 15:32:04 +0000 (16:32 +0100)]
privsep: Fix a shutdown race
Only test a successful stop IPC command.
By the time we shutdown the socket to be extra nice, the
process we sent stop to could have already exited, therefore
we can discard any error.
Roy Marples [Wed, 10 Jun 2020 06:04:29 +0000 (07:04 +0100)]
privsep: Disable RLIMIT_FSIZE when using the logfile option
We cannot offload it to the root process either because not all
sandboxes have access to that.....
Really need to fix syslog so that it starts before dhcpcd.
Roy Marples [Tue, 9 Jun 2020 21:39:05 +0000 (22:39 +0100)]
privsep: For Linux and Solaris, set RLIMIT_NOFILES to nevents
Because poll(2) returns EINVAL if nfds is higher.
This really blows chunks, but it is what it is.
An attacker could close a fd and open something else, but it's
the best we can do.
Roy Marples [Tue, 9 Jun 2020 17:25:18 +0000 (18:25 +0100)]
privsep: Implement a resource limited sandbox
For systems without Capsicum or Pledge we can create a resource
limited sandbox provided that either ppoll(2) or works with
RLIMIT_NOFILES set to zero.
As far as dhcpcd is concerned, that means Linux and Solaris
won't work with this, but NetBSD and DragonFlyBSD will.
To achieve this, a special control proxy process will be spawned
just to accept new connections over the control socket because
this *cannot* be limited by RLIMIT_NOFILES.
Roy Marples [Fri, 5 Jun 2020 19:24:21 +0000 (20:24 +0100)]
privsep: Limit rights generically rather than Capsicum specifc
You never know when another sandbox tech comes around.
While here, add limits for every socket in the unpriviledged
processes. Some were absent before.
Also, note that RLIMIT_NOFILE breaks our control socket so
temporary disable that.