set target user groups before setuid'ing

Without this patch daemonized process os.getgroups() returns [0].