Remove fcntl wrapper
[lttng-tools.git] / src / common / compat / getenv.hpp
1 #ifndef _COMPAT_GETENV_H
2 #define _COMPAT_GETENV_H
3
4 /*
5 * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 *
7 * SPDX-License-Identifier: LGPL-2.1-only
8 *
9 */
10
11 #include <common/error.hpp>
12
13 #include <stdlib.h>
14 #include <sys/types.h>
15 #include <unistd.h>
16
17 static inline int lttng_is_setuid_setgid()
18 {
19 return geteuid() != getuid() || getegid() != getgid();
20 }
21
22 static inline char *lttng_secure_getenv(const char *name)
23 {
24 if (lttng_is_setuid_setgid()) {
25 WARN("Getting environment variable '%s' from setuid/setgid binary refused for security reasons.",
26 name);
27 return nullptr;
28 }
29 return getenv(name);
30 }
31
32 #endif /* _COMPAT_GETENV_H */
This page took 0.030882 seconds and 4 git commands to generate.