Skip to content

Unix socket support in the standard library - #1479

Merged
alexcrichton merged 4 commits into
rust-lang:masterfrom
sfackler:unix-socket
Mar 17, 2016
Merged

alexcrichton merged 4 commits into
rust-lang:masterfrom
sfackler:unix-socket

Conversation

@sfackler

Copy link
Copy Markdown
Member

@sfackler sfackler added the T-libs-api [DEPRECATED; DO NOT USE] label Jan 26, 2016
@sfackler sfackler self-assigned this Jan 26, 2016
Comment thread text/0000-unix-socket.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps another unresolved question for now could be whether Windows named pipes should be added in parallel? Or something along the lines of if we should hold off on stabilization until there's a suitable Windows alternative as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that blocking this feature on named pipes makes a ton of sense. Named pipes do not appear to be used heavily in the Rust ecosystem, and I don't really want us to get into a habit of wanting to add platform specific feature X to the standard library and then hunting for a roughly comparable other-platform specific feature Y to implement along side it for "symmetry".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm ok, but I do also want to not tip the scales too far in favor of Unix as there are lots of abstractions on Windows we could reasonably provide (e.g. named pipes, IOCP bindings, etc). While crates today may not use these much it may just be because the Windows community is a little smaller.

These are mostly just musings, though, I'd be ok if the RFC doesn't explicitly mention named pipes.

Comment thread text/0000-unix-socket.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOCK_DGRAM Unix sockets are reliable.

@alexcrichton

Copy link
Copy Markdown
Member

🔔 This RFC is now entering its week-long final comment period 🔔

@alexcrichton

Copy link
Copy Markdown
Member

Also from discussion in triage yesterday, the libs team concluded that a good way forward for now with abstract sockets is to do something like:

  • Validate no nul bytes are found in strings
  • Perhaps eventually add a linux-specific extension trait to manage abstract sockets.

It at least errs on the side of being conservative for now!

@alexcrichton alexcrichton added the final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. label Mar 3, 2016
@sfackler

sfackler commented Mar 4, 2016

Copy link
Copy Markdown
Member Author

Updated to disallow use of the abstract namespace.

@gkoz

gkoz commented Mar 7, 2016

Copy link
Copy Markdown

Shouldn't there be a way to set permissions on the socket before starting to listen to it?

@sfackler

sfackler commented Mar 7, 2016

Copy link
Copy Markdown
Member Author

What libc API would that use? According to the man page, the socket will inherit the permissions of the directory it's defined in on Linux, but filesystem permissions are ignored on BSD: http://man7.org/linux/man-pages/man7/unix.7.html#NOTES

@gkoz

gkoz commented Mar 7, 2016

Copy link
Copy Markdown

I had chmod in mind ;) Okay, while I doubt any modern BSDs ignore "file" permissions I totally missed that the portable way is to rely on directory-level permissions.

@alexcrichton

Copy link
Copy Markdown
Member

The libs team discussed this RFC during triage yesterday, an the decision was to merge. This was the original intention for how Unix sockets would reenter the standard library and the unix-socket crate is doing well enough that moving it in almost wholesale seems good at this time (it's quickly becoming a vetted API).

Thanks again for the RFC @sfackler!

Tracking issue: rust-lang/rust#32312

@alexcrichton
alexcrichton merged commit 97780a7 into rust-lang:master Mar 17, 2016
@alexcrichton

Copy link
Copy Markdown
Member

Ah, also, the initial implementation: rust-lang/rust#32302

@Centril Centril added A-net Proposals relating to networking. A-platform Platform related proposals & ideas A-types-libstd Proposals & ideas introducing new types to the standard library. labels Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-net Proposals relating to networking. A-platform Platform related proposals & ideas A-types-libstd Proposals & ideas introducing new types to the standard library. final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. T-libs-api [DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants