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/setgid.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/setgid.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/setgid.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/setgid.html on line 8
Set the real, effective and saved group IDs
#include <unistd.h>
int setgid( gid_t gid );
- gid
- The 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 setgid() function lets the calling process set the
real, effective and saved group IDs, based on the following:
- If the process is the superuser, the setgid()
function sets the real group ID, effective group ID and saved group ID
to gid.
- If the process isn't the superuser, but
gid is equal to the real group ID, setgid() sets the
effective group ID to gid; the real and saved group IDs
aren't changed.
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.
- 0
- Success.
- -1
- An error occurred; errno
is set to indicate the error.
- EINVAL
- The value of gid is invalid.
- EPERM
- The process doesn't have appropriate privileges, and gid
doesn't match the real group ID.
#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
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
errno,
setegid(),
seteuid(),
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/setgid.html on line 186
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/setgid.html on line 186