aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrent Cook <bcook@openbsd.org>2015-02-16 22:19:01 -0600
committerBrent Cook <bcook@openbsd.org>2015-02-16 22:30:27 -0600
commitadc416e922f98b4b52093f26c91216e3b4106f3d (patch)
treefbadeb7715964afeacb5a066d7e94933b6eb15f2
parentad7ac48d030b5ba7b8449bf3621b817affe3190f (diff)
downloadportable-adc416e922f98b4b52093f26c91216e3b4106f3d.tar.gz
portable-adc416e922f98b4b52093f26c91216e3b4106f3d.tar.bz2
portable-adc416e922f98b4b52093f26c91216e3b4106f3d.zip
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.
-rw-r--r--crypto/compat/issetugid_hpux.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/crypto/compat/issetugid_hpux.c b/crypto/compat/issetugid_hpux.c
index 73def9b..ca0e42c 100644
--- a/crypto/compat/issetugid_hpux.c
+++ b/crypto/compat/issetugid_hpux.c
@@ -4,23 +4,14 @@
4 4
5/* 5/*
6 * HP-UX does not have issetugid(). 6 * HP-UX does not have issetugid().
7 * This experimental implementation uses pstat_getproc() and get*id(). 7 * Use pstat_getproc() and check PS_CHANGEDPRIV bit of pst_flag. If this call
8 * First, try pstat_getproc() and check PS_CHANGEDPRIV bit of pst_flag. 8 * cannot be used, assume we must be running in a privileged environment.
9 * In case unsuccessful calling pstat_getproc(), using get*id().
10 *
11 */ 9 */
12int issetugid(void) 10int issetugid(void)
13{ 11{
14 struct pst_status buf; 12 struct pst_status buf;
15 if(pstat_getproc(&buf, sizeof(buf), 0, getpid()) != 1) { 13 if (pstat_getproc(&buf, sizeof(buf), 0, getpid()) == 1 &&
16 perror("pstat_getproc()"); 14 !(buf.pst_flag & PS_CHANGEDPRIV))
17 } else { 15 return 0;
18 if(buf.pst_flag & PS_CHANGEDPRIV) 16 return 1;
19 return 1;
20 }
21 if(getuid() != geteuid())
22 return 1;
23 if(getgid() != getegid())
24 return 1;
25 return 0;
26} 17}