From: Roy Marples Date: Sun, 2 Jul 2023 00:28:34 +0000 (+0100) Subject: privsep: Only unlink control sockets if we created them X-Git-Tag: v10.0.2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=327e19a5cce11e0250f086695641b4a3b238ee4f;p=thirdparty%2Fdhcpcd.git privsep: Only unlink control sockets if we created them Fixes a segfault when trying to start dhcpcd as a non root user. Closes #219 without an explicit test for being the root user. --- diff --git a/src/control.c b/src/control.c index 3de8bf91..5325ac35 100644 --- a/src/control.c +++ b/src/control.c @@ -498,9 +498,11 @@ control_stop(struct dhcpcd_ctx *ctx) #ifdef PRIVSEP if (IN_PRIVSEP_SE(ctx)) { - if (ps_root_unlink(ctx, ctx->control_sock) == -1) + if (ctx->control_sock[0] != '\0' && + ps_root_unlink(ctx, ctx->control_sock) == -1) retval = -1; - if (ps_root_unlink(ctx, ctx->control_sock_unpriv) == -1) + if (ctx->control_sock_unpriv[0] != '\0' && + ps_root_unlink(ctx, ctx->control_sock_unpriv) == -1) retval = -1; return retval; } else if (ctx->options & DHCPCD_FORKED)