xref: /original-bsd/lib/libc/sys/setuid.2 (revision c1946e27)
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.4 (Berkeley) 04/19/91
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.Ft int
22.Fn setuid "uid_t uid"
23.Ft int
24.Fn seteuid "uid_t euid"
25.Ft int
26.Fn setruid "uid_t ruid"
27.Ft int
28.Fn setgid "gid_t gid"
29.Ft int
30.Fn setegid "gid_t egid"
31.Ft int
32.Fn setrgid "gid_t rgid"
33.Sh DESCRIPTION
34The
35.Fn setuid
36function
37.Pq Fn setgid
38sets both the real and effective
39user ID (group ID) of the current process
40as specified.
41.Pp
42The
43.Fn seteuid
44function
45.Pq Fn setegid
46sets the effective user ID (group ID) of the
47current process.
48.Pp
49The
50.Fn setruid
51function
52.Pq Fn setrgid
53sets the real user ID (group ID) of the
54current process.
55.Sh RETURN VALUES
56Upon success, these functions return 0;
57otherwise \-1 is returned.
58.Pp
59If the user is not the super user, or the uid
60specified is not the real or effective ID, these
61functions return \-1.
62.Sh SEE ALSO
63.Xr setreuid 2 ,
64.Xr setregid 2 ,
65.Xr getuid 2 ,
66.Xr getgid 2
67.Sh HISTORY
68A
69.Fn setuid
70and
71.Fn setgid
72syscall appeared in
73.At v6 .
74