Blame SOURCES/glibc-rh1523119-compat-symbols.patch

00db10
Provide GLIBC_PRIVATE symbols no longer used by the current library
00db10
version to increase backwards compatibility during glibc updates.
00db10
This will help to avoid some of the issues that surface while a
00db10
glibc update is performed with concurrent application updates,
00db10
and it also allows old nscd to trigger cache invalidation in a
00db10
running nscd daemon.
00db10
00db10
While at this, also add interfaces for supporting old nss_dns modules.
00db10
00db10
This patch is not needed upstream because upstream does not provide
00db10
backwards compatibility for GLIBC_PRIVATE symbols.
00db10
00db10
diff --git a/inet/herrno.c b/inet/herrno.c
00db10
index 0cd84445190728b3..4d26e9b254181422 100644
00db10
--- a/inet/herrno.c
00db10
+++ b/inet/herrno.c
00db10
@@ -28,3 +28,9 @@ __thread int __h_errno;
00db10
 extern __thread int __libc_h_errno __attribute__ ((alias ("__h_errno")))
00db10
   attribute_hidden;
00db10
 #define h_errno __libc_h_errno
00db10
+
00db10
+#ifdef SHARED
00db10
+/* Provide an alias for use by the old libpthread.so.0 during
00db10
+   updates.  */
00db10
+asm (".symver __h_errno, h_errno@GLIBC_PRIVATE");
00db10
+#endif
00db10
diff --git a/resolv/res_libc.c b/resolv/res_libc.c
00db10
index 9f2d3c3bd442bb38..5ab02c79c72eb1ac 100644
00db10
--- a/resolv/res_libc.c
00db10
+++ b/resolv/res_libc.c
00db10
@@ -41,6 +41,7 @@
00db10
 #include <resolv.h>
00db10
 #include <libc-lock.h>
00db10
 #include <resolv-internal.h>
00db10
+#include <resolv_context.h>
00db10
 
00db10
 int
00db10
 res_init (void)
00db10
@@ -80,7 +81,34 @@ res_init (void)
00db10
 
00db10
   return __res_vinit (&_res, 1);
00db10
 }
00db10
-
00db10
+
00db10
+#ifdef SHARED
00db10
+
00db10
+/* An old nscd binary may bind to __res_maybe_init during a glibc
00db10
+   update.  Emulate it using the new functions.  Ignore PREINIT
00db10
+   because almost all existing __res_maybe_init callers used zero
00db10
+   PREINIT, and the difference for RESP == &_res is very minor (a
00db10
+   potential override of application configuration).  */
00db10
+attribute_compat_text_section
00db10
+int
00db10
+__res_maybe_init (res_state resp, int preinit)
00db10
+{
00db10
+  if (resp == &_res)
00db10
+    {
00db10
+      /* This performs an implicit initialization of _res.  */
00db10
+      struct resolv_context *ctx = __resolv_context_get ();
00db10
+      if (ctx == NULL)
00db10
+        return -1;
00db10
+      __resolv_context_put (ctx);
00db10
+      return 0;
00db10
+    }
00db10
+  else
00db10
+    return __res_vinit (resp, 0);
00db10
+}
00db10
+asm (".symver __res_maybe_init, __res_maybe_init@GLIBC_PRIVATE");
00db10
+
00db10
+#endif /* SHARED */
00db10
+
00db10
 /* This needs to be after the use of _res in res_init, above.  */
00db10
 #undef _res
00db10
 
00db10
diff --git a/resolv/res_query.c b/resolv/res_query.c
00db10
index ebbe5a6a4ed86abe..24fefb561e7f1f5e 100644
00db10
--- a/resolv/res_query.c
00db10
+++ b/resolv/res_query.c
00db10
@@ -705,6 +705,96 @@ hostalias (const char *name)
00db10
     (__resolv_context_get (), name, abuf, sizeof (abuf));
00db10
 }
00db10
 
00db10
+#ifdef SHARED
00db10
+/* Compatibiliaty functions to support old nss_dns modules.  */
00db10
+
00db10
+typedef int (*compat_query_function) (struct resolv_context *,
00db10
+				      const char *name,
00db10
+				      int class, int type,
00db10
+				      u_char *answer,
00db10
+				      int anslen,
00db10
+				      u_char **answerp,
00db10
+				      u_char **answerp2,
00db10
+				      int *nanswerp2,
00db10
+				      int *resplen2,
00db10
+				      int *answerp2_malloced);
00db10
+
00db10
+attribute_compat_text_section
00db10
+static int
00db10
+wrap_compat_call (compat_query_function qf,
00db10
+		  res_state statp,
00db10
+		  const char *name,	/* domain name */
00db10
+		  int class, int type,	/* class and type of query */
00db10
+		  u_char *answer,	/* buffer to put answer */
00db10
+		  int anslen,		/* size of answer buffer */
00db10
+		  u_char **answerp,	/* if buffer needs to be enlarged */
00db10
+		  u_char **answerp2,
00db10
+		  int *nanswerp2,
00db10
+		  int *resplen2,
00db10
+		  int *answerp2_malloced)
00db10
+{
00db10
+  if (statp == &_res)
00db10
+    {
00db10
+      struct resolv_context *ctx = __resolv_context_get ();
00db10
+      if (ctx == NULL)
00db10
+	{
00db10
+	  __set_h_errno (NO_RECOVERY);
00db10
+	  return -1;
00db10
+	}
00db10
+      int ret = qf (ctx, name, class, type,
00db10
+		    answer, anslen, answerp, answerp2,
00db10
+		    nanswerp2, resplen2, answerp2_malloced);
00db10
+      __resolv_context_put (ctx);
00db10
+      return ret;
00db10
+    }
00db10
+  else
00db10
+    {
00db10
+      __set_h_errno (NO_RECOVERY);
00db10
+      __set_errno (ENOTSUP);
00db10
+      return -1;
00db10
+    }
00db10
+}
00db10
+
00db10
+attribute_compat_text_section
00db10
+int
00db10
+__libc_res_nquery(res_state statp,
00db10
+		  const char *name,	/* domain name */
00db10
+		  int class, int type,	/* class and type of query */
00db10
+		  u_char *answer,	/* buffer to put answer */
00db10
+		  int anslen,		/* size of answer buffer */
00db10
+		  u_char **answerp,	/* if buffer needs to be enlarged */
00db10
+		  u_char **answerp2,
00db10
+		  int *nanswerp2,
00db10
+		  int *resplen2,
00db10
+		  int *answerp2_malloced)
00db10
+{
00db10
+  return wrap_compat_call (__res_context_query, statp, name, class, type,
00db10
+			   answer, anslen, answerp, answerp2,
00db10
+			   nanswerp2, resplen2, answerp2_malloced);
00db10
+}
00db10
+asm (".symver __libc_res_nquery, __libc_res_nquery@GLIBC_PRIVATE");
00db10
+
00db10
+attribute_compat_text_section
00db10
+int
00db10
+__libc_res_nsearch(res_state statp,
00db10
+		   const char *name,	/* domain name */
00db10
+		   int class, int type,	/* class and type of query */
00db10
+		   u_char *answer,	/* buffer to put answer */
00db10
+		   int anslen,		/* size of answer */
00db10
+		   u_char **answerp,
00db10
+		   u_char **answerp2,
00db10
+		   int *nanswerp2,
00db10
+		   int *resplen2,
00db10
+		   int *answerp2_malloced)
00db10
+{
00db10
+  return wrap_compat_call (__res_context_search, statp, name, class, type,
00db10
+			   answer, anslen, answerp, answerp2,
00db10
+			   nanswerp2, resplen2, answerp2_malloced);
00db10
+}
00db10
+asm (".symver __libc_res_nsearch, __libc_res_nsearch@GLIBC_PRIVATE");
00db10
+
00db10
+#endif /* SHARED */
00db10
+
00db10
 #if SHLIB_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_2)
00db10
 # undef res_query
00db10
 # undef res_querydomain