]>
Commit | Line | Data |
---|---|---|
d2e9e320 | 1 | /* |
da1c088f | 2 | * Copyright 2001-2023 The OpenSSL Project Authors. All Rights Reserved. |
36fafffa | 3 | * |
0e9725bc | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
d2e9e320 RS |
5 | * this file except in compliance with the License. You can obtain a copy |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
36fafffa UM |
8 | */ |
9 | ||
74cd365b | 10 | #include <openssl/crypto.h> |
91dc71f9 | 11 | #include <openssl/opensslconf.h> |
36fafffa | 12 | |
66f61ece | 13 | #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) || defined(__wasi__) |
36fafffa UM |
14 | |
15 | int OPENSSL_issetugid(void) | |
0f113f3e | 16 | { |
e24bdcde | 17 | return 0; |
0f113f3e | 18 | } |
36fafffa | 19 | |
3a1fa011 | 20 | #elif defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) || defined(__DragonFly__) || (defined(__GLIBC__) && defined(__FreeBSD_kernel__)) |
e24bdcde | 21 | |
6b10d29c | 22 | # include <unistd.h> |
36fafffa UM |
23 | |
24 | int OPENSSL_issetugid(void) | |
0f113f3e | 25 | { |
e24bdcde | 26 | return issetugid(); |
0f113f3e | 27 | } |
36fafffa UM |
28 | |
29 | #else | |
30 | ||
6b10d29c | 31 | # include <unistd.h> |
0f113f3e | 32 | # include <sys/types.h> |
36fafffa | 33 | |
756510c1 P |
34 | # if defined(__GLIBC__) && defined(__GLIBC_PREREQ) |
35 | # if __GLIBC_PREREQ(2, 16) | |
36 | # include <sys/auxv.h> | |
aefb980c | 37 | # define OSSL_IMPLEMENT_GETAUXVAL |
756510c1 | 38 | # endif |
d5567d5f | 39 | # elif defined(__ANDROID_API__) |
40 | /* see https://developer.android.google.cn/ndk/guides/cpu-features */ | |
41 | # if __ANDROID_API__ >= 18 | |
42 | # include <sys/auxv.h> | |
43 | # define OSSL_IMPLEMENT_GETAUXVAL | |
44 | # endif | |
756510c1 P |
45 | # endif |
46 | ||
36fafffa | 47 | int OPENSSL_issetugid(void) |
0f113f3e | 48 | { |
aefb980c | 49 | # ifdef OSSL_IMPLEMENT_GETAUXVAL |
756510c1 P |
50 | return getauxval(AT_SECURE) != 0; |
51 | # else | |
52 | return getuid() != geteuid() || getgid() != getegid(); | |
53 | # endif | |
0f113f3e | 54 | } |
36fafffa | 55 | #endif |