]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/seteuid.2
ffix
[thirdparty/man-pages.git] / man2 / seteuid.2
CommitLineData
fea681da
MK
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]
305a0578 24.\" Modified, 27 May 2004, Michael Kerrisk <mtk-manpages@gmx.net>
fea681da
MK
25.\" Added notes on capability requirements
26.\"
27.TH SETEGID 2 2004-05-27 "Linux 2.6.6" "Linux Programmer's Manual"
28.SH NAME
29seteuid, 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.SH DESCRIPTION
e511ffb6 39.BR seteuid ()
fea681da
MK
40sets the effective user ID of the current process.
41Unprivileged user processes may only set the effective user ID to the
d9df8ff8 42real user ID, the effective user ID or the saved set-user-ID.
fea681da
MK
43
44Precisely the same holds for
e511ffb6 45.BR setegid ()
fea681da 46with "group" instead of "user".
fea681da
MK
47.\" When
48.\" .I euid
49.\" equals \-1, nothing is changed.
50.SH "RETURN VALUE"
51On success, zero is returned. On error, \-1 is returned, and
52.I errno
53is set appropriately.
54.SH ERRORS
55.\" .TP
56.\" .B EINVAL
57.TP
58.B EPERM
59The current process is not privileged (Linux: does not have the
60.B CAP_SETUID
61capability in the case of
62.BR seteuid (),
63or the
64.B CAP_SETGID
65capability in the case of
66.BR setegid ())
67and
68.I euid
69(resp.
70.IR egid )
d9df8ff8
MK
71is not the real user (group) ID, the effective user (group) ID,
72or the saved set-user-ID (saved set-group-ID).
fea681da 73.SH NOTES
d9df8ff8
MK
74Setting the effective user (group) ID to the
75saved set-user-ID (saved set-group-ID) is
fea681da
MK
76possible since Linux 1.1.37 (1.1.38).
77On an arbitrary system one should check _POSIX_SAVED_IDS.
78.LP
79Under libc4, libc5 and glibc2.0
80.BI seteuid( euid )
81is equivalent to
2bc2f479 82.BI setreuid(\-1, " euid" )
d9df8ff8 83and hence may change the saved set-user-ID.
fea681da 84Under glibc2.1 it is equivalent to
2bc2f479 85.BI setresuid(\-1, " euid" ,\-1)
d9df8ff8 86and hence does not change the saved set-user-ID.
fea681da 87Similar remarks hold for
e511ffb6 88.BR setegid ().
fea681da 89.SH "CONFORMING TO"
97c1eac8 904.3BSD, POSIX.1-2001.
fea681da
MK
91.SH "SEE ALSO"
92.BR geteuid (2),
93.BR setresuid (2),
94.BR setreuid (2),
95.BR setuid (2),
96.BR capabilities (7)