Add better support for unnamed unix socket addrs#1857
Add better support for unnamed unix socket addrs#1857bors[bot] merged 4 commits intonix-rust:masterfrom
Conversation
b1af529 to
60f17d7
Compare
|
I decided to only enable these on Linux/Android, since unnamed unix sockets seem to behave differently on FreeBSD and I can't find any documentation for its behaviour. For example when running The current test failures seem to be unrelated, probably from a new clippy version. |
|
|
||
| let addr_1: UnixAddr = getsockname(fd_1).expect("getsockname failed"); | ||
| assert!(addr_1.is_unnamed()); | ||
| assert_eq!(addr_1, UnixAddr::new_unnamed()); |
There was a problem hiding this comment.
Is this part guaranteed to work, according to any Linux documentation, or is it just luck? I'm not sure we should have this assertion.
There was a problem hiding this comment.
Linux says "When the address of an unnamed socket is returned, its length is sizeof(sa_family_t)", so the only possible unnamed unix socket address it could return would be sockaddr_un { sun_family: AF_UNIX, ... } with length 2. But I agree that the documentation around this still isn't great, so I removed this assertion.
|
Also, rebasing should fix the CI failures. |
60f17d7 to
500baa1
Compare
Removed test assertion
Use it in the from_sockaddr_un_abstract_unnamed test. That test and this method were introduced by PRs nix-rust#1871 and nix-rust#1857, which crossed each other.
This adds the following 2 functions/methods:
UnixAddr::new_unnamedandUnixAddr::is_unnamed.Closes #1585
unix(7) on Linux:
Edit: This currently isn't working on BSD, but I see why. Will fix it shortly.