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

Feat(Apple): Add the LOCAL_PEERTOKEN socket option #3929

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

PaulDance
Copy link
Contributor

Dear maintainers,

This proposes to add the Darwin-only LOCAL_PEERTOKEN constant as a new API. It is a getsockopt option variant that enables retrieving the connected peer's audit token, which enables uniquely identifying the process with respect to the underlying system. It is taken from XNU's sys/un.h header.

Regarding a justification of a use case, this would be for reliably authenticating a peer process that attempts to communicate with the current one after connecting to one of its opened sockets. However, due to it being a simple constant, this is not strictly-speaking necessary. This should therefore be seen as more of an upstreaming and contributing to complete the already-existing APIs as all the other LOCAL_PEER* constants are already included.

One thing this also does in addition is to add the small descriptions from the header as documentation comments in the Rust module, since I could see it was done from time to time, although not always. It is also done for the other similar constants, for completion's sake. If needed, this can be restricted to only LOCAL_PEERTOKEN or even removed entirely.

Cheers,
Paul.

@rustbot
Copy link
Collaborator

rustbot commented Sep 17, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @tgross35 (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@PaulDance PaulDance marked this pull request as ready for review September 17, 2024 11:01
@PaulDance
Copy link
Contributor Author

@rustbot label stable-nominated

seems appropriate?

@rustbot rustbot added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Sep 17, 2024
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@tgross35 tgross35 added this pull request to the merge queue Sep 30, 2024
Merged via the queue into rust-lang:main with commit 0a25ed8 Sep 30, 2024
41 checks passed
@PaulDance
Copy link
Contributor Author

Cool, thanks! Should I open a PR for the backport to 0.2 myself or will it be done soon anyway?

@PaulDance PaulDance deleted the macos-socket-token branch September 30, 2024 19:02
@tgross35
Copy link
Contributor

Before doing a release I go through and cherry pick the backports, nothing for you to do :)

@tgross35 tgross35 mentioned this pull request Oct 15, 2024
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Oct 15, 2024
* Feat(apple): Add LOCAL_PEERTOKEN

Taken from `sys/un.h`.

Signed-off-by: Paul Mabileau <[email protected]>

* Docs(apple): Add description for LOCAL_PEER* socket options

Signed-off-by: Paul Mabileau <[email protected]>

* Chore(test/apple): Add the LOCAL_PEERTOKEN symbol

Signed-off-by: Paul Mabileau <[email protected]>

---------

Signed-off-by: Paul Mabileau <[email protected]>

(backport <rust-lang#3929>)
(cherry picked from commit 0a25ed8)
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review stable-applied This PR has been cherry-picked to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants