Updated: April 19, 2023 |
Set the effective user ID
#include <unistd.h> int seteuid( uid_t uid );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The seteuid() function lets the calling process set its effective user ID to its real or effective user ID, its saved set-user ID, or to any of the user IDs identified by the PROCMGR_AID_SETUID ability (see procmgr_ability()).
The real and saved user IDs aren't changed.
/* * This process sets its effective userid to 0 (root). */ #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> int main( void ) { uid_t oeuid; oeuid = geteuid(); if( seteuid( 0 ) == -1 ) { perror( "seteuid" ); return EXIT_FAILURE; } printf( "effective userid now 0, was %d\n", oeuid ); return EXIT_SUCCESS; }
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |