Add UnixCredentials support on FreeBSD/DragonFly#1216
Add UnixCredentials support on FreeBSD/DragonFly#1216bors[bot] merged 1 commit intonix-rust:masterfrom
Conversation
d0a32db to
ba031dd
Compare
asomers
left a comment
There was a problem hiding this comment.
This looks pretty good! One thing I would suggest would be to consider creating separate types for Linux vs the BSDs. Nix's purpose is to provide a Rusty API to system libraries, not to provide a cross-platform API. If separate types with different APIs solve the invalid uid problem, then it would be worthwhile.
| ControlMessageOwned::ScmCredentials(cred.into()) | ||
| } | ||
| #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] | ||
| (libc::SOL_SOCKET, /* libc::SCM_CREDS */ 0x03) => { |
There was a problem hiding this comment.
Adding a note to this line so we don't forget to fix it before committing.
| #[cfg(any(target_os = "android", target_os = "linux"))] | ||
| ControlMessage::ScmCredentials(_) => libc::SCM_CREDENTIALS, | ||
| #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] | ||
| ControlMessage::ScmCredentials(_) => /* libc::SCM_CREDS */ 0x03, // https://github.com/rust-lang/libc/pull/1740 |
There was a problem hiding this comment.
Adding a comment here to ensure we fix this before merging
2322289 to
c5accbb
Compare
asomers
left a comment
There was a problem hiding this comment.
Much improved. I like the new constructorless ControlMessage. Ping me after the libc PR merges and then we can finish this one.
| #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] | ||
| ControlMessage::ScmCreds => { | ||
| // The kernel overwrites the data, don't worry | ||
| return |
There was a problem hiding this comment.
Could this result in cmsg_data being uninitialized? That way might lead to UB. I think that you should zero it instead.
|
The libc PR (rust-lang/libc#1740) has apparently been merged, if that may be of use to this one. |
|
ping @myfreeweb . It looks like the libc PR has been merged. Can you finish this one now? |
c5accbb to
b2a9c4f
Compare
|
It's still not released to crates.io.. Okay, switched to git for now. |
|
Build succeeded: |
This allows working with
SCM_CREDSmessages, which are likeSCM_CREDENTIALSon Linux, but slightly different (always overwritten by the kernel, contain a bit more info — euid and groups).With this PR, it is possible to write portable code that would use the appropriate message for the platform, but one remaining quirk is that
PassCredthing still has to be present andcfg'd to Linux.Adding the
SCM_CREDSconstant to libc: rust-lang/libc#1740