| 1 | /* |
| 2 | * COPYRIGHT (c) International Business Machines Corp. 2024 |
| 3 | * |
| 4 | * This program is provided under the terms of the Common Public License, |
| 5 | * version 1.0 (CPL-1.0). Any use, reproduction or distribution for this |
| 6 | * software constitutes recipient's acceptance of CPL-1.0 terms which can be |
| 7 | * found in the file LICENSE file or at |
| 8 | * https://opensource.org/licenses/cpl1.0.php |
| 9 | */ |
| 10 | #ifndef SECURE_GETENV_H |
| 11 | #define SECURE_GETENV_H |
| 12 | |
| 13 | #include <stdlib.h> |
| 14 | #include <unistd.h> |
| 15 | |
| 16 | static inline char* secure_getenv(char const *name) |
| 17 | { |
| 18 | if (geteuid() != getuid() || getegid() != getgid()) |
| 19 | return NULL; |
| 20 | return getenv(name); |
| 21 | } |
| 22 | #endif /* SECURE_GETENV_H */ |