set the effective group ID for a process
#include <unistd.h> int setegid( gid_t gid );
The setegid() function allows the calling process to set the effective group ID. The real and saved group ID aren't changed.
/*
* This process sets its effective group ID to 2.
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
void main()
{
gid_t oegid;
oegid = getegid();
if( setegid( 2 ) == -1 ) {
perror( "setegid" );
exit( EXIT_FAILURE );
}
printf( "Was effective group %d, is 2\n", oegid );
exit( EXIT_SUCCESS );
}
UNIX
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | Yes, but modifies errno |
| Thread | Yes |
errno, seteuid(), setgid(), setuid()