1issetugid(2) System Calls issetugid(2)
2
3
4
6 issetugid - determine if current executable is running setuid or setgid
7
9 #include <unistd.h>
10
11 int issetugid(void);
12
13
15 The issetugid() function enables library functions (in libtermlib,
16 libc, or other libraries) to guarantee safe behavior when used in
17 setuid or setgid programs or programs that run with more privileges
18 after a succesful exec(2). Some library functions might be passed
19 insufficient information and not know whether the current program was
20 started setuid or setgid because a higher level calling code might have
21 made changes to the uid, euid, gid, or egid. These low-level library
22 functions are therefore unable to determine if they are being run with
23 elevated or normal privileges.
24
25
26 The issetugid() function should be used to determine if a path name
27 returned from a getenv(3C) call can be used safely to open the speci‐
28 fied file. It is often not safe to open such a file because the status
29 of the effective uid is not known.
30
31
32 The result of a call to issetugid() is unaffected by calls to setuid(),
33 setgid(), or other such calls. In case of a call to fork(2), the child
34 process inherits the same status.
35
36
37 The status of issetugid() is affected only by execve() (see exec(2)).
38 If a child process executes a new executable file, a new issetugid()
39 status will be based on the existing process's uid, euid, gid, and egid
40 permissions and on the modes of the executable file. If the new exe‐
41 cutable file modes are setuid or setgid, or if the existing process is
42 executing the new image with uid != euid or gid != egid, or if the per‐
43 mitted set before the call to the exec function is not a superset of
44 the inheritable set at that time, issetugid() returns 1 in the new
45 process.
46
48 The issetugid() function returns 1 if the process was made setuid or
49 setgid as the result of the last or a previous call to execve(). Other‐
50 wise it returns 0.
51
53 The issetugid() function is always successful. No return value is
54 reserved to indicate an error.
55
57 See attributes(5) for descriptions of the following attributes:
58
59
60
61
62 ┌─────────────────────────────┬─────────────────────────────┐
63 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
64 ├─────────────────────────────┼─────────────────────────────┤
65 │Interface Stability │Evolving │
66 ├─────────────────────────────┼─────────────────────────────┤
67 │MT-Level │Async-Signal-Safe │
68 └─────────────────────────────┴─────────────────────────────┘
69
71 exec(2), fork(2), setuid(2), getenv(3C), attributes(5), privileges(5)
72
73
74
75SunOS 5.11 19 Feb 2003 issetugid(2)