setuid()

NAME

setuid(), seteuid(), setgid(), setegid(), - set user and group ID

SYNOPSIS

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

int setuid (uid_t uid) int seteuid (uid_t euid) int setgid (gid_t gid) int setegid (gid_t egid)

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.

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)