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