~kennylevinsen/seatd

9b3bdcb12d0dea1cc5b96eefbc083114556df565 — Kenny Levinsen 4 months ago e99e7d7
client: Use cr_pid if available

This is only available on FreeBSD 13, so test for that version.
1 files changed, 4 insertions(+), 0 deletions(-)

M seatd/client.c
M seatd/client.c => seatd/client.c +4 -0
@@ 40,7 40,11 @@ static int get_peer(int fd, pid_t *pid, uid_t *uid, gid_t *gid) {
	if (getsockopt(fd, 0, LOCAL_PEERCRED, &cred, &len) == -1) {
		return -1;
	}
#if __FreeBSD_version >= 1300030
	pid = cred.cr_pid;
#else
	*pid = -1;
#endif
	*uid = cred.cr_uid;
	*gid = cred.cr_ngroups > 0 ? cred.cr_groups[0] : (gid_t)-1;
	return 0;