Cleanup: ret is unused in relay_process_data_receive_header()
[lttng-tools.git] / src / common / compat / getenv.h
1 #ifndef _COMPAT_GETENV_H
2 #define _COMPAT_GETENV_H
3
4 /*
5 * Copyright (C) 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2 only,
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <sys/types.h>
24 #include <common/error.h>
25
26 static inline
27 int lttng_is_setuid_setgid(void)
28 {
29 return geteuid() != getuid() || getegid() != getgid();
30 }
31
32 static inline
33 char *lttng_secure_getenv(const char *name)
34 {
35 if (lttng_is_setuid_setgid()) {
36 WARN("Getting environment variable '%s' from setuid/setgid binary refused for security reasons.",
37 name);
38 return NULL;
39 }
40 return getenv(name);
41 }
42
43 #endif /* _COMPAT_GETENV_H */
This page took 0.036759 seconds and 4 git commands to generate.