| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- determine if current executable is running setuid or setgid
#include <unistd.h>intissetugid(void);
Theissetugid() function enables library functions (inlibtermlib,libc, or other libraries)to guarantee safe behavior when used insetuid orsetgid programs orprograms that run with more privileges after a succesfulexec(2). Some library functionsmight be passed insufficient information and not know whether the current programwas startedsetuid orsetgid because a higher level calling code might havemade changes to theuid,euid,gid, oregid. These low-level libraryfunctions are therefore unable to determine if they are being run withelevated or normal privileges.
Theissetugid() function should be used to determine if a path namereturned from agetenv(3C) call can be used safely to open thespecified file. It is often not safe to open such a file becausethe status of the effectiveuid is not known.
The result of a call toissetugid() is unaffected by calls tosetuid(),setgid(), or other such calls. In case of a calltofork(2), the child process inherits the same status.
The status ofissetugid() is affected only byexecve() (seeexec(2)). Ifa child process executes a new executable file, a newissetugid() statuswill be based on the existing process'suid,euid,gid, andegidpermissions and on the modes of the executable file. If the newexecutable file modes aresetuid orsetgid, or if the existing process isexecuting the new image withuid !=euid orgid !=egid,or if the permitted set before the call to theexec functionis not a superset of the inheritable set at that time,issetugid()returns 1 in the new process.
Theissetugid() function returns 1 if the process was madesetuid orsetgid as the result of the last or a previous call toexecve(). Otherwise it returns 0.
Theissetugid() function is always successful. No return value is reserved toindicate an error.
Seeattributes(5) for descriptions of the following attributes:
|
exec(2),fork(2),setuid(2),getenv(3C),attributes(5),privileges(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |