summaryrefslogtreecommitdiffstats
path: root/src/if-bsd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-05-12 10:26:35 +0100
committerRoy Marples <roy@marples.name>2020-05-12 10:26:35 +0100
commitcf85354d04d98ba2117ac413edd97a46cda05293 (patch)
tree5c79c1346f9b7435837be856798f8aa0099be3be /src/if-bsd.c
parent123d78292563042e643024fc9abf154d631b0cad (diff)
downloaddhcpcd-cf85354d04d98ba2117ac413edd97a46cda05293.tar.xz
privsep: Handle all file IO in the Priviledged Actioneer
This allows us to move the database directory back into the root of the filesystem. While here, harden the files by denying any user read access to them. As part of this change, init the DUID from any machine data and cache the default DHCP vendor field before dropping priviledges as we may lose access to this later.
Diffstat (limited to 'src/if-bsd.c')
-rw-r--r--src/if-bsd.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/if-bsd.c b/src/if-bsd.c
index 958542ca..5849b52e 100644
--- a/src/if-bsd.c
+++ b/src/if-bsd.c
@@ -1555,7 +1555,7 @@ if_handlelink(struct dhcpcd_ctx *ctx)
}
#ifndef SYS_NMLN /* OSX */
-# define SYS_NMLN 256
+# define SYS_NMLN __SYS_NAMELEN
#endif
#ifndef HW_MACHINE_ARCH
# ifdef HW_MODEL /* OpenBSD */
@@ -1566,14 +1566,8 @@ int
if_machinearch(char *str, size_t len)
{
int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
- char march[SYS_NMLN];
- size_t marchlen = sizeof(march);
-return -1;
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
- march, &marchlen, NULL, 0) != 0)
- return -1;
- return snprintf(str, len, ":%s", march);
+ return sysctl(mib, sizeof(mib) / sizeof(mib[0]), str, &len, NULL, 0);
}
#ifdef INET6