From 5018f16c6205404ba3aa7298dc8a3d45fbd46bfc Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Mon, 2 May 2016 15:25:20 +0200 Subject: hesiod: Always use thread-local resolver state [BZ #19573] The Hesiod implementation imported into glibc was enhanced to support caller-supplied resolver states. But its only consumer is nss_hesiod, and it supplies the thread-local resolver state. Therefore, this commit changes the Hesiod implementation to use the thread-local resolver state (_res) directly. This fixes bug 19573 because the Hesiod implementation no longer has to initialize and free any resolver state. To avoid any risk of interposition of ABI-incompatible Hesiod function implementations, this commit marks the Hesiod functions as hidden. (They were already hidden using a linker version script.) --- hesiod/nss_hesiod/hesiod-grp.c | 8 ++------ hesiod/nss_hesiod/hesiod-init.c | 38 -------------------------------------- hesiod/nss_hesiod/hesiod-proto.c | 5 +---- hesiod/nss_hesiod/hesiod-pwd.c | 5 +---- hesiod/nss_hesiod/hesiod-service.c | 5 +---- hesiod/nss_hesiod/nss_hesiod.h | 20 -------------------- 6 files changed, 5 insertions(+), 76 deletions(-) delete mode 100644 hesiod/nss_hesiod/hesiod-init.c delete mode 100644 hesiod/nss_hesiod/nss_hesiod.h (limited to 'hesiod/nss_hesiod') diff --git a/hesiod/nss_hesiod/hesiod-grp.c b/hesiod/nss_hesiod/hesiod-grp.c index 7e4ecb4..944e5e0 100644 --- a/hesiod/nss_hesiod/hesiod-grp.c +++ b/hesiod/nss_hesiod/hesiod-grp.c @@ -26,8 +26,6 @@ #include #include -#include "nss_hesiod.h" - /* Get the declaration of the parser function. */ #define ENTNAME grent #define STRUCTURE group @@ -58,8 +56,7 @@ lookup (const char *name, const char *type, struct group *grp, size_t len; int olderr = errno; - context = _nss_hesiod_init (); - if (context == NULL) + if (hesiod_init (&context) < 0) return NSS_STATUS_UNAVAIL; list = hesiod_resolve (context, name, type); @@ -179,8 +176,7 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start, gid_t *groups = *groupsp; int save_errno; - context = _nss_hesiod_init (); - if (context == NULL) + if (hesiod_init (&context) < 0) return NSS_STATUS_UNAVAIL; list = hesiod_resolve (context, user, "grplist"); diff --git a/hesiod/nss_hesiod/hesiod-init.c b/hesiod/nss_hesiod/hesiod-init.c deleted file mode 100644 index 2315040..0000000 --- a/hesiod/nss_hesiod/hesiod-init.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Mark Kettenis , 2000. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include /* Needs to come before . */ -#include -#include -#include - -#include "nss_hesiod.h" - -void * -_nss_hesiod_init (void) -{ - void *context; - - if (hesiod_init (&context) == -1) - return NULL; - - /* Use the default (per-thread) resolver state. */ - __hesiod_res_set (context, &_res, NULL); - - return context; -} diff --git a/hesiod/nss_hesiod/hesiod-proto.c b/hesiod/nss_hesiod/hesiod-proto.c index 3c59e73..8a13bba 100644 --- a/hesiod/nss_hesiod/hesiod-proto.c +++ b/hesiod/nss_hesiod/hesiod-proto.c @@ -25,8 +25,6 @@ #include #include -#include "nss_hesiod.h" - /* Declare a parser for Hesiod protocol entries. Although the format of the entries is identical to those in /etc/protocols, here is no predefined parser for us to use. */ @@ -68,8 +66,7 @@ lookup (const char *name, const char *type, struct protoent *proto, int found; int olderr = errno; - context = _nss_hesiod_init (); - if (context == NULL) + if (hesiod_init (&context) < 0) return NSS_STATUS_UNAVAIL; list = hesiod_resolve (context, name, type); diff --git a/hesiod/nss_hesiod/hesiod-pwd.c b/hesiod/nss_hesiod/hesiod-pwd.c index 1ddf3e3..c119167 100644 --- a/hesiod/nss_hesiod/hesiod-pwd.c +++ b/hesiod/nss_hesiod/hesiod-pwd.c @@ -24,8 +24,6 @@ #include #include -#include "nss_hesiod.h" - /* Get the declaration of the parser function. */ #define ENTNAME pwent #define STRUCTURE passwd @@ -56,8 +54,7 @@ lookup (const char *name, const char *type, struct passwd *pwd, size_t len; int olderr = errno; - context = _nss_hesiod_init (); - if (context == NULL) + if (hesiod_init (&context) < 0) return NSS_STATUS_UNAVAIL; list = hesiod_resolve (context, name, type); diff --git a/hesiod/nss_hesiod/hesiod-service.c b/hesiod/nss_hesiod/hesiod-service.c index 756345f..2df9cbb 100644 --- a/hesiod/nss_hesiod/hesiod-service.c +++ b/hesiod/nss_hesiod/hesiod-service.c @@ -25,8 +25,6 @@ #include #include -#include "nss_hesiod.h" - /* Hesiod uses a format for service entries that differs from the traditional format. We therefore declare our own parser. */ @@ -69,8 +67,7 @@ lookup (const char *name, const char *type, const char *protocol, int found; int olderr = errno; - context = _nss_hesiod_init (); - if (context == NULL) + if (hesiod_init (&context) < 0) return NSS_STATUS_UNAVAIL; list = hesiod_resolve (context, name, type); diff --git a/hesiod/nss_hesiod/nss_hesiod.h b/hesiod/nss_hesiod/nss_hesiod.h deleted file mode 100644 index a6ed8ee..0000000 --- a/hesiod/nss_hesiod/nss_hesiod.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Mark Kettenis , 2000. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* Initialize a Hesiod context. */ -extern void *_nss_hesiod_init (void); -- cgit v1.1