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.
This commit is contained in:
Brent Cook 2015-02-16 22:19:01 -06:00
parent ad7ac48d03
commit adc416e922

View File

@ -4,23 +4,14 @@
/*
* HP-UX does not have issetugid().
* This experimental implementation uses pstat_getproc() and get*id().
* First, try pstat_getproc() and check PS_CHANGEDPRIV bit of pst_flag.
* In case unsuccessful calling pstat_getproc(), using get*id().
*
* 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) {
perror("pstat_getproc()");
} else {
if(buf.pst_flag & PS_CHANGEDPRIV)
return 1;
}
if(getuid() != geteuid())
return 1;
if(getgid() != getegid())
return 1;
return 0;
if (pstat_getproc(&buf, sizeof(buf), 0, getpid()) == 1 &&
!(buf.pst_flag & PS_CHANGEDPRIV))
return 0;
return 1;
}