Code cleanups and error handling fixes to setting/dropping groups.
Code cleanups and error handling fixes to setting/dropping groups.

damoxc/dovecot,damoxc/dovecot,damoxc/dovecot,damoxc/dovecot,damoxc/dovecot