xref: /openbsd/lib/libc/sys/setresuid.2 (revision 7b36286a)
1.\" $OpenBSD: setresuid.2,v 1.5 2007/05/31 19:19:33 jmc Exp $
2.\"
3.\" Copyright (c) 2000
4.\"      Sheldon Hearn.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES
21.\"
22.\" $FreeBSD: src/lib/libc/sys/setresuid.2,v 1.12 2001/10/01 16:09:02 ru Exp $
23.\"
24.Dd $Mdocdate: May 31 2007 $
25.Dt SETRESUID 2
26.Os
27.Sh NAME
28.Nm getresgid ,
29.Nm getresuid ,
30.Nm setresgid ,
31.Nm setresuid
32.Nd "get or set real, effective and saved user or group ID"
33.Sh SYNOPSIS
34.Fd #include <sys/types.h>
35.Fd #include <unistd.h>
36.Ft int
37.Fn getresgid "gid_t *rgid" "gid_t *egid" "gid_t *sgid"
38.Ft int
39.Fn getresuid "uid_t *ruid" "uid_t *euid" "uid_t *suid"
40.Ft int
41.Fn setresgid "gid_t rgid" "gid_t egid" "gid_t sgid"
42.Ft int
43.Fn setresuid "uid_t ruid" "uid_t euid" "uid_t suid"
44.Sh DESCRIPTION
45The
46.Fn setresuid
47function sets the real,
48effective and saved user IDs of the current process.
49The analogous
50.Fn setresgid
51sets the real, effective and saved group IDs.
52.Pp
53Privileged processes may set these IDs to arbitrary values.
54Unprivileged processes are restricted
55in that each of the new IDs must match one of the current IDs.
56.Pp
57Passing \-1 as an argument causes the corresponding value
58to remain unchanged.
59.Pp
60The
61.Fn getresgid
62and
63.Fn getresuid
64calls retrieve the real, effective, and saved group and user IDs of
65the current process, respectively.
66.Sh RETURN VALUES
67Upon success, these functions return 0; otherwise \-1 is returned.
68.Sh ERRORS
69.Bl -tag -width Er
70.It Bq Er EPERM
71The calling process was not privileged and tried to change one or
72more IDs to a value which was not the current real ID, the current
73effective ID nor the current saved ID.
74.It Bq Er EFAULT
75An address passed to
76.Fn getresgid
77or
78.Fn getresuid
79was invalid.
80.El
81.Sh SEE ALSO
82.Xr getegid 2 ,
83.Xr geteuid 2 ,
84.Xr getgid 2 ,
85.Xr getuid 2 ,
86.Xr issetugid 2 ,
87.Xr setgid 2 ,
88.Xr setregid 2 ,
89.Xr setreuid 2 ,
90.Xr setuid 2
91.Sh STANDARDS
92These functions are not part of the
93.St -p1003.1
94specification.
95While they are not completely portable, they are the least ambiguous way to
96manage user and group IDs.
97.Sh HISTORY
98These functions first appeared in HP-UX.
99