Open System Services System Calls Reference Manual (G06.25+, H06.03+)
setuid(2) OSS System Calls Reference Manual
NAME
setuid - Sets the user ID of the calling process
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsecsrl
H-series OSS processes: /G/system/zdllnnn/zsecdll
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <unistd.h>
int setuid(
uid_t uid);
PARAMETERS
uid Specifies the new user ID.
DESCRIPTION
When invoked by processes with appropriate privileges, the setuid() function sets the real user
ID, effective user ID, and saved-set-user ID of the calling process to the value of the uid parame-
ter.
To change the real user ID, the effective user ID, and the saved-set-user ID, the calling process
must have appropriate privileges. If the process does not have appropriate privileges but the uid
parameter is equal to the real user ID or the saved-set-user ID, the setuid() function sets the
effective user ID to uid; the real user ID and saved-set-user ID remain unchanged.
The value of uid must be in the range 0 through 65535.
NOTES
Changing the effective user ID sets the operating system process access ID (PAID) to the value
of the effective user ID.
RETURN VALUES
Upon successful completion, the value 0 (zero) is returned. Otherwise, the value -1 is returned
and errno is set to indicate the error.
ERRORS
If any of the following conditions occurs, the setuid() function sets errno to the corresponding
value:
[EINVAL] The uid parameter is out of range.
[EPERM] The process lacks appropriate privileges, and the uid parameter does not match
the real user ID or the saved-set-user ID.
RELATED INFORMATION
Functions: exec(2), getuid(2).
7−44 Hewlett-Packard Company 527186-003