summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2018-08-17 14:35:37 +1000
committerPauli <paul.dale@oracle.com>2018-08-20 11:12:26 +1000
commit756510c102885005c2fc31eb01e3a6b95f8ed985 (patch)
tree8168d948e21104ddd9acb774415d280a9ea67b69
parent723bd004730a773354dcdc579d62e99a7e125cee (diff)
Check getauxval on systems that have it when checking for setuid execution.
Reviewed-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/6993)
-rw-r--r--crypto/uid.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/crypto/uid.c b/crypto/uid.c
index 4e1890f2d2..b2bfee32b5 100644
--- a/crypto/uid.c
+++ b/crypto/uid.c
@@ -31,12 +31,18 @@ int OPENSSL_issetugid(void)
# include OPENSSL_UNISTD
# include <sys/types.h>
+# if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+# if __GLIBC_PREREQ(2, 16)
+# include <sys/auxv.h>
+# endif
+# endif
+
int OPENSSL_issetugid(void)
{
- if (getuid() != geteuid())
- return 1;
- if (getgid() != getegid())
- return 1;
- return 0;
+# ifdef AT_SECURE
+ return getauxval(AT_SECURE) != 0;
+# else
+ return getuid() != geteuid() || getgid() != getegid();
+# endif
}
#endif