diff options
| author | Roy Marples <roy@marples.name> | 2020-05-24 05:47:14 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-05-24 05:47:14 +0000 |
| commit | 12b0db43b2a139744fbcf04824390fcb1de445ea (patch) | |
| tree | 5cde5e68c8d6710d707d8a54da0de97d856b7602 /src/privsep-root.c | |
| parent | c572835e98da5a186f7453f3daa2aec765ef2d9b (diff) | |
| download | dhcpcd-12b0db43b2a139744fbcf04824390fcb1de445ea.tar.xz | |
privsep: Allow Linux to work without needing any mounts
Diffstat (limited to 'src/privsep-root.c')
| -rw-r--r-- | src/privsep-root.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/privsep-root.c b/src/privsep-root.c index 716a55c4..b4216760 100644 --- a/src/privsep-root.c +++ b/src/privsep-root.c @@ -295,6 +295,14 @@ ps_root_validpath(const struct dhcpcd_ctx *ctx, uint16_t cmd, const char *path) return true; if (strncmp(RUNDIR, path, strlen(RUNDIR)) == 0) return true; + +#ifdef __linux__ + if (strncmp("/proc/net/", path, strlen("/proc/net/")) == 0 || + strncmp("/proc/sys/net/", path, strlen("/proc/sys/net/")) == 0 || + strncmp("/sys/class/net/", path, strlen("/sys/class/net/")) == 0) + return true; +#endif + errno = EPERM; return false; } @@ -310,6 +318,7 @@ ps_root_dowritefile(const struct dhcpcd_ctx *ctx, errno = EINVAL; return -1; } + if (!ps_root_validpath(ctx, PS_WRITEFILE, file)) return -1; nc++; @@ -511,6 +520,11 @@ ps_root_recvmsgcb(void *arg, struct ps_msghdr *psm, struct msghdr *msg) free_rdata = true; break; #endif +#if defined(__linux__) || defined(HAVE_PLEDGE) + case PS_IP6FORWARDING: + err = ip6_forwarding(data); + break; +#endif default: err = ps_root_os(psm, msg); break; @@ -800,3 +814,15 @@ err: return -1; } #endif + +#if defined(__linux__) || defined(HAVE_PLEDGE) +ssize_t +ps_root_ip6forwarding(struct dhcpcd_ctx *ctx, const char *ifname) +{ + + if (ps_sendcmd(ctx, ctx->ps_root_fd, + PS_IP6FORWARDING, 0, ifname, strlen(ifname) + 1) == -1) + return -1; + return ps_root_readerror(ctx, NULL, 0); +} +#endif |
