OSDN Git Service

(split) LDP: Update original to LDP v3.65
[linuxjm/LDP_man-pages.git] / original / man2 / setresuid.2
1 .\" Copyright (C) 1997 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified, 2003-05-26, Michael Kerrisk, <mtk.manpages@gmail.com>
26 .TH SETRESUID 2 2010-11-22 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 setresuid, setresgid \- set real, effective and saved user or group ID
29 .SH SYNOPSIS
30 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
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
38 .BR setresuid ()
39 sets the real user ID, the effective user ID, and the
40 saved set-user-ID of the calling process.
41
42 Unprivileged user processes
43 may change the real UID,
44 effective UID, and saved set-user-ID, each to one of:
45 the current real UID, the current effective UID or the
46 current saved set-user-ID.
47
48 Privileged processes (on Linux, those having the \fBCAP_SETUID\fP capability)
49 may set the real UID, effective UID, and
50 saved set-user-ID to arbitrary values.
51
52 If one of the arguments equals \-1, the corresponding value is not changed.
53
54 Regardless of what changes are made to the real UID, effective UID,
55 and saved set-user-ID, the filesystem UID is always set to the same
56 value as the (possibly new) effective UID.
57
58 Completely analogously,
59 .BR setresgid ()
60 sets the real GID, effective GID, and saved set-group-ID
61 of the calling process (and always modifies the filesystem GID
62 to be the same as the effective GID),
63 with the same restrictions for unprivileged processes.
64 .SH RETURN VALUE
65 On success, zero is returned.
66 On error, \-1 is returned, and
67 .I errno
68 is set appropriately.
69 .SH ERRORS
70 .TP
71 .B EAGAIN
72 .I uid
73 does not match the current UID and this call would
74 bring that user ID over its
75 .B RLIMIT_NPROC
76 resource limit.
77 .TP
78 .B EPERM
79 The calling process is not privileged (did not have the \fBCAP_SETUID\fP
80 capability) and tried to change the IDs to values that are not permitted.
81 .SH VERSIONS
82 These calls are available under Linux since Linux 2.1.44.
83 .SH CONFORMING TO
84 These calls are nonstandard;
85 they also appear on HP-UX and some of the BSDs.
86 .SH NOTES
87 Under HP-UX and FreeBSD, the prototype is found in
88 .IR <unistd.h> .
89 Under Linux the prototype is provided by glibc since version 2.3.2.
90
91 The original Linux
92 .BR setresuid ()
93 and
94 .BR setresgid ()
95 system calls supported only 16-bit user and group IDs.
96 Subsequently, Linux 2.4 added
97 .BR setresuid32 ()
98 and
99 .BR setresgid32 (),
100 supporting 32-bit IDs.
101 The glibc
102 .BR setresuid ()
103 and
104 .BR setresgid ()
105 wrapper functions transparently deal with the variations across kernel versions.
106 .SH SEE ALSO
107 .BR getresuid (2),
108 .BR getuid (2),
109 .BR setfsgid (2),
110 .BR setfsuid (2),
111 .BR setreuid (2),
112 .BR setuid (2),
113 .BR capabilities (7),
114 .BR credentials (7)
115 .SH COLOPHON
116 This page is part of release 3.65 of the Linux
117 .I man-pages
118 project.
119 A description of the project,
120 and information about reporting bugs,
121 can be found at
122 \%http://www.kernel.org/doc/man\-pages/.