]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add compat for Ilumos
authorRoy Marples <roy@marples.name>
Sun, 5 Jul 2026 15:05:25 +0000 (16:05 +0100)
committerRoy Marples <roy@marples.name>
Sun, 5 Jul 2026 15:20:51 +0000 (16:20 +0100)
src/control.c
src/privsep-control.c

index 960ac4c3528239bcfd56e6f3753ab84e6dcfbccd..8afc4f6253014130609d57173c8a842364d8d568 100644 (file)
 #include <time.h>
 #include <unistd.h>
 
+#if defined(__sun)
+#include <ucred.h>
+#endif
+
 #include "common.h"
 #include "config.h"
 #include "control.h"
@@ -55,7 +59,7 @@
        (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
 #endif
 
-#define SUN_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
+#define SUN_MODE       (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
 
 #define LISTEN_BACKLOG 5
 
@@ -113,6 +117,20 @@ getpeereid(int fd, uid_t *uid, gid_t *gid)
        *gid = creds.gid;
        return 0;
 }
+#elif defined(__sun)
+static int
+getpeereid(int fd, uid_t *uid, gid_t *gid)
+{
+       ucred_t *ucred = NULL;
+
+       if (getpeerucred(fd, &ucred) == -1)
+               return -1;
+
+       *uid = ucred_geteuid(ucred);
+       *gid_t gid = ucred_getegid(ucred);
+       ucred_free(ucred);
+       return 0;
+}
 #endif
 
 static int
index 3ace3ad3027bf11247206809c3529a16d3469183..cb27de1bdf56003e718fb3bd8b6032bf2ace784e 100644 (file)
@@ -37,7 +37,7 @@
 #include "logerr.h"
 #include "privsep.h"
 
-#define PS_CTL_FD(ctx)   (ctx)->ps_ctl->psp_fd
+#define PS_CTL_FD(ctx) (ctx)->ps_ctl->psp_fd
 
 /* We expect to have open 2 privsep STREAM, 2 STREAM and 2 file STREAM fds */