Skip to content

Conversation

@reubeno
Copy link
Contributor

@reubeno reubeno commented Nov 4, 2025

Posting to get some conversation going around openness to using fgetpwent_r on the platforms that provide it (i.e., Linux).

Per docs, it's actually reentrant and could be used to implement a non-unsafe version of group and user enumeration on the platforms that support it. That somewhat begs the question of whether it's feasible (and/or a good idea) to provide functions that are only unsafe on some platforms. It would be great to get your feedback on whether you'd consider something in this direction.

(Aside: this macOS man page indicates that getpwent is thread-safe on that platform because they happen to place its internal buffer in a thread-specific structure. Would need to more properly validate that, though.)

@reubeno
Copy link
Contributor Author

reubeno commented Nov 24, 2025

@gierens Any early feedback on this?

@gierens
Copy link
Member

gierens commented Nov 26, 2025

Hi @reubeno, thanks, and sorry for the late reply, I'm currently very busy, after next week I should have a bit more time, I'll try to look at it then :)

@reubeno
Copy link
Contributor Author

reubeno commented Nov 26, 2025

@gierens Totally understood, thanks for the ack!

@gierens
Copy link
Member

gierens commented Dec 15, 2025

Hi again, this looks very interesting, also very clean and neatly documented. Thanks for that!

In my opinion this is a definite improvement. I'm not sure if there are any best practices regarding "target-dependent safety", and that surely is a public API change, but assuming there are no side-effects we don't see at the moment, I think, I actually prefer this streamlined version over having a separate interface, just for API consistency. I'm also pretty certain, that, if this would've been developed with fgetpwent_r originally, and then ported to targets without it, "target-dependent safety" is exactly what it would've ended up with.

Maybe just to entertain the thought, if one would want to introduce this slowly, we would need a separate Linux only AllUsersSafe or so and mark all_users as deprecated on Linux and provide a new all_users_safe as alternative, ... This does sound fairly messy. So, I'm still inclined to prefer your approach.

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