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.
Roy Marples [Fri, 5 Jun 2020 10:12:21 +0000 (11:12 +0100)]
privsep: Remove pledges inet and dns from the master process
Achieved by adding IPC to ignore interfaces names based on
the interface group.
This means every process just pledges stdio for IPC which the
exception of the master process which also pledges route so it
can access the routing table.
Roy Marples [Wed, 3 Jun 2020 22:30:08 +0000 (23:30 +0100)]
eloop: Just use ppoll(2)
epoll and kqueue are really too heavy weight.
With privsep, we now favour more processes for BPF and per address sockets.
As such, the number of fds to monitor will always be quite small.
All modern OS now have ppoll(2) (NetBSD has pollts, which is the same)
which works perfectly for us.
If neither are present, the a wrapper around pselect(2) is provided,
which can be found on all POSIX systems.
This makes the code a lot smaller and easier to follow.
The reduced binary size and memory usage is a nice win here.
Roy Marples [Tue, 2 Jun 2020 14:50:17 +0000 (15:50 +0100)]
privsep: harden process handling
If eloop is exited, only allow explicit re-entry.
Only exit on read/write error if a forked process and not root.
If the root process fails to read/write to a sub-process,
stop the sub-process.
Roy Marples [Tue, 2 Jun 2020 02:01:37 +0000 (03:01 +0100)]
auth: Only accept RECONFIGURE messages from LL hosts
This has to be authentiated, and there is a chance we cannot know
the token if IP address sharing.
The initial messages are send via LL anyway, so the peer address
the server should record is the LL.
While here, drop the lease at exit if we accepted a reconfigure token.
The token may not be in all the replies from the server and we
always save the last reply.
Roy Marples [Thu, 28 May 2020 08:02:13 +0000 (09:02 +0100)]
DHCP6: Revert part of prior - only allow vendorclassid to disable
Not set.
dhcpcd owns the IANA_PEN defined.
Either use it as is, or get your own.
This restores the prior behaviour but still allows the option
as a whole to be disabled by vendorclassid being disabled.