]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/setfsgid.2
select.2: Rewrote text describing feature test macro requirements for pselect()
[thirdparty/man-pages.git] / man2 / setfsgid.2
CommitLineData
fea681da
MK
1.\" Copyright (C) 1995, Thomas K. Dyas <tdyas@eden.rutgers.edu>
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.\" Created 1995-08-06 Thomas K. Dyas <tdyas@eden.rutgers.edu>
24.\" Modified 2000-07-01 aeb
25.\" Modified 2002-07-23 aeb
c11b1abf 26.\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
fea681da
MK
27.\" Added notes on capability requirements
28.\"
d9343c5c 29.TH SETFSGID 2 2004-05-27 "Linux" "Linux Programmer's Manual"
fea681da
MK
30.SH NAME
31setfsgid \- set group identity used for file system checks
32.SH SYNOPSIS
33.B #include <unistd.h>
34/* glibc uses <sys/fsuid.h> */
35.sp
36.BI "int setfsgid(uid_t " fsgid );
37.SH DESCRIPTION
38The system call
e511ffb6 39.BR setfsgid ()
fea681da 40sets the group ID that the Linux kernel uses to check for all accesses
c13182ef
MK
41to the file system.
42Normally, the value of
fea681da 43.I fsgid
c13182ef
MK
44will shadow the value of the effective group ID.
45In fact, whenever the
fea681da
MK
46effective group ID is changed,
47.I fsgid
48will also be changed to the new value of the effective group ID.
49
50Explicit calls to
0bfa087b 51.BR setfsuid (2)
fea681da 52and
e511ffb6 53.BR setfsgid ()
fea681da
MK
54are usually only used by programs such as the Linux NFS server that
55need to change what user and group ID is used for file access without a
56corresponding change in the real and effective user and group IDs.
57A change in the normal user IDs for a program such as the NFS server
6387216b
MK
58is a security hole that can expose it to unwanted signals.
59(But see below.)
fea681da 60
e511ffb6 61.BR setfsgid ()
fea681da
MK
62will only succeed if the caller is the superuser or if
63.I fsgid
64matches either the real group ID, effective group ID,
65saved set-group-ID, or the current value of
66.IR fsgid .
67.SH "RETURN VALUE"
68On success, the previous value of
69.I fsgid
c13182ef
MK
70is returned.
71On error, the current value of
fea681da
MK
72.I fsgid
73is returned.
74.SH "CONFORMING TO"
e511ffb6 75.BR setfsgid ()
8382f16d 76is Linux-specific and should not be used in programs intended
97c1eac8 77to be portable.
fea681da 78It is present since Linux 1.1.44 and in libc since libc 4.7.6.
fea681da
MK
79.SH NOTES
80When glibc determines that the argument is not a valid group ID,
1274071a
MK
81it will return \-1 and set \fIerrno\fP to
82.B EINVAL
83without attempting
fea681da
MK
84the system call.
85.LP
86Note that at the time this system call was introduced, a process
87could send a signal to a process with the same effective user ID.
88Today signal permission handling is slightly different.
a1d5f77c
MK
89.SH BUGS
90No error messages of any kind are returned to the caller.
91At the very
92least,
93.B EPERM
94should be returned when the call fails (because the caller lacks the
95.B CAP_SETGID
96capability).
fea681da
MK
97.SH "SEE ALSO"
98.BR kill (2),
99.BR setfsuid (2),
53a1443c
MK
100.BR capabilities (7),
101.BR credentials (7)