xref: /freebsd/lib/libsys/issetugid.2 (revision 8269e7673cf033aba67dab8264fe719920c70f87)
1*8269e767SBrooks Davis.\"	$OpenBSD: issetugid.2,v 1.7 1997/02/18 00:16:09 deraadt Exp $
2*8269e767SBrooks Davis.\"
3*8269e767SBrooks Davis.\" Copyright (c) 1980, 1991, 1993
4*8269e767SBrooks Davis.\"	The Regents of the University of California.  All rights reserved.
5*8269e767SBrooks Davis.\"
6*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
7*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
8*8269e767SBrooks Davis.\" are met:
9*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
10*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
11*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
12*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
13*8269e767SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
14*8269e767SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors
15*8269e767SBrooks Davis.\"    may be used to endorse or promote products derived from this software
16*8269e767SBrooks Davis.\"    without specific prior written permission.
17*8269e767SBrooks Davis.\"
18*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*8269e767SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28*8269e767SBrooks Davis.\" SUCH DAMAGE.
29*8269e767SBrooks Davis.\"
30*8269e767SBrooks Davis.Dd August 25, 1996
31*8269e767SBrooks Davis.Dt ISSETUGID 2
32*8269e767SBrooks Davis.Os
33*8269e767SBrooks Davis.Sh NAME
34*8269e767SBrooks Davis.Nm issetugid
35*8269e767SBrooks Davis.Nd is current process tainted by uid or gid changes
36*8269e767SBrooks Davis.Sh LIBRARY
37*8269e767SBrooks Davis.Lb libc
38*8269e767SBrooks Davis.Sh SYNOPSIS
39*8269e767SBrooks Davis.In unistd.h
40*8269e767SBrooks Davis.Ft int
41*8269e767SBrooks Davis.Fn issetugid void
42*8269e767SBrooks Davis.Sh DESCRIPTION
43*8269e767SBrooks DavisThe
44*8269e767SBrooks Davis.Fn issetugid
45*8269e767SBrooks Davissystem call returns 1 if the process environment or memory address space
46*8269e767SBrooks Davisis considered
47*8269e767SBrooks Davis.Dq tainted ,
48*8269e767SBrooks Davisand returns 0 otherwise.
49*8269e767SBrooks Davis.Pp
50*8269e767SBrooks DavisA process is tainted if it was created as a result of an
51*8269e767SBrooks Davis.Xr execve 2
52*8269e767SBrooks Davissystem call which had either of the setuid or setgid bits set (and extra
53*8269e767SBrooks Davisprivileges were given as a result) or if it has changed any of its real,
54*8269e767SBrooks Daviseffective or saved user or group ID's since it began execution.
55*8269e767SBrooks Davis.Pp
56*8269e767SBrooks DavisThis system call exists so that library routines (eg: libc, libtermcap)
57*8269e767SBrooks Daviscan reliably determine if it is safe to use information
58*8269e767SBrooks Davisthat was obtained from the user, in particular the results from
59*8269e767SBrooks Davis.Xr getenv 3
60*8269e767SBrooks Davisshould be viewed with suspicion if it is used to control operation.
61*8269e767SBrooks Davis.Pp
62*8269e767SBrooks DavisA
63*8269e767SBrooks Davis.Dq tainted
64*8269e767SBrooks Davisstatus is inherited by child processes as a result of the
65*8269e767SBrooks Davis.Xr fork 2
66*8269e767SBrooks Davissystem call (or other library code that calls fork, such as
67*8269e767SBrooks Davis.Xr popen 3 ) .
68*8269e767SBrooks Davis.Pp
69*8269e767SBrooks DavisIt is assumed that a program that clears all privileges as it prepares
70*8269e767SBrooks Davisto execute another will also reset the environment, hence the
71*8269e767SBrooks Davis.Dq tainted
72*8269e767SBrooks Davisstatus will not be passed on.
73*8269e767SBrooks DavisThis is important for programs such as
74*8269e767SBrooks Davis.Xr su 1
75*8269e767SBrooks Daviswhich begin setuid but need to be able to create an untainted process.
76*8269e767SBrooks Davis.Sh ERRORS
77*8269e767SBrooks DavisThe
78*8269e767SBrooks Davis.Fn issetugid
79*8269e767SBrooks Davissystem call is always successful, and no return value is reserved to
80*8269e767SBrooks Davisindicate an error.
81*8269e767SBrooks Davis.Sh SEE ALSO
82*8269e767SBrooks Davis.Xr execve 2 ,
83*8269e767SBrooks Davis.Xr fork 2 ,
84*8269e767SBrooks Davis.Xr setegid 2 ,
85*8269e767SBrooks Davis.Xr seteuid 2 ,
86*8269e767SBrooks Davis.Xr setgid 2 ,
87*8269e767SBrooks Davis.Xr setregid 2 ,
88*8269e767SBrooks Davis.Xr setreuid 2 ,
89*8269e767SBrooks Davis.Xr setuid 2
90*8269e767SBrooks Davis.Sh HISTORY
91*8269e767SBrooks DavisThe
92*8269e767SBrooks Davis.Fn issetugid
93*8269e767SBrooks Davissystem call first appeared in
94*8269e767SBrooks Davis.Ox 2.0
95*8269e767SBrooks Davisand was also implemented in
96*8269e767SBrooks Davis.Fx 3.0 .
97