Skip to content

FreeBSD build depends on cgo #331

@dfr

Description

@dfr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions