summaryrefslogtreecommitdiffstats
path: root/src/privsep-root.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-06-02 17:48:34 +0100
committerRoy Marples <roy@marples.name>2020-06-02 17:48:34 +0100
commitb8ed6cdf7919b1fc406634ccd043b1a995c89921 (patch)
tree2c6e067fa0bb59e1fb9f439c1ef2cdcb5a0ec699 /src/privsep-root.c
parentd3de73d80c7f307bab0278162ff81c3731ac2ce7 (diff)
downloaddhcpcd-b8ed6cdf7919b1fc406634ccd043b1a995c89921.tar.xz
privsep: Access the RDM monotic file via IPC
As we can't get at it in the chroot. While here, harden the file.
Diffstat (limited to 'src/privsep-root.c')
-rw-r--r--src/privsep-root.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/privsep-root.c b/src/privsep-root.c
index 4f963d31..ae52c6ed 100644
--- a/src/privsep-root.c
+++ b/src/privsep-root.c
@@ -43,6 +43,7 @@
#include <string.h>
#include <unistd.h>
+#include "auth.h"
#include "common.h"
#include "dev.h"
#include "dhcpcd.h"
@@ -333,6 +334,19 @@ ps_root_dowritefile(const struct dhcpcd_ctx *ctx,
return writefile(file, mode, nc, len - (size_t)(nc - file));
}
+#ifdef AUTH
+static ssize_t
+ps_root_monordm(uint64_t *rdm, size_t len)
+{
+
+ if (len != sizeof(*rdm)) {
+ errno = EINVAL;
+ return -1;
+ }
+ return auth_get_rdm_monotonic(rdm);
+}
+#endif
+
#ifdef HAVE_CAPSICUM
#define IFA_NADDRS 3
static ssize_t
@@ -537,6 +551,15 @@ ps_root_recvmsgcb(void *arg, struct ps_msghdr *psm, struct msghdr *msg)
rlen = sizeof(mtime);
}
break;
+#ifdef AUTH
+ case PS_AUTH_MONORDM:
+ err = ps_root_monordm(data, len);
+ if (err != -1) {
+ rdata = data;
+ rlen = len;
+ }
+ break;
+#endif
#ifdef HAVE_CAPSICUM
case PS_GETIFADDRS:
err = ps_root_dogetifaddrs(&rdata, &rlen);
@@ -937,6 +960,18 @@ ps_root_ip6forwarding(struct dhcpcd_ctx *ctx, const char *ifname)
}
#endif
+#ifdef AUTH
+int
+ps_root_getauthrdm(struct dhcpcd_ctx *ctx, uint64_t *rdm)
+{
+
+ if (ps_sendcmd(ctx, ctx->ps_root_fd, PS_AUTH_MONORDM, 0,
+ rdm, sizeof(rdm))== -1)
+ return -1;
+ return (int)ps_root_readerror(ctx, rdm, sizeof(*rdm));
+}
+#endif
+
#ifdef PLUGIN_DEV
int
ps_root_dev_initialized(struct dhcpcd_ctx *ctx, const char *ifname)