Rich Salz | d2e9e32 | 2016-05-17 14:51:26 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. |
Ulf Möller | 36fafff | 2001-02-14 01:35:44 +0000 | [diff] [blame] | 3 | * |
Rich Salz | d2e9e32 | 2016-05-17 14:51:26 -0400 | [diff] [blame] | 4 | * Licensed under the OpenSSL license (the "License"). You may not use |
| 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 |
Ulf Möller | 36fafff | 2001-02-14 01:35:44 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
Richard Levitte | 74cd365 | 2001-02-19 22:04:02 +0000 | [diff] [blame] | 10 | #include <openssl/crypto.h> |
Richard Levitte | 91dc71f | 2001-04-26 08:26:18 +0000 | [diff] [blame] | 11 | #include <openssl/opensslconf.h> |
Ulf Möller | 36fafff | 2001-02-14 01:35:44 +0000 | [diff] [blame] | 12 | |
jrmarino | 2df7f11 | 2016-10-21 08:48:31 -0500 | [diff] [blame] | 13 | #if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) || defined(__DragonFly__) |
Ulf Möller | 36fafff | 2001-02-14 01:35:44 +0000 | [diff] [blame] | 14 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 15 | # include OPENSSL_UNISTD |
Ulf Möller | 36fafff | 2001-02-14 01:35:44 +0000 | [diff] [blame] | 16 | |
| 17 | int OPENSSL_issetugid(void) |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 18 | { |
| 19 | return issetugid(); |
| 20 | } |
Ulf Möller | 36fafff | 2001-02-14 01:35:44 +0000 | [diff] [blame] | 21 | |
Qin Long | cff55b9 | 2017-03-15 23:33:57 +0800 | [diff] [blame] | 22 | #elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) |
Ulf Möller | 36fafff | 2001-02-14 01:35:44 +0000 | [diff] [blame] | 23 | |
| 24 | int OPENSSL_issetugid(void) |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 25 | { |
| 26 | return 0; |
| 27 | } |
Ulf Möller | 36fafff | 2001-02-14 01:35:44 +0000 | [diff] [blame] | 28 | |
| 29 | #else |
| 30 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 31 | # include OPENSSL_UNISTD |
| 32 | # include <sys/types.h> |
Ulf Möller | 36fafff | 2001-02-14 01:35:44 +0000 | [diff] [blame] | 33 | |
| 34 | int OPENSSL_issetugid(void) |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 35 | { |
| 36 | if (getuid() != geteuid()) |
| 37 | return 1; |
| 38 | if (getgid() != getegid()) |
| 39 | return 1; |
| 40 | return 0; |
| 41 | } |
Ulf Möller | 36fafff | 2001-02-14 01:35:44 +0000 | [diff] [blame] | 42 | #endif |