]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/setgid.2
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man2 / setgid.2
CommitLineData
fea681da
MK
1.\" Copyright (C), 1994, Graeme W. Wilford. (Wilf.)
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
c13182ef 23.\" Fri Jul 29th 12:56:44 BST 1994 Wilf. <G.Wilford@ee.surrey.ac.uk>
fea681da
MK
24.\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
25.\" Modified 2002-03-09 by aeb
26.\"
27.TH SETGID 2 2002-03-09 "Linux 2.5" "Linux Programmer's Manual"
28.SH NAME
29setgid \- set group identity
30.SH SYNOPSIS
31.B #include <sys/types.h>
32.br
33.B #include <unistd.h>
34.sp
35.BI "int setgid(gid_t " gid );
36.SH DESCRIPTION
e511ffb6 37.BR setgid ()
c13182ef
MK
38sets the effective group ID of the current process.
39If the caller is the
d9df8ff8 40superuser, the real GID and saved set-group-ID are also set.
fea681da 41
c13182ef 42Under Linux,
e511ffb6 43.BR setgid ()
fea681da 44is implemented like the POSIX version with the _POSIX_SAVED_IDS feature.
d9df8ff8 45This allows a set-group-ID program that is not set-user-ID-root
880f5b4b 46to drop all of its group
fea681da
MK
47privileges, do some un-privileged work, and then re-engage the original
48effective group ID in a secure manner.
49.SH "RETURN VALUE"
c13182ef
MK
50On success, zero is returned.
51On error, \-1 is returned, and
fea681da
MK
52.I errno
53is set appropriately.
54.SH ERRORS
55.TP
56.B EPERM
d3c8b3e9
MK
57The calling process is not privileged (does not have the
58CAP_SETGID capability), and
fea681da
MK
59.I gid
60does not match the effective group ID or saved set-group-ID of
61the calling process.
62.SH "CONFORMING TO"
97c1eac8 63SVr4, POSIX.1-2001.
fea681da
MK
64.SH "SEE ALSO"
65.BR getgid (2),
66.BR setegid (2),
67.BR setregid (2),
68.BR capabilities (7)