xref: /original-bsd/lib/libc/sys/setuid.2 (revision 13ec26c3)
1.\" Copyright (c) 1983, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)setuid.2	6.5 (Berkeley) 06/04/92
7.\"
8.Dd
9.Dt SETUID 3
10.Os BSD 4.2
11.Sh NAME
12.Nm setuid ,
13.Nm seteuid ,
14.Nm setruid ,
15.Nm setgid ,
16.Nm setegid ,
17.Nm setrgid
18.Nd set user and group ID
19.Sh SYNOPSIS
20.Fd #include <sys/types.h>
21.Fd #include <unistd.h>
22.Ft int
23.Fn setuid "uid_t uid"
24.Ft int
25.Fn seteuid "uid_t euid"
26.Ft int
27.Fn setruid "uid_t ruid"
28.Ft int
29.Fn setgid "gid_t gid"
30.Ft int
31.Fn setegid "gid_t egid"
32.Ft int
33.Fn setrgid "gid_t rgid"
34.Sh DESCRIPTION
35The
36.Fn setuid
37function
38.Pq Fn setgid
39sets both the real and effective
40user ID (group ID) of the current process
41as specified.
42.Pp
43The
44.Fn seteuid
45function
46.Pq Fn setegid
47sets the effective user ID (group ID) of the
48current process.
49.Pp
50The
51.Fn setruid
52function
53.Pq Fn setrgid
54sets the real user ID (group ID) of the
55current process.
56.Sh RETURN VALUES
57Upon success, these functions return 0;
58otherwise \-1 is returned.
59.Pp
60If the user is not the super user, or the uid
61specified is not the real or effective ID, these
62functions return \-1.
63.Sh SEE ALSO
64.Xr setreuid 2 ,
65.Xr setregid 2 ,
66.Xr getuid 2 ,
67.Xr getgid 2
68.Sh HISTORY
69A
70.Fn setuid
71and
72.Fn setgid
73syscall appeared in
74.At v6 .
75