Yes, it is definitely is worth implementing, and I consider it to be a bug, not missing feature.
We stumbled on this problem recently too and I'm currently looking for the best way to implement it.
setgid will probably be called even if group is not specified explicitly, with "main" user group as an argument.
I'm still not sure how to get this users's main group, though. "su" source code calls initgroups() function from libc for similar task, and I haven't found its perl analog yet.
--
Vyacheslav Matyukhin
http://github.com/berekuk
http://friendfeed.com/mmcleric
http://berekuk.ru
getpwent() doesn't take any arguments and can only be called after setuid.Isn't gid returned by simple getpwent() appropriate?And to be able to provide group both implicitly and explicitly we need group() to be the method of Ubic::Service class, which could be called from any user and still return correct value.I worry about backward compatibity too. Will it break anything for you if your non-root daemons will suddenly become www-data/www-data instead of www-data/root?By now, I'm preparing a quick patch with group() method returning 'root' by default and 'group' parameter to SimpleDaemon overriding it.Oops, I meant getpwnam().% perl -E 'say +(getpwnam "www-data")[3]'33Thanks, this should work, don't know why i missed it.There are also "supplementary" groups on most systems (including linux) which we should init too, though.
I think that setgid() to main group by default will be enough. Old supplementary group list should definitely be reset.