* nis/nss_nis/nis-hosts.c: Make _nss_nis_endhostent an alias of
	_nss_nis_sethostent.  Work around the different prototypes.
	* nis/nss_nis/nis-grp.c: Make _nss_nis_endgrent an alias of
	_nss_nis_setgrent.  Work around the different prototypes.
	* nis/nss_nis/nis-ethers.c (internal_nis_endetherent): New
	function.  Split out from _nss_nis_endetherent.
	(internal_nis_setetherent): Use internal_nis_endetherent instead of
	duplicating the code.
	* nis/nss_nis/nis-alias.c: Make _nss_nss_nis_endaliasent an alias
	of _nss_nis_setaliasent.
	* nis/nss_nis/nis-service.c (internal_nis_setservent): Reuse
	internal_nis_endservent code, don't duplicate it.
This commit is contained in:
Ulrich Drepper 2003-01-18 10:42:51 +00:00
parent 039c1b7527
commit 6675b19146
6 changed files with 96 additions and 130 deletions

View File

@ -1,5 +1,18 @@
2003-01-18 Ulrich Drepper <drepper@redhat.com>
* nis/nss_nis/nis-hosts.c: Make _nss_nis_endhostent an alias of
_nss_nis_sethostent. Work around the different prototypes.
* nis/nss_nis/nis-grp.c: Make _nss_nis_endgrent an alias of
_nss_nis_setgrent. Work around the different prototypes.
* nis/nss_nis/nis-ethers.c (internal_nis_endetherent): New
function. Split out from _nss_nis_endetherent.
(internal_nis_setetherent): Use internal_nis_endetherent instead of
duplicating the code.
* nis/nss_nis/nis-alias.c: Make _nss_nss_nis_endaliasent an alias
of _nss_nis_setaliasent.
* nis/nss_nis/nis-service.c (internal_nis_setservent): Reuse
internal_nis_endservent code, don't duplicate it.
* inet/rexec.c (rexec_af): Protect socket operations with
TEMP_FAILURE_RETRY. Use writev instead of multiple write.
* inet/rcmd.c (rcmd_af): Likewise.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996,1997,1998,1999,2001,2002 Free Software Foundation, Inc.
/* Copyright (C) 1996-2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@ -117,24 +117,8 @@ _nss_nis_setaliasent (void)
return NSS_STATUS_SUCCESS;
}
enum nss_status
_nss_nis_endaliasent (void)
{
__libc_lock_lock (lock);
new_start = 1;
if (oldkey != NULL)
{
free (oldkey);
oldkey = NULL;
oldkeylen = 0;
}
__libc_lock_unlock (lock);
return NSS_STATUS_SUCCESS;
}
/* The 'endaliasent' function is identical. */
strong_alias (_nss_nis_setaliasent, _nss_nis_endaliasent)
static enum nss_status
internal_nis_getaliasent_r (struct aliasent *alias, char *buffer,

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996-2000, 2001, 2002 Free Software Foundation, Inc.
/* Copyright (C) 1996-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@ -81,6 +81,32 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
return 0;
}
static void
internal_nis_endetherent (void)
{
while (start != NULL)
{
if (start->val != NULL)
free (start->val);
next = start;
start = start->next;
free (next);
}
}
enum nss_status
_nss_nis_endetherent (void)
{
__libc_lock_lock (lock);
internal_nis_endetherent ();
next = NULL;
__libc_lock_unlock (lock);
return NSS_STATUS_SUCCESS;
}
static enum nss_status
internal_nis_setetherent (void)
{
@ -90,15 +116,7 @@ internal_nis_setetherent (void)
yp_get_default_domain (&domainname);
while (start != NULL)
{
if (start->val != NULL)
free (start->val);
next = start;
start = start->next;
free (next);
}
start = NULL;
internal_nis_endetherent ();
ypcb.foreach = saveit;
ypcb.data = NULL;
@ -122,27 +140,6 @@ _nss_nis_setetherent (int stayopen)
return result;
}
enum nss_status
_nss_nis_endetherent (void)
{
__libc_lock_lock (lock);
while (start != NULL)
{
if (start->val != NULL)
free (start->val);
next = start;
start = start->next;
free (next);
}
start = NULL;
next = NULL;
__libc_lock_unlock (lock);
return NSS_STATUS_SUCCESS;
}
static enum nss_status
internal_nis_getetherent_r (struct etherent *eth, char *buffer, size_t buflen,
int *errnop)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996,1997,1998,1999,2001,2002 Free Software Foundation, Inc.
/* Copyright (C) 1996-1999, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@ -18,7 +18,11 @@
02111-1307 USA. */
#include <nss.h>
/* The following is an ugly trick to avoid a prototype declaration for
_nss_nis_endgrent. */
#define _nss_nis_endgrent _nss_nis_endgrent_XXX
#include <grp.h>
#undef _nss_nis_endgrent
#include <ctype.h>
#include <errno.h>
#include <string.h>
@ -58,24 +62,10 @@ _nss_nis_setgrent (int stayopen)
return NSS_STATUS_SUCCESS;
}
enum nss_status
_nss_nis_endgrent (void)
{
__libc_lock_lock (lock);
new_start = 1;
if (oldkey != NULL)
{
free (oldkey);
oldkey = NULL;
oldkeylen = 0;
}
__libc_lock_unlock (lock);
return NSS_STATUS_SUCCESS;
}
/* Make _nss_nis_endgrent an alias of _nss_nis_setgrent. We do this
even though the prototypes don't match. The argument of setgrent
is used so this makes no difference. */
strong_alias (_nss_nis_setgrent, _nss_nis_endgrent)
static enum nss_status
internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen,

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996,1997,1998,1999,2000,2002 Free Software Foundation, Inc.
/* Copyright (C) 1996-2000, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@ -19,7 +19,11 @@
#include <nss.h>
#include <ctype.h>
/* The following is an ugly trick to avoid a prototype declaration for
_nss_nis_endgrent. */
#define _nss_nis_endhostent _nss_nis_endhostent_XXX
#include <netdb.h>
#undef _nss_nis_endhostent
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@ -115,24 +119,10 @@ _nss_nis_sethostent (int stayopen)
return NSS_STATUS_SUCCESS;
}
enum nss_status
_nss_nis_endhostent (void)
{
__libc_lock_lock (lock);
new_start = 1;
if (oldkey != NULL)
{
free (oldkey);
oldkey = NULL;
oldkeylen = 0;
}
__libc_lock_unlock (lock);
return NSS_STATUS_SUCCESS;
}
/* Make _nss_nis_endhostent an alias of _nss_nis_sethostent. We do this
even though the prototypes don't match. The argument of sethostent
is used so this makes no difference. */
strong_alias (_nss_nis_sethostent, _nss_nis_endhostent)
/* The calling function always need to get a lock first. */
static enum nss_status

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc.
/* Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@ -87,47 +87,6 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
return 0;
}
static enum nss_status
internal_nis_setservent (intern_t *intern)
{
char *domainname;
struct ypall_callback ypcb;
enum nss_status status;
if (yp_get_default_domain (&domainname))
return NSS_STATUS_UNAVAIL;
while (intern->start != NULL)
{
if (intern->start->val != NULL)
free (intern->start->val);
intern->next = intern->start;
intern->start = intern->start->next;
free (intern->next);
}
intern->start = NULL;
ypcb.foreach = saveit;
ypcb.data = (char *) intern;
status = yperr2nss (yp_all (domainname, "services.byname", &ypcb));
intern->next = intern->start;
return status;
}
enum nss_status
_nss_nis_setservent (int stayopen)
{
enum nss_status status;
__libc_lock_lock (lock);
status = internal_nis_setservent (&intern);
__libc_lock_unlock (lock);
return status;
}
static enum nss_status
internal_nis_endservent (intern_t * intern)
{
@ -158,6 +117,39 @@ _nss_nis_endservent (void)
return status;
}
static enum nss_status
internal_nis_setservent (intern_t *intern)
{
char *domainname;
struct ypall_callback ypcb;
enum nss_status status;
if (yp_get_default_domain (&domainname))
return NSS_STATUS_UNAVAIL;
(void) internal_nis_endservent (intern);
ypcb.foreach = saveit;
ypcb.data = (char *) intern;
status = yperr2nss (yp_all (domainname, "services.byname", &ypcb));
intern->next = intern->start;
return status;
}
enum nss_status
_nss_nis_setservent (int stayopen)
{
enum nss_status status;
__libc_lock_lock (lock);
status = internal_nis_setservent (&intern);
__libc_lock_unlock (lock);
return status;
}
static enum nss_status
internal_nis_getservent_r (struct servent *serv, char *buffer,
size_t buflen, int *errnop, intern_t *data)