]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/setreuid.2
ffix
[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.\"
43.TH SETREUID 2 2004-07-04 "Linux 2.6" "Linux Programmer's Manual"
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 );
54.SH DESCRIPTION
e511ffb6 55.BR setreuid ()
fea681da
MK
56sets real and effective user IDs of the current process.
57
58Supplying a value of \-1 for either the real or effective user ID forces
59the system to leave that ID unchanged.
60
61Unprivileged processes may only set the effective user ID to the real user ID,
d9df8ff8 62the effective user ID or the saved set-user-ID.
fea681da
MK
63
64POSIX: It is unspecified whether unprivileged processes may set the
d9df8ff8
MK
65real user ID to the real user ID, the effective user ID or the
66saved set-user-ID.
fea681da
MK
67
68Linux: Unprivileged users may only set the real user ID to
69the real user ID or the effective user ID.
70
71Linux: If the real user ID is set or the effective user ID is set to a value
d9df8ff8
MK
72not equal to the previous real user ID,
73the saved set-user-ID will be set to the new effective user ID.
fea681da
MK
74
75Completely analogously,
e511ffb6 76.BR setregid ()
fea681da
MK
77sets real and effective group ID's of the current process,
78and all of the above holds with "group" instead of "user".
fea681da
MK
79.SH "RETURN VALUE"
80On success, zero is returned. On error, \-1 is returned, and
81.I errno
82is set appropriately.
83.SH ERRORS
84.TP
85.B EPERM
86The current process is not privileged
87(Linux: does not have the
88.B CAP_SETUID
89capability in the case of
90.BR setreuid (),
91or the
92.B CAP_SETGID
93capability in the case of
94.BR setregid ())
95and a change other than (i)
96swapping the effective user (group) ID with the real user (group) ID,
97or (ii) setting one to the value of the other or (iii) setting the
d9df8ff8
MK
98effective user (group) ID to the value of the
99saved set-user-ID (saved set-group-ID) was specified.
fea681da 100.SH NOTES
d9df8ff8
MK
101Setting the effective user (group) ID to the
102saved set-user-ID (saved set-group-ID) is
fea681da
MK
103possible since Linux 1.1.37 (1.1.38).
104.SH "CONFORMING TO"
97c1eac8 105POSIX.1-2001, 4.3BSD (the
e511ffb6 106.BR setreuid ()
fea681da 107and
e511ffb6 108.BR setregid ()
fea681da
MK
109function calls first appeared in 4.2BSD).
110.SH "SEE ALSO"
111.BR getgid (2),
112.BR getuid (2),
113.BR seteuid (2),
114.BR setgid (2),
115.BR setresuid (2),
116.BR setuid (2),
117.BR capabilities (7)