setgid32 (2)
Leading comments
Copyright (C), 1994, Graeme W. Wilford. (Wilf.) and Copyright (C) 2010, 2015, Michael Kerrisk <mtk.manpages@gmail.com> %%%LICENSE_START(VERBATIM) Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed und...
NAME
setgid - set group identitySYNOPSIS
#include <sys/types.h>#include <unistd.h>
int setgid(gid_t gid);
DESCRIPTION
setgid() sets the effective group ID of the calling process. If the caller is privileged (has the CAP_SETGID capability), the real GID and saved set-group-ID are also set.Under Linux, setgid() is implemented like the POSIX version with the _POSIX_SAVED_IDS feature. This allows a set-group-ID program that is not set-user-ID-root to drop all of its group privileges, do some un-privileged work, and then reengage the original effective group ID in a secure manner.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.ERRORS
- EINVAL
- The group ID specified in gid is not valid in this user namespace.
- EPERM
- The calling process is not privileged (does not have the CAP_SETGID capability), and gid does not match the real group ID or saved set-group-ID of the calling process.