]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/setgid.2
intro.1, _exit.2, access.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bind.2, chdir...
[thirdparty/man-pages.git] / man2 / setgid.2
CommitLineData
fea681da
MK
1.\" Copyright (C), 1994, Graeme W. Wilford. (Wilf.)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da 24.\"
c13182ef 25.\" Fri Jul 29th 12:56:44 BST 1994 Wilf. <G.Wilford@ee.surrey.ac.uk>
fea681da
MK
26.\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
27.\" Modified 2002-03-09 by aeb
28.\"
6dc1520b 29.TH SETGID 2 2010-11-22 "Linux" "Linux Programmer's Manual"
fea681da
MK
30.SH NAME
31setgid \- set group identity
32.SH SYNOPSIS
33.B #include <sys/types.h>
34.br
35.B #include <unistd.h>
36.sp
37.BI "int setgid(gid_t " gid );
38.SH DESCRIPTION
e511ffb6 39.BR setgid ()
a1ffe9f5 40sets the effective group ID of the calling process.
c13182ef 41If the caller is the
d9df8ff8 42superuser, the real GID and saved set-group-ID are also set.
fea681da 43
c13182ef 44Under Linux,
e511ffb6 45.BR setgid ()
8c4f34f8
MK
46is implemented like the POSIX version with the
47.B _POSIX_SAVED_IDS
48feature.
d9df8ff8 49This allows a set-group-ID program that is not set-user-ID-root
880f5b4b 50to drop all of its group
3b777aff 51privileges, do some un-privileged work, and then reengage the original
fea681da 52effective group ID in a secure manner.
47297adb 53.SH RETURN VALUE
c13182ef
MK
54On success, zero is returned.
55On error, \-1 is returned, and
fea681da
MK
56.I errno
57is set appropriately.
58.SH ERRORS
59.TP
60.B EPERM
d3c8b3e9 61The calling process is not privileged (does not have the
0b9bdf82 62\fBCAP_SETGID\fP capability), and
fea681da 63.I gid
7a8fe6a9 64does not match the real group ID or saved set-group-ID of
fea681da 65the calling process.
47297adb 66.SH CONFORMING TO
7484d5a7 67SVr4, POSIX.1-2001.
6dc1520b
MK
68.SH NOTES
69The original Linux
70.BR setgid ()
71system call supported only 16-bit group IDs.
c5662d5d 72Subsequently, Linux 2.4 added
6dc1520b
MK
73.BR setgid32 ()
74supporting 32-bit IDs.
75The glibc
76.BR setgid ()
77wrapper function transparently deals with the variation across kernel versions.
47297adb 78.SH SEE ALSO
fea681da
MK
79.BR getgid (2),
80.BR setegid (2),
81.BR setregid (2),
53a1443c
MK
82.BR capabilities (7),
83.BR credentials (7)