setgid

I have a setuid to root program that has now to be changed to setuid to oracle depending on who is running it. Oracle has only two groups, dba (primary) and osgrp1 (secondary). But running 'id' if oracle shows all the secondary groups belonging to root, and only dba or osgrp1 as the primary group (depending on which was setgid later).

Calling setgid in any program only sets the primary gid. Multiple calls keep changing the primary gid. How can I set the secondary gids for a process?

setgroups() will set the list of secondary groups.

Thanks for the quick reply.