setreuid() - set real and effective user ID's
#include <unistd.h>
int setreuid (uid_t ruid, uid_t euid)
The real and effective user IDs of the current process are set according to the arguments. If ruid or euid is -1, the current uid is filled in by the system. Unprivileged users may change the real user ID to the effective user ID and vice-versa; only the superuser may make other changes.
The setreuid(2) function has been used to swap the real and effective user IDs in set-user-ID programs to temporarily relinquish the set-user-ID value. This purpose is now better served by the use of the seteuid(2) function (see setuid(2)).
When setting the real and effective user IDs to the same value, the standard setuid(2) function is preferred.
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.
The setreuid(2) call can fail for the following reasons:
The appropriate privileges are granted to the following users: The SYSTEM account, the Administrator account of the principal domain, and the Administrator account of the local domain.
The local Administrator account is restricted to setting the UID to local accounts.
getuid(2)
seteuid(2)
setuid(2)