Skip to content

Commit 1360f06

Browse files
committed
Add compat for Ilumos
1 parent af3750d commit 1360f06

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/control.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#include <time.h>
4242
#include <unistd.h>
4343

44+
#if defined(__sun)
45+
#include <ucred.h>
46+
#endif
47+
4448
#include "common.h"
4549
#include "config.h"
4650
#include "control.h"
@@ -55,7 +59,7 @@
5559
(sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
5660
#endif
5761

58-
#define SUN_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
62+
#define SUN_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
5963

6064
#define LISTEN_BACKLOG 5
6165

@@ -113,6 +117,20 @@ getpeereid(int fd, uid_t *uid, gid_t *gid)
113117
*gid = creds.gid;
114118
return 0;
115119
}
120+
#elif defined(__sun)
121+
static int
122+
getpeereid(int fd, uid_t *uid, gid_t *gid)
123+
{
124+
ucred_t *ucred = NULL;
125+
126+
if (getpeerucred(fd, &ucred) == -1)
127+
return -1;
128+
129+
*uid = ucred_geteuid(ucred);
130+
*gid_t gid = ucred_getegid(ucred);
131+
ucred_free(ucred);
132+
return 0;
133+
}
116134
#endif
117135

118136
static int

src/privsep-control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "logerr.h"
3838
#include "privsep.h"
3939

40-
#define PS_CTL_FD(ctx) (ctx)->ps_ctl->psp_fd
40+
#define PS_CTL_FD(ctx) (ctx)->ps_ctl->psp_fd
4141

4242
/* We expect to have open 2 privsep STREAM, 2 STREAM and 2 file STREAM fds */
4343

0 commit comments

Comments
 (0)