Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pthread_setugid_np(2) [osx man page]

PTHREAD_SETUGID_NP(2)					      BSD System Calls Manual					     PTHREAD_SETUGID_NP(2)

NAME
pthread_setugid_np -- Set the per-thread userid and single groupid. SYNOPSIS
#include <sys/types.h> #include <sys/unistd.h> int pthread_setugid_np(uid_t uid, gid_t gid); DESCRIPTION
pthread_setugid_np() changes the current thread's effective, real, and saved userid and groupid to the requested userid and groupid ( uid and gid , respectively) and clears all other groupids. uid can be the current real userid, KAUTH_UID_NONE, or, if the caller is privileged, any userid. gid can be the current real groupid or, if the caller is priviledged, any single groupid. Setting uid to KAUTH_UID_NONE means to "revert to the per process credential". CAVEATS
Temporarily restoring root privileges for a non-privileged process is only possible on a per-process basis and not a per-thread basis. pthread_setugid_np() is not intended as a privilege escalation mechanism. Do not use pthread_setugid_np.2() in a security sensitive situation. RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, -1 is returned and the global variable errno is set to indicate the error. ERRORS
pthread_setugid_np() fails if one or more of the following are true: [EPERM] The calling process does not have the correct credentials to set the override identity (i.e. The current credentials do not imply "super-user"). [EPERM] If uid is set to KAUTH_UID_NONE, the current thread must already be assuming another identity in order to revert back. [EPERM] The current thread cannot already be assuming another identity. SEE ALSO
setuid(2) setgid(2) seteuid(2) setegid(2) BSD
October 1, 2008 BSD

Check Out this Related Man Page

SETUID(2)						     Linux Programmer's Manual							 SETUID(2)

NAME
setuid - set user identity SYNOPSIS
#include <sys/types.h> #include <unistd.h> int setuid(uid_t uid); DESCRIPTION
setuid sets the effective user ID of the current process. If the effective userid of the caller is root, the real and saved user ID's are also set. Under Linux, setuid is implemented like the POSIX version with the _POSIX_SAVED_IDS feature. This allows a setuid (other than root) pro- gram to drop all of its user privileges, do some un-privileged work, and then re-engage the original effective user ID in a secure manner. If the user is root or the program is setuid root, special care must be taken. The setuid function checks the effective uid of the caller and if it is the superuser, all process related user ID's are set to uid. After this has occurred, it is impossible for the program to regain root privileges. Thus, a setuid-root program wishing to temporarily drop root privileges, assume the identity of a non-root user, and then regain root priv- ileges afterwards cannot use setuid. You can accomplish this with the (non-POSIX, BSD) call seteuid. RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS
EPERM The user is not the super-user, and uid does not match the real or saved user ID of the calling process. CONFORMING TO
SVr4, SVID, POSIX.1. Not quite compatible with the 4.4BSD call, which sets all of the real, saved, and effective user IDs. SVr4 documents an additional EINVAL error condition. LINUX-SPECIFIC REMARKS Linux has the concept of filesystem user ID, normally equal to the effective user ID. The setuid call also sets the filesystem user ID of the current process. See setfsuid(2). If uid is different from the old effective uid, the process will be forbidden from leaving core dumps. SEE ALSO
getuid(2), setreuid(2), seteuid(2), setfsuid(2) Linux 1.1.36 1994-07-29 SETUID(2)
Man Page