Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

setrgid(3) [ultrix man page]

setuid(3)						     Library Functions Manual							 setuid(3)

Name
       setuid, seteuid, setruid, setgid, setegid, setrgid - set user and group ID

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

       setuid(uid)
       uid_t uid;
       seteuid(euid)
       uid_t euid;
       setruid(ruid)
       uid_t ruid;

       setgid(gid)
       gid_t gid;
       setegid(egid)
       gid_t egid;
       setrgid(rgid)
       gid_t rgid;

Description
       The subroutine sets both the real and effective user ID of the current process to the ID specified.  Likewise, the subroutine sets the real
       and effective group ID of the current process to the ID specified.

       The subroutine sets the effective user ID of the current process, while the subroutine sets the effective group ID of the current process.

       The subroutine sets the real user ID of the current process, while the subroutine sets the real group ID of the current process.

       These calls are only permitted to the super-user or if the argument is the real or effective ID.

Environment
       POSIX
       SYSTEM_FIVE
       When your program is compiled in POSIX or System V mode the following semantics apply when using the or functions:

       If the process is the super-user the real, effective, and saved set (as described in user/group ID are set to uid.

       If the process is not the super-user, but uid is equal to the real or the saved set user/group ID, the effective user/group ID  is  set	to
       uid.  The real and saved set user/group ID remain unchanged.

       POSIX
       In POSIX mode, the function returns a value of type uid_t. The function returns a value of type gid_t.

Return Values
       Zero is returned if the user ID or group ID is set; -1 is returned otherwise.

See Also
       setreuid(2), setregid(2), getuid(2), getgid(2)

																	 setuid(3)

Check Out this Related Man Page

SETUID(2)						      BSD System Calls Manual							 SETUID(2)

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() function sets the real and effective user IDs and the saved set-user-ID of the current process to the specified value. The setuid() function is permitted if the effective user ID is that of the super user, or if the specified user ID is the same as the effective user ID. If not, but the specified user ID is the same as the real user ID, setuid() will set the effective user ID to the real user ID. The setgid() function sets the real and effective group IDs and the saved set-group-ID of the current process to the specified value. The setgid() function is permitted if the effective user ID is that of the super user, or if the specified group ID is the same as the effective group ID. If not, but the specified group ID is the same as the real group ID, setgid() will set the effective group ID to the real group ID. The seteuid() function (setegid()) 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 intro(2) and execve(2)); in this way, the effective user ID of a set-user-ID exe- cutable 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 super user, or the uid specified is not the real, effective ID, or saved ID, these functions return -1. SEE ALSO
getuid(2), getgid(2) STANDARDS
The setuid() and setgid() functions are compliant with the ISO/IEC 9945-1:1990 (``POSIX.1'') specification with _POSIX_SAVED_IDS defined, with the extensions allowed in section B.4.2.2. The seteuid() and setegid() functions are extensions based on the POSIX concept of _POSIX_SAVED_IDS, and have been proposed for a future revision of the standard. 4.2 Berkeley Distribution June 4, 1993 4.2 Berkeley Distribution
Man Page