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:
parent
ad7ac48d03
commit
adc416e922
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user