1 .\" Copyright (C) 2001 Andries Brouwer (aeb@cwi.nl)
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.
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.
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
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" [should really be seteuid.3]
26 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
27 .\" Added notes on capability requirements
29 .TH SETEUID 2 2016-10-08 "Linux" "Linux Programmer's Manual"
31 seteuid, setegid \- set effective user or group ID
33 .B #include <sys/types.h>
35 .B #include <unistd.h>
37 .BI "int seteuid(uid_t " euid );
39 .BI "int setegid(gid_t " egid );
42 Feature Test Macro Requirements for glibc (see
43 .BR feature_test_macros (7)):
50 _POSIX_C_SOURCE\ >=\ 200112L
51 || /* Glibc versions <= 2.19: */ _BSD_SOURCE
56 sets the effective user ID of the calling process.
57 Unprivileged processes may only set the effective user ID to the
58 real user ID, the effective user ID or the saved set-user-ID.
60 Precisely the same holds for
62 with "group" instead of "user".
65 .\" equals \-1, nothing is changed.
66 .\" (This is an artifact of the implementation in glibc of seteuid()
67 .\" using setresuid(2).)
69 On success, zero is returned.
70 On error, \-1 is returned, and
77 can fail even when the caller is UID 0;
78 it is a grave security error to omit checking for a failure return from
83 The target user or group ID is not valid in this user namespace.
88 the calling process is not privileged (does not have the
90 capability in its user namespace) and
92 does not match the current real user ID, current effective user ID,
93 or current saved set-user-ID.
97 the calling process is not privileged (does not have the
99 capability in its user namespace) and
101 does not match the current real group ID, current effective group ID,
102 or current saved set-group-ID.
104 POSIX.1-2001, POSIX.1-2008, 4.3BSD.
106 Setting the effective user (group) ID to the
107 saved set-user-ID (saved set-group-ID) is
108 possible since Linux 1.1.37 (1.1.38).
109 On an arbitrary system one should check
110 .BR _POSIX_SAVED_IDS .
115 .BI setreuid(\-1, " euid" )
116 and hence may change the saved set-user-ID.
117 Under glibc 2.1 and later it is equivalent to
118 .BI setresuid(\-1, " euid" ", \-1)"
119 and hence does not change the saved set-user-ID.
120 Analogous remarks hold for
122 with the difference that the change in implementation from
123 .BI setregid(\-1, " egid" )
125 .BI setresgid(\-1, " egid" ", \-1)"
126 occurred in glibc 2.2 or 2.3 (depending on the hardware architecture).
128 According to POSIX.1,
134 to be the same value as the current effective user (group) ID,
135 and some implementations do not permit this.
136 .SS C library/kernel differences
141 are implemented as library functions that call, respectively,
150 .BR capabilities (7),
152 .BR user_namespaces (7)