Node:Setting User ID, Next:Setting Groups, Previous:Reading Persona, Up:Users and Groups
This section describes the functions for altering the user ID (real
and/or effective) of a process. To use these facilities, you must
include the header files sys/types.h
and unistd.h
.
int seteuid (uid_t neweuid) | Function |
This function sets the effective user ID of a process to newuid,
provided that the process is allowed to change its effective user ID. A
privileged process (effective user ID zero) can change its effective
user ID to any legal value. An unprivileged process with a file user ID
can change its effective user ID to its real user ID or to its file user
ID. Otherwise, a process may not change its effective user ID at all.
The
Older systems (those without the |
int setuid (uid_t newuid) | Function |
If the calling process is privileged, this function sets both the real
and effective user ID of the process to newuid. It also deletes
the file user ID of the process, if any. newuid may be any
legal value. (Once this has been done, there is no way to recover the
old effective user ID.)
If the process is not privileged, and the system supports the
The return values and error conditions are the same as for |
int setreuid (uid_t ruid, uid_t euid) | Function |
This function sets the real user ID of the process to ruid and the
effective user ID to euid. If ruid is -1 , it means
not to change the real user ID; likewise if euid is -1 , it
means not to change the effective user ID.
The The return value is
|