xref: /netbsd-src/share/man/man9/do_setresuid.9 (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1.\"	$NetBSD: do_setresuid.9,v 1.3 2004/10/04 19:09:28 rumble Exp $
2.\"
3.\"-
4.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
5.\" All rights reserved.
6.\"
7.\" This code is derived from software contributed to The NetBSD Foundation
8.\" by David Laight.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. Neither the name of The NetBSD Foundation nor the names of its
19.\"    contributors may be used to endorse or promote products derived
20.\"    from this software without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32.\" POSSIBILITY OF SUCH DAMAGE.
33.\"
34.Dd September 28, 2003
35.Dt DO_SETRESUID 9
36.Os
37.Sh NAME
38.Nm do_setresuid ,
39.Nm do_setresgid
40.Nd set process uid and gid
41.Sh SYNOPSIS
42.In sys/ucred.h
43.Ft int
44.Fn do_setresuid "struct lwp *lwp" "uid_t ruid" "uid_t euid" "uid_t svuid" "u_int flags"
45.Ft int
46.Fn do_setresgid "struct lwp *lwp" "uid_t ruid" "uid_t euid" "uid_t svuid" "u_int flags"
47.Sh DESCRIPTION
48The
49.Nm do_setresuid
50and
51.Nm do_setresgid
52functions are used to implement the various system calls that allow a
53process to change its real, effective, and saved uid and gid values.
54.Pp
55The
56.Nm do_setresuid
57function sets the specified processes real user ID to
58.Ar ruid ,
59its effective user ID to
60.Ar euid ,
61and its saved user ID to
62.Ar svuid .
63If any of the uid arguments are \-1 then that assignment is skipped.
64.Pp
65If
66.Fn suser
67is true, then any values may be assigned, otherwise the new uid
68values must match one of the existing values and the caller must have
69set the relevant bit in
70.Ar flags .
71.Pp
72The
73.Ar flags
74argument specifies which of the existing uid values the new value must match.
75It should be set to a logical OR of ID_{R,E,S}_EQ_{R,E,S}, where ID_E_EQ_R
76means that it is valid to set the effective ID to the current value of the
77real ID.
78.Pp
79The
80.Nm do_setresgid
81function sets the group IDs but otherwise behaves in the same manner as
82.Nm .
83The processes group list is neither examined nor effected.
84.Sh SEE ALSO
85.Xr setregid 2 ,
86.Xr setreuid 2 ,
87.Xr setuid 2 ,
88.Xr suser 9
89.Sh CODE REFERENCES
90These functions are implemented in:
91.Pa sys/kern/kern_prot.c .
92.Sh HISTORY
93Implemented for
94.Nx 2.0
95to replace ad-hoc code in each system call routine and in the
96various compat modules.
97