-
Notifications
You must be signed in to change notification settings - Fork 666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misc cleanup #814
Misc cleanup #814
Conversation
2b3fb11
to
eb998f3
Compare
For example, I'm not certain if we should be using |
For the BSDs, it's looks like NetBSD uses the Next steps are to add those structs to libc. I'm not certain how I want to abstract this, if I want to hide all these structs behind the new |
@Susurrus The answer lies here. Despite the doc comments, it looks like Nix is using |
src/sys/socket/mod.rs
Outdated
@@ -173,6 +170,47 @@ libc_bitflags!{ | |||
} | |||
} | |||
|
|||
/// Unix credentials of the sending process. | |||
/// | |||
/// This struct is used with the `SCM_CREDENTIALS` ancillary message for UNIX sockets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message, while true, is red herring because Nix doesn't support SCM_CREDENTIALS
. It should read "This struct is used with the SO_PEERCRED
/LOCAL_PEERCRED
socket options for UNIX sockets.
src/sys/socket/mod.rs
Outdated
/// This struct is used with the `SCM_CREDENTIALS` ancillary message for UNIX sockets. | ||
#[repr(C)] | ||
#[derive(Clone, Copy)] | ||
pub struct UnixCredentials(libc::ucred); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be libc::xucred
on FreeBSD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very different looking struct, I'm really surprised that this is correct. I would have thought it'd be the struct I mentioned above, cmsgcred
, which does have pid, uid, and gid fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except there are two problems. If UnixCredentials
were actually used with SCM_CREDENTIALS
, then you would be correct. struct cmsgcred
would be the struct to wrap. However, the SCM_CREDENTIALS
comment is red herring. UnixCredentials
is actually used as a socket option, with SO_PEERCRED
. That's why I say that it should wrap xucred
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From this SO question it seems like SCM_CREDENTIALS
should be what we offer as an API and we abandon the SO_PEERCRED
implementation, since one looks to be a newer/better version of the other.
@@ -151,7 +152,7 @@ sockopt_impl!(Both, OobInline, libc::SOL_SOCKET, libc::SO_OOBINLINE, bool); | |||
sockopt_impl!(GetOnly, SocketError, libc::SOL_SOCKET, libc::SO_ERROR, i32); | |||
sockopt_impl!(Both, KeepAlive, libc::SOL_SOCKET, libc::SO_KEEPALIVE, bool); | |||
#[cfg(all(target_os = "linux", not(target_arch="arm")))] | |||
sockopt_impl!(GetOnly, PeerCredentials, libc::SOL_SOCKET, libc::SO_PEERCRED, super::ucred); | |||
sockopt_impl!(GetOnly, PeerCredentials, libc::SOL_SOCKET, libc::SO_PEERCRED, super::UnixCredentials); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On FreeBSD, this should be LOCAL_PEERCRED
instead of SO_PEERCRED
.
3462db7
to
3a741ed
Compare
Note that all Linux MIPS build jobs will fail until rust-lang/libc#867 is merged. Once that's merged, this can go in. I'm going to back off expanding APIs to any other platforms as it's just too much work. I'd really like to get all this |
3a741ed
to
fe51348
Compare
Should go green once this runs through. @asomers Let me know if you have any feedback here, hopefully these changes are uncontroversial at this point. |
e15e5dc
to
7c387b6
Compare
@asomers Can I get a final check with you on this before I merge it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It all looks good, but I think you should group the CHANGELOG entries with the changes that made them.
CHANGELOG.md
Outdated
@@ -83,6 +85,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). | |||
- The `ucred` struct has been removed in favor of a `UserCredentials` struct that | |||
contains only getters for its fields. | |||
([#814](https://github.com/nix-rust/nix/pull/814)) | |||
- Both `ip_mreq` and `ipv6_mreq` have been replaced with `IpMembershipRequest` and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit should be squashed with a9022b5
@@ -98,6 +103,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). | |||
([#747](https://github.com/nix-rust/nix/pull/747)) | |||
- The `Errno` variants are no longer reexported from the `errno` module. `Errno` itself is no longer reexported from the | |||
crate root and instead must be accessed using the `errno` module. ([#696](https://github.com/nix-rust/nix/pull/696)) | |||
- Removed `MS_VERBOSE`, `MS_NOSEC`, and `MS_BORN` from `MsFlags`. These |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part should be squashed with 5837c6d
@@ -48,6 +48,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). | |||
- Added the `from_raw()` method to `WaitStatus` for converting raw status values | |||
to `WaitStatus` independent of syscalls. | |||
([#741](https://github.com/nix-rust/nix/pull/741)) | |||
- Added more standard trait implementations for various types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The `ucred` struct has been removed in favor of a `UserCredentials` struct that | ||
contains only getters for its fields. | ||
([#814](https://github.com/nix-rust/nix/pull/814)) | ||
- Both `ip_mreq` and `ipv6_mreq` have been replaced with `IpMembershipRequest` and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit should be squashed wit a9022b5
([#749](https://github.com/nix-rust/nix/pull/749)) | ||
- `AioCb::Drop` will now panic if the `AioCb` is still in-progress ([#715](https://github.com/nix-rust/nix/pull/715)) | ||
- Restricted `nix::sys::socket::UnixAddr::new_abstract` to Linux and Android only. | ||
([#785](https://github.com/nix-rust/nix/pull/785)) | ||
- The `ucred` struct has been removed in favor of a `UserCredentials` struct that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit should be squashed with c25f551
This hasn't been available for a while now. And was not updated for even longer before that. Let's not mislead our users any longer.
7c387b6
to
111950d
Compare
You're right, I was just being lazy about it. Bors r+ asomers |
814: Misc cleanup r=Susurrus a=Susurrus Add more traits to the various datatypes in `nix`. Also try to utilize more `libc` types where appropriate. This is still WIP because: * Looking for feedback on ba2d85b. Does it make sense for bitflags structs to have `Ord` & `PartialOrd` derived for them? * Need to implement a newtype wrapper around `libc::linger` with both a `new()` constructor and getters. Additionally this needs manual implementations of `Eq`, `PartialEq`, `Debug` (I've been skipping manually implementing `Hash` for now. * In 2b3fb11 I need to implement newtype wrappers around `ip_mreq` and `ipv6_mreq` that have `new()` constructors and field getters. Additionally they need manual implementations of `Eq`, `PartialEq`, `Debug` (I've been skipping manually implementing `Hash` for now. This commit also needs a CHANGELOG entry. * ed79cfb needs a CHANGELOG entry because its variants names have changed with the switch to using `libc_bitflags!`.
Add more traits to the various datatypes in
nix
. Also try to utilize morelibc
types where appropriate.This is still WIP because:
Ord
&PartialOrd
derived for them?libc::linger
with both anew()
constructor and getters. Additionally this needs manual implementations ofEq
,PartialEq
,Debug
(I've been skipping manually implementingHash
for now.ip_mreq
andipv6_mreq
that havenew()
constructors and field getters. Additionally they need manual implementations ofEq
,PartialEq
,Debug
(I've been skipping manually implementingHash
for now. This commit also needs a CHANGELOG entry.libc_bitflags!
.