1 .\" Copyright (C) 1995, Thomas K. Dyas <tdyas@eden.rutgers.edu>
2 .\" and Copyright (C) 2019, Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" Created 1995-08-06 Thomas K. Dyas <tdyas@eden.rutgers.edu>
27 .\" Modified 2000-07-01 aeb
28 .\" Modified 2002-07-23 aeb
29 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
30 .\" Added notes on capability requirements
32 .TH SETFSGID 2 2021-03-22 "Linux" "Linux Programmer's Manual"
34 setfsgid \- set group identity used for filesystem checks
37 .B #include <sys/fsuid.h>
39 .BI "int setfsgid(gid_t " fsgid );
42 On Linux, a process has both a filesystem group ID and an effective group ID.
43 The (Linux-specific) filesystem group ID is used
44 for permissions checking when accessing filesystem objects,
45 while the effective group ID is used for some other kinds
46 of permissions checks (see
49 Normally, the value of the process's filesystem group ID
50 is the same as the value of its effective group ID.
51 This is so, because whenever a process's effective group ID is changed,
52 the kernel also changes the filesystem group ID to be the same as
53 the new value of the effective group ID.
54 A process can cause the value of its filesystem group ID to diverge
55 from its effective group ID by using
57 to change its filesystem group ID to the value given in
61 will succeed only if the caller is the superuser or if
63 matches either the caller's real group ID, effective group ID,
64 saved set-group-ID, or current the filesystem user ID.
66 On both success and failure,
67 this call returns the previous filesystem group ID of the caller.
69 This system call is present in Linux since version 1.2.
70 .\" This system call is present since Linux 1.1.44
71 .\" and in libc since libc 4.7.6.
74 is Linux-specific and should not be used in programs intended
77 The filesystem group ID concept and the
79 system call were invented for historical reasons that are
80 no longer applicable on modern Linux kernels.
83 for a discussion of why the use of both
91 system call supported only 16-bit group IDs.
92 Subsequently, Linux 2.4 added
94 supporting 32-bit IDs.
97 wrapper function transparently deals with the variation across kernel versions.
98 .SS C library/kernel differences
99 In glibc 2.15 and earlier,
100 when the wrapper for this system call determines that the argument can't be
101 passed to the kernel without integer truncation (because the kernel
102 is old and does not support 32-bit group IDs),
103 it will return \-1 and set \fIerrno\fP to
108 No error indications of any kind are returned to the caller,
109 and the fact that both successful and unsuccessful calls return
110 the same value makes it impossible to directly determine
111 whether the call succeeded or failed.
112 Instead, the caller must resort to looking at the return value
113 from a further call such as
115 (which will always fail), in order to determine if a preceding call to
117 changed the filesystem group ID.
121 should be returned when the call fails (because the caller lacks the
127 .BR capabilities (7),