SETREUID(2)

NAME
setreuid - set real and effective user ID

SYNOPSIS
#include <unistd.h>

int setreuid(uid_t ruid ,uid_t euid );

DESCRIPTION
The real and effective user ID's of the current process are set to the arguments. Unprivileged users may change the real user ID to the effective user ID and vice-versa; only the super-user may make other changes. Supplying a value of -1 for either the real or effective user ID forces the system to substitute the current ID in place of the -1 parameter.

NOTES FROM KERNEL SOURCE
In Linux 0.99.11, unprivileged users may change the real user ID to the effective uid or vice versa. (BSD-style) When you set the effective uid, it sets the saved uid too. This makes it possible for a setuid program to completely drop its privileges, which is often a useful assertion to make when you are doing a security audit over a program. The general idea is that a program which uses just setreuid will be 100% compatible with BSD. A program which uses just setuid will be 100% compatible with POSIX w/ Saved ID's.

RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

ERRORS

EPERM
    The current process is not the super-user and a change other than changing the effective user-id to the real user-id was specified.

HISTORY
The setreuid function call appeared in BSD 4.2.

CONFORMING TO
BSD 4.3

SEE ALSO
getuid(2), setuid(2)