Commit Graph

304 Commits

Author SHA1 Message Date
Roy Marples
e322db4915 For systems without open_memstream(3) warn that /tmp needs to exit
Inside the privsep users home directory.
2020-05-27 15:52:01 +00:00
Roy Marples
12b0db43b2 privsep: Allow Linux to work without needing any mounts 2020-05-24 05:47:14 +00:00
Roy Marples
b51f785d92 privsep: Just ensure default user has a home directory 2020-05-12 11:32:22 +01:00
Roy Marples
a9671ceddf privsep: No longer need the chrootdir configure option.
As we work with an empty chroot directory.
2020-05-12 11:23:03 +01:00
Roy Marples
8ec63e6a62 privsep: Implement pledge(2) support as found on OpenBSD 2020-05-10 16:09:54 +01:00
Roy Marples
08958eaee7 privsep: Enable capsicum for network facing processes
All fd's in network facing processes are fully limited.
Capability mode is only enabled for BPF processes because
it's too restrictive otherwise - the reasons are noted
in the commit.
2020-05-07 20:57:22 +01:00
Roy Marples
5a3fd90a17 privsep: Allow a blank string to force privsep users home directory
So FreeBSD users can set it like other OS's if they so choose.
2020-05-05 17:55:10 +01:00
Roy Marples
cc4dd2f134 privsep: Document any overridden chroot directory. 2020-05-05 17:34:54 +01:00
Roy Marples
1ad6c18f3e Log chrootdir set. 2020-05-04 16:32:37 +01:00
Roy Marples
c721907901 privsep: allow --chrootdir= to configure a default chroot directory 2020-04-30 21:26:16 +01:00
Roy Marples
cc2d257183 privsep: Add --chroot configurable
Overrides the directory to chroot to away from the privilege separation
users home directory.
2020-04-30 21:13:45 +01:00
Roy Marples
219bb4da4f configure: Set a blank default hostname for non Linux
Wups, I was debugging.
2020-04-16 23:26:49 +01:00
Roy Marples
fa54fc1687 privsep: Detect a suitable user for dhcpcd, otherwise use dhcpcd
System users generally have _ preceeding their username.
Only use this user if it exists and their home dir is not /var/empty.
Otherwise default to using dhcpcd.
2020-04-05 16:44:32 +01:00
Roy Marples
0227431cc8 Revert "privsep: default to using _dhcpcd and not _dhcp"
This reverts commit 36c47a8df0.
2020-04-05 15:52:50 +01:00
Roy Marples
a942a2622e privsep: default to using _dhcpcd and not _dhcp
_dhcp home dir defaults to /var/empty.
System integrators can and should be in charge of changing it when needed.
Packagers on the other hand don't have such a luxury and so should not
use _dhcp by default.
2020-04-10 10:17:38 +01:00
Roy Marples
fc6c3b857a dhcpcd: disable address sanitization by default
As recent production kernels ship with ASLR by default which
stops dhcpcd running dead when this is enabled.
We dont want to break a systems boot, so force it via configure.
2020-03-31 20:21:58 +01:00
Roy Marples
61be15b48f linux: the default hostname is (none)
It's blank for the BSD's.
Respect this when relinquishing the hostname.
2020-03-31 19:45:17 +01:00
Roy Marples
64f3b7cf2c another typo 2020-02-10 14:35:08 +00:00
Roy Marples
754f62b6b3 spelling: Correct both privilege and separation
Found by Arfrever.
2020-02-10 13:26:30 +00:00
Roy Marples
91f6f362cf Linux: setup mounts in chroot
This allows dhcpcd to work.
udev sadly requires /run/udev as well, so heh ho.
2020-01-21 22:09:14 +00:00
Roy Marples
fa070df4e9 ioctl: The POSIX signature differs from BSD and glibc
BSD and glibc have the signature for request as unsigned long.
musl and Solaris have a signed int.

As such, we need to detect this at compile time and adjust the
signature of our internal ioctl functions to match.
To keep the onwire format the same, memcpy the request to the
unsigned long request and back again, thus preserving the signedness.
2020-01-08 20:13:20 +00:00
Roy Marples
d67dbc4226 privsep: Support the generic _dhcp entry on DragonFly
No need to create a specific _dhcpcd user in this instance.
2019-12-18 14:38:03 +00:00
Roy Marples
d7cb42ad79 privsep: Allow priviledge separation user to be specified by configure 2019-12-02 00:43:07 +00:00
Roy Marples
8a7aa9822d privsep: Enable privsep by default
Except on Solaris where it's not expected to work.
2019-12-01 22:09:18 +00:00
Roy Marples
6502584888 privsep: Add support for priviledge separation
Not enabled by default - enable with ./configure --enable-privsep
Requires a user added to the system - default _dhcpcd

Several processes will be spawned off the main state engine:
a privileged actioneer and a generic network proxy.
Only the privileged actioneer process will retain root permissions.

When required, the privileged actioneer will also spawn
BPF listeners for BOOTP (DHCP) and ARP.
The BOOTP BPF listener should be a short lived process.
On kernels with RFC 5227 support, the ARP BPF listener will only
be used for ARPing and announcing a preferred address and will
also be a short lived process.

When not running in master mode, an address listener will be
spawned for each address (with the exception of RA dervived addresses)
dhcpcd cares about.

TODO:
 * Solaris support.
 * ARP BPF address filtering.
2019-11-28 16:41:15 +00:00
Roy Marples
5a60e41dd6 build: Add -Wundef to debugging CFLAGS 2019-11-28 12:22:28 +00:00
Roy Marples
49e5ee5eee build: Move rundir from /var/run to /var/run/dhcpcd
This will allow dhcpcd to create and unlink pidfiles and sockets
which it could otherwise not if dropped priviledges.

Downstream packages such as dhcpcd-ui will need to be adjusted.
2019-11-28 11:47:29 +00:00
Roy Marples
f8d107d75d build: Improve detection of dlopen(3) in libdl 2019-11-05 16:23:02 +00:00
Roy Marples
4442fe05d3 and more pretty 2019-11-04 20:02:36 +00:00
Roy Marples
e4aa0af49d build: make prior output more pretty 2019-11-04 19:56:32 +00:00
Roy Marples
0654ec3d63 build: Check compiler actually supports address sanitisation. 2019-11-04 19:56:51 +00:00
Roy Marples
e23d415cba build: Enforce address sanitisaton when debugging. 2019-11-03 23:24:09 +00:00
Max Coplan
c30ec8f17c Added documentation for undocumented option
The dbdir option is used to specify the location of the DHCPd database.  The default /var/db is not FHS compliant so some may wish to change this to
2019-10-16 17:31:20 -04:00
Roy Marples
70d2685dc5 FreeBSD: Fix test for setproctitle 2019-10-16 15:19:58 +01:00
Roy Marples
f12658df3e compat: Add setproctitle from LXC 2019-10-14 21:49:31 +01:00
Roy Marples
04e663b990 DragonFlyBSD: rc.d scripts need onestatus also .... 2019-09-19 08:54:08 +01:00
Roy Marples
964b161594 Dilos: work with Debian style configure calling 2019-09-13 20:33:25 +03:00
Roy Marples
93d62baa84 build: Fix DragonFlyBSD config for import. 2019-09-05 09:35:23 +01:00
Roy Marples
20101dd485 Solaris: remove development warning, all looks good now :) 2019-09-04 06:53:33 +03:00
Roy Marples
0134c158ad OpenBSD: Fix compile 2019-08-28 22:57:11 +01:00
Roy Marples
82caef1651 build: Fix import-src when there is no compat to import. 2019-08-28 22:41:11 +01:00
Roy Marples
24211e21be DragonFly: make import-src now prepares the source for importing
I'm a lazy man and there's too many steps to import dhcpcd into
DragonFlyBSD, so hopefully this makes it a lot easier.
2019-08-28 16:15:04 +01:00
Roy Marples
5f106a2237 rbtree: Fix building from a DragonFlyBSD import 2019-08-28 13:55:02 +01:00
Roy Marples
f61961f5cb queue: Support TAILQ_FOREACH_MUTABLE
Basically another name for TAILQ_FOREACH_SAFE.
2019-08-28 13:52:38 +01:00
Roy Marples
ecbfe26bf8 DragonFlyBSD: hooks live in /usr/libexec
Which is inconsitent with dhcpcd living in /sbin!
Still, that's what it is. While here, if the build system
defines directories, don't re-define them.
2019-08-28 13:50:06 +01:00
Roy Marples
8d8adc107a configure: Fix test for open_memstream
glibc-2.19 needs the return value testing....
2019-07-28 12:53:03 +01:00
Roy Marples
eadb341911 Merge branch 'memstream' 2019-07-04 12:22:46 +01:00
Oleksandr Kravchuk
e08a91245d Fix typo in configure 2019-06-25 22:28:35 +02:00
Roy Marples
c8521994da script: Write variables to a FILE
Each variable is NULL terminated inside the file just like the
control stream which saves us from having to flatten it when
writing to the control stream.
Once written, create env pointers to the start of each string
just after the NULL terminator.

This also means that we just need to free two buffers when
dhcpcd exits (FILE buffer and env buffer) rather than each variable
individually.

If open_memstream(3) is not supported by libc then dhcpcd will
write to a file in /tmp instead.
2019-06-18 11:33:53 +01:00
Roy Marples
1257e19195 Merge branch 'master' into rbtree 2019-05-04 11:05:17 +01:00