diff options
| author | Roy Marples <roy@marples.name> | 2020-09-06 12:20:40 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-09-06 12:20:40 +0100 |
| commit | 887a28b736970e3c79a243f77986545cd56d62b1 (patch) | |
| tree | d4da27c7524873c153762fc33f71a48e9d55ba12 /src/dhcpcd.c | |
| parent | c7047b246b43453c8ecd42154b608b6f899b8b9e (diff) | |
| download | dhcpcd-887a28b736970e3c79a243f77986545cd56d62b1.tar.xz | |
privsep: Dump leases from stdin in a limited sandbox
Diffstat (limited to 'src/dhcpcd.c')
| -rw-r--r-- | src/dhcpcd.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 9c47ca7c..861ff3bf 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -2135,11 +2135,20 @@ printpidfile: } #endif +#ifdef PRIVSEP + ps_init(&ctx); +#endif + #ifndef SMALL if (ctx.options & DHCPCD_DUMPLEASE && ioctl(fileno(stdin), FIONREAD, &i, sizeof(i)) == 0 && i > 0) { + ctx.options |= DHCPCD_FORKED; /* pretend child process */ +#ifdef PRIVSEP + if (IN_PRIVSEP(&ctx) && ps_mastersandbox(&ctx) == -1) + goto exit_failure; +#endif ifp = calloc(1, sizeof(*ifp)); if (ifp == NULL) { logerr(__func__); @@ -2241,11 +2250,6 @@ printpidfile: if (freopen(_PATH_DEVNULL, "r", stdin) == NULL) logerr("%s: freopen stdin", __func__); - -#ifdef PRIVSEP - ps_init(&ctx); -#endif - #if defined(USE_SIGNALS) && !defined(THERE_IS_NO_FORK) if (xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, fork_fd) == -1 || xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, stderr_fd) == -1) |
