xref: /original-bsd/lib/libc/compat-43/setreuid.2 (revision 7e5c8007)
1.\" Copyright (c) 1980, 1991, 1993, 1994
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)setreuid.2	8.2 (Berkeley) 04/16/94
7.\"
8.Dd
9.Dt SETREUID 2
10.Os BSD 4
11.Sh NAME
12.Nm setreuid
13.Nd set real and effective user ID's
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft int
17.Fn setreuid "uid_t ruid" "uid_t euid"
18.Sh DESCRIPTION
19The real and effective user IDs of the
20current process are set according to the arguments.
21If
22.Fa ruid
23or
24.Fa euid
25is -1, the current uid is filled in by the system.
26Unprivileged users may change the real user
27ID to the effective user ID and vice-versa; only the super-user may
28make other changes.
29.Pp
30The
31.Fn setreuid
32function has been used to swap the real and effective user IDs
33in set-user-ID programs to temporarily relinquish the set-user-ID value.
34This purpose is now better served by the use of the
35.Fn seteuid
36function (see
37.Xr setuid 2 ) .
38.Pp
39When setting the real and effective user IDs to the same value,
40the standard
41.Fn setuid
42function is preferred.
43.Sh RETURN VALUES
44Upon successful completion, a value of 0 is returned.  Otherwise,
45a value of -1 is returned and
46.Va errno
47is set to indicate the error.
48.Sh ERRORS
49.Bl -tag -width [EPERM]
50.It Bq Er EPERM
51The current process is not the super-user and a change
52other than changing the effective user-id to the real user-id
53was specified.
54.El
55.Sh SEE ALSO
56.Xr getuid 2 ,
57.Xr seteuid 2 ,
58.Xr setuid 2
59.Sh HISTORY
60The
61.Nm
62function call appeared in
63.Bx 4.2
64and was dropped in
65.Bx 4.4 .
66