]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Note CHROOT script
authorRoy Marples <roy@marples.name>
Tue, 21 Jan 2020 22:35:31 +0000 (22:35 +0000)
committerRoy Marples <roy@marples.name>
Tue, 21 Jan 2020 22:35:31 +0000 (22:35 +0000)
While here make BUILDING.md match reality and fix a warning
compiling without privsep.

BUILDING.md
hooks/dhcpcd-run-hooks.8.in
src/privsep.c
src/script.c

index 87df556d1198519d7c07e9fde9811c05f065a152..20157b7617a293880b2fbad72cbcecde6b985acf 100644 (file)
@@ -22,6 +22,7 @@ Or by removing the following features:
   *  `--disable-arping`
   *  `--disable-ipv4ll`
   *  `--disable-dhcp6`
+  *  `--disable-privsep`
 
 You can also move the embedded extended configuration from the dhcpcd binary
 to an external file (LIBEXECDIR/dhcpcd-definitions.conf)
@@ -30,11 +31,6 @@ If dhcpcd cannot load this file at runtime, dhcpcd will work but will not be
 able to decode any DHCP/DHCPv6 options that are not defined by the user
 in /etc/dhcpcd.conf. This does not really change the total on disk size.
 
-## Priviledge Separation
-To enable this, use the `--enable-privsep` configure option.
-It's not enabled by default because it's an experimental feature and
-requires adding a user (default `_dhcpcd`) to the system.
-
 ## Cross compiling
 If you're cross compiling you may need set the platform if OS is different
 from the host.  
@@ -170,6 +166,11 @@ The configure program attempts to find hooks for systems you have installed.
 To add more simply
 `./configure -with-hook=ntp.conf`
 
+If running privilege separation and on Linux then the `00-linux` hook is
+**mandatory**.
+If you choose not to run it, then you are responsible for setting up the
+needed mount points: `/dev`, `/proc`, `/sys`, `/run/udev`
+
 Some system services expose the name of the service we are in,
 by default dhcpcd will pick `RC_SVCNAME` from the environment.
 You can override this in `CPPFLAGS+= -DRC_SVCNAME="YOUR_SVCNAME"`.
index af2f78ce5c0eb750ff2371b0ec29371d7c0bf55e..7cf17ed11199af2ed30e13004bb2bad7a8cbaf07 100644 (file)
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2006-2018 Roy Marples
+.\" Copyright (c) 2006-2020 Roy Marples
 .\" All rights reserved
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd February 20, 2018
+.Dd January 21, 2020
 .Dt DHCPCD-RUN-HOOKS 8
 .Os
 .Sh NAME
@@ -69,6 +69,7 @@ is set to the interface that
 is run on and
 .Ev $reason
 is to the reason why
+q
 .Nm
 was invoked.
 DHCP information to be configured is held in variables starting with the word
@@ -83,6 +84,8 @@ Here's a list of reasons why
 .Nm
 could be invoked:
 .Bl -tag -width EXPIREXXXEXPIRE6
+.It Dv CHROOT
+dhcpcd is starting up and needs to configure a chroot environment.
 .It Dv PREINIT
 dhcpcd is starting up and any pre-initialisation should be done.
 .It Dv CARRIER
@@ -150,6 +153,10 @@ and
 The following variables will then be set, along with any protocol supplied
 ones.
 .Bl -tag -width xnew_delegated_dhcp6_prefix
+.It Ev $chroot
+the directory where
+.Nm dhcpcd
+is chrooted.
 .It Ev $interface
 the name of the interface.
 .It Ev $protocol
index af9e27bf80385f00f84849fff5491ffe3532c49e..f0fd444f81afd33d44acf0621d57eca3ad4c88aa 100644 (file)
  * or address specific listener.
  * Spawn an unpriv process to send/receive common network data.
  * Then drop all privs and start running.
+ * Every process aside from the privileged actioneer is chrooted.
+ *
+ * dhcpcd will maintain the config file in the chroot, no need to handle
+ * this in a script or something.
  */
 
 #include <sys/socket.h>
index 81cae18c968a6105098b807308fafc583717d3e0..d919333a85a9062ef9a3c8115d67d66e6c19f66e 100644 (file)
@@ -275,11 +275,12 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
                goto eexit;
 
 #ifdef PRIVSEP
-       if (strcmp(reason, "CHROOT") == 0) {
+       if (ctx->options & DHCPCD_PRIVSEP && ctx->ps_user != NULL) {
                if (efprintf(fp, "chroot=%s", ctx->ps_user->pw_dir) == -1)
                        goto eexit;
-               goto make;
        }
+       if (strcmp(reason, "CHROOT") == 0)
+               goto make;
 #endif
 
        ifo = ifp->options;
@@ -508,7 +509,9 @@ dumplease:
                                goto eexit;
        }
 
+#ifdef PRIVSEP
 make:
+#endif
        /* Convert buffer to argv */
        fflush(fp);