How to use secure_getenv

In glibc 2.17, __secure_getenv was renamed to secure_getenv. Old applications continue to run unchanged, but some care is required to ensure that source code can be compiled with all glibc versions.

Using autoconf

If you use autoconf, you need the following directives in your or file:

AC_CHECK_FUNCS([__secure_getenv secure_getenv])

Instead of AC_GNU_SOURCE, you can use AC_USE_SYSTEM_EXTENSIONS (introduced in autoconf 2.60).

In the file which uses secure_getenv, include the following preprocessor directives:

#include <stdlib.h>

#    define secure_getenv __secure_getenv
#  else
#    error neither secure_getenv nor __secure_getenv are available
#  endif

Instead of the #error directive, you could include emulation code which compares getuid() with geteuid() and getgid() with getegid(), but such emulation is necessarily brittle.