Set the effective group ID for a process
#include <unistd.h> int setegid( gid_t gid );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The setegid() function lets the calling process set the effective group ID based on the following:
The real and saved group ID aren't changed.
Zero for success, or -1 if an error occurs (errno is set).
/*
* This process sets its effective group ID to 2
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main( void )
{
gid_t oegid;
oegid = getegid();
if( setegid( 2 ) == -1 ) {
perror( "setegid" );
return EXIT_FAILURE;
}
printf( "Was effective group %d, is 2\n", oegid );
return EXIT_SUCCESS;
}
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |