diff options
Diffstat (limited to 'crypto/compat/issetugid_hpux.c')
-rw-r--r-- | crypto/compat/issetugid_hpux.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/crypto/compat/issetugid_hpux.c b/crypto/compat/issetugid_hpux.c new file mode 100644 index 0000000..73def9b --- /dev/null +++ b/crypto/compat/issetugid_hpux.c | |||
@@ -0,0 +1,26 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <unistd.h> | ||
3 | #include <sys/pstat.h> | ||
4 | |||
5 | /* | ||
6 | * HP-UX does not have issetugid(). | ||
7 | * This experimental implementation uses pstat_getproc() and get*id(). | ||
8 | * First, try pstat_getproc() and check PS_CHANGEDPRIV bit of pst_flag. | ||
9 | * In case unsuccessful calling pstat_getproc(), using get*id(). | ||
10 | * | ||
11 | */ | ||
12 | int issetugid(void) | ||
13 | { | ||
14 | struct pst_status buf; | ||
15 | if(pstat_getproc(&buf, sizeof(buf), 0, getpid()) != 1) { | ||
16 | perror("pstat_getproc()"); | ||
17 | } else { | ||
18 | if(buf.pst_flag & PS_CHANGEDPRIV) | ||
19 | return 1; | ||
20 | } | ||
21 | if(getuid() != geteuid()) | ||
22 | return 1; | ||
23 | if(getgid() != getegid()) | ||
24 | return 1; | ||
25 | return 0; | ||
26 | } | ||