]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/setreuid.2
s/current process/calling process/
[thirdparty/man-pages.git] / man2 / setreuid.2
CommitLineData
fea681da
MK
1.\" Copyright (c) 1983, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)setregid.2 6.4 (Berkeley) 3/10/91
33.\"
34.\" Modified Sat Jul 24 09:08:49 1993 by Rik Faith <faith@cs.unc.edu>
35.\" Portions extracted from linux/kernel/sys.c:
36.\" Copyright (C) 1991, 1992 Linus Torvalds
37.\" May be distributed under the GNU General Public License
38.\" Changes: 1994-07-29 by Wilf <G.Wilford@ee.surrey.ac.uk>
39.\" 1994-08-02 by Wilf due to change in kernel.
40.\" 2004-07-04 by aeb
41.\" 2004-05-27 by Michael Kerrisk
42.\"
cc4615cc 43.TH SETREUID 2 2007-07-26 "Linux" "Linux Programmer's Manual"
fea681da
MK
44.SH NAME
45setreuid, setregid \- set real and/or effective user or group ID
46.SH SYNOPSIS
47.B #include <sys/types.h>
48.br
49.B #include <unistd.h>
50.sp
51.BI "int setreuid(uid_t " ruid ", uid_t " euid );
52.br
53.BI "int setregid(gid_t " rgid ", gid_t " egid );
cc4615cc
MK
54.sp
55.in -4n
56Feature Test Macro Requirements for glibc (see
57.BR feature_test_macros (7)):
58.in
59.sp
60.BR setreuid (),
61.BR setregid ():
62_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
fea681da 63.SH DESCRIPTION
e511ffb6 64.BR setreuid ()
a1ffe9f5 65sets real and effective user IDs of the calling process.
fea681da
MK
66
67Supplying a value of \-1 for either the real or effective user ID forces
68the system to leave that ID unchanged.
69
70Unprivileged processes may only set the effective user ID to the real user ID,
d9df8ff8 71the effective user ID or the saved set-user-ID.
fea681da
MK
72
73POSIX: It is unspecified whether unprivileged processes may set the
d9df8ff8
MK
74real user ID to the real user ID, the effective user ID or the
75saved set-user-ID.
fea681da
MK
76
77Linux: Unprivileged users may only set the real user ID to
78the real user ID or the effective user ID.
79
c13182ef 80Linux: If the real user ID is set or the effective user ID is set to a value
d9df8ff8
MK
81not equal to the previous real user ID,
82the saved set-user-ID will be set to the new effective user ID.
fea681da
MK
83
84Completely analogously,
e511ffb6 85.BR setregid ()
a1ffe9f5 86sets real and effective group ID's of the calling process,
fea681da 87and all of the above holds with "group" instead of "user".
fea681da 88.SH "RETURN VALUE"
c13182ef
MK
89On success, zero is returned.
90On error, \-1 is returned, and
fea681da
MK
91.I errno
92is set appropriately.
93.SH ERRORS
94.TP
95.B EPERM
a1ffe9f5 96The calling process is not privileged
fea681da
MK
97(Linux: does not have the
98.B CAP_SETUID
99capability in the case of
c13182ef
MK
100.BR setreuid (),
101or the
fea681da
MK
102.B CAP_SETGID
103capability in the case of
104.BR setregid ())
105and a change other than (i)
106swapping the effective user (group) ID with the real user (group) ID,
107or (ii) setting one to the value of the other or (iii) setting the
d9df8ff8
MK
108effective user (group) ID to the value of the
109saved set-user-ID (saved set-group-ID) was specified.
fea681da 110.SH "CONFORMING TO"
97c1eac8 111POSIX.1-2001, 4.3BSD (the
e511ffb6 112.BR setreuid ()
fea681da 113and
e511ffb6 114.BR setregid ()
fea681da 115function calls first appeared in 4.2BSD).
a1d5f77c
MK
116.SH NOTES
117Setting the effective user (group) ID to the
118saved set-user-ID (saved set-group-ID) is
119possible since Linux 1.1.37 (1.1.38).
fea681da
MK
120.SH "SEE ALSO"
121.BR getgid (2),
122.BR getuid (2),
123.BR seteuid (2),
124.BR setgid (2),
125.BR setresuid (2),
126.BR setuid (2),
127.BR capabilities (7)