xref: /original-bsd/lib/libc/sys/setuid.2 (revision a043e977)
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.6 (Berkeley) 02/03/93
7.\"
8.Dd
9.Dt SETUID 2
10.Os BSD 4.2
11.Sh NAME
12.Nm setuid ,
13.Nm seteuid ,
14.Nm setgid ,
15.Nm setegid ,
16.Nd set user and group ID
17.Sh SYNOPSIS
18.Fd #include <sys/types.h>
19.Fd #include <unistd.h>
20.Ft int
21.Fn setuid "uid_t uid"
22.Ft int
23.Fn seteuid "uid_t euid"
24.Ft int
25.Fn setgid "gid_t gid"
26.Ft int
27.Fn setegid "gid_t egid"
28.Sh DESCRIPTION
29The
30.Fn setuid
31function
32.Pq Fn setgid
33sets both the real and effective
34user ID (group ID) of the current process
35as specified.
36.Pp
37The
38.Fn seteuid
39function
40.Pq Fn setegid
41sets the effective user ID (group ID) of the
42current process.
43.Pp
44.Sh RETURN VALUES
45Upon success, these functions return 0;
46otherwise \-1 is returned.
47.Pp
48If the user is not the super user, or the uid
49specified is not the real, effective ID, or saved ID,
50these functions return \-1.
51.Sh SEE ALSO
52.Xr getuid 2 ,
53.Xr getgid 2
54.Sh HISTORY
55A
56.Fn setuid
57and
58.Fn setgid
59syscall appeared in
60.At v6 .
61