fa3bfd
This backports the hesiod subdirectory up to and including these
fa3bfd
upstream commits:
fa3bfd
fa3bfd
commit bfff8b1becd7d01c074177df7196ab327cd8c844
fa3bfd
Author: Joseph Myers <joseph@codesourcery.com>
fa3bfd
Date:   Sun Jan 1 00:14:16 2017 +0000
fa3bfd
fa3bfd
    Update copyright dates with scripts/update-copyrights.
fa3bfd
fa3bfd
commit 8a03ccbb77f52ec4b55062eeedddb8daec1a33e4
fa3bfd
Author: Florian Weimer <fweimer@redhat.com>
fa3bfd
Date:   Mon May 2 16:04:32 2016 +0200
fa3bfd
fa3bfd
    hesiod: Avoid heap overflow in get_txt_records [BZ #20031]
fa3bfd
fa3bfd
It is required to eliminate a dependency on resolver internals.
fa3bfd
fa3bfd
diff --git a/hesiod/Makefile b/hesiod/Makefile
fa3bfd
index 5aeb86eaf8971535..3c967441e17240b4 100644
fa3bfd
--- a/hesiod/Makefile
fa3bfd
+++ b/hesiod/Makefile
fa3bfd
@@ -1,4 +1,4 @@
fa3bfd
-# Copyright (C) 1997, 1998, 2000, 2001, 2012 Free Software Foundation, Inc.
fa3bfd
+# Copyright (C) 1997-2017 Free Software Foundation, Inc.
fa3bfd
 # This file is part of the GNU C Library.
fa3bfd
 
fa3bfd
 # The GNU C Library is free software; you can redistribute it and/or
fa3bfd
@@ -20,13 +20,15 @@
fa3bfd
 #
fa3bfd
 subdir	:= hesiod
fa3bfd
 
fa3bfd
+include ../Makeconfig
fa3bfd
+
fa3bfd
 extra-libs := libnss_hesiod
fa3bfd
 extra-libs-others = $(extra-libs)
fa3bfd
 
fa3bfd
 subdir-dirs = nss_hesiod
fa3bfd
 vpath %.c nss_hesiod
fa3bfd
 
fa3bfd
-libnss_hesiod-routines	:= hesiod hesiod-grp hesiod-init hesiod-proto \
fa3bfd
+libnss_hesiod-routines	:= hesiod hesiod-grp hesiod-proto \
fa3bfd
 			   hesiod-pwd hesiod-service
fa3bfd
 # Build only shared library
fa3bfd
 libnss_hesiod-inhibit-o	= $(filter-out .os,$(object-suffixes))
fa3bfd
diff --git a/hesiod/hesiod.c b/hesiod/hesiod.c
fa3bfd
index 657dabebc144db7d..9b54d1cb6b18f0e5 100644
fa3bfd
--- a/hesiod/hesiod.c
fa3bfd
+++ b/hesiod/hesiod.c
fa3bfd
@@ -1,6 +1,19 @@
fa3bfd
-#if defined(LIBC_SCCS) && !defined(lint)
fa3bfd
-static const char rcsid[] = "$BINDId: hesiod.c,v 1.21 2000/02/28 14:51:08 vixie Exp $";
fa3bfd
-#endif
fa3bfd
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
fa3bfd
+   This file is part of the GNU C Library.
fa3bfd
+
fa3bfd
+   The GNU C Library is free software; you can redistribute it and/or
fa3bfd
+   modify it under the terms of the GNU Lesser General Public
fa3bfd
+   License as published by the Free Software Foundation; either
fa3bfd
+   version 2.1 of the License, or (at your option) any later version.
fa3bfd
+
fa3bfd
+   The GNU C Library is distributed in the hope that it will be useful,
fa3bfd
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
fa3bfd
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
fa3bfd
+   Lesser General Public License for more details.
fa3bfd
+
fa3bfd
+   You should have received a copy of the GNU Lesser General Public
fa3bfd
+   License along with the GNU C Library; if not, see
fa3bfd
+   <http://www.gnu.org/licenses/>.  */
fa3bfd
 
fa3bfd
 /*
fa3bfd
  * Copyright (c) 1996,1999 by Internet Software Consortium.
fa3bfd
@@ -46,24 +59,14 @@ static const char rcsid[] = "$BINDId: hesiod.c,v 1.21 2000/02/28 14:51:08 vixie
fa3bfd
 
fa3bfd
 #include "hesiod.h"
fa3bfd
 #include "hesiod_p.h"
fa3bfd
-#undef DEF_RHS
fa3bfd
 
fa3bfd
 #define _PATH_HESIOD_CONF "/etc/hesiod.conf"
fa3bfd
 
fa3bfd
 /* Forward */
fa3bfd
 
fa3bfd
-int		hesiod_init(void **context);
fa3bfd
-void		hesiod_end(void *context);
fa3bfd
-char *		hesiod_to_bind(void *context, const char *name,
fa3bfd
-			       const char *type);
fa3bfd
-char **		hesiod_resolve(void *context, const char *name,
fa3bfd
-			       const char *type);
fa3bfd
-void		hesiod_free_list(void *context, char **list);
fa3bfd
-
fa3bfd
 static int	parse_config_file(struct hesiod_p *ctx, const char *filename);
fa3bfd
 static char **	get_txt_records(struct hesiod_p *ctx, int class,
fa3bfd
 				const char *name);
fa3bfd
-static int	init(struct hesiod_p *ctx);
fa3bfd
 
fa3bfd
 /* Public */
fa3bfd
 
fa3bfd
@@ -82,7 +85,6 @@ hesiod_init(void **context) {
fa3bfd
 
fa3bfd
 	ctx->LHS = NULL;
fa3bfd
 	ctx->RHS = NULL;
fa3bfd
-	ctx->res = NULL;
fa3bfd
 	/* Set default query classes. */
fa3bfd
 	ctx->classes[0] = C_IN;
fa3bfd
 	ctx->classes[1] = C_HS;
fa3bfd
@@ -91,19 +93,7 @@ hesiod_init(void **context) {
fa3bfd
 	if (!configname)
fa3bfd
 	  configname = _PATH_HESIOD_CONF;
fa3bfd
 	if (parse_config_file(ctx, configname) < 0) {
fa3bfd
-#ifdef DEF_RHS
fa3bfd
-		/*
fa3bfd
-		 * Use compiled in defaults.
fa3bfd
-		 */
fa3bfd
-		ctx->LHS = malloc(strlen(DEF_LHS)+1);
fa3bfd
-		ctx->RHS = malloc(strlen(DEF_RHS)+1);
fa3bfd
-		if (ctx->LHS == 0 || ctx->RHS == 0)
fa3bfd
-			goto cleanup;
fa3bfd
-		strcpy(ctx->LHS, DEF_LHS);
fa3bfd
-		strcpy(ctx->RHS, DEF_RHS);
fa3bfd
-#else
fa3bfd
 		goto cleanup;
fa3bfd
-#endif
fa3bfd
 	}
fa3bfd
 	/*
fa3bfd
 	 * The default RHS can be overridden by an environment
fa3bfd
@@ -131,11 +121,6 @@ hesiod_init(void **context) {
fa3bfd
 		goto cleanup;
fa3bfd
 	}
fa3bfd
 
fa3bfd
-#if 0
fa3bfd
-	if (res_ninit(ctx->res) < 0)
fa3bfd
-		goto cleanup;
fa3bfd
-#endif
fa3bfd
-
fa3bfd
 	*context = ctx;
fa3bfd
 	return (0);
fa3bfd
 
fa3bfd
@@ -152,12 +137,8 @@ hesiod_end(void *context) {
fa3bfd
 	struct hesiod_p *ctx = (struct hesiod_p *) context;
fa3bfd
 	int save_errno = errno;
fa3bfd
 
fa3bfd
-	if (ctx->res)
fa3bfd
-		res_nclose(ctx->res);
fa3bfd
 	free(ctx->RHS);
fa3bfd
 	free(ctx->LHS);
fa3bfd
-	if (ctx->res && ctx->free_res)
fa3bfd
-		(*ctx->free_res)(ctx->res);
fa3bfd
 	free(ctx);
fa3bfd
 	__set_errno(save_errno);
fa3bfd
 }
fa3bfd
@@ -232,10 +213,6 @@ hesiod_resolve(void *context, const char *name, const char *type) {
fa3bfd
 
fa3bfd
 	if (bindname == NULL)
fa3bfd
 		return (NULL);
fa3bfd
-	if (init(ctx) == -1) {
fa3bfd
-		free(bindname);
fa3bfd
-		return (NULL);
fa3bfd
-	}
fa3bfd
 
fa3bfd
 	retvec = get_txt_records(ctx, ctx->classes[0], bindname);
fa3bfd
 
fa3bfd
@@ -365,13 +342,13 @@ get_txt_records(struct hesiod_p *ctx, int class, const char *name) {
fa3bfd
 	/*
fa3bfd
 	 * Construct the query and send it.
fa3bfd
 	 */
fa3bfd
-	n = res_nmkquery(ctx->res, QUERY, name, class, T_TXT, NULL, 0,
fa3bfd
+	n = res_mkquery(QUERY, name, class, T_TXT, NULL, 0,
fa3bfd
 			 NULL, qbuf, MAX_HESRESP);
fa3bfd
 	if (n < 0) {
fa3bfd
 		__set_errno(EMSGSIZE);
fa3bfd
 		return (NULL);
fa3bfd
 	}
fa3bfd
-	n = res_nsend(ctx->res, qbuf, n, abuf, MAX_HESRESP);
fa3bfd
+	n = res_send(qbuf, n, abuf, MAX_HESRESP);
fa3bfd
 	if (n < 0) {
fa3bfd
 		__set_errno(ECONNREFUSED);
fa3bfd
 		return (NULL);
fa3bfd
@@ -421,7 +398,7 @@ get_txt_records(struct hesiod_p *ctx, int class, const char *name) {
fa3bfd
 		cp += INT16SZ + INT32SZ;	/* skip the ttl, too */
fa3bfd
 		rr.dlen = ns_get16(cp);
fa3bfd
 		cp += INT16SZ;
fa3bfd
-		if (cp + rr.dlen > eom) {
fa3bfd
+		if (rr.dlen == 0 || cp + rr.dlen > eom) {
fa3bfd
 			__set_errno(EMSGSIZE);
fa3bfd
 			goto cleanup;
fa3bfd
 		}
fa3bfd
@@ -464,44 +441,3 @@ get_txt_records(struct hesiod_p *ctx, int class, const char *name) {
fa3bfd
 	free(list);
fa3bfd
 	return (NULL);
fa3bfd
 }
fa3bfd
-
fa3bfd
-struct __res_state *
fa3bfd
-__hesiod_res_get(void *context) {
fa3bfd
-	struct hesiod_p *ctx = context;
fa3bfd
-
fa3bfd
-	if (!ctx->res) {
fa3bfd
-		struct __res_state *res;
fa3bfd
-		res = (struct __res_state *)calloc(1, sizeof *res);
fa3bfd
-		if (res == NULL)
fa3bfd
-			return (NULL);
fa3bfd
-		__hesiod_res_set(ctx, res, free);
fa3bfd
-	}
fa3bfd
-
fa3bfd
-	return (ctx->res);
fa3bfd
-}
fa3bfd
-
fa3bfd
-void
fa3bfd
-__hesiod_res_set(void *context, struct __res_state *res,
fa3bfd
-		 void (*free_res)(void *)) {
fa3bfd
-	struct hesiod_p *ctx = context;
fa3bfd
-
fa3bfd
-	if (ctx->res && ctx->free_res) {
fa3bfd
-		res_nclose(ctx->res);
fa3bfd
-		(*ctx->free_res)(ctx->res);
fa3bfd
-	}
fa3bfd
-
fa3bfd
-	ctx->res = res;
fa3bfd
-	ctx->free_res = free_res;
fa3bfd
-}
fa3bfd
-
fa3bfd
-static int
fa3bfd
-init(struct hesiod_p *ctx) {
fa3bfd
-
fa3bfd
-	if (!ctx->res && !__hesiod_res_get(ctx))
fa3bfd
-		return (-1);
fa3bfd
-
fa3bfd
-	if (__res_maybe_init (ctx->res, 0) == -1)
fa3bfd
-		return (-1);
fa3bfd
-
fa3bfd
-	return (0);
fa3bfd
-}
fa3bfd
diff --git a/hesiod/hesiod.h b/hesiod/hesiod.h
fa3bfd
index 82fce30764e15071..2cb640a7df668cab 100644
fa3bfd
--- a/hesiod/hesiod.h
fa3bfd
+++ b/hesiod/hesiod.h
fa3bfd
@@ -1,3 +1,20 @@
fa3bfd
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
fa3bfd
+   This file is part of the GNU C Library.
fa3bfd
+
fa3bfd
+   The GNU C Library is free software; you can redistribute it and/or
fa3bfd
+   modify it under the terms of the GNU Lesser General Public
fa3bfd
+   License as published by the Free Software Foundation; either
fa3bfd
+   version 2.1 of the License, or (at your option) any later version.
fa3bfd
+
fa3bfd
+   The GNU C Library is distributed in the hope that it will be useful,
fa3bfd
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
fa3bfd
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
fa3bfd
+   Lesser General Public License for more details.
fa3bfd
+
fa3bfd
+   You should have received a copy of the GNU Lesser General Public
fa3bfd
+   License along with the GNU C Library; if not, see
fa3bfd
+   <http://www.gnu.org/licenses/>.  */
fa3bfd
+
fa3bfd
 /*
fa3bfd
  * Copyright (c) 1996,1999 by Internet Software Consortium.
fa3bfd
  *
fa3bfd
@@ -19,22 +36,15 @@
fa3bfd
  * This file is primarily maintained by <tytso@mit.edu> and <ghudson@mit.edu>.
fa3bfd
  */
fa3bfd
 
fa3bfd
-/*
fa3bfd
- * $BINDId: hesiod.h,v 1.7 1999/01/08 19:22:45 vixie Exp $
fa3bfd
- */
fa3bfd
-
fa3bfd
 #ifndef _HESIOD_H_INCLUDED
fa3bfd
 #define _HESIOD_H_INCLUDED
fa3bfd
 
fa3bfd
-int		hesiod_init (void **context);
fa3bfd
-void		hesiod_end (void *context);
fa3bfd
+int		hesiod_init (void **context) attribute_hidden;
fa3bfd
+void		hesiod_end (void *context) attribute_hidden;
fa3bfd
 char *		hesiod_to_bind (void *context, const char *name,
fa3bfd
-				const char *type);
fa3bfd
+				const char *type) attribute_hidden;
fa3bfd
 char **		hesiod_resolve (void *context, const char *name,
fa3bfd
-				const char *type);
fa3bfd
-void		hesiod_free_list (void *context, char **list);
fa3bfd
-struct __res_state * __hesiod_res_get (void *context);
fa3bfd
-void		__hesiod_res_set (void *context, struct __res_state *,
fa3bfd
-				  void (*)(void *));
fa3bfd
+				const char *type) attribute_hidden;
fa3bfd
+void		hesiod_free_list (void *context, char **list) attribute_hidden;
fa3bfd
 
fa3bfd
 #endif /*_HESIOD_H_INCLUDED*/
fa3bfd
diff --git a/hesiod/hesiod_p.h b/hesiod/hesiod_p.h
fa3bfd
index 5010d71bc91879c4..7ed70158d9ffc5cc 100644
fa3bfd
--- a/hesiod/hesiod_p.h
fa3bfd
+++ b/hesiod/hesiod_p.h
fa3bfd
@@ -1,3 +1,20 @@
fa3bfd
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
fa3bfd
+   This file is part of the GNU C Library.
fa3bfd
+
fa3bfd
+   The GNU C Library is free software; you can redistribute it and/or
fa3bfd
+   modify it under the terms of the GNU Lesser General Public
fa3bfd
+   License as published by the Free Software Foundation; either
fa3bfd
+   version 2.1 of the License, or (at your option) any later version.
fa3bfd
+
fa3bfd
+   The GNU C Library is distributed in the hope that it will be useful,
fa3bfd
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
fa3bfd
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
fa3bfd
+   Lesser General Public License for more details.
fa3bfd
+
fa3bfd
+   You should have received a copy of the GNU Lesser General Public
fa3bfd
+   License along with the GNU C Library; if not, see
fa3bfd
+   <http://www.gnu.org/licenses/>.  */
fa3bfd
+
fa3bfd
 /*
fa3bfd
  * Copyright (c) 1996,1999 by Internet Software Consortium.
fa3bfd
  *
fa3bfd
@@ -20,27 +37,17 @@
fa3bfd
  */
fa3bfd
 
fa3bfd
 /*
fa3bfd
- * $BINDId: hesiod_p.h,v 1.9 1999/01/08 19:24:39 vixie Exp $
fa3bfd
- */
fa3bfd
-
fa3bfd
-/*
fa3bfd
  * hesiod_p.h -- private definitions for the hesiod library
fa3bfd
  */
fa3bfd
 
fa3bfd
 #ifndef _HESIOD_P_H_INCLUDED
fa3bfd
 #define _HESIOD_P_H_INCLUDED
fa3bfd
 
fa3bfd
-#define DEF_RHS		".Athena.MIT.EDU"	/* Defaults if HESIOD_CONF */
fa3bfd
 #define DEF_LHS		".ns"			/*    file is not */
fa3bfd
 						/*    present. */
fa3bfd
 struct hesiod_p {
fa3bfd
 	char *		LHS;		/* normally ".ns" */
fa3bfd
 	char *		RHS;		/* AKA the default hesiod domain */
fa3bfd
-	struct __res_state * res;	/* resolver context */
fa3bfd
-	void		(*free_res)(void *);
fa3bfd
-	void		(*res_set)(struct hesiod_p *, struct __res_state *,
fa3bfd
-				   void (*)(void *));
fa3bfd
-	struct __res_state * (*res_get)(struct hesiod_p *);
fa3bfd
 	int		classes[2];	/* The class search order. */
fa3bfd
 };
fa3bfd
 
fa3bfd
diff --git a/hesiod/nss_hesiod/hesiod-grp.c b/hesiod/nss_hesiod/hesiod-grp.c
fa3bfd
index 5c14554ce9fd647e..a04f5309453047e2 100644
fa3bfd
--- a/hesiod/nss_hesiod/hesiod-grp.c
fa3bfd
+++ b/hesiod/nss_hesiod/hesiod-grp.c
fa3bfd
@@ -1,4 +1,4 @@
fa3bfd
-/* Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
fa3bfd
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
fa3bfd
    This file is part of the GNU C Library.
fa3bfd
    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
fa3bfd
 
fa3bfd
@@ -26,8 +26,6 @@
fa3bfd
 #include <string.h>
fa3bfd
 #include <sys/param.h>
fa3bfd
 
fa3bfd
-#include "nss_hesiod.h"
fa3bfd
-
fa3bfd
 /* Get the declaration of the parser function.  */
fa3bfd
 #define ENTNAME grent
fa3bfd
 #define STRUCTURE group
fa3bfd
@@ -58,8 +56,7 @@ lookup (const char *name, const char *type, struct group *grp,
fa3bfd
   size_t len;
fa3bfd
   int olderr = errno;
fa3bfd
 
fa3bfd
-  context = _nss_hesiod_init ();
fa3bfd
-  if (context == NULL)
fa3bfd
+  if (hesiod_init (&context) < 0)
fa3bfd
     return NSS_STATUS_UNAVAIL;
fa3bfd
 
fa3bfd
   list = hesiod_resolve (context, name, type);
fa3bfd
@@ -179,8 +176,7 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
fa3bfd
   gid_t *groups = *groupsp;
fa3bfd
   int save_errno;
fa3bfd
 
fa3bfd
-  context = _nss_hesiod_init ();
fa3bfd
-  if (context == NULL)
fa3bfd
+  if (hesiod_init (&context) < 0)
fa3bfd
     return NSS_STATUS_UNAVAIL;
fa3bfd
 
fa3bfd
   list = hesiod_resolve (context, user, "grplist");
fa3bfd
@@ -191,33 +187,6 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
fa3bfd
       return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL;
fa3bfd
     }
fa3bfd
 
fa3bfd
-  if (!internal_gid_in_list (groups, group, *start))
fa3bfd
-    {
fa3bfd
-      if (__builtin_expect (*start == *size, 0))
fa3bfd
-	{
fa3bfd
-	  /* Need a bigger buffer.  */
fa3bfd
-	  gid_t *newgroups;
fa3bfd
-	  long int newsize;
fa3bfd
-
fa3bfd
-	  if (limit > 0 && *size == limit)
fa3bfd
-	    /* We reached the maximum.  */
fa3bfd
-	    goto done;
fa3bfd
-
fa3bfd
-	  if (limit <= 0)
fa3bfd
-	    newsize = 2 * *size;
fa3bfd
-	  else
fa3bfd
-	    newsize = MIN (limit, 2 * *size);
fa3bfd
-
fa3bfd
-	  newgroups = realloc (groups, newsize * sizeof (*groups));
fa3bfd
-	  if (newgroups == NULL)
fa3bfd
-	    goto done;
fa3bfd
-	  *groupsp = groups = newgroups;
fa3bfd
-	  *size = newsize;
fa3bfd
-	}
fa3bfd
-
fa3bfd
-      groups[(*start)++] = group;
fa3bfd
-    }
fa3bfd
-
fa3bfd
   save_errno = errno;
fa3bfd
 
fa3bfd
   p = *list;
fa3bfd
@@ -254,7 +223,7 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
fa3bfd
 	  if (status == NSS_STATUS_SUCCESS
fa3bfd
 	      && !internal_gid_in_list (groups, group, *start))
fa3bfd
 	    {
fa3bfd
-	      if (__builtin_expect (*start == *size, 0))
fa3bfd
+	      if (__glibc_unlikely (*start == *size))
fa3bfd
 		{
fa3bfd
 		  /* Need a bigger buffer.  */
fa3bfd
 		  gid_t *newgroups;
fa3bfd
diff --git a/hesiod/nss_hesiod/hesiod-init.c b/hesiod/nss_hesiod/hesiod-init.c
fa3bfd
deleted file mode 100644
fa3bfd
index 964987d0755425b5..0000000000000000
fa3bfd
--- a/hesiod/nss_hesiod/hesiod-init.c
fa3bfd
+++ /dev/null
fa3bfd
@@ -1,38 +0,0 @@
fa3bfd
-/* Copyright (C) 2000 Free Software Foundation, Inc.
fa3bfd
-   This file is part of the GNU C Library.
fa3bfd
-   Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 2000.
fa3bfd
-
fa3bfd
-   The GNU C Library is free software; you can redistribute it and/or
fa3bfd
-   modify it under the terms of the GNU Lesser General Public
fa3bfd
-   License as published by the Free Software Foundation; either
fa3bfd
-   version 2.1 of the License, or (at your option) any later version.
fa3bfd
-
fa3bfd
-   The GNU C Library is distributed in the hope that it will be useful,
fa3bfd
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
fa3bfd
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
fa3bfd
-   Lesser General Public License for more details.
fa3bfd
-
fa3bfd
-   You should have received a copy of the GNU Lesser General Public
fa3bfd
-   License along with the GNU C Library; if not, see
fa3bfd
-   <http://www.gnu.org/licenses/>.  */
fa3bfd
-
fa3bfd
-#include <sys/cdefs.h>		/* Needs to come before <hesiod.h>.  */
fa3bfd
-#include <hesiod.h>
fa3bfd
-#include <resolv.h>
fa3bfd
-#include <stddef.h>
fa3bfd
-
fa3bfd
-#include "nss_hesiod.h"
fa3bfd
-
fa3bfd
-void *
fa3bfd
-_nss_hesiod_init (void)
fa3bfd
-{
fa3bfd
-  void *context;
fa3bfd
-
fa3bfd
-  if (hesiod_init (&context) == -1)
fa3bfd
-    return NULL;
fa3bfd
-
fa3bfd
-  /* Use the default (per-thread) resolver state.  */
fa3bfd
-  __hesiod_res_set (context, &_res, NULL);
fa3bfd
-
fa3bfd
-  return context;
fa3bfd
-}
fa3bfd
diff --git a/hesiod/nss_hesiod/hesiod-proto.c b/hesiod/nss_hesiod/hesiod-proto.c
fa3bfd
index 7ea38bc24fbff3ca..6af32aad35edfc0a 100644
fa3bfd
--- a/hesiod/nss_hesiod/hesiod-proto.c
fa3bfd
+++ b/hesiod/nss_hesiod/hesiod-proto.c
fa3bfd
@@ -1,4 +1,4 @@
fa3bfd
-/* Copyright (C) 1997, 2000, 2002 Free Software Foundation, Inc.
fa3bfd
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
fa3bfd
    This file is part of the GNU C Library.
fa3bfd
    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
fa3bfd
 
fa3bfd
@@ -25,8 +25,6 @@
fa3bfd
 #include <stdlib.h>
fa3bfd
 #include <string.h>
fa3bfd
 
fa3bfd
-#include "nss_hesiod.h"
fa3bfd
-
fa3bfd
 /* Declare a parser for Hesiod protocol entries.  Although the format
fa3bfd
    of the entries is identical to those in /etc/protocols, here is no
fa3bfd
    predefined parser for us to use.  */
fa3bfd
@@ -68,8 +66,7 @@ lookup (const char *name, const char *type, struct protoent *proto,
fa3bfd
   int found;
fa3bfd
   int olderr = errno;
fa3bfd
 
fa3bfd
-  context = _nss_hesiod_init ();
fa3bfd
-  if (context == NULL)
fa3bfd
+  if (hesiod_init (&context) < 0)
fa3bfd
     return NSS_STATUS_UNAVAIL;
fa3bfd
 
fa3bfd
   list = hesiod_resolve (context, name, type);
fa3bfd
diff --git a/hesiod/nss_hesiod/hesiod-pwd.c b/hesiod/nss_hesiod/hesiod-pwd.c
fa3bfd
index 929cbce80e238a67..8309af245d3f0268 100644
fa3bfd
--- a/hesiod/nss_hesiod/hesiod-pwd.c
fa3bfd
+++ b/hesiod/nss_hesiod/hesiod-pwd.c
fa3bfd
@@ -1,4 +1,4 @@
fa3bfd
-/* Copyright (C) 1997, 2000, 2002 Free Software Foundation, Inc.
fa3bfd
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
fa3bfd
    This file is part of the GNU C Library.
fa3bfd
    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
fa3bfd
 
fa3bfd
@@ -24,8 +24,6 @@
fa3bfd
 #include <stdlib.h>
fa3bfd
 #include <string.h>
fa3bfd
 
fa3bfd
-#include "nss_hesiod.h"
fa3bfd
-
fa3bfd
 /* Get the declaration of the parser function.  */
fa3bfd
 #define ENTNAME pwent
fa3bfd
 #define STRUCTURE passwd
fa3bfd
@@ -56,8 +54,7 @@ lookup (const char *name, const char *type, struct passwd *pwd,
fa3bfd
   size_t len;
fa3bfd
   int olderr = errno;
fa3bfd
 
fa3bfd
-  context = _nss_hesiod_init ();
fa3bfd
-  if (context == NULL)
fa3bfd
+  if (hesiod_init (&context) < 0)
fa3bfd
     return NSS_STATUS_UNAVAIL;
fa3bfd
 
fa3bfd
   list = hesiod_resolve (context, name, type);
fa3bfd
diff --git a/hesiod/nss_hesiod/hesiod-service.c b/hesiod/nss_hesiod/hesiod-service.c
fa3bfd
index 28bd31a70f31c89c..1942188517d94508 100644
fa3bfd
--- a/hesiod/nss_hesiod/hesiod-service.c
fa3bfd
+++ b/hesiod/nss_hesiod/hesiod-service.c
fa3bfd
@@ -1,4 +1,4 @@
fa3bfd
-/* Copyright (C) 1997, 2000, 2002 Free Software Foundation, Inc.
fa3bfd
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
fa3bfd
    This file is part of the GNU C Library.
fa3bfd
    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
fa3bfd
 
fa3bfd
@@ -25,8 +25,6 @@
fa3bfd
 #include <stdlib.h>
fa3bfd
 #include <string.h>
fa3bfd
 
fa3bfd
-#include "nss_hesiod.h"
fa3bfd
-
fa3bfd
 /* Hesiod uses a format for service entries that differs from the
fa3bfd
    traditional format.  We therefore declare our own parser.  */
fa3bfd
 
fa3bfd
@@ -69,8 +67,7 @@ lookup (const char *name, const char *type, const char *protocol,
fa3bfd
   int found;
fa3bfd
   int olderr = errno;
fa3bfd
 
fa3bfd
-  context = _nss_hesiod_init ();
fa3bfd
-  if (context == NULL)
fa3bfd
+  if (hesiod_init (&context) < 0)
fa3bfd
     return NSS_STATUS_UNAVAIL;
fa3bfd
 
fa3bfd
   list = hesiod_resolve (context, name, type);
fa3bfd
diff --git a/hesiod/nss_hesiod/nss_hesiod.h b/hesiod/nss_hesiod/nss_hesiod.h
fa3bfd
deleted file mode 100644
fa3bfd
index fdf0241860b7e825..0000000000000000
fa3bfd
--- a/hesiod/nss_hesiod/nss_hesiod.h
fa3bfd
+++ /dev/null
fa3bfd
@@ -1,20 +0,0 @@
fa3bfd
-/* Copyright (C) 2000 Free Software Foundation, Inc.
fa3bfd
-   This file is part of the GNU C Library.
fa3bfd
-   Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 2000.
fa3bfd
-
fa3bfd
-   The GNU C Library is free software; you can redistribute it and/or
fa3bfd
-   modify it under the terms of the GNU Lesser General Public
fa3bfd
-   License as published by the Free Software Foundation; either
fa3bfd
-   version 2.1 of the License, or (at your option) any later version.
fa3bfd
-
fa3bfd
-   The GNU C Library is distributed in the hope that it will be useful,
fa3bfd
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
fa3bfd
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
fa3bfd
-   Lesser General Public License for more details.
fa3bfd
-
fa3bfd
-   You should have received a copy of the GNU Lesser General Public
fa3bfd
-   License along with the GNU C Library; if not, see
fa3bfd
-   <http://www.gnu.org/licenses/>.  */
fa3bfd
-
fa3bfd
-/* Initialize a Hesiod context.  */
fa3bfd
-extern void *_nss_hesiod_init (void);