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(). * HP-UX does not have issetugid().
* This experimental implementation uses pstat_getproc() and get*id(). * Use pstat_getproc() and check PS_CHANGEDPRIV bit of pst_flag. If this call
* First, try pstat_getproc() and check PS_CHANGEDPRIV bit of pst_flag. * cannot be used, assume we must be running in a privileged environment.
* In case unsuccessful calling pstat_getproc(), using get*id().
*
*/ */
int issetugid(void) int issetugid(void)
{ {
struct pst_status buf; struct pst_status buf;
if(pstat_getproc(&buf, sizeof(buf), 0, getpid()) != 1) { if (pstat_getproc(&buf, sizeof(buf), 0, getpid()) == 1 &&
perror("pstat_getproc()"); !(buf.pst_flag & PS_CHANGEDPRIV))
} else {
if(buf.pst_flag & PS_CHANGEDPRIV)
return 1;
}
if(getuid() != geteuid())
return 1;
if(getgid() != getegid())
return 1;
return 0; return 0;
return 1;
} }