feat: use fgetpwent_r on linux#30
Conversation
|
@gierens Any early feedback on this? |
|
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 :) |
|
@gierens Totally understood, thanks for the ack! |
|
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 Maybe just to entertain the thought, if one would want to introduce this slowly, we would need a separate Linux only |
Posting to get some conversation going around openness to using
fgetpwent_ron 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
getpwentis 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.)