main: move -u and -g processing outside fork, fixes 2331