2018-09-13 19:18:07 +00:00
|
|
|
/*
|
2019-02-26 18:06:51 +00:00
|
|
|
* Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.
|
2001-05-20 03:07:21 +00:00
|
|
|
*
|
2018-09-13 19:18:07 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2001-05-20 03:07:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <openssl/crypto.h>
|
2003-01-28 21:43:22 +00:00
|
|
|
#include <openssl/opensslconf.h>
|
2001-05-20 03:07:21 +00:00
|
|
|
|
2019-09-10 17:40:53 +00:00
|
|
|
#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
|
2001-05-20 03:07:21 +00:00
|
|
|
|
|
|
|
int OPENSSL_issetugid(void)
|
2015-03-20 15:28:40 +00:00
|
|
|
{
|
2019-09-10 17:40:53 +00:00
|
|
|
return 0;
|
2015-03-20 15:28:40 +00:00
|
|
|
}
|
2001-05-20 03:07:21 +00:00
|
|
|
|
2019-09-10 17:40:53 +00:00
|
|
|
#elif defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) || defined(__DragonFly__)
|
|
|
|
|
|
|
|
# include OPENSSL_UNISTD
|
2001-05-20 03:07:21 +00:00
|
|
|
|
|
|
|
int OPENSSL_issetugid(void)
|
2015-03-20 15:28:40 +00:00
|
|
|
{
|
2019-09-10 17:40:53 +00:00
|
|
|
return issetugid();
|
2015-03-20 15:28:40 +00:00
|
|
|
}
|
2001-05-20 03:07:21 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2015-03-20 15:28:40 +00:00
|
|
|
# include OPENSSL_UNISTD
|
|
|
|
# include <sys/types.h>
|
2001-05-20 03:07:21 +00:00
|
|
|
|
2018-09-13 19:18:07 +00:00
|
|
|
# if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
|
|
|
# if __GLIBC_PREREQ(2, 16)
|
|
|
|
# include <sys/auxv.h>
|
2019-02-26 18:06:51 +00:00
|
|
|
# define OSSL_IMPLEMENT_GETAUXVAL
|
2018-09-13 19:18:07 +00:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
|
2001-05-20 03:07:21 +00:00
|
|
|
int OPENSSL_issetugid(void)
|
2015-03-20 15:28:40 +00:00
|
|
|
{
|
2019-02-26 18:06:51 +00:00
|
|
|
# ifdef OSSL_IMPLEMENT_GETAUXVAL
|
2018-09-13 19:18:07 +00:00
|
|
|
return getauxval(AT_SECURE) != 0;
|
|
|
|
# else
|
|
|
|
return getuid() != geteuid() || getgid() != getegid();
|
|
|
|
# endif
|
2015-03-20 15:28:40 +00:00
|
|
|
}
|
2001-05-20 03:07:21 +00:00
|
|
|
#endif
|