1*66822Sbostic.\" Copyright (c) 1980, 1991, 1993, 1994 260986Sbostic.\" The Regents of the University of California. All rights reserved. 320129Smckusick.\" 443568Strent.\" %sccs.include.redist.man% 520129Smckusick.\" 6*66822Sbostic.\" @(#)setreuid.2 8.2 (Berkeley) 04/16/94 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 17*66822Sbostic.Fn setreuid "uid_t ruid" "uid_t euid" 1847208Scael.Sh DESCRIPTION 1958271SmckusickThe real and effective user IDs of the 2058271Smckusickcurrent process are set according to the arguments. 2120130SmckusickIf 2258271Smckusick.Fa ruid 2358271Smckusickor 2447208Scael.Fa euid 2547208Scaelis -1, the current uid is filled in by the system. 2658271SmckusickUnprivileged users may change the real user 2758271SmckusickID to the effective user ID and vice-versa; only the super-user may 2858271Smckusickmake other changes. 2958271Smckusick.Pp 3058271SmckusickThe 3158446Sbostic.Fn setreuid 3258446Sbosticfunction has been used to swap the real and effective user IDs 3358271Smckusickin set-user-ID programs to temporarily relinquish the set-user-ID value. 3458271SmckusickThis purpose is now better served by the use of the 3558271Smckusick.Fn seteuid 3658271Smckusickfunction (see 3758271Smckusick.Xr setuid 2 ) . 3858271Smckusick.Pp 3958271SmckusickWhen setting the real and effective user IDs to the same value, 4058271Smckusickthe standard 4158271Smckusick.Fn setuid 4258271Smckusickfunction is preferred. 4347208Scael.Sh RETURN VALUES 4420130SmckusickUpon successful completion, a value of 0 is returned. Otherwise, 4547208Scaela value of -1 is returned and 4647208Scael.Va errno 4747208Scaelis set to indicate the error. 4847208Scael.Sh ERRORS 4947208Scael.Bl -tag -width [EPERM] 5047208Scael.It Bq Er EPERM 5120130SmckusickThe current process is not the super-user and a change 5220130Smckusickother than changing the effective user-id to the real user-id 5358271Smckusickwas specified. 5447208Scael.El 5547208Scael.Sh SEE ALSO 5647208Scael.Xr getuid 2 , 5754847Smckusick.Xr seteuid 2 , 5854847Smckusick.Xr setuid 2 5947208Scael.Sh HISTORY 6047208ScaelThe 6147208Scael.Nm 6247208Scaelfunction call appeared in 6354847Smckusick.Bx 4.2 6454847Smckusickand was dropped in 6554847Smckusick.Bx 4.4 . 66