aboutsummaryrefslogtreecommitdiff
path: root/nss
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-09-10 03:20:33 +0000
committerUlrich Drepper <drepper@redhat.com>2005-09-10 03:20:33 +0000
commitff3cacc50c42290ff76922257247c95f27fa3736 (patch)
tree3763ebc50123e2cf7d51090539c2073125cc0014 /nss
parentf7ca66d1156ce7e7532aa604d8fe4209eeee1f55 (diff)
downloadglibc-ff3cacc50c42290ff76922257247c95f27fa3736.zip
glibc-ff3cacc50c42290ff76922257247c95f27fa3736.tar.gz
glibc-ff3cacc50c42290ff76922257247c95f27fa3736.tar.bz2
* inet/getnetgrent_r.c: Include assert.cvs/fedora-glibc-20050912T0656
(setup): Remove FUNC_NAME and ALL arguments, assume they are always "setnetgrent" and 1. (endnetgrent_hook): New function. (internal_endnetgrent): Use it. (__internal_setnetgrent_reuse): Use it. Adjust setup caller. If status is NSS_STATUS_SUCCESS, yet action is continue, call endnetgrent hook. (internal_getnetgrent_r): Use __nss_lookup_function rather than setup. Recompute getfct pointer after successful __internal_setnetgrent_reuse. Don't use __nss_next. (innetgr): Use __nss_lookup_function instead of __nss_lookup. Adjust setup caller. * nss/nss_files/files-netgrp.c (_nss_files_endnetgrent): Always clear data_size and cursor. Add libnss_files_hidden_proto and libnss_files_hidden_def. (_nss_files_setnetgrent): Call _nss_files_endnetgrent on failure. * nis/nss_nis/nis-netgrp.c (internal_endnetgrent): Always clear data_size and cursor. (_nss_nis_setnetgrent): Don't call internal_endnetgrent. (_nss_nis_getnetgrent_r): Remove result->cursor == NULL handling. * nis/nss_nisplus/nisplus-netgrp.c (internal_endnetgrent): Always clear data_size and position. (_nss_nisplus_setnetgrent): Don't call internal_endnetgrent. 2005-09-09 Ulrich Drepper <drepper@redhat.com> * nss/getent.c (netgroup_keys): Call endnetgrent. (main): Call mtrace. * nss/nss_files/files-netgrp.c (_nss_files_setnetgrent): We don't need locking for the stream. Use feof_unlocked. 2005-09-09 Jakub Jelinek <jakub@redhat.com>
Diffstat (limited to 'nss')
-rw-r--r--nss/getent.c21
-rw-r--r--nss/nss_files/files-netgrp.c24
2 files changed, 27 insertions, 18 deletions
diff --git a/nss/getent.c b/nss/getent.c
index 7124e63..02bba39 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -21,22 +21,23 @@
#include <aliases.h>
#include <argp.h>
-#include <grp.h>
-#include <pwd.h>
-#include <shadow.h>
#include <ctype.h>
#include <error.h>
+#include <grp.h>
#include <libintl.h>
#include <locale.h>
+#include <mcheck.h>
#include <netdb.h>
+#include <pwd.h>
+#include <shadow.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/ether.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
+#include <netinet/ether.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
/* Get libc version number. */
#include <version.h>
@@ -410,6 +411,8 @@ netgroup_keys (int number, char *key[])
}
}
+ endnetgrent ();
+
return result;
}
@@ -838,7 +841,8 @@ more_help (int key, const char *text, void *input)
int
main (int argc, char *argv[])
{
- int remaining, i;
+ /* Debugging support. */
+ mtrace ();
/* Set locale via LC_ALL. */
setlocale (LC_ALL, "");
@@ -846,6 +850,7 @@ main (int argc, char *argv[])
textdomain (PACKAGE);
/* Parse and process arguments. */
+ int remaining;
argp_parse (&argp, argc, argv, 0, &remaining, NULL);
if ((argc - remaining) < 1)
@@ -855,7 +860,7 @@ main (int argc, char *argv[])
return 1;
}
- for (i = 0; databases[i].name; ++i)
+ for (int i = 0; databases[i].name; ++i)
if (argv[remaining][0] == databases[i].name[0]
&& !strcmp (argv[remaining], databases[i].name))
return databases[i].func (argc - remaining - 1, &argv[remaining + 1]);
diff --git a/nss/nss_files/files-netgrp.c b/nss/nss_files/files-netgrp.c
index 8bdc68b..45f3b8a 100644
--- a/nss/nss_files/files-netgrp.c
+++ b/nss/nss_files/files-netgrp.c
@@ -1,5 +1,5 @@
/* Netgroup file parser in nss_files modules.
- Copyright (C) 1996, 1997, 2000, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 2000, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -22,6 +22,7 @@
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
+#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
#include "nsswitch.h"
@@ -29,6 +30,7 @@
#define DATAFILE "/etc/netgroup"
+libnss_files_hidden_proto (_nss_files_endnetgrent)
#define EXPAND(needed) \
do \
@@ -75,7 +77,9 @@ _nss_files_setnetgrent (const char *group, struct __netgrent *result)
status = NSS_STATUS_NOTFOUND;
result->cursor = result->data;
- while (!feof (fp))
+ __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
+ while (!feof_unlocked (fp))
{
ssize_t curlen = getline (&line, &line_len, fp);
int found;
@@ -140,6 +144,9 @@ _nss_files_setnetgrent (const char *group, struct __netgrent *result)
/* We don't need the file and the line buffer anymore. */
free (line);
fclose (fp);
+
+ if (status != NSS_STATUS_SUCCESS)
+ _nss_files_endnetgrent (result);
}
return status;
@@ -150,16 +157,13 @@ int
_nss_files_endnetgrent (struct __netgrent *result)
{
/* Free allocated memory for data if some is present. */
- if (result->data != NULL)
- {
- free (result->data);
- result->data = NULL;
- result->data_size = 0;
- result->cursor = NULL;
- }
-
+ free (result->data);
+ result->data = NULL;
+ result->data_size = 0;
+ result->cursor = NULL;
return NSS_STATUS_SUCCESS;
}
+libnss_files_hidden_def (_nss_files_endnetgrent)
static char *
strip_whitespace (char *str)