COHERENT manpages
This page displays the COHERENT manpage for setuid() [Set user identifier].
List of available manpages
Index
setuid() -- System Call (libc) Set user identifier #include <unistd.h> int setuid(id) int id; The user identifier is the number that identifies the user who ``owns'' a given file. The suite of users is defined in file /etc/passwd. When a file is executable, the executing process inherits its user identifier (and thus, its user-level permissions) from the file where it lives on disk. The user identifier comes in three forms: real This is the identifier of the user who is running the process. effective This is the user identifier that determines the access rights of the process. These rights are the same as those of the real user identifier unless they have been altered by executing a file whose setuid bit is set. saved effective This permits a process to step back and forth between its real and effective user identifiers. If you return from an effective user identifier to your real one, the previously effective id is saved so you can revert to it if need be. The system call setuid() lets you alter the real and effective user identifiers of the calling process to the user identifier uid. The behavior of setuid() varies depending upon the following: 1. If the effective user identifier is that of the superuser, setuid() sets the real, effective, and saved effective user identifiers to uid. 2. If the real user identifier is the same as uid, setuid() sets the effective user identifier to uid. 3. If the saved effective user identifier is same as uid, setuid() sets the effective user identifier to uid. To setuid an existing executable file, use the command chmod. See Also chmod, execution, getuid(), libc, login, setgid(), unistd.h POSIX Standard, §4.2.2 Diagnostics setuid() returns zero on success, or -1 on failure. Notes For more information on the user id, see the Lexicon entry for execution.