Support reading ucred from the socket on FreeBSD

On FreeBSD we have to use getsockopt(fd, SOL_LOCAL, LOCAL_PEERCRED)
instead. This change is based on a downstream patch in FreeBSD ports.

Co-authored-by: Greg V <greg@unrelenting.technology>
Co-authored-by: Koop Mast <kwm@rainbow-runner.nl>
Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
This commit is contained in:
Alex Richardson 2021-03-15 22:21:12 +00:00 committed by Alexander Richardson
parent f1552700ce
commit 54b237a612
4 changed files with 63 additions and 11 deletions

View file

@ -26,7 +26,7 @@ add_project_arguments(
language: 'c'
)
foreach h: [ 'sys/prctl.h' ]
foreach h: [ 'sys/prctl.h', 'sys/ucred.h' ]
config_h.set('HAVE_' + h.underscorify().to_upper(), cc.has_header(h))
endforeach
@ -41,6 +41,7 @@ have_funcs = [
foreach f: have_funcs
config_h.set('HAVE_' + f.underscorify().to_upper(), cc.has_function(f))
endforeach
config_h.set10('HAVE_XUCRED_CR_PID', cc.has_member('struct xucred', 'cr_pid', prefix : '#include <sys/ucred.h>'))
if get_option('libraries')
if host_machine.system() == 'freebsd'