adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
530 stars 125 forks source link

Improve privilege dropping in cgi.d #327

Closed 0xEAB closed 2 years ago

0xEAB commented 2 years ago

Moves the previously thread-local uid/guid variables into RequestServer. Checks whether setgid/setuid succeeds, throws otherwise. Being uid 0 (aka root) is no longer a precondition – see also: CAP_SETUID.

Background: I was particularly unhappy that there was no API to set uid/gid apart from configureFromCommandLine(string[])

adamdruppe commented 2 years ago

ok yeah, this was something on my todo list anyway i just never got around to it. i'll look over the code later.

adamdruppe commented 2 years ago

code looks ok, i expect to merge tomorrow

0xEAB commented 2 years ago

theoretically, we could get rid of Nullable again, if we treat zero as a special value like before (assuming nobody would probably want to setuid/setguid to root anyway)

adamdruppe commented 2 years ago

yeah you'd never use 0, it would be pretty useless.

well i guess some other wheel user could switch to root but meh

adamdruppe commented 2 years ago

whoops i got busy with other things and forgot about this. but it all looks good

0xEAB commented 2 years ago

thanks