Sure - that’s rather important for our subsequent fork / etc. If FreeBSD doesn’t have capabilities then just having a root process for the forkit would be sufficient.
FreeBSD does have a capabilities framework, I just wondering under what circumstances the process may not have these capabilities? These are pretty common even for unprivileged user.
On linux, the ability to chroot is a security capability, as is creating device nodes, as is changing the ownership of those device nodes, for quite obvious reasons I hope creating a new /dev/sda and changing ownership to yourself might allow low-level un-controlled disk access (I speculate)
I presume, the process first creates the socket and then forks under non-privileged user, and this check is to make sure that we are in the forked one? Why not just look at getppid() in this case?
The intention clearly is to check the creds of the accepted child, and not the listening socket =) we could do something via the pid cred, and walk up to the parents - but forkits can die and/or get re-started so - prefer to keep this approach. Will poke the accepted child instead though - good catch =) thanks!