]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (C) 1995, Thomas K. Dyas <tdyas@eden.rutgers.edu> |
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 MK |
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 | |
c11b1abf | 28 | .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da MK |
29 | .\" Added notes on capability requirements |
30 | .\" | |
ff4739ce | 31 | .TH SETFSGID 2 2013-08-08 "Linux" "Linux Programmer's Manual" |
fea681da | 32 | .SH NAME |
9ee4a2b6 | 33 | setfsgid \- set group identity used for filesystem checks |
fea681da | 34 | .SH SYNOPSIS |
0070a62d | 35 | .B #include <sys/fsuid.h> |
fea681da MK |
36 | .sp |
37 | .BI "int setfsgid(uid_t " fsgid ); | |
38 | .SH DESCRIPTION | |
39 | The system call | |
e511ffb6 | 40 | .BR setfsgid () |
4069bc44 MK |
41 | changes the value of the caller's filesystem group ID\(emthe |
42 | group ID that the Linux kernel uses to check for all accesses | |
9ee4a2b6 | 43 | to the filesystem. |
c13182ef | 44 | Normally, the value of |
4069bc44 | 45 | the filesystem group ID |
c13182ef MK |
46 | will shadow the value of the effective group ID. |
47 | In fact, whenever the | |
fea681da | 48 | effective group ID is changed, |
4069bc44 | 49 | the filesystem group ID |
fea681da MK |
50 | will also be changed to the new value of the effective group ID. |
51 | ||
52 | Explicit calls to | |
0bfa087b | 53 | .BR setfsuid (2) |
fea681da | 54 | and |
e511ffb6 | 55 | .BR setfsgid () |
33a0ccb2 | 56 | are usually used only by programs such as the Linux NFS server that |
fea681da MK |
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 | |
6387216b MK |
60 | is a security hole that can expose it to unwanted signals. |
61 | (But see below.) | |
fea681da | 62 | |
e511ffb6 | 63 | .BR setfsgid () |
33a0ccb2 | 64 | will succeed only if the caller is the superuser or if |
fea681da | 65 | .I fsgid |
4069bc44 MK |
66 | matches either the caller's real group ID, effective group ID, |
67 | saved set-group-ID, or current the filesystem user ID. | |
47297adb | 68 | .SH RETURN VALUE |
ff4739ce MK |
69 | On both success and failure, |
70 | this call returns the previous filesystem group ID of the caller. | |
a3680fde MK |
71 | .SH VERSIONS |
72 | This system call is present in Linux since version 1.2. | |
73 | .\" This system call is present since Linux 1.1.44 | |
74 | .\" and in libc since libc 4.7.6. | |
47297adb | 75 | .SH CONFORMING TO |
e511ffb6 | 76 | .BR setfsgid () |
8382f16d | 77 | is Linux-specific and should not be used in programs intended |
97c1eac8 | 78 | to be portable. |
fea681da | 79 | .SH NOTES |
de61071a JH |
80 | When old versions of glibc determine that the argument can not be |
81 | passed to the kernel without integer truncation (because the kernel | |
82 | is old and does not support 32-bit group IDs), | |
83 | they will return \-1 and set \fIerrno\fP to | |
1274071a MK |
84 | .B EINVAL |
85 | without attempting | |
fea681da MK |
86 | the system call. |
87 | .LP | |
88 | Note that at the time this system call was introduced, a process | |
89 | could send a signal to a process with the same effective user ID. | |
90 | Today signal permission handling is slightly different. | |
6ace3248 MK |
91 | See |
92 | .BR setfsuid (2) | |
93 | for a discussion of why the use of both | |
94 | .BR setfsuid (2) | |
95 | and | |
96 | .BR setfsgid () | |
97 | is nowadays unneeded. | |
0f0b04f8 MK |
98 | |
99 | The original Linux | |
100 | .BR setfsgid () | |
101 | system call supported only 16-bit group IDs. | |
c5662d5d | 102 | Subsequently, Linux 2.4 added |
0f0b04f8 MK |
103 | .BR setfsgid32 () |
104 | supporting 32-bit IDs. | |
105 | The glibc | |
106 | .BR setfsgid () | |
107 | wrapper function transparently deals with the variation across kernel versions. | |
a1d5f77c | 108 | .SH BUGS |
ff4739ce MK |
109 | No error indications of any kind are returned to the caller, |
110 | and the fact that both successful and unsuccessful calls return | |
111 | the same value makes it impossible to directly determine | |
112 | whether the call succeeded or failed. | |
113 | Instead, the caller must resort to looking at the return value | |
114 | from a further call such as | |
115 | .IR setfsgid(\-1) | |
116 | (which will always fail), in order to determine if a preceding call to | |
117 | .BR setfsgid () | |
118 | changed the filesystem group ID. | |
a1d5f77c MK |
119 | At the very |
120 | least, | |
121 | .B EPERM | |
122 | should be returned when the call fails (because the caller lacks the | |
123 | .B CAP_SETGID | |
124 | capability). | |
47297adb | 125 | .SH SEE ALSO |
fea681da MK |
126 | .BR kill (2), |
127 | .BR setfsuid (2), | |
53a1443c MK |
128 | .BR capabilities (7), |
129 | .BR credentials (7) |