2016-05-18 02:51:26 +08:00
|
|
|
/*
|
2021-07-29 22:41:35 +08:00
|
|
|
* Copyright 2001-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2001-02-14 09:35:44 +08:00
|
|
|
*
|
2018-12-06 21:03:01 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:51:26 +08:00
|
|
|
* 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-02-14 09:35:44 +08:00
|
|
|
*/
|
|
|
|
|
2001-02-20 06:04:02 +08:00
|
|
|
#include <openssl/crypto.h>
|
2001-04-26 16:26:18 +08:00
|
|
|
#include <openssl/opensslconf.h>
|
2001-02-14 09:35:44 +08:00
|
|
|
|
2019-06-18 11:02:32 +08:00
|
|
|
#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
|
2001-02-14 09:35:44 +08:00
|
|
|
|
|
|
|
int OPENSSL_issetugid(void)
|
2015-01-22 11:40:55 +08:00
|
|
|
{
|
2019-06-18 11:02:32 +08:00
|
|
|
return 0;
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
2001-02-14 09:35:44 +08:00
|
|
|
|
2021-08-31 14:26:06 +08:00
|
|
|
#elif defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) || defined(__DragonFly__) || (defined(__GLIBC__) && defined(__FreeBSD_kernel__))
|
2019-06-18 11:02:32 +08:00
|
|
|
|
2019-06-21 05:07:25 +08:00
|
|
|
# include <unistd.h>
|
2001-02-14 09:35:44 +08:00
|
|
|
|
|
|
|
int OPENSSL_issetugid(void)
|
2015-01-22 11:40:55 +08:00
|
|
|
{
|
2019-06-18 11:02:32 +08:00
|
|
|
return issetugid();
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
2001-02-14 09:35:44 +08:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2019-06-21 05:07:25 +08:00
|
|
|
# include <unistd.h>
|
2015-01-22 11:40:55 +08:00
|
|
|
# include <sys/types.h>
|
2001-02-14 09:35:44 +08:00
|
|
|
|
2018-08-17 12:35:37 +08:00
|
|
|
# if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
|
|
|
# if __GLIBC_PREREQ(2, 16)
|
|
|
|
# include <sys/auxv.h>
|
2018-12-20 17:17:38 +08:00
|
|
|
# define OSSL_IMPLEMENT_GETAUXVAL
|
2018-08-17 12:35:37 +08:00
|
|
|
# endif
|
2021-06-23 09:46:42 +08:00
|
|
|
# elif defined(__ANDROID_API__)
|
|
|
|
/* see https://developer.android.google.cn/ndk/guides/cpu-features */
|
|
|
|
# if __ANDROID_API__ >= 18
|
|
|
|
# include <sys/auxv.h>
|
|
|
|
# define OSSL_IMPLEMENT_GETAUXVAL
|
|
|
|
# endif
|
2018-08-17 12:35:37 +08:00
|
|
|
# endif
|
|
|
|
|
2001-02-14 09:35:44 +08:00
|
|
|
int OPENSSL_issetugid(void)
|
2015-01-22 11:40:55 +08:00
|
|
|
{
|
2018-12-20 17:17:38 +08:00
|
|
|
# ifdef OSSL_IMPLEMENT_GETAUXVAL
|
2018-08-17 12:35:37 +08:00
|
|
|
return getauxval(AT_SECURE) != 0;
|
|
|
|
# else
|
|
|
|
return getuid() != geteuid() || getgid() != getegid();
|
|
|
|
# endif
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
2001-02-14 09:35:44 +08:00
|
|
|
#endif
|