Page MenuHomeFreeBSD

lposix: Use reentrant passwd and group lookup functions
AcceptedPublic

Authored by markj on Sep 5 2024, 10:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 28, 10:36 PM
Unknown Object (File)
Sep 27 2024, 2:13 PM
Unknown Object (File)
Sep 25 2024, 4:18 PM
Unknown Object (File)
Sep 25 2024, 11:01 AM
Unknown Object (File)
Sep 24 2024, 5:13 AM
Unknown Object (File)
Sep 22 2024, 1:43 PM
Unknown Object (File)
Sep 22 2024, 9:29 AM
Unknown Object (File)
Sep 18 2024, 5:23 AM
Subscribers
None

Details

Reviewers
kevans
imp
bapt
Summary

Avoid nasty surprises for code which calls posix.unistd.chmod() in a
loop while iterating over passwd or group entries.

Fix some style nits while here.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 59331
Build 56218: arc lint + arc unit

Event Timeline

markj requested review of this revision.Sep 5 2024, 10:42 PM
markj created this revision.
This revision is now accepted and ready to land.Sep 6 2024, 11:51 AM

The change is fine. Had a question about the code, but if itakes more than a sec to answer, then 'it was like that when I got here' is fine :)

libexec/flua/modules/lposix.c
114

So what happens if you pass in none or nil for this argument? You just get the -1 default?

libexec/flua/modules/lposix.c
114

Yes, so chown("/foo/bar", "markj") doesn't change the group ownership.

If you want to avoid modifying the user ownership, you have to write chown("/foo/bar", -1, "imp") instead, though it's not immediately clear to me that that will work as implemented.

When dealing with lua integers, I tend to write something like:

lua_Integer i = lua_tointeger(L, 2);
if (i < 0 || i > UID_MAX)
    /* raise an error */
uid_t uid = (uid_t)i;
...

so that we don't silently truncate arguments.