OSDN Git Service

ed6b0a5b63ee41b4b1287aa10413877a5fc0aacd
[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 2010-11-22 "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 EPERM
61 The calling process is not privileged (does not have the
62 \fBCAP_SETGID\fP capability), and
63 .I gid
64 does not match the real group ID or saved set-group-ID of
65 the calling process.
66 .SH CONFORMING TO
67 SVr4, POSIX.1-2001.
68 .SH NOTES
69 The original Linux
70 .BR setgid ()
71 system call supported only 16-bit group IDs.
72 Subsequently, Linux 2.4 added
73 .BR setgid32 ()
74 supporting 32-bit IDs.
75 The glibc
76 .BR setgid ()
77 wrapper function transparently deals with the variation across kernel versions.
78 .SH SEE ALSO
79 .BR getgid (2),
80 .BR setegid (2),
81 .BR setregid (2),
82 .BR capabilities (7),
83 .BR credentials (7)
84 .SH COLOPHON
85 This page is part of release 3.64 of the Linux
86 .I man-pages
87 project.
88 A description of the project,
89 and information about reporting bugs,
90 can be found at
91 \%http://www.kernel.org/doc/man\-pages/.