-
Notifications
You must be signed in to change notification settings - Fork 244
Description
Having support for non-cgo builds is useful - for instance the podman project uses cross builds as a low-cost smoke test for all its supported platforms. I came across this issue when I attempted to add FreeBSD to this smoke test.
The implementation of UnixCredentials uses cgo to get the sizes of void pointers and for the kernel-internal ucred structure. This structure is the wrong choice for the SCM_CREDS control message which actually needs a cmsgcred structure - the only reason the current code works at all is that sizeof(ucred) is greater than sizeof(cmsgcred). The size of void pointer can be found without cgo via golang.org/x/sys/unix which exports SizeofPtr.
To break the dependancy on cgo, I suggest hard-coding the size of struct cmsgcred - this structure has not changed in the FreeBSD ABI for about 25 years and is the same on all supported platforms, both 32- and 64bit. I will submit a PR along those lines.