1SETFSGID(2)                Linux Programmer's Manual               SETFSGID(2)
2
3
4

NAME

6       setfsgid - set group identity used for filesystem checks
7

SYNOPSIS

9       #include <sys/fsuid.h>
10
11       int setfsgid(uid_t fsgid);
12

DESCRIPTION

14       The system call setfsgid() changes the value of the caller's filesystem
15       group ID—the group ID that the Linux  kernel  uses  to  check  for  all
16       accesses  to  the  filesystem.   Normally,  the value of the filesystem
17       group ID will shadow the value of the effective  group  ID.   In  fact,
18       whenever  the  effective  group  ID is changed, the filesystem group ID
19       will also be changed to the new value of the effective group ID.
20
21       Explicit calls to setfsuid(2) and setfsgid() are usually used  only  by
22       programs such as the Linux NFS server that need to change what user and
23       group ID is used for file access without a corresponding change in  the
24       real and effective user and group IDs.  A change in the normal user IDs
25       for a program such as the NFS server is a security hole that can expose
26       it to unwanted signals.  (But see below.)
27
28       setfsgid() will succeed only if the caller is the superuser or if fsgid
29       matches either the caller's real group ID, effective  group  ID,  saved
30       set-group-ID, or current the filesystem user ID.
31

RETURN VALUE

33       On  both success and failure, this call returns the previous filesystem
34       group ID of the caller.
35

VERSIONS

37       This system call is present in Linux since version 1.2.
38

CONFORMING TO

40       setfsgid() is  Linux-specific  and  should  not  be  used  in  programs
41       intended to be portable.
42

NOTES

44       Note  that at the time this system call was introduced, a process could
45       send a signal to a process with the same effective user ID.  Today sig‐
46       nal  permission  handling is slightly different.  See setfsuid(2) for a
47       discussion of why the use of both setfsuid(2) and setfsgid()  is  nowa‐
48       days unneeded.
49
50       The  original  Linux setfsgid() system call supported only 16-bit group
51       IDs.  Subsequently, Linux 2.4 added setfsgid32() supporting 32-bit IDs.
52       The  glibc  setfsgid()  wrapper  function  transparently deals with the
53       variation across kernel versions.
54
55   C library/kernel differences
56       In glibc 2.15 and earlier, when the wrapper for this system call deter‐
57       mines  that  the argument can't be passed to the kernel without integer
58       truncation (because the kernel is old and does not support 32-bit group
59       IDs),  they  will  return -1 and set errno to EINVAL without attempting
60       the system call.
61

BUGS

63       No error indications of any kind are returned to the  caller,  and  the
64       fact  that both successful and unsuccessful calls return the same value
65       makes it impossible to directly determine whether the call succeeded or
66       failed.  Instead, the caller must resort to looking at the return value
67       from a further call such as setfsgid(-1) (which will always  fail),  in
68       order  to  determine  if  a  preceding  call  to setfsgid() changed the
69       filesystem group ID.  At the very least, EPERM should be returned  when
70       the call fails (because the caller lacks the CAP_SETGID capability).
71

SEE ALSO

73       kill(2), setfsuid(2), capabilities(7), credentials(7)
74

COLOPHON

76       This  page  is  part of release 4.15 of the Linux man-pages project.  A
77       description of the project, information about reporting bugs,  and  the
78       latest     version     of     this    page,    can    be    found    at
79       https://www.kernel.org/doc/man-pages/.
80
81
82
83Linux                             2017-09-15                       SETFSGID(2)
Impressum