]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/setresuid.2
seteuid.2: seteuid() and setegid() are implemented as library functions
[thirdparty/man-pages.git] / man2 / setresuid.2
CommitLineData
fea681da
MK
1.\" Copyright (C) 1997 Andries Brouwer (aeb@cwi.nl)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da 24.\"
c11b1abf 25.\" Modified, 2003-05-26, Michael Kerrisk, <mtk.manpages@gmail.com>
1e7eb3a7 26.TH SETRESUID 2 2010-11-22 "Linux" "Linux Programmer's Manual"
fea681da
MK
27.SH NAME
28setresuid, setresgid \- set real, effective and saved user or group ID
29.SH SYNOPSIS
b80f966b 30.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
fea681da
MK
31.br
32.B #include <unistd.h>
33.sp
34.BI "int setresuid(uid_t " ruid ", uid_t " euid ", uid_t " suid );
35.br
c13182ef 36.BI "int setresgid(gid_t " rgid ", gid_t " egid ", gid_t " sgid );
fea681da 37.SH DESCRIPTION
e511ffb6 38.BR setresuid ()
d9df8ff8 39sets the real user ID, the effective user ID, and the
a1ffe9f5 40saved set-user-ID of the calling process.
fea681da 41
d9df8ff8
MK
42Unprivileged user processes
43may change the real UID,
44effective UID, and saved set-user-ID, each to one of:
c13182ef 45the current real UID, the current effective UID or the
d9df8ff8 46current saved set-user-ID.
fea681da 47
0b9bdf82 48Privileged processes (on Linux, those having the \fBCAP_SETUID\fP capability)
c13182ef 49may set the real UID, effective UID, and
d9df8ff8 50saved set-user-ID to arbitrary values.
fea681da 51
c4bb193f 52If one of the arguments equals \-1, the corresponding value is not changed.
fea681da 53
bb40bc01 54Regardless of what changes are made to the real UID, effective UID,
9ee4a2b6 55and saved set-user-ID, the filesystem UID is always set to the same
bb40bc01
MK
56value as the (possibly new) effective UID.
57
fea681da 58Completely analogously,
e511ffb6 59.BR setresgid ()
c13182ef 60sets the real GID, effective GID, and saved set-group-ID
9ee4a2b6 61of the calling process (and always modifies the filesystem GID
bb40bc01 62to be the same as the effective GID),
60b9e97c 63with the same restrictions for unprivileged processes.
47297adb 64.SH RETURN VALUE
c13182ef
MK
65On success, zero is returned.
66On error, \-1 is returned, and
fea681da
MK
67.I errno
68is set appropriately.
69.SH ERRORS
70.TP
71.B EAGAIN
72.I uid
d9df8ff8 73does not match the current UID and this call would
2f0af33b 74bring that user ID over its
0daa9e92 75.B RLIMIT_NPROC
2f0af33b 76resource limit.
fea681da
MK
77.TP
78.B EPERM
0b9bdf82 79The calling process is not privileged (did not have the \fBCAP_SETUID\fP
d3c8b3e9 80capability) and tried to change the IDs to values that are not permitted.
a1d5f77c
MK
81.SH VERSIONS
82These calls are available under Linux since Linux 2.1.44.
47297adb 83.SH CONFORMING TO
c8f2dd47 84These calls are nonstandard;
97c1eac8 85they also appear on HP-UX and some of the BSDs.
fea681da 86.SH NOTES
1e7eb3a7 87Under HP-UX and FreeBSD, the prototype is found in
fea681da 88.IR <unistd.h> .
cc4615cc 89Under Linux the prototype is provided by glibc since version 2.3.2.
ea03a3ac
MK
90
91The original Linux
92.BR setresuid ()
93and
94.BR setresgid ()
95system calls supported only 16-bit user and group IDs.
c5662d5d 96Subsequently, Linux 2.4 added
ea03a3ac
MK
97.BR setresuid32 ()
98and
99.BR setresgid32 (),
100supporting 32-bit IDs.
101The glibc
102.BR setresuid ()
103and
104.BR setresgid ()
105wrapper functions transparently deal with the variations across kernel versions.
47297adb 106.SH SEE ALSO
fea681da
MK
107.BR getresuid (2),
108.BR getuid (2),
bb40bc01 109.BR setfsgid (2),
f0c34053 110.BR setfsuid (2),
fea681da
MK
111.BR setreuid (2),
112.BR setuid (2),
0a90178c 113.BR capabilities (7),
0a4f8b7b 114.BR credentials (7)