2 .\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH ISSETUGID 2 "April 9, 2016"
8 issetugid \- determine if current executable is running setuid or setgid
14 \fBint\fR \fBissetugid\fR(\fBvoid\fR);
19 The \fBissetugid()\fR function enables library functions (in \fBlibtermlib\fR,
20 \fBlibc\fR, or other libraries) to guarantee safe behavior when used in
21 \fBsetuid\fR or \fBsetgid\fR programs or programs that run with more privileges
22 after a successful \fBexec\fR(2). Some library functions might be passed
23 insufficient information and not know whether the current program was started
24 \fBsetuid\fR or \fBsetgid\fR because a higher level calling code might have
25 made changes to the \fBuid\fR, \fBeuid\fR, \fBgid\fR, or \fBegid\fR. These
26 low-level library functions are therefore unable to determine if they are being
27 run with elevated or normal privileges.
30 The \fBissetugid()\fR function should be used to determine if a path name
31 returned from a \fBgetenv\fR(3C) call can be used safely to open the specified
32 file. It is often not safe to open such a file because the status of the
33 effective \fBuid\fR is not known.
36 The result of a call to \fBissetugid()\fR is unaffected by calls to
37 \fBsetuid()\fR, \fBsetgid()\fR, or other such calls. In case of a call to
38 \fBfork\fR(2), the child process inherits the same status.
41 The status of \fBissetugid()\fR is affected only by \fBexecve()\fR (see
42 \fBexec\fR(2)). If a child process executes a new executable file, a new
43 \fBissetugid()\fR status will be based on the existing process's \fBuid\fR,
44 \fBeuid\fR, \fBgid\fR, and \fBegid\fR permissions and on the modes of the
45 executable file. If the new executable file modes are \fBsetuid\fR or
46 \fBsetgid\fR, or if the existing process is executing the new image with
47 \fBuid\fR != \fBeuid\fR or \fBgid\fR != \fBegid\fR, or if the permitted set
48 before the call to the \fBexec\fR function is not a superset of the inheritable
49 set at that time, \fBissetugid()\fR returns 1 in the new process.
52 The \fBissetugid()\fR function returns 1 if the process was made \fBsetuid\fR
53 or \fBsetgid\fR as the result of the last or a previous call to \fBexecve()\fR.
54 Otherwise it returns 0.
57 The \fBissetugid()\fR function is always successful. No return value is
58 reserved to indicate an error.
61 See \fBattributes\fR(5) for descriptions of the following attributes:
69 ATTRIBUTE TYPE ATTRIBUTE VALUE
71 Interface Stability Evolving
73 MT-Level Async-Signal-Safe
78 \fBexec\fR(2), \fBfork\fR(2), \fBsetuid\fR(2), \fBgetenv\fR(3C),
79 \fBattributes\fR(5), \fBprivileges\fR(5)