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.
If you use autoconf, you need the following directives in your configure.in or configure.ac file:
AC_GNU_SOURCE 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> #ifndef HAVE_SECURE_GETENV # ifdef HAVE__SECURE_GETENV # define secure_getenv __secure_getenv # else # error neither secure_getenv nor __secure_getenv are available # endif #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.