dhcpcd-discuss

Re: privsep chroot dbdir

Roy Marples

Sat Mar 14 16:06:06 2020

Hi Julian, sorry for the late reply.

On 10/03/2020 11:54, Julian Wollrath wrote:
Am Tue, 10 Mar 2020 12:40:51 +0100
schrieb Julian Wollrath <julian@xxxxxxxxxxxx>:

Hi,

I have the home folder for the dhcpcd user set as /var/lib/dhcpcd
and hence the chroot for lives there. I set '--dbdir=/db' to get it
under /var/lib/dhcpcd/db. When I start dhcpcd in a pristine
installation /db gets created in addition to /var/lib/dhcpcd/db,
while I would expect, that only /var/lib/dhcpcd/db gets created,
since this is the only folder which is actually used. With a quick
glance, /var/lib/dhcpcd/db gets created by ps_init which should not
create /db but maybe there is also another place.

there is, probably it should be guarded as follows:
[…]

ähem, missing PRIVSEP before, correctly it should be:

diff --git a/src/dhcpcd.c b/src/dhcpcd.c
index d8c102bb..c4b503a4 100644
--- a/src/dhcpcd.c
+++ b/src/dhcpcd.c
@@ -2028,8 +2028,10 @@ printpidfile:
  		/* Ensure we have the needed directories */
  		if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST)
  			logerr("%s: mkdir `%s'", __func__, RUNDIR);
+#ifndef PRIVSEP
  		if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST)
  			logerr("%s: mkdir `%s'", __func__, DBDIR);
+#endif
if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
  			if (pid == -1)



Cheers,
Julian

Thanks for fixing this!

I fixed this differently here:
https://roy.marples.name/cgit/dhcpcd.git/commit/?id=303500c5365369ce8b8baed73d401b17b85544d1

Basically we need to test if in privsep or not and take action if not, so we can't just use an #ifdef

Roy

References:
privsep chroot dbdirJulian Wollrath
Re: privsep chroot dbdirJulian Wollrath
Re: privsep chroot dbdirJulian Wollrath
Archive administrator: postmaster@marples.name