Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/setegid.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/setegid.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/setegid.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/setegid.html on line 8
Set the effective group ID for a process
#include <unistd.h>
int setegid( gid_t gid );
- gid
- The effective group ID that you want to use for the process.
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:
- If the process is the superuser, the setegid() function
sets the effective group ID to gid.
- If the process isn't the superuser, but gid is equal to
the real group ID or saved set-group ID, setegid() sets
the effective group ID to gid.
The real and saved group ID aren't changed.
|
If a set-group ID process sets its effective group ID to its real
group ID, it can still set its effective group ID back to the saved
set-group ID. |
The “superuser” is defined as any process with an effective
user ID of 0, or an effective user ID of root.
Zero for success, or -1 if an error occurs
(errno is set).
- EINVAL
- The value of gid is out of range.
- EPERM
- The process isn't the superuser, and gid
doesn't match the real group ID or the saved set-group ID.
/*
* 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;
}
POSIX 1003.1
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
errno,
getegid(),
seteuid(),
setgid(),
setuid()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/setegid.html on line 183
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/setegid.html on line 183