summaryrefslogtreecommitdiff
path: root/crypto/compat/issetugid_hpux.c
blob: 73def9b89336777073308fde6e3a144b7a107afe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <unistd.h>
#include <sys/pstat.h>

/*
 * 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().
 *
 */
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;
}