Differences between revisions 1 and 2
Revision 1 as of 2012-07-25 18:19:47
Size: 1025
Comment:
Revision 2 as of 2012-07-25 18:26:41
Size: 1045
Comment: Fix formatting
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
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. 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.
Line 5: Line 5:
If you use autoconf, you need the following directives in your configure.in or configure.ac file:AC_GNU_SOURCE If you use autoconf, you need the following directives in your `configure.in` or `configure.ac` file:
Line 11: Line 11:
Instead of AC_GNU_SOURCE , you can use AC_USE_SYSTEM_EXTENSIONS (introduced in autoconf 2.60). Instead of `AC_GNU_SOURCE`, you can use `AC_USE_SYSTEM_EXTENSIONS` (introduced in autoconf 2.60).
Line 13: Line 13:
In the file which uses secure_getenv, include the following preprocessor directives: In the file which uses `secure_getenv`, include the following preprocessor directives:
Line 26: Line 26:
Instead of the #error, you could include emulation code which compares getuid() with geteuid() and getgid() with getegid(), but such emulation is necessarily brittle. 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.

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 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.

None: Tips_and_Tricks/secure_getenv (last edited 2013-04-04 19:10:04 by DmitryLevin)