Blame gettext-tools/gnulib-lib/secure_getenv.c

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