libreSSL/crypto/compat/issetugid_hpux.c
Brent Cook adc416e922 remove getuid/getgid fallbacks from hp-ux issetugid emulation
Fail closed if we cannot obtain the process flags. Noticed while looking
at a similar function for AIX.
2015-02-16 22:30:27 -06:00

18 lines
427 B
C

#include <stdio.h>
#include <unistd.h>
#include <sys/pstat.h>
/*
* HP-UX does not have issetugid().
* Use pstat_getproc() and check PS_CHANGEDPRIV bit of pst_flag. If this call
* cannot be used, assume we must be running in a privileged environment.
*/
int issetugid(void)
{
struct pst_status buf;
if (pstat_getproc(&buf, sizeof(buf), 0, getpid()) == 1 &&
!(buf.pst_flag & PS_CHANGEDPRIV))
return 0;
return 1;
}