Skip to content
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

Support for getpeereid(3) #1339

Closed
woodruffw opened this issue Nov 24, 2020 · 3 comments · Fixed by #1342
Closed

Support for getpeereid(3) #1339

woodruffw opened this issue Nov 24, 2020 · 3 comments · Fixed by #1342

Comments

@woodruffw
Copy link
Contributor

macOS and most of the BSDs have a getpeereid(3) library routine, which can be used to retrieve the effective UID and GID for a given Unix domain socket.

This roughly mirrors the functionality provided by getsockopt(2) + SO_PEERCRED on Linux (minus the PID), which the nix crate already supports.

I have the bandwidth and ability to implement this, if desired.

@valpackett
Copy link
Contributor

We'll need this in zbus, so you have a consumer already!


Side note, OpenBSD also supports SO_PEERCRED with minor differences (usage example); FreeBSD supports LOCAL_PEERCRED but gained the pid field very recently; NetBSD has LOCAL_PEEREID; Solaris/illumos(?) has getpeerucred. Would be nice to also get all these mechanisms in here eventually…

@woodruffw
Copy link
Contributor Author

Fantastic. I have rust-lang/rust#79387 pending on Rust itself to improve the nightly-only UCred API, which should eventually handle those minor differences on the BSDs as well. But yeah, it would certainly good to have them exposed independently in nix as well.

woodruffw added a commit to woodruffw-forks/nix that referenced this issue Nov 26, 2020
@woodruffw
Copy link
Contributor Author

Okay, #1342 has the wrapper.

woodruffw added a commit to woodruffw-forks/nix that referenced this issue Nov 29, 2020
bors bot added a commit that referenced this issue Nov 29, 2020
1342: feat(unistd): Add getpeereid(3) r=asomers a=woodruffw

`getpeereid(3)` is not POSIX, but it's present on many BSD-derived Unices. It's also the standard mechanism on those OSes for retrieving socket peer credentials (compare `getsockopt` + `SO_PEERCRED` on Linux, which `nix` already supports).

Closes #1339.

Co-authored-by: William Woodruff <william@yossarian.net>
woodruffw added a commit to woodruffw-forks/nix that referenced this issue Nov 29, 2020
woodruffw added a commit to woodruffw-forks/nix that referenced this issue Nov 29, 2020
woodruffw added a commit to woodruffw-forks/nix that referenced this issue Nov 29, 2020
bors bot added a commit that referenced this issue Dec 2, 2020
1342: feat(unistd): Add getpeereid(3) r=asomers a=woodruffw

`getpeereid(3)` is not POSIX, but it's present on many BSD-derived Unices. It's also the standard mechanism on those OSes for retrieving socket peer credentials (compare `getsockopt` + `SO_PEERCRED` on Linux, which `nix` already supports).

Closes #1339.

Co-authored-by: William Woodruff <william@yossarian.net>
bors bot added a commit that referenced this issue Dec 2, 2020
1342: feat(unistd): Add getpeereid(3) r=asomers a=woodruffw

`getpeereid(3)` is not POSIX, but it's present on many BSD-derived Unices. It's also the standard mechanism on those OSes for retrieving socket peer credentials (compare `getsockopt` + `SO_PEERCRED` on Linux, which `nix` already supports).

Closes #1339.

Co-authored-by: William Woodruff <william@yossarian.net>
woodruffw added a commit to woodruffw-forks/nix that referenced this issue Dec 8, 2020
woodruffw added a commit to woodruffw-forks/nix that referenced this issue Dec 15, 2020
woodruffw added a commit to woodruffw-forks/nix that referenced this issue Dec 15, 2020
bors bot added a commit that referenced this issue Dec 16, 2020
1342: feat(unistd): Add getpeereid(3) r=asomers a=woodruffw

`getpeereid(3)` is not POSIX, but it's present on many BSD-derived Unices. It's also the standard mechanism on those OSes for retrieving socket peer credentials (compare `getsockopt` + `SO_PEERCRED` on Linux, which `nix` already supports).

Closes #1339.

Co-authored-by: William Woodruff <william@yossarian.net>
woodruffw added a commit to woodruffw-forks/nix that referenced this issue Dec 19, 2020
bors bot added a commit that referenced this issue Dec 22, 2020
1342: feat(unistd): Add getpeereid(3) r=asomers a=woodruffw

`getpeereid(3)` is not POSIX, but it's present on many BSD-derived Unices. It's also the standard mechanism on those OSes for retrieving socket peer credentials (compare `getsockopt` + `SO_PEERCRED` on Linux, which `nix` already supports).

Closes #1339.

Co-authored-by: William Woodruff <william@yossarian.net>
@bors bors bot closed this as completed in 7c3a353 Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants