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

Convert Unix{Datagram,Stream}::{set_}passcred() to per-OS traits #117156

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

jmillikin
Copy link
Contributor

These methods are the pre-stabilized API for obtaining peer credentials from an AF_UNIX socket, part of the unix_socket_ancillary_data feature.

Their current behavior is to get/set one of the SO_PASSCRED (Linux), LOCAL_CREDS_PERSISTENT (FreeBSD), or LOCAL_CREDS (NetBSD) socket options. On other targets the {set_}passcred() methods do not exist.

There are two problems with this approach:

  1. Having public methods only exist for certain targets isn't permitted in a stable std API.

  2. These options have generally similar purposes, but they are non-POSIX and their details can differ in subtle and surprising ways (such as whether they continue to be set after the next call to recvmsg()).

Splitting into OS-specific extension traits is the preferred solution to both problems.

These methods are the pre-stabilized API for obtaining peer credentials
from an `AF_UNIX` socket, part of the `unix_socket_ancillary_data` feature.

Their current behavior is to get/set one of the `SO_PASSCRED` (Linux),
`LOCAL_CREDS_PERSISTENT` (FreeBSD), or `LOCAL_CREDS` (NetBSD) socket
options. On other targets the `{set_}passcred()` methods do not exist.

There are two problems with this approach:

1. Having public methods only exist for certain targets isn't permitted
   in a stable `std` API.

2. These options have generally similar purposes, but they are non-POSIX
   and their details can differ in subtle and surprising ways (such as
   whether they continue to be set after the next call to `recvmsg()`).

Splitting into OS-specific extension traits is the preferred solution to
both problems.
@rustbot
Copy link
Collaborator

rustbot commented Oct 25, 2023

r? @joshtriplett

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added O-linux Operating system: Linux O-netbsd Operating system: NetBSD O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 25, 2023
@jmillikin
Copy link
Contributor Author

Additional context: #76915 (comment)

This part of the unix_socket_ancillary_data feature is not affected by proposed API changes in RFC 3430.

@jmillikin
Copy link
Contributor Author

@rustbot label +T-libs-api -T-libs

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 26, 2023
@bors
Copy link
Contributor

bors commented Jan 13, 2024

☔ The latest upstream changes (presumably #117285) made this pull request unmergeable. Please resolve the merge conflicts.

@joshtriplett
Copy link
Member

r? libs

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Feb 11, 2024
@rustbot rustbot assigned cuviper and unassigned joshtriplett Feb 11, 2024
@cuviper
Copy link
Member

cuviper commented Feb 11, 2024

r? libs-api

@rustbot rustbot assigned dtolnay and unassigned cuviper Feb 11, 2024
@Amanieu Amanieu added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Feb 21, 2024
@Amanieu Amanieu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed I-libs-api-nominated Nominated for discussion during a libs-api team meeting. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 28, 2024
@jmillikin
Copy link
Contributor Author

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 29, 2024
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks!

@dtolnay
Copy link
Member

dtolnay commented Mar 1, 2024

@bors r=Amanieu,dtolnay

@bors
Copy link
Contributor

bors commented Mar 1, 2024

📌 Commit 2ed49fc has been approved by Amanieu,dtolnay

It is now in the queue for this repository.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 2, 2024
…anieu,dtolnay

Convert `Unix{Datagram,Stream}::{set_}passcred()` to per-OS traits

These methods are the pre-stabilized API for obtaining peer credentials from an `AF_UNIX` socket, part of the `unix_socket_ancillary_data` feature.

Their current behavior is to get/set one of the `SO_PASSCRED` (Linux), `LOCAL_CREDS_PERSISTENT` (FreeBSD), or `LOCAL_CREDS` (NetBSD) socket options. On other targets the `{set_}passcred()` methods do not exist.

There are two problems with this approach:

1. Having public methods only exist for certain targets isn't permitted in a stable `std` API.

2. These options have generally similar purposes, but they are non-POSIX and their details can differ in subtle and surprising ways (such as whether they continue to be set after the next call to `recvmsg()`).

Splitting into OS-specific extension traits is the preferred solution to both problems.
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 2, 2024
Rollup of 9 pull requests

Successful merges:

 - rust-lang#109263 (fix typo in documentation for std::fs::Permissions)
 - rust-lang#117156 (Convert `Unix{Datagram,Stream}::{set_}passcred()` to per-OS traits)
 - rust-lang#120684 (Update E0716.md for clarity)
 - rust-lang#121739 (Display short types for unimplemented trait)
 - rust-lang#121815 (Move `gather_comments`.)
 - rust-lang#121835 (Move `HandleStore` into `server.rs`.)
 - rust-lang#121847 (Remove hidden use of Global)
 - rust-lang#121861 (Use the guaranteed precision of a couple of float functions in docs)
 - rust-lang#121875 ( Account for unmet T: !Copy in E0277 message)

r? `@ghost`
`@rustbot` modify labels: rollup
@Dylan-DPC
Copy link
Member

failed in rollup
@bors r-

@bors rollup=iffy

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 2, 2024
@jmillikin
Copy link
Contributor Author

jmillikin commented Mar 2, 2024

Is there any way to run the Android portion of CI before trying to merge?

I've tried to fix the Android test failure based on the failed merge's build logs, but I don't have an Android build environment or any Android devices capable of running the Rust test suite. Having to iterate on the build via the full bors merge queue is bothersome to other developers, and takes quite a long time.

@jmillikin
Copy link
Contributor Author

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 2, 2024
@Amanieu
Copy link
Member

Amanieu commented Mar 4, 2024

You can edit the CI configuration to run the Android builder for PR CI instead of just for bors. You can find the configuration in src/ci/github-actions/ci.yml.

r=me once you've checked that the Android CI passes.

@dtolnay
Copy link
Member

dtolnay commented Mar 11, 2024

Arm-android CI succeeded in #122324.

@bors r=Amanieu,dtolnay

@bors
Copy link
Contributor

bors commented Mar 11, 2024

📌 Commit 93f2f2c has been approved by Amanieu,dtolnay

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 11, 2024
@bors
Copy link
Contributor

bors commented Mar 11, 2024

⌛ Testing commit 93f2f2c with merge 6639672...

@bors
Copy link
Contributor

bors commented Mar 11, 2024

☀️ Test successful - checks-actions
Approved by: Amanieu,dtolnay
Pushing 6639672 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 11, 2024
@bors bors merged commit 6639672 into rust-lang:master Mar 11, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Mar 11, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6639672): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.8% [-3.1%, -0.4%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-3.4%, -2.7%] 4
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 645.581s -> 645.914s (0.05%)
Artifact size: 309.97 MiB -> 309.95 MiB (-0.00%)

@jmillikin jmillikin deleted the os-unix-socket-ext branch March 11, 2024 11:59
@jmillikin
Copy link
Contributor Author

@dtolnay Thank you so much for handling the ARM testing! I had poked a bit at the CI config YAML but didn't have time last week to dig in deeper.

Should the same situation happen again, I'll use your commit ed48ec0 as a reference for platform-specific CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. O-android Operating system: Android O-linux Operating system: Linux O-netbsd Operating system: NetBSD O-unix Operating system: Unix-like S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants