setuid - set-user-ID
#include <sys/types.h> #include <unistd.h> int setuid(uid_t uid);
If the process has appropriate privileges, setuid() sets the real user ID, effective user ID, and the saved set-user-ID to uid.
If the process does not have appropriate privileges, but uid is equal to the real user ID or the saved set-user-ID, setuid() sets the effective user ID to uid; the real user ID and saved set-user-ID remain unchanged.
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error.
The setuid() function will fail and return -1 and set errno to the corresponding value if one or more of the following are true:
- The value of the uid argument is invalid and not supported by the implementation.
- The process does not have appropriate privileges and uid does not match the real user ID or the saved set-user-ID.
exec, geteuid(), getuid(), setgid(), <sys/types.h>, <unistd.h>.
Derived from Issue 1 of the SVID.