The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

setuid - set-user-ID

 SYNOPSIS



#include <sys/types.h>
#include <unistd.h>

int setuid(uid_t uid);

 DESCRIPTION

If the process has appropriate privileges, setuid() sets the real user ID, effective user ID, and the saved set-user-ID to uid.

If the process does not have appropriate privileges, but uid is equal to the real user ID or the saved set-user-ID, setuid() sets the effective user ID to uid; the real user ID and saved set-user-ID remain unchanged.

 RETURN VALUE

Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error.

 ERRORS

The setuid() function will fail and return -1 and set errno to the corresponding value if one or more of the following are true:
[EINVAL]
The value of the uid argument is invalid and not supported by the implementation.
[EPERM]
The process does not have appropriate privileges and uid does not match the real user ID  or the saved set-user-ID.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

exec, geteuid(), getuid(), setgid(), <sys/types.h>, <unistd.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]