]>
Commit | Line | Data |
---|---|---|
d2e9e320 | 1 | /* |
1212818e | 2 | * Copyright 2001-2018 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 | |
e24bdcde | 13 | #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) |
36fafffa UM |
14 | |
15 | int OPENSSL_issetugid(void) | |
0f113f3e | 16 | { |
e24bdcde | 17 | return 0; |
0f113f3e | 18 | } |
36fafffa | 19 | |
e24bdcde RC |
20 | #elif defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) || defined(__DragonFly__) |
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 P |
38 | # endif |
39 | # endif | |
40 | ||
36fafffa | 41 | int OPENSSL_issetugid(void) |
0f113f3e | 42 | { |
aefb980c | 43 | # ifdef OSSL_IMPLEMENT_GETAUXVAL |
756510c1 P |
44 | return getauxval(AT_SECURE) != 0; |
45 | # else | |
46 | return getuid() != geteuid() || getgid() != getegid(); | |
47 | # endif | |
0f113f3e | 48 | } |
36fafffa | 49 | #endif |