Import upstream version 1.28
[debian/tar] / gnu / secure_getenv.c
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Look up an environment variable more securely.
4
5    Copyright 2013-2014 Free Software Foundation, Inc.
6
7    This program is free software: you can redistribute it and/or modify it
8    under the terms of the GNU General Public License as published
9    by the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program 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    General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 #include <config.h>
21
22 #include <stdlib.h>
23
24 #if !HAVE___SECURE_GETENV
25 # if HAVE_ISSETUGID
26 #  include <unistd.h>
27 # else
28 #  undef issetugid
29 #  define issetugid() 1
30 # endif
31 #endif
32
33 char *
34 secure_getenv (char const *name)
35 {
36 #if HAVE___SECURE_GETENV
37   return __secure_getenv (name);
38 #else
39   if (issetugid ())
40     return 0;
41   return getenv (name);
42 #endif
43 }