xref: /netbsd/share/man/man9/do_setresuid.9 (revision 6550d01e)
1.\"	$NetBSD: do_setresuid.9,v 1.4 2008/04/30 13:10:58 martin 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.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29.\" POSSIBILITY OF SUCH DAMAGE.
30.\"
31.Dd September 28, 2003
32.Dt DO_SETRESUID 9
33.Os
34.Sh NAME
35.Nm do_setresuid ,
36.Nm do_setresgid
37.Nd set process uid and gid
38.Sh SYNOPSIS
39.In sys/ucred.h
40.Ft int
41.Fn do_setresuid "struct lwp *lwp" "uid_t ruid" "uid_t euid" "uid_t svuid" "u_int flags"
42.Ft int
43.Fn do_setresgid "struct lwp *lwp" "uid_t ruid" "uid_t euid" "uid_t svuid" "u_int flags"
44.Sh DESCRIPTION
45The
46.Nm do_setresuid
47and
48.Nm do_setresgid
49functions are used to implement the various system calls that allow a
50process to change its real, effective, and saved uid and gid values.
51.Pp
52The
53.Nm do_setresuid
54function sets the specified processes real user ID to
55.Ar ruid ,
56its effective user ID to
57.Ar euid ,
58and its saved user ID to
59.Ar svuid .
60If any of the uid arguments are \-1 then that assignment is skipped.
61.Pp
62If
63.Fn suser
64is true, then any values may be assigned, otherwise the new uid
65values must match one of the existing values and the caller must have
66set the relevant bit in
67.Ar flags .
68.Pp
69The
70.Ar flags
71argument specifies which of the existing uid values the new value must match.
72It should be set to a logical OR of ID_{R,E,S}_EQ_{R,E,S}, where ID_E_EQ_R
73means that it is valid to set the effective ID to the current value of the
74real ID.
75.Pp
76The
77.Nm do_setresgid
78function sets the group IDs but otherwise behaves in the same manner as
79.Nm .
80The processes group list is neither examined nor effected.
81.Sh SEE ALSO
82.Xr setregid 2 ,
83.Xr setreuid 2 ,
84.Xr setuid 2 ,
85.Xr suser 9
86.Sh CODE REFERENCES
87These functions are implemented in:
88.Pa sys/kern/kern_prot.c .
89.Sh HISTORY
90Implemented for
91.Nx 2.0
92to replace ad-hoc code in each system call routine and in the
93various compat modules.
94