gtpc2m6d | C/C++ Language Support User's Guide |
This function sets the effective user ID (UID) to uid.
Format
#include <unistd.h> int seteuid(uid_t uid);
Normal Return
If successful, the seteuid function returns an integer value of 0 and the effective user ID is set to uid. The real UID and the saved set UID are not changed.
Error Return
If unsuccessful, the seteuid function returns -1 and sets errno to one of the following:
Programming Considerations
The appropriate privileges are when the calling program has the key 0 macro option set on in the PAT or when the process is a superuser.
Examples
The following example provides information for the effective user ID of the caller and sets its effective UID.
#include <unistd.h> #include <stdio.h> int main(void) { printf("Your effective user id is %d\n", (int) geteuid() ); if ( seteuid ( 25 ) != 0 ) perror ( "seteuid() error" ); else printf("Your effective user id was changed to %d\n", (int) geteuid() ); return 0; }
The seteuid function returns 0.
Related Information