~ubuntu-branches/ubuntu/wily/ust/wily-proposed

« back to all changes in this revision

Viewing changes to liblttng-ust/getenv.h

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2015-06-24 14:18:03 UTC
  • mfrom: (11.2.11 sid)
  • Revision ID: package-import@ubuntu.com-20150624141803-zfj6xzpr7dlxiysg
Tags: 2.6.2-1ubuntu1
* Merge from Debian unstable. (LP: #1468345) Remaining changes:
  - debian/control, debian/patches/use-python3.patch:
    + Switch to use python3. (Closes: #789790)
* Drop following changes, fixed in Debian / upstream:
  - debian/patches/0001-Add-aarch64-host-cpu-in-configure.ac.patch:
    + Add arm64 host_cpu stanzas in configure.ac
  - debian/liblttng-ust0.symbols:
    + Update symbols file.
  - debian/control:
    + Enable builds on arm64 and ppc64el.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Lesser General Public
 
9
 * License as published by the Free Software Foundation; only
 
10
 * version 2.1 of the License.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
15
 * Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this library; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
20
 */
 
21
 
 
22
#include <stdlib.h>
 
23
#include <unistd.h>
 
24
#include <sys/types.h>
 
25
#include <usterr-signal-safe.h>
 
26
 
 
27
static inline
 
28
int lttng_is_setuid_setgid(void)
 
29
{
 
30
        return geteuid() != getuid() || getegid() != getgid();
 
31
}
 
32
 
 
33
static inline
 
34
char *lttng_secure_getenv(const char *name)
 
35
{
 
36
        if (lttng_is_setuid_setgid()) {
 
37
                ERR("Getting environment variable '%s' from setuid/setgid binary refused for security reasons.",
 
38
                        name);
 
39
                return NULL;
 
40
        }
 
41
        return getenv(name);
 
42
}
 
43
 
 
44
#endif /* _COMPAT_GETENV_H */