]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/setresuid.2
Document _FORTIFY_SOURCE, _REENTRANT, and _THREAD_SAFE.
[thirdparty/man-pages.git] / man2 / setresuid.2
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" Copyright (C) 1997 Andries Brouwer (aeb@cwi.nl)
4.\"
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
13.\"
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
21.\"
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
24.\"
305a0578 25.\" Modified, 2003-05-26, Michael Kerrisk, <mtk-manpages@gmx.net>
fea681da
MK
26.TH SETRESUID 2 2003-05-26 "Linux 2.4" "Linux Programmer's Manual"
27.SH NAME
28setresuid, setresgid \- set real, effective and saved user or group ID
29.SH SYNOPSIS
30.B #define _GNU_SOURCE
31.br
32.B #include <unistd.h>
33.sp
34.BI "int setresuid(uid_t " ruid ", uid_t " euid ", uid_t " suid );
35.br
36.BI "int setresgid(gid_t " rgid ", gid_t " egid ", gid_t " sgid );
37.SH DESCRIPTION
e511ffb6 38.BR setresuid ()
d9df8ff8
MK
39sets the real user ID, the effective user ID, and the
40saved set-user-ID of the current process.
fea681da 41
d9df8ff8
MK
42Unprivileged user processes
43may change the real UID,
44effective UID, and saved set-user-ID, each to one of:
45the current real UID, the current effective UID or the
46current saved set-user-ID.
fea681da 47
d9df8ff8
MK
48Privileged processes (on Linux, those having the CAP_SETUID capability)
49may set the real UID, effective UID, and
50saved set-user-ID to arbitrary values.
fea681da
MK
51
52If one of the parameters equals \-1, the corresponding value is not changed.
53
bb40bc01
MK
54Regardless of what changes are made to the real UID, effective UID,
55and saved set-user-ID, the file system UID is always set to the same
56value as the (possibly new) effective UID.
57
fea681da 58Completely analogously,
e511ffb6 59.BR setresgid ()
d9df8ff8 60sets the real GID, effective GID, and saved set-group-ID
bb40bc01
MK
61of the current process (and always modifies the file system GID
62to be the same as the effective GID),
d9df8ff8 63with the same restrictions for non-privileged processes.
fea681da
MK
64
65.SH "RETURN VALUE"
66On success, zero is returned. On error, \-1 is returned, and
67.I errno
68is set appropriately.
69.SH ERRORS
70.TP
71.B EAGAIN
72.I uid
d9df8ff8
MK
73does not match the current UID and this call would
74bring that user ID over its NPROC rlimit.
fea681da
MK
75.TP
76.B EPERM
d3c8b3e9
MK
77The calling process is not privileged (did not have the CAP_SETUID
78capability) and tried to change the IDs to values that are not permitted.
fea681da 79.SH "CONFORMING TO"
97c1eac8
MK
80These calls are non-standard;
81they also appear on HP-UX and some of the BSDs.
fea681da
MK
82.SH HISTORY
83This system call was first introduced in HP-UX.
84It is available under Linux since Linux 2.1.44.
85These days it is also found in FreeBSD (for emulation of Linux binaries).
86.SH NOTES
87Under HP-UX and FreeBSD the prototype is found in
88.IR <unistd.h> .
89Under Linux the prototype is given by glibc since version 2.3.2
90provided _GNU_SOURCE is defined.
91.SH "SEE ALSO"
92.BR getresuid (2),
93.BR getuid (2),
bb40bc01
MK
94.BR setfsuid (2),
95.BR setfsgid (2),
fea681da
MK
96.BR setreuid (2),
97.BR setuid (2),
98.BR capabilities (7)