]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/seteuid.2
Added/updated glibc feature test macro requirements
[thirdparty/man-pages.git] / man2 / seteuid.2
1 .\" Copyright (C) 2001 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" [should really be seteuid.3]
24 .\" Modified, 27 May 2004, Michael Kerrisk <mtk-manpages@gmx.net>
25 .\" Added notes on capability requirements
26 .\"
27 .TH SETEGID 2 2007-07-26 "Linux" "Linux Programmer's Manual"
28 .SH NAME
29 seteuid, setegid \- set effective user or group ID
30 .SH SYNOPSIS
31 .B #include <sys/types.h>
32 .br
33 .B #include <unistd.h>
34 .sp
35 .BI "int seteuid(uid_t " euid );
36 .br
37 .BI "int setegid(gid_t " egid );
38 .sp
39 .in -4n
40 Feature Test Macro Requirements for glibc (see
41 .BR feature_test_macros (7)):
42 .in
43 .sp
44 .ad l
45 .BR seteuid (),
46 .BR setegid ():
47 _BSD_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
48 .ad b
49 .SH DESCRIPTION
50 .BR seteuid ()
51 sets the effective user ID of the current process.
52 Unprivileged user processes may only set the effective user ID to the
53 real user ID, the effective user ID or the saved set-user-ID.
54
55 Precisely the same holds for
56 .BR setegid ()
57 with "group" instead of "user".
58 .\" When
59 .\" .I euid
60 .\" equals \-1, nothing is changed.
61 .SH "RETURN VALUE"
62 On success, zero is returned.
63 On error, \-1 is returned, and
64 .I errno
65 is set appropriately.
66 .SH ERRORS
67 .\" .TP
68 .\" .B EINVAL
69 .TP
70 .B EPERM
71 The current process is not privileged (Linux: does not have the
72 .B CAP_SETUID
73 capability in the case of
74 .BR seteuid (),
75 or the
76 .B CAP_SETGID
77 capability in the case of
78 .BR setegid ())
79 and
80 .I euid
81 (resp.
82 .IR egid )
83 is not the real user (group) ID, the effective user (group) ID,
84 or the saved set-user-ID (saved set-group-ID).
85 .SH "CONFORMING TO"
86 4.3BSD, POSIX.1-2001.
87 .SH NOTES
88 Setting the effective user (group) ID to the
89 saved set-user-ID (saved set-group-ID) is
90 possible since Linux 1.1.37 (1.1.38).
91 On an arbitrary system one should check _POSIX_SAVED_IDS.
92 .LP
93 Under libc4, libc5 and glibc 2.0
94 .BI seteuid( euid )
95 is equivalent to
96 .BI setreuid(\-1, " euid" )
97 and hence may change the saved set-user-ID.
98 Under glibc2.1 it is equivalent to
99 .BI setresuid(\-1, " euid" ", \-1)"
100 and hence does not change the saved set-user-ID.
101 Similar remarks hold for
102 .BR setegid ().
103 .SH "SEE ALSO"
104 .BR geteuid (2),
105 .BR setresuid (2),
106 .BR setreuid (2),
107 .BR setuid (2),
108 .BR capabilities (7),
109 .BR credentials (7)