Seems this was a n00b bug with setting UID before GID, and since root priviliges were already lost, setgid failed.
The attached patch solves this problem.
Seems this was a n00b bug with setting UID before GID, and since root priviliges were already lost, setgid failed.
The attached patch solves this problem.