OSDN Git Service

c0d74c91d163b7802659230901aaeb9a8d1b80e6
[linuxjm/LDP_man-pages.git] / original / man2 / setfsgid.2
1 .\" Copyright (C) 1995, Thomas K. Dyas <tdyas@eden.rutgers.edu>
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 .\" Created   1995-08-06 Thomas K. Dyas <tdyas@eden.rutgers.edu>
26 .\" Modified  2000-07-01 aeb
27 .\" Modified  2002-07-23 aeb
28 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
29 .\"     Added notes on capability requirements
30 .\"
31 .TH SETFSGID 2 2010-11-22 "Linux" "Linux Programmer's Manual"
32 .SH NAME
33 setfsgid \- set group identity used for file system checks
34 .SH SYNOPSIS
35 .B #include <unistd.h>
36 /* glibc uses <sys/fsuid.h> */
37 .sp
38 .BI "int setfsgid(uid_t " fsgid );
39 .SH DESCRIPTION
40 The system call
41 .BR setfsgid ()
42 sets the group ID that the Linux kernel uses to check for all accesses
43 to the file system.
44 Normally, the value of
45 .I fsgid
46 will shadow the value of the effective group ID.
47 In fact, whenever the
48 effective group ID is changed,
49 .I fsgid
50 will also be changed to the new value of the effective group ID.
51
52 Explicit calls to
53 .BR setfsuid (2)
54 and
55 .BR setfsgid ()
56 are usually only used by programs such as the Linux NFS server that
57 need to change what user and group ID is used for file access without a
58 corresponding change in the real and effective user and group IDs.
59 A change in the normal user IDs for a program such as the NFS server
60 is a security hole that can expose it to unwanted signals.
61 (But see below.)
62
63 .BR setfsgid ()
64 will only succeed if the caller is the superuser or if
65 .I fsgid
66 matches either the real group ID, effective group ID,
67 saved set-group-ID, or the current value of
68 .IR fsgid .
69 .SH RETURN VALUE
70 On success, the previous value of
71 .I fsgid
72 is returned.
73 On error, the current value of
74 .I fsgid
75 is returned.
76 .SH VERSIONS
77 This system call is present in Linux since version 1.2.
78 .\" This system call is present since Linux 1.1.44
79 .\" and in libc since libc 4.7.6.
80 .SH CONFORMING TO
81 .BR setfsgid ()
82 is Linux-specific and should not be used in programs intended
83 to be portable.
84 .SH NOTES
85 When glibc determines that the argument is not a valid group ID,
86 it will return \-1 and set \fIerrno\fP to
87 .B EINVAL
88 without attempting
89 the system call.
90 .LP
91 Note that at the time this system call was introduced, a process
92 could send a signal to a process with the same effective user ID.
93 Today signal permission handling is slightly different.
94
95 The original Linux
96 .BR setfsgid ()
97 system call supported only 16-bit group IDs.
98 Subsequently, Linux 2.4 added
99 .BR setfsgid32 ()
100 supporting 32-bit IDs.
101 The glibc
102 .BR setfsgid ()
103 wrapper function transparently deals with the variation across kernel versions.
104 .SH BUGS
105 No error messages of any kind are returned to the caller.
106 At the very
107 least,
108 .B EPERM
109 should be returned when the call fails (because the caller lacks the
110 .B CAP_SETGID
111 capability).
112 .SH SEE ALSO
113 .BR kill (2),
114 .BR setfsuid (2),
115 .BR capabilities (7),
116 .BR credentials (7)