Установить реальные, эффективные и сохраненные идентификаторы групп
#include <unistd.h>int setgid( gid_t gid );
libc
The setgid() function lets the calling process set the real, effective and saved group IDs, based on the following:
This function doesn't change any supplementary group IDs of the calling process.
If you wish to change only the effective group ID, and even if you are the superuser, you should consider using the setegid() function.
The “superuser” is defined as any process with an effective user ID of 0
, or an effective user ID of root.
#include <stdio.h>#include <sys/types.h>#include <unistd.h>#include <stdlib.h>int main( void ){gid_t ogid;ogid = getgid();if ( setgid( 2 ) == -1 ){perror( "setgid" );return (EXIT_FAILURE);}printf( "group id is now 2, was %d\n", ogid );return (EXIT_SUCCESS);}
POSIX 1003.1
errno, setegid(), seteuid(), setuid()
Предыдущий раздел: Описание API системной библиотеки