]> gcc.gnu.org Git - gcc.git/commitdiff
Don't assume __secure_getenv is available
authorJanne Blomqvist <jb@gcc.gnu.org>
Thu, 11 May 2017 20:04:53 +0000 (23:04 +0300)
committerJanne Blomqvist <jb@gcc.gnu.org>
Thu, 11 May 2017 20:04:53 +0000 (23:04 +0300)
Glibc 2.17 made __secure_getenv an officially supported function, and
renamed it secure_getenv. The libgfortran configure has checked for
both of these, per
https://sourceware.org/glibc/wiki/Tips_and_Tricks/secure_getenv.

Unfortunately, while the dynamical library (libc.so) retains the
__secure_getenv symbol for backwards compatibility, the static library
(libc.a) does not. This means that a libgfortran.a compiled against an
older glibc will not work if one tries to link against a newer
libc.a. This creates problems for providing gfortran binary
distributions that work on as many target systems as possible.

Thus, retain the support for __secure_getenv but call it only via a
weak reference.

Regtested on x86_64-pc-linux-gnu.

2017-05-11  Janne Blomqvist  <jb@gcc.gnu.org>

* libgfortran.h: HAVE_SECURE_GETENV: Don't check
HAVE___SECURE_GETENV.
* environ/runtime.c (secure_getenv): Use __secure_getenv via a
        weak reference.

From-SVN: r247927

libgfortran/ChangeLog
libgfortran/libgfortran.h
libgfortran/runtime/environ.c

index 720219f2063b4c3be9234c022166c979bc953725..337daafa5a84a6d63c1f0a3b8141ca511c8414cf 100644 (file)
@@ -1,3 +1,10 @@
+2017-05-11  Janne Blomqvist  <jb@gcc.gnu.org>
+
+       * libgfortran.h: HAVE_SECURE_GETENV: Don't check
+       HAVE___SECURE_GETENV.
+       * environ/runtime.c (secure_getenv): Use __secure_getenv via a
+        weak reference.
+
 2017-05-10  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
         PR fortran/80687
index cfa4fcf0edc4fcaa73ea9788fe79d12117f4cdaf..9d9d11728bdb4a6290436ae6f0c3ff728570b369 100644 (file)
@@ -808,9 +808,7 @@ internal_proto(get_unformatted_convert);
 
 /* Secure getenv() which returns NULL if running as SUID/SGID.  */
 #ifndef HAVE_SECURE_GETENV
-#ifdef HAVE___SECURE_GETENV
-#define secure_getenv __secure_getenv
-#elif defined(HAVE_GETUID) && defined(HAVE_GETEUID) \
+#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) \
   && defined(HAVE_GETGID) && defined(HAVE_GETEGID)
 #define FALLBACK_SECURE_GETENV
 extern char *secure_getenv (const char *);
index bf02188edec87de2a82dbd3ea111976246176ca5..969dcdfcf21c5a07a6d0611e71877918768ac75a 100644 (file)
@@ -37,9 +37,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    provided. */
 
 #ifdef FALLBACK_SECURE_GETENV
+
+#if SUPPORTS_WEAKREF && defined(HAVE___SECURE_GETENV)
+static char* weak_secure_getenv (const char*)
+  __attribute__((__weakref__("__secure_gettime")));
+#endif
+
 char *
 secure_getenv (const char *name)
 {
+#if SUPPORTS_WEAKREF && defined(HAVE__SECURE_GETENV)
+  if (weak_secure_getenv)
+    return weak_secure_getenv (name);
+#endif
+
   if ((getuid () == geteuid ()) && (getgid () == getegid ()))
     return getenv (name);
   else
This page took 0.062999 seconds and 5 git commands to generate.