]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/setfsgid.2
execve.2, setfsgid.2, setfsuid.2, splice.2, fopen.3, malloc_trim.3, posix_memalign...
[thirdparty/man-pages.git] / man2 / setfsgid.2
CommitLineData
fea681da 1.\" Copyright (C) 1995, Thomas K. Dyas <tdyas@eden.rutgers.edu>
d478d0de 2.\" and Copyright (C) 2019, Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
c13182ef 13.\"
fea681da
MK
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
c13182ef 21.\"
fea681da
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
fea681da
MK
25.\"
26.\" Created 1995-08-06 Thomas K. Dyas <tdyas@eden.rutgers.edu>
27.\" Modified 2000-07-01 aeb
28.\" Modified 2002-07-23 aeb
c11b1abf 29.\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
fea681da
MK
30.\" Added notes on capability requirements
31.\"
2e3023c4 32.TH SETFSGID 2 2019-05-09 "Linux" "Linux Programmer's Manual"
fea681da 33.SH NAME
9ee4a2b6 34setfsgid \- set group identity used for filesystem checks
fea681da 35.SH SYNOPSIS
0070a62d 36.B #include <sys/fsuid.h>
68e4db0a 37.PP
fea681da
MK
38.BI "int setfsgid(uid_t " fsgid );
39.SH DESCRIPTION
d478d0de
MK
40On Linux, a process has both a filesystem group ID and an effective group ID.
41The (Linux-specific) filesystem group ID is used
42for permissions checking when accessing filesystem objects,
43while the effective group ID is used for some other kinds
44of permissions checks (see
45.BR credentials (7)).
efeece04 46.PP
d478d0de
MK
47Normally, the value of the process's filesystem group ID
48is the same as the value of its effective group ID.
49This is so, because whenever a process's effective group ID is changed,
50the kernel also changes the filesystem group ID to be the same as
51the new value of the effective group ID.
52A process can cause the value of its filesystem group ID to diverge
53from its effective group ID by using
e511ffb6 54.BR setfsgid ()
d478d0de
MK
55to change its filesystem group ID to the value given in
56.IR fsgid .
efeece04 57.PP
e511ffb6 58.BR setfsgid ()
33a0ccb2 59will succeed only if the caller is the superuser or if
fea681da 60.I fsgid
4069bc44
MK
61matches either the caller's real group ID, effective group ID,
62saved set-group-ID, or current the filesystem user ID.
47297adb 63.SH RETURN VALUE
ff4739ce
MK
64On both success and failure,
65this call returns the previous filesystem group ID of the caller.
a3680fde
MK
66.SH VERSIONS
67This system call is present in Linux since version 1.2.
68.\" This system call is present since Linux 1.1.44
69.\" and in libc since libc 4.7.6.
47297adb 70.SH CONFORMING TO
e511ffb6 71.BR setfsgid ()
8382f16d 72is Linux-specific and should not be used in programs intended
97c1eac8 73to be portable.
fea681da 74.SH NOTES
d478d0de
MK
75The filesystem group ID concept and the
76.BR setfsgid ()
77system call were invented for historical reasons that are
78no longer applicable on modern Linux kernels.
6ace3248
MK
79See
80.BR setfsuid (2)
81for a discussion of why the use of both
82.BR setfsuid (2)
83and
84.BR setfsgid ()
85is nowadays unneeded.
efeece04 86.PP
0f0b04f8
MK
87The original Linux
88.BR setfsgid ()
89system call supported only 16-bit group IDs.
c5662d5d 90Subsequently, Linux 2.4 added
0f0b04f8
MK
91.BR setfsgid32 ()
92supporting 32-bit IDs.
93The glibc
94.BR setfsgid ()
95wrapper function transparently deals with the variation across kernel versions.
dc439d82 96.SS C library/kernel differences
659cc17f
MK
97In glibc 2.15 and earlier,
98when the wrapper for this system call determines that the argument can't be
dc439d82
MK
99passed to the kernel without integer truncation (because the kernel
100is old and does not support 32-bit group IDs),
3cc069d5 101it will return \-1 and set \fIerrno\fP to
dc439d82
MK
102.B EINVAL
103without attempting
104the system call.
a1d5f77c 105.SH BUGS
ff4739ce
MK
106No error indications of any kind are returned to the caller,
107and the fact that both successful and unsuccessful calls return
108the same value makes it impossible to directly determine
109whether the call succeeded or failed.
110Instead, the caller must resort to looking at the return value
111from a further call such as
112.IR setfsgid(\-1)
113(which will always fail), in order to determine if a preceding call to
114.BR setfsgid ()
115changed the filesystem group ID.
a1d5f77c
MK
116At the very
117least,
118.B EPERM
119should be returned when the call fails (because the caller lacks the
120.B CAP_SETGID
121capability).
47297adb 122.SH SEE ALSO
fea681da
MK
123.BR kill (2),
124.BR setfsuid (2),
53a1443c
MK
125.BR capabilities (7),
126.BR credentials (7)