147208Scael.\" Copyright (c) 1980, 1991 The Regents of the University of California. 238053Sbostic.\" All rights reserved. 320129Smckusick.\" 443568Strent.\" %sccs.include.redist.man% 520129Smckusick.\" 6*58271Smckusick.\" @(#)setreuid.2 6.6 (Berkeley) 02/26/93 738053Sbostic.\" 847208Scael.Dd 947208Scael.Dt SETREUID 2 1047208Scael.Os BSD 4 1147208Scael.Sh NAME 1247208Scael.Nm setreuid 1347208Scael.Nd set real and effective user ID's 1447208Scael.Sh SYNOPSIS 1547208Scael.Fd #include <unistd.h> 1647208Scael.Ft int 1747208Scael.Fn setreuid "int ruid" "int euid" 1847208Scael.Sh DESCRIPTION 19*58271SmckusickThe real and effective user IDs of the 20*58271Smckusickcurrent process are set according to the arguments. 2120130SmckusickIf 22*58271Smckusick.Fa ruid 23*58271Smckusickor 2447208Scael.Fa euid 2547208Scaelis -1, the current uid is filled in by the system. 26*58271SmckusickUnprivileged users may change the real user 27*58271SmckusickID to the effective user ID and vice-versa; only the super-user may 28*58271Smckusickmake other changes. 29*58271Smckusick.Pp 30*58271SmckusickThe 31*58271Smckusick.Fn setreuid function has been used to swap the real and effective user IDs 32*58271Smckusickin set-user-ID programs to temporarily relinquish the set-user-ID value. 33*58271SmckusickThis purpose is now better served by the use of the 34*58271Smckusick.Fn seteuid 35*58271Smckusickfunction (see 36*58271Smckusick.Xr setuid 2 ) . 37*58271Smckusick.Pp 38*58271SmckusickWhen setting the real and effective user IDs to the same value, 39*58271Smckusickthe standard 40*58271Smckusick.Fn setuid 41*58271Smckusickfunction is preferred. 4247208Scael.Sh RETURN VALUES 4320130SmckusickUpon successful completion, a value of 0 is returned. Otherwise, 4447208Scaela value of -1 is returned and 4547208Scael.Va errno 4647208Scaelis set to indicate the error. 4747208Scael.Sh ERRORS 4847208Scael.Bl -tag -width [EPERM] 4947208Scael.It Bq Er EPERM 5020130SmckusickThe current process is not the super-user and a change 5120130Smckusickother than changing the effective user-id to the real user-id 52*58271Smckusickwas specified. 5347208Scael.El 5447208Scael.Sh SEE ALSO 5547208Scael.Xr getuid 2 , 5654847Smckusick.Xr seteuid 2 , 5754847Smckusick.Xr setuid 2 5847208Scael.Sh HISTORY 5947208ScaelThe 6047208Scael.Nm 6147208Scaelfunction call appeared in 6254847Smckusick.Bx 4.2 6354847Smckusickand was dropped in 6454847Smckusick.Bx 4.4 . 65