]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Refuse chroot if privsep users home dir is /var/empty
authorRoy Marples <roy@marples.name>
Mon, 30 Mar 2020 16:12:26 +0000 (17:12 +0100)
committerRoy Marples <roy@marples.name>
Mon, 30 Mar 2020 16:12:26 +0000 (17:12 +0100)
As we should not be filling it.
This means we don't mess up a stock install where the pkg admin
hasn't setup privsep correctly.

src/privsep.c

index 99a507e77b39fb363d54981b5516e1788c1b9a4a..be4dc34efc5188a379c3b8fb00f4ee2dbffe85ee 100644 (file)
@@ -113,6 +113,13 @@ ps_init(struct dhcpcd_ctx *ctx)
                return -1;
        }
 
+       /* If we pickup the _dhcp user refuse the default directory */
+       if (strcmp(pw->pw_dir, "/var/empty") == 0) {
+               logerrx("refusing chroot: %s: %s", PRIVSEP_USER, pw->pw_dir);
+               errno = 0;
+               return -1;
+       }
+
        /* Create the database directory. */
        if (snprintf(path, sizeof(path), "%s%s", pw->pw_dir, DBDIR) == -1 ||
            ps_mkdir(path) == -1 ||