Blame gnulib/lib/secure_getenv.c

Packit eba2e2
/* Look up an environment variable more securely.
Packit eba2e2
Packit eba2e2
   Copyright 2013-2014 Free Software Foundation, Inc.
Packit eba2e2
Packit eba2e2
   This program is free software: you can redistribute it and/or modify it
Packit eba2e2
   under the terms of the GNU General Public License as published
Packit eba2e2
   by the Free Software Foundation; either version 3 of the License, or
Packit eba2e2
   (at your option) any later version.
Packit eba2e2
Packit eba2e2
   This program is distributed in the hope that it will be useful,
Packit eba2e2
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit eba2e2
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit eba2e2
   General Public License for more details.
Packit eba2e2
Packit eba2e2
   You should have received a copy of the GNU General Public License
Packit eba2e2
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit eba2e2
Packit eba2e2
#include <config.h>
Packit eba2e2
Packit eba2e2
#include <stdlib.h>
Packit eba2e2
Packit eba2e2
#if !HAVE___SECURE_GETENV
Packit eba2e2
# if HAVE_ISSETUGID
Packit eba2e2
#  include <unistd.h>
Packit eba2e2
# else
Packit eba2e2
#  undef issetugid
Packit eba2e2
#  define issetugid() 1
Packit eba2e2
# endif
Packit eba2e2
#endif
Packit eba2e2
Packit eba2e2
char *
Packit eba2e2
secure_getenv (char const *name)
Packit eba2e2
{
Packit eba2e2
#if HAVE___SECURE_GETENV
Packit eba2e2
  return __secure_getenv (name);
Packit eba2e2
#else
Packit eba2e2
  if (issetugid ())
Packit eba2e2
    return 0;
Packit eba2e2
  return getenv (name);
Packit eba2e2
#endif
Packit eba2e2
}