Index of Section 2 Manual Pages
| Interix / SUA | seteuid.2 | Interix / SUA |
seteuid(2) seteuid(2)
setuid()
NAME
setuid(), seteuid(), setgid(), setegid(), - set user and group ID
SYNOPSIS
#include
#include
int setuid (uid_t uid)
int seteuid (uid_t uid)
int setgid (gid_t gid)
int setegid (gid_t gid)
DESCRIPTION
The setuid(2) function sets the real and effective user IDs and the saved
set-user-ID of the current process to the specified value. The setuid(2)
function is permitted if the specified ID is equal to the real user ID of
the process, or if the effective user ID has the appropriate privileges.
The setgid(2) function sets the real and effective group IDs and the saved
set-group-ID of the current process to the specified value. The setgid(2)
function is permitted if the specified ID is equal to the real group ID of
the process, or if the effective user ID has the appropriate privileges.
For more details on security and appropriate permissions, see Security in
the "Interix Overview" section of Windows Services for UNIX Help. Future
releases of Window Services for UNIX may have a different implementation.
The seteuid(2) function setegid(2) sets the effective user ID (group ID)
of the current process. The effective user ID may be set to the value of
the real user ID or the saved set-user-ID (see execve(2)); in this way,
the effective user ID of a set-user-ID executable may be toggled by
switching to the real user ID, then re-enabled by reverting to the set-
user-ID value. Similarly, the effective group ID may be set to the value
of the real group ID or the saved set-user-ID.
RETURN VALUES
Upon success, these functions return 0; otherwise -1 is returned.
If the user is not the superuser, or the uid specified is not the real,
effective ID, or saved ID, these functions return -1.
ERRORS
The setuid(2) and seteuid(2) functions can fail for the following reasons:
[EINVAL]
The value of the uid argument is invalid.
[EPERM]
The process does not have appropriate privileges and uid does not
match the real user ID or the saved set-user-ID.
The setegid(2) and setegid(2) functions can fail for the following
reasons:
[EINVAL]
The value of the gid argument is invalid.
[EPERM]
The process does not have appropriate privileges and gid does not
match the real group ID or the saved set-group-ID.
NOTES
The appropriate privileges are granted to the following users: The SYSTEM
account, the Administrator account of the principal domain, and the
Administrator account of the local domain.
The local Administrator account is restricted to setting the UID to local
accounts.
By default, Interix does not execute files with the set-user-ID (setuid)
or set-group-ID (setgid) mode bit set for security reasons. If an attempt
is made to execute such a file, the ENOSETUID error is returned. For more
information and and instructions for enabling execution of files with
these mode bits set, see The superuser account and appropriate privileges
in Windows Services for UNIX Help.
SEE ALSO
getuid(2)
getgid(2)
USAGE NOTES
All of these functions are thread safe.
The following functions are async-signal safe: setuid, setgid. The
following functions are not async-signal safe: seteuid, setegid.