aboutsummaryrefslogtreecommitdiff
path: root/nis
diff options
context:
space:
mode:
Diffstat (limited to 'nis')
-rw-r--r--nis/nss_nis/nis-alias.c22
-rw-r--r--nis/nss_nis/nis-ethers.c59
-rw-r--r--nis/nss_nis/nis-grp.c28
-rw-r--r--nis/nss_nis/nis-hosts.c28
-rw-r--r--nis/nss_nis/nis-service.c54
5 files changed, 72 insertions, 119 deletions
diff --git a/nis/nss_nis/nis-alias.c b/nis/nss_nis/nis-alias.c
index 2ceaa1da64..fa717be747 100644
--- a/nis/nss_nis/nis-alias.c
+++ b/nis/nss_nis/nis-alias.c
@@ -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,
diff --git a/nis/nss_nis/nis-ethers.c b/nis/nss_nis/nis-ethers.c
index 54f10a5d0d..713fe31e93 100644
--- a/nis/nss_nis/nis-ethers.c
+++ b/nis/nss_nis/nis-ethers.c
@@ -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,15 +81,9 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
return 0;
}
-static enum nss_status
-internal_nis_setetherent (void)
+static void
+internal_nis_endetherent (void)
{
- char *domainname;
- struct ypall_callback ypcb;
- enum nss_status status;
-
- yp_get_default_domain (&domainname);
-
while (start != NULL)
{
if (start->val != NULL)
@@ -98,7 +92,31 @@ internal_nis_setetherent (void)
start = start->next;
free (next);
}
- start = NULL;
+}
+
+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)
+{
+ char *domainname;
+ struct ypall_callback ypcb;
+ enum nss_status status;
+
+ yp_get_default_domain (&domainname);
+
+ 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)
diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c
index 68db76636b..e000e6a825 100644
--- a/nis/nss_nis/nis-grp.c
+++ b/nis/nss_nis/nis-grp.c
@@ -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,
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index 9b0332939c..9e59f59bdd 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -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
diff --git a/nis/nss_nis/nis-service.c b/nis/nss_nis/nis-service.c
index 6affdb5209..c25422f3ca 100644
--- a/nis/nss_nis/nis-service.c
+++ b/nis/nss_nis/nis-service.c
@@ -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.
@@ -88,15 +88,8 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
}
static enum nss_status
-internal_nis_setservent (intern_t *intern)
+internal_nis_endservent (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)
@@ -107,21 +100,17 @@ internal_nis_setservent (intern_t *intern)
}
intern->start = NULL;
- ypcb.foreach = saveit;
- ypcb.data = (char *) intern;
- status = yperr2nss (yp_all (domainname, "services.byname", &ypcb));
- intern->next = intern->start;
-
- return status;
+ return NSS_STATUS_SUCCESS;
}
+
enum nss_status
-_nss_nis_setservent (int stayopen)
+_nss_nis_endservent (void)
{
enum nss_status status;
__libc_lock_lock (lock);
- status = internal_nis_setservent (&intern);
+ status = internal_nis_endservent (&intern);
__libc_lock_unlock (lock);
@@ -129,29 +118,32 @@ _nss_nis_setservent (int stayopen)
}
static enum nss_status
-internal_nis_endservent (intern_t * intern)
+internal_nis_setservent (intern_t *intern)
{
- 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;
+ char *domainname;
+ struct ypall_callback ypcb;
+ enum nss_status status;
- return NSS_STATUS_SUCCESS;
-}
+ 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_endservent (void)
+_nss_nis_setservent (int stayopen)
{
enum nss_status status;
__libc_lock_lock (lock);
- status = internal_nis_endservent (&intern);
+ status = internal_nis_setservent (&intern);
__libc_lock_unlock (lock);