-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add os::unix::net::SocketAddr::from_path #93239
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Creates a new SocketAddr from a path, supports both regular paths and abstract namespaces.
I don't think we should do that. |
I see you point, but
👍 We could use it internally though, so that |
Depends what you mean with 'valid'. Such paths are not accepted by any api like Linux APIs do not treat AF_UNIX sockaddrs starting with a Using a leading |
That's fair, I'll remove reject |
And change it to disallow NULL bytes.
I've renamed it to |
(We should also add |
The creation of libc::sockaddr_un is a safe operation, no need for it to be unsafe. This also uses the more performant copy_nonoverlapping instead of an iterator.
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.
(We should also add
as_path
for completeness, but that doesn't have to be part of this PR.)
@m-ou-se what would it do differently from as_pathname
?
This comment has been minimized.
This comment has been minimized.
I don't know why the CI failed, it seems it received some unexpected signal? |
It's not unique error, it's all over CI #93375 (comment) |
Apologies, I missed that we already had that one. It makes me wonder if we should name this new function Can you open a new tracking issue for
Looks spurious. I've restarted the CI. |
Personally I don't really have a preference here.
I originally linked it to #65275, but I've created #93423.
|
@bors r+ |
📌 Commit 35f578f has been approved by |
…askrgr Rollup of 10 pull requests Successful merges: - rust-lang#92611 (Add links to the reference and rust by example for asm! docs and lints) - rust-lang#93158 (wasi: implement `sock_accept` and enable networking) - rust-lang#93239 (Add os::unix::net::SocketAddr::from_path) - rust-lang#93261 (Some unwinding related cg_ssa cleanups) - rust-lang#93295 (Avoid double panics when using `TempDir` in tests) - rust-lang#93353 (Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>) - rust-lang#93356 (Edit docs introduction for `std::cmp::PartialOrd`) - rust-lang#93375 (fix typo `documenation`) - rust-lang#93399 (rustbuild: Fix compiletest warning when building outside of root.) - rust-lang#93404 (Fix a typo from rust-lang#92899) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
// null byte for pathname addresses is already there because we zeroed the | ||
// struct | ||
// SAFETY: `bytes` and `addr.sun_path` are not overlapping and | ||
// both point to valid memory. |
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.
Perhaps add "we checked path is not too long"
Creates a new SocketAddr from a path, supports both regular paths and
abstract namespaces.
Note that
SocketAddr::from_abstract_namespace
could be removed after this asSocketAddr::unix
also supports abstract namespaces.Updates #65275
Unblocks tokio-rs/mio#1527
r? @m-ou-se