Document the tricky code - TODO, make it less tricky

This commit is contained in:
Hamish Coleman 2021-11-05 12:57:30 +00:00
parent 954547a9c1
commit 3713d357c8

View File

@ -639,10 +639,24 @@ int main (int argc, char * const argv[]) {
scan->socket_fd = sss_node.sock;
#ifndef WIN32
/*
* If no uid/gid is specified on the commandline, use the uid/gid of the
* first found out of user "n2n" or "nobody"
*/
if(((pw = getpwnam ("n2n")) != NULL) || ((pw = getpwnam ("nobody")) != NULL)) {
/*
* If the uid/gid is not set from the CLI, set it from getpwnam
* otherwise reset it to zero
* (TODO: this looks wrong)
*/
sss_node.userid = sss_node.userid == 0 ? pw->pw_uid : 0;
sss_node.groupid = sss_node.groupid == 0 ? pw->pw_gid : 0;
}
/*
* If we have a non-zero requested uid/gid, attempt to switch to use
* those
*/
if((sss_node.userid != 0) || (sss_node.groupid != 0)) {
traceEvent(TRACE_NORMAL, "dropping privileges to uid=%d, gid=%d",
(signed int)sss_node.userid, (signed int)sss_node.groupid);