Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

setregid(2) [netbsd man page]

SETREGID(2)						      BSD System Calls Manual						       SETREGID(2)

NAME
setregid -- set real and effective group ID's LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> int setregid(gid_t rgid, gid_t egid); DESCRIPTION
This interface is made obsolete by the saved ID functionality in setgid(2) and setegid(2). The real and effective group ID's of the current process are set according to the arguments. If the real group ID is changed, the saved group ID is changed to the new value of the effective group ID. If rgid or egid is -1, the current gid is filled in by the system. Unprivileged users may change the real group ID to the effective group ID, and may change the effective group ID to the real group ID or the saved group ID; only the super-user may make other changes. The setregid() function has been used to swap the real and effective group IDs in set-group-ID programs to temporarily relinquish the set- group-ID value. This purpose is now better served by the use of the setegid() function (see setgid(2)). When setting the real and effective group IDs to the same value, this function is equivalent to the setgid() function. When setting only the effective group ID, this function is equivalent to the setegid() function. RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. ERRORS
[EPERM] The current process is not the super-user and a change other than changing the effective group-id to the real group-id was specified. SEE ALSO
getgid(2), setegid(2), setgid(2), setuid(2) HISTORY
The setregid() function call appeared in 4.2BSD. An incompatible version was implemented in 4.4BSD. It was reimplemented in NetBSD 1.2 in a way compatible with 4.3BSD, SunOS and Linux, but should not be used in new code. BSD
January 5, 2001 BSD

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