}
static void
-stop_interface(struct interface *ifp)
+stop_interface(struct interface *ifp, const char *reason)
{
struct dhcpcd_ctx *ctx;
ifp->options->options |= DHCPCD_STOPPING;
dhcpcd_drop(ifp, 1);
- if (ifp->options->options & DHCPCD_DEPARTED)
- script_runreason(ifp, "DEPARTED");
- else
- script_runreason(ifp, "STOPPED");
+ script_runreason(ifp, reason == NULL ? "STOPPED" : reason);
/* Delete all timeouts for the interfaces */
eloop_q_timeout_delete(ctx->eloop, ELOOP_QUEUE_ALL, NULL, ifp);
}
if (ifp->active) {
logdebugx("%s: interface departed", ifp->name);
- ifp->options->options |= DHCPCD_DEPARTED;
- stop_interface(ifp);
+ stop_interface(ifp, "DEPARTED");
}
TAILQ_REMOVE(ctx->ifaces, ifp, next);
if_free(ifp);
if (ifp->options->options & DHCPCD_RELEASE)
ifp->options->options &= ~DHCPCD_PERSISTENT;
ifp->options->options |= DHCPCD_EXITING;
- stop_interface(ifp);
+ stop_interface(ifp, NULL);
}
}
ifp->options->options |= opts;
if (opts & DHCPCD_RELEASE)
ifp->options->options &= ~DHCPCD_PERSISTENT;
- stop_interface(ifp);
+ stop_interface(ifp, NULL);
}
return 0;
}
break;
default:
setproctitle("[launcher]");
- ctx.options |= DHCPCD_FORKED;
+ ctx.options |= DHCPCD_FORKED | DHCPCD_LAUNCHER;
ctx.fork_fd = fork_fd[0];
close(fork_fd[1]);
#ifdef PRIVSEP_RIGHTS
#define DHCPCD_NOALIAS (1ULL << 39)
#define DHCPCD_IA_FORCED (1ULL << 40)
#define DHCPCD_STOPPING (1ULL << 41)
-#define DHCPCD_DEPARTED (1ULL << 42)
+#define DHCPCD_LAUNCHER (1ULL << 42)
#define DHCPCD_HOSTNAME_SHORT (1ULL << 43)
#define DHCPCD_EXITING (1ULL << 44)
#define DHCPCD_WAITIP4 (1ULL << 45)
{
struct passwd *pw = ctx->ps_user;
- if (!(ctx->options & DHCPCD_FORKED))
+ if (ctx->options & DHCPCD_LAUNCHER)
logdebugx("chrooting as %s to %s", pw->pw_name, pw->pw_dir);
if (chroot(pw->pw_dir) == -1 &&
(errno != EPERM || ctx->options & DHCPCD_FORKED))
}
logerr("%s: %s", __func__, sandbox);
return -1;
- } else if (!forked)
+ } else if (ctx->options & DHCPCD_LAUNCHER)
logdebugx("sandbox: %s", sandbox);
return 0;
}