Skip to content

Add setgroups(2) to macOS/Apple targets#2793

Open
kpcyrd wants to merge 1 commit into
nix-rust:masterfrom
kpcyrd:macos-setgroups
Open

Add setgroups(2) to macOS/Apple targets#2793
kpcyrd wants to merge 1 commit into
nix-rust:masterfrom
kpcyrd:macos-setgroups

Conversation

@kpcyrd
Copy link
Copy Markdown
Contributor

@kpcyrd kpcyrd commented May 15, 2026

What does this PR do

This is related to #2069 and kpcyrd/acme-redirect#50, the setgroups api definitely exists, but it's currently not available in nix for that target, causing compile errors with some projects.

The nix commit had some information that was likely not accurate:

"Note: This function is not available for Apple platforms. On those platforms, group membership management should be achieved via communication with the opendirectoryd service."

Quoting from @Elizafox in #2069 (which I believe to be correct):

This is erroneous for this function. OpenDirectory is just for querying the directory. It cannot manage the groups of the process.

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

@kpcyrd
Copy link
Copy Markdown
Contributor Author

kpcyrd commented May 15, 2026

The test failures seem to be related to Linux kernel exploit mitigations (the FreeBSD one I don't know though).

@SteveLauC
Copy link
Copy Markdown
Member

SteveLauC commented May 18, 2026

The test failures seem to be related to Linux kernel exploit mitigations (the FreeBSD one I don't know though).

They are unrelated, don't worry about them.

Update: you can rebase your branch after #2796 is merged.

Copy link
Copy Markdown
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

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

Maybe we should also add the other two functions as well:

  • initgroups
  • getgroups

I previously had concerns about the weird semantics of getgtoups, but that does not really bother me anymore since Nix is ultimately just a bindings crate.

Comment thread src/unistd.rs
///
/// [Further reading](https://man7.org/linux/man-pages/man2/getgroups.2.html)
///
/// **Note:** This function is not available for Apple platforms. On those
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.

This comment should be updated if we expose it on apple targets.

@SteveLauC
Copy link
Copy Markdown
Member

A changelog entry is needed, see https://github.com/nix-rust/nix/blob/master/CONTRIBUTING.md#pull-requests.

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 this pull request may close these issues.

2 participants