actually we should setgid() first, or else it would fail when setgid() :(