summaryrefslogtreecommitdiff
path: root/nss
diff options
context:
space:
mode:
Diffstat (limited to 'nss')
-rw-r--r--nss/databases.def5
-rw-r--r--nss/function.def3
-rw-r--r--nss/getXXbyYY_r.c11
-rw-r--r--nss/getent.c86
-rw-r--r--nss/nss_files/files-alias.c6
-rw-r--r--nss/nss_files/files-hosts.c10
-rw-r--r--nss/nss_files/files-key.c3
-rw-r--r--nss/nss_files/files-netgrp.c26
-rw-r--r--nss/nsswitch.c11
9 files changed, 67 insertions, 94 deletions
diff --git a/nss/databases.def b/nss/databases.def
index c35d7f18c2..27c15fc04f 100644
--- a/nss/databases.def
+++ b/nss/databases.def
@@ -1,5 +1,5 @@
/* List of all databases defined for the NSS in GNU C Library.
- Copyright (C) 1996, 1997, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -18,8 +18,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-/* This list must be kept sorted!!! If any long name is added the
- field size for it must be increases. */
+/* This list must be kept sorted!!! */
DEFINE_DATABASE (aliases)
DEFINE_DATABASE (ethers)
diff --git a/nss/function.def b/nss/function.def
index 505fb9307f..59a06a2d31 100644
--- a/nss/function.def
+++ b/nss/function.def
@@ -1,5 +1,5 @@
/* List of functions defined for static NSS in GNU C Library.
- Copyright (C) 1996, 1997, 1998, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -37,7 +37,6 @@ DEFINE_GET (files, grnam)
DEFINE_ENT (files, host)
DEFINE_GETBY (files, host, addr)
DEFINE_GETBY (files, host, name)
-DEFINE_GETBY (files, host, name2)
DEFINE_GET (files, hostton)
DEFINE_GET (files, ntohost)
DEFINE_GETBY (dns, host, addr)
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index 080163aac9..34c305f3b2 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -18,7 +18,6 @@
02111-1307 USA. */
#include <assert.h>
-#include <atomic.h>
#include <errno.h>
#include <stdbool.h>
#include "nsswitch.h"
@@ -174,6 +173,9 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
startp = (service_user *) -1l;
else
{
+ startp = nip;
+ start_fct = fct.l;
+
#ifdef NEED__RES
/* The resolver code will really be used so we have to
initialize it. */
@@ -188,11 +190,6 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
if (!_res_hconf.initialized)
_res_hconf_init ();
#endif /* need _res_hconf */
-
- start_fct = fct.l;
- /* Make sure start_fct is written before startp. */
- atomic_write_barrier ();
- startp = nip;
}
}
else
diff --git a/nss/getent.c b/nss/getent.c
index 14ec3c4755..c0a273241f 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998-2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (c) 1998-2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
@@ -21,23 +21,22 @@
#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>
@@ -84,7 +83,7 @@ print_version (FILE *stream, struct argp_state *state)
Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
-"), "2006");
+"), "2004");
fprintf (stream, gettext ("Written by %s.\n"), "Thorsten Kukuk");
}
@@ -280,9 +279,9 @@ hosts_keys (int number, char *key[])
char addr[IN6ADDRSZ];
if (inet_pton (AF_INET6, key[i], &addr) > 0)
- host = gethostbyaddr (addr, IN6ADDRSZ, AF_INET6);
+ host = gethostbyaddr (addr, sizeof (addr), AF_INET6);
else if (inet_pton (AF_INET, key[i], &addr) > 0)
- host = gethostbyaddr (addr, INADDRSZ, AF_INET);
+ host = gethostbyaddr (addr, sizeof (addr), AF_INET);
else if ((host = gethostbyname2 (key[i], AF_INET6)) == NULL)
host = gethostbyname2 (key[i], AF_INET);
@@ -411,8 +410,6 @@ netgroup_keys (int number, char *key[])
}
}
- endnetgrent ();
-
return result;
}
@@ -760,27 +757,12 @@ D(shadow)
static error_t
parse_option (int key, char *arg, struct argp_state *state)
{
- char *endp;
+ int i;
switch (key)
{
case 's':
- endp = strchr (arg, ':');
- if (endp == NULL)
- /* No specific database, change them all. */
- for (int i = 0; databases[i].name != NULL; ++i)
- __nss_configure_lookup (databases[i].name, arg);
- else
- {
- int i;
- for (i = 0; databases[i].name != NULL; ++i)
- if (strncmp (databases[i].name, arg, endp - arg) == 0)
- {
- __nss_configure_lookup (databases[i].name, endp + 1);
- break;
- }
- if (databases[i].name == NULL)
- error (EXIT_FAILURE, 0, gettext ("Unknown database name"));
- }
+ for (i = 0; databases[i].name; ++i)
+ __nss_configure_lookup (databases[i].name, arg);
break;
default:
@@ -794,20 +776,31 @@ parse_option (int key, char *arg, struct argp_state *state)
static char *
more_help (int key, const char *text, void *input)
{
+ int len;
+ char *long_doc, *doc, *p;
+
switch (key)
{
- size_t len;
- char *doc;
- FILE *fp;
-
case ARGP_KEY_HELP_EXTRA:
/* We print some extra information. */
- fp = open_memstream (&doc, &len);
- if (fp != NULL)
+#if 0
+ return xstrdup (gettext ("\
+For bug reporting instructions, please see:\n\
+<http://www.gnu.org/software/libc/bugs.html>.\n"));
+#endif
+ long_doc = _("Supported databases:");
+ len = strlen (long_doc) + 2;
+
+ for (int i = 0; databases[i].name; ++i)
+ len += strlen (databases[i].name) + 1;
+
+ doc = (char *) malloc (len);
+ if (doc != NULL)
{
- fputs_unlocked (_("Supported databases:\n"), fp);
+ p = stpcpy (doc, long_doc);
+ *p++ = '\n';
- for (int i = 0, col = 0; databases[i].name != NULL; ++i)
+ for (int i = 0, col = 0; databases[i].name; ++i)
{
len = strlen (databases[i].name);
if (i != 0)
@@ -815,18 +808,17 @@ more_help (int key, const char *text, void *input)
if (col + len > 72)
{
col = 0;
- fputc_unlocked ('\n', fp);
+ *p++ = '\n';
}
else
- fputc_unlocked (' ', fp);
+ *p++ = ' ';
}
- fputs_unlocked (databases[i].name, fp);
+ p = mempcpy (p, databases[i].name, len);
col += len + 1;
}
- if (fclose (fp) == 0)
- return doc;
+ return doc;
}
break;
@@ -841,8 +833,7 @@ more_help (int key, const char *text, void *input)
int
main (int argc, char *argv[])
{
- /* Debugging support. */
- mtrace ();
+ int remaining, i;
/* Set locale via LC_ALL. */
setlocale (LC_ALL, "");
@@ -850,7 +841,6 @@ 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)
@@ -860,7 +850,7 @@ main (int argc, char *argv[])
return 1;
}
- for (int i = 0; databases[i].name; ++i)
+ for (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-alias.c b/nss/nss_files/files-alias.c
index c4717e1242..8ee54f121f 100644
--- a/nss/nss_files/files-alias.c
+++ b/nss/nss_files/files-alias.c
@@ -1,5 +1,5 @@
/* Mail alias file parser in nss_files module.
- Copyright (C) 1996,97,98,99,2002,2006 Free Software Foundation, Inc.
+ Copyright (C) 1996,97,98,99,2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -298,8 +298,8 @@ get_next_alias (const char *match, struct aliasent *result,
first_unused[room_left - 1] = '\0';
strncpy (first_unused, old_line, room_left);
- free (old_line);
- line = first_unused;
+ if (old_line != NULL)
+ free (old_line);
if (first_unused[room_left - 1] != '\0')
goto no_more_room;
diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c
index b1ba3aa76d..8d1a8ee588 100644
--- a/nss/nss_files/files-hosts.c
+++ b/nss/nss_files/files-hosts.c
@@ -1,6 +1,5 @@
/* Hosts file parser in nss_files module.
- Copyright (C) 1996-2001, 2003, 2004, 2007
- Free Software Foundation, Inc.
+ Copyright (C) 1996-2001, 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -87,10 +86,6 @@ _nss_files_get##name##_r (proto, \
{ \
enum nss_status status; \
\
- uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct hostent_data); \
- buffer += pad; \
- buflen = buflen > pad ? buflen - pad : 0; \
- \
__libc_lock_lock (lock); \
\
/* Reset file pointer to beginning or open file. */ \
@@ -111,8 +106,7 @@ _nss_files_get##name##_r (proto, \
{ \
/* We have to get all host entries from the file. */ \
const size_t tmp_buflen = MIN (buflen, 4096); \
- char tmp_buffer[tmp_buflen] \
- __attribute__ ((__aligned__ (__alignof__ (struct hostent_data))));\
+ char tmp_buffer[tmp_buflen]; \
struct hostent tmp_result_buf; \
int naddrs = 1; \
int naliases = 0; \
diff --git a/nss/nss_files/files-key.c b/nss/nss_files/files-key.c
index 5c7ad0999a..f00fc1cfe9 100644
--- a/nss/nss_files/files-key.c
+++ b/nss/nss_files/files-key.c
@@ -1,5 +1,5 @@
/* Public key file parser in nss_files module.
- Copyright (C) 1996, 1997, 1998, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -78,7 +78,6 @@ search (const char *netname, char *result, int *errnop, int secret)
p = __strtok_r (NULL, ":\n", &save_ptr);
if (p == NULL) /* malformed line? */
continue;
- fclose (stream);
strcpy (result, p);
return NSS_STATUS_SUCCESS;
}
diff --git a/nss/nss_files/files-netgrp.c b/nss/nss_files/files-netgrp.c
index 4b5d774fdd..8bdc68bd14 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, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 2000, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -22,7 +22,6 @@
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
-#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
#include "nsswitch.h"
@@ -30,7 +29,6 @@
#define DATAFILE "/etc/netgroup"
-libnss_files_hidden_proto (_nss_files_endnetgrent)
#define EXPAND(needed) \
do \
@@ -77,9 +75,7 @@ _nss_files_setnetgrent (const char *group, struct __netgrent *result)
status = NSS_STATUS_NOTFOUND;
result->cursor = result->data;
- __fsetlocking (fp, FSETLOCKING_BYCALLER);
-
- while (!feof_unlocked (fp))
+ while (!feof (fp))
{
ssize_t curlen = getline (&line, &line_len, fp);
int found;
@@ -144,26 +140,26 @@ _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;
}
-enum nss_status
+int
_nss_files_endnetgrent (struct __netgrent *result)
{
/* Free allocated memory for data if some is present. */
- free (result->data);
- result->data = NULL;
- result->data_size = 0;
- result->cursor = NULL;
+ if (result->data != 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)
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index 21174dfbab..895b17825a 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006
+/* Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -59,9 +59,9 @@ static service_library *nss_new_service (name_database *database,
#undef DEFINE_DATABASE
/* Structure to map database name to variable. */
-static const struct
+static struct
{
- const char name[10];
+ const char *name;
service_user **dbp;
} databases[] =
{
@@ -70,7 +70,6 @@ static const struct
#include "databases.def"
#undef DEFINE_DATABASE
};
-#define ndatabases (sizeof (databases) / sizeof (databases[0]))
__libc_lock_define_initialized (static, lock)
@@ -212,7 +211,7 @@ __nss_configure_lookup (const char *dbname, const char *service_line)
service_user *new_db;
size_t cnt;
- for (cnt = 0; cnt < ndatabases; ++cnt)
+ for (cnt = 0; cnt < sizeof databases; ++cnt)
{
int cmp = strcmp (dbname, databases[cnt].name);
if (cmp == 0)
@@ -224,7 +223,7 @@ __nss_configure_lookup (const char *dbname, const char *service_line)
}
}
- if (cnt == ndatabases)
+ if (cnt == sizeof databases)
{
__set_errno (EINVAL);
return -1;