set the effective user ID
#include <unistd.h> int seteuid( uid_t uid );
The seteuid() function allows the calling process to set the effective user ID. 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> void main() { uid_t oeuid; oeuid = geteuid(); if( seteuid( 0 ) == -1 ) { perror( "seteuid" ); exit( 1 ); } printf( "Effective userid now 0, was %d\n", oeuid ); }
UNIX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
errno, setegid(), setuid(), setgid()