OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / setgid.2
1 .\" Copyright (C), 1994, Graeme W. Wilford. (Wilf.)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Fri Jul 29th 12:56:44 BST 1994  Wilf. <G.Wilford@ee.surrey.ac.uk>
26 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
27 .\" Modified 2002-03-09 by aeb
28 .\"
29 .TH SETGID 2 2014-09-21 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 setgid \- 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
39 .BR setgid ()
40 sets the effective group ID of the calling process.
41 If the caller is the
42 superuser, the real GID and saved set-group-ID are also set.
43
44 Under Linux,
45 .BR setgid ()
46 is implemented like the POSIX version with the
47 .B _POSIX_SAVED_IDS
48 feature.
49 This allows a set-group-ID program that is not set-user-ID-root
50 to drop all of its group
51 privileges, do some un-privileged work, and then reengage the original
52 effective group ID in a secure manner.
53 .SH RETURN VALUE
54 On success, zero is returned.
55 On error, \-1 is returned, and
56 .I errno
57 is set appropriately.
58 .SH ERRORS
59 .TP
60 .B EINVAL
61 The group ID specified in
62 .I gid
63 is not valid in this user namespace.
64 .TP
65 .B EPERM
66 The calling process is not privileged (does not have the
67 \fBCAP_SETGID\fP capability), and
68 .I gid
69 does not match the real group ID or saved set-group-ID of
70 the calling process.
71 .SH CONFORMING TO
72 SVr4, POSIX.1-2001.
73 .SH NOTES
74 The original Linux
75 .BR setgid ()
76 system call supported only 16-bit group IDs.
77 Subsequently, Linux 2.4 added
78 .BR setgid32 ()
79 supporting 32-bit IDs.
80 The glibc
81 .BR setgid ()
82 wrapper function transparently deals with the variation across kernel versions.
83 .SH SEE ALSO
84 .BR getgid (2),
85 .BR setegid (2),
86 .BR setregid (2),
87 .BR capabilities (7),
88 .BR credentials (7),
89 .BR user_namespaces (7)
90 .SH COLOPHON
91 This page is part of release 3.79 of the Linux
92 .I man-pages
93 project.
94 A description of the project,
95 information about reporting bugs,
96 and the latest version of this page,
97 can be found at
98 \%http://www.kernel.org/doc/man\-pages/.