about summary refs log tree commit diff
path: root/nss/nss_files
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-06-14 22:21:51 -0400
committerUlrich Drepper <drepper@gmail.com>2011-06-15 21:06:18 -0400
commit2666d441c2d8107b1987b869714189af64b954c6 (patch)
treec7b8877d691db280202b4c7655907a1165ec84fc /nss/nss_files
parent9ee76b5ae861ff9891e5586fc6906c94c447a9e0 (diff)
downloadglibc-2666d441c2d8107b1987b869714189af64b954c6.tar.gz
glibc-2666d441c2d8107b1987b869714189af64b954c6.tar.xz
glibc-2666d441c2d8107b1987b869714189af64b954c6.zip
Reenable nss_db with a completely new implementation
No longer is Berkeley db used.  Instead a simple hash function is used.
The database files are not updated once they are created and therefore
no complicated database is needed.
Diffstat (limited to 'nss/nss_files')
-rw-r--r--nss/nss_files/files-XXX.c10
-rw-r--r--nss/nss_files/files-ethers.c6
-rw-r--r--nss/nss_files/files-grp.c6
-rw-r--r--nss/nss_files/files-hosts.c2
-rw-r--r--nss/nss_files/files-network.c6
-rw-r--r--nss/nss_files/files-proto.c6
-rw-r--r--nss/nss_files/files-pwd.c6
-rw-r--r--nss/nss_files/files-rpc.c6
-rw-r--r--nss/nss_files/files-service.c11
-rw-r--r--nss/nss_files/files-sgrp.c4
-rw-r--r--nss/nss_files/files-spwd.c4
11 files changed, 34 insertions, 33 deletions
diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c
index 852b58a7e5..1a6fa0ddd5 100644
--- a/nss/nss_files/files-XXX.c
+++ b/nss/nss_files/files-XXX.c
@@ -1,5 +1,5 @@
 /* Common code for file-based databases in nss_files module.
-   Copyright (C) 1996-1999,2001,2002,2004,2007,2008
+   Copyright (C) 1996-1999,2001,2002,2004,2007,2008,2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -306,15 +306,15 @@ CONCAT(_nss_files_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer,
 
    NAME is the name of the lookup; e.g. `hostbyname'.
 
-   KEYSIZE and KEYPATTERN are ignored here but used by ../nss_db/db-XXX.c.
+   DB_CHAR, KEYPATTERN, KEYSIZE are ignored here but used by db-XXX.c
+   e.g. `1 + sizeof (id) * 4'.
 
-   PROTO describes the arguments for the lookup key;
-   e.g. `const char *hostname'.
+   PROTO is the potentially empty list of other parameters.
 
    BREAK_IF_MATCH is a block of code which compares `struct STRUCTURE *result'
    to the lookup key arguments and does `break;' if they match.  */
 
-#define DB_LOOKUP(name, keysize, keypattern, break_if_match, proto...)	      \
+#define DB_LOOKUP(name, db_char, keysize, keypattern, break_if_match, proto...)\
 enum nss_status								      \
 _nss_files_get##name##_r (proto,					      \
 			  struct STRUCTURE *result, char *buffer,	      \
diff --git a/nss/nss_files/files-ethers.c b/nss/nss_files/files-ethers.c
index e662c1a4e1..91363ba173 100644
--- a/nss/nss_files/files-ethers.c
+++ b/nss/nss_files/files-ethers.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2000, 2011 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
@@ -51,13 +51,13 @@ LINE_PARSER
 
 #include GENERIC
 
-DB_LOOKUP (hostton, 1 + strlen (name), (".%s", name),
+DB_LOOKUP (hostton, '.', 0, ("%s", name),
 	   {
 	     if (__strcasecmp (result->e_name, name) == 0)
 	       break;
 	   }, const char *name)
 
-DB_LOOKUP (ntohost, 18, ("=%x:%x:%x:%x:%x:%x",
+DB_LOOKUP (ntohost, '=', 18, ("%x:%x:%x:%x:%x:%x",
 			 addr->ether_addr_octet[0], addr->ether_addr_octet[1],
 			 addr->ether_addr_octet[2], addr->ether_addr_octet[3],
 			 addr->ether_addr_octet[4], addr->ether_addr_octet[5]),
diff --git a/nss/nss_files/files-grp.c b/nss/nss_files/files-grp.c
index 1f205c1093..30751ab048 100644
--- a/nss/nss_files/files-grp.c
+++ b/nss/nss_files/files-grp.c
@@ -1,5 +1,5 @@
 /* Group file parser in nss_files module.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2011 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
@@ -30,14 +30,14 @@ struct grent_data {};
 #include "files-parse.c"
 #include GENERIC
 
-DB_LOOKUP (grnam, 1 + strlen (name), (".%s", name),
+DB_LOOKUP (grnam, '.', 0, ("%s", name),
 	   {
 	     if (name[0] != '-' && name[0] != '+'
 		 && ! strcmp (name, result->gr_name))
 	       break;
 	   }, const char *name)
 
-DB_LOOKUP (grgid, 20, ("=%lu", (unsigned long int) gid),
+DB_LOOKUP (grgid, '=', 20, ("%lu", (unsigned long int) gid),
 	   {
 	     if (result->gr_gid == gid && result->gr_name[0] != '+'
 		 && result->gr_name[0] != '-')
diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c
index 83de650756..f6f960ecbe 100644
--- a/nss/nss_files/files-hosts.c
+++ b/nss/nss_files/files-hosts.c
@@ -358,7 +358,7 @@ HOST_DB_LOOKUP (hostbyname2, ,,
    gethostbyaddr() function is an IPv6 address.  */
 #define EXTRA_ARGS_VALUE \
   , af, (len == IN6ADDRSZ ? AI_V4MAPPED : 0)
-DB_LOOKUP (hostbyaddr, ,,
+DB_LOOKUP (hostbyaddr, ,,,
 	   {
 	     if (result->h_length == (int) len
 		 && ! memcmp (addr, result->h_addr_list[0], len))
diff --git a/nss/nss_files/files-network.c b/nss/nss_files/files-network.c
index 92aea75d9e..9017c54997 100644
--- a/nss/nss_files/files-network.c
+++ b/nss/nss_files/files-network.c
@@ -1,5 +1,5 @@
 /* Networks file parser in nss_files module.
-   Copyright (C) 1996-1998, 2000, 2001, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1996-1998, 2000, 2001, 2009, 2011 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
@@ -75,11 +75,11 @@ LINE_PARSER
 
 #include "files-XXX.c"
 
-DB_LOOKUP (netbyname, ,,
+DB_LOOKUP (netbyname, ,,,
 	   LOOKUP_NAME_CASE (n_name, n_aliases),
 	   const char *name)
 
-DB_LOOKUP (netbyaddr, ,,
+DB_LOOKUP (netbyaddr, ,,,
 	   {
 	     if ((type == AF_UNSPEC || result->n_addrtype == type)
 		 && result->n_net == net)
diff --git a/nss/nss_files/files-proto.c b/nss/nss_files/files-proto.c
index 0cede6ebd4..5df325b496 100644
--- a/nss/nss_files/files-proto.c
+++ b/nss/nss_files/files-proto.c
@@ -1,5 +1,5 @@
 /* Protocols file parser in nss_files module.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2011 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
@@ -36,11 +36,11 @@ LINE_PARSER
 
 #include GENERIC
 
-DB_LOOKUP (protobyname, 1 + strlen (name), (".%s", name),
+DB_LOOKUP (protobyname, '.', 0, ("%s", name),
 	   LOOKUP_NAME (p_name, p_aliases),
 	   const char *name)
 
-DB_LOOKUP (protobynumber, 20, ("=%d", proto),
+DB_LOOKUP (protobynumber, '=', 20, ("%zd", (ssize_t) proto),
 	   {
 	     if (result->p_proto == proto)
 	       break;
diff --git a/nss/nss_files/files-pwd.c b/nss/nss_files/files-pwd.c
index 4913c3183d..4763f0149a 100644
--- a/nss/nss_files/files-pwd.c
+++ b/nss/nss_files/files-pwd.c
@@ -1,5 +1,5 @@
 /* User file parser in nss_files module.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2011 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
@@ -30,14 +30,14 @@ struct pwent_data {};
 #include "files-parse.c"
 #include GENERIC
 
-DB_LOOKUP (pwnam, 1 + strlen (name), (".%s", name),
+DB_LOOKUP (pwnam, '.', 0, ("%s", name),
 	   {
 	     if (name[0] != '+' && name[0] != '-'
 		 && ! strcmp (name, result->pw_name))
 	       break;
 	   }, const char *name)
 
-DB_LOOKUP (pwuid, 20, ("=%lu", (unsigned long int) uid),
+DB_LOOKUP (pwuid, '=', 20, ("%lu", (unsigned long int) uid),
 	   {
 	     if (result->pw_uid == uid && result->pw_name[0] != '+'
 		 && result->pw_name[0] != '-')
diff --git a/nss/nss_files/files-rpc.c b/nss/nss_files/files-rpc.c
index b99ede399b..2b41611d4c 100644
--- a/nss/nss_files/files-rpc.c
+++ b/nss/nss_files/files-rpc.c
@@ -1,5 +1,5 @@
 /* SunRPC program number file parser in nss_files module.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2011 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
@@ -36,11 +36,11 @@ LINE_PARSER
 
 #include GENERIC
 
-DB_LOOKUP (rpcbyname, 1 + strlen (name), (".%s", name),
+DB_LOOKUP (rpcbyname, '.', 0, ("%s", name),
 	   LOOKUP_NAME (r_name, r_aliases),
 	   const char *name)
 
-DB_LOOKUP (rpcbynumber, 20, ("=%d", number),
+DB_LOOKUP (rpcbynumber, '=', 20, ("%zd", (ssize_t) number),
 	   {
 	     if (result->r_number == number)
 	       break;
diff --git a/nss/nss_files/files-service.c b/nss/nss_files/files-service.c
index 13532ddc9b..6f2b0e64a6 100644
--- a/nss/nss_files/files-service.c
+++ b/nss/nss_files/files-service.c
@@ -1,5 +1,5 @@
 /* Services file parser in nss_files module.
-   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 2011 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
@@ -39,8 +39,9 @@ LINE_PARSER
 
 #include GENERIC
 
-DB_LOOKUP (servbyname, 2 + strlen (name) + (proto ? strlen (proto) : 0),
-	   (".%s/%s", name, proto ?: ""),
+DB_LOOKUP (servbyname, ':',
+	   strlen (name) + 2 + (proto == NULL ? 0 : strlen (proto)),
+	   ("%s/%s", name, proto ?: ""),
 	   {
 	     /* Must match both protocol (if specified) and name.  */
 	     if (proto != NULL && strcmp (result->s_proto, proto))
@@ -49,8 +50,8 @@ DB_LOOKUP (servbyname, 2 + strlen (name) + (proto ? strlen (proto) : 0),
 	   },
 	   const char *name, const char *proto)
 
-DB_LOOKUP (servbyport, 21 + (proto ? strlen (proto) : 0),
-	   ("=%d/%s", ntohs (port), proto ?: ""),
+DB_LOOKUP (servbyport, '=', 21 + (proto ? strlen (proto) : 0),
+	   ("%zd/%s", (ssize_t) ntohs (port), proto ?: ""),
 	   {
 	     /* Must match both port and protocol.  */
 	     if (result->s_port == port
diff --git a/nss/nss_files/files-sgrp.c b/nss/nss_files/files-sgrp.c
index 4e12cd83d4..684bacc3d0 100644
--- a/nss/nss_files/files-sgrp.c
+++ b/nss/nss_files/files-sgrp.c
@@ -1,5 +1,5 @@
 /* User file parser in nss_files module.
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2011 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
@@ -30,7 +30,7 @@ struct sgent_data {};
 #include "files-parse.c"
 #include GENERIC
 
-DB_LOOKUP (sgnam, 1 + strlen (name), (".%s", name),
+DB_LOOKUP (sgnam, '.', 0, ("%s", name),
 	   {
 	     if (name[0] != '+' && name[0] != '-'
 		 && ! strcmp (name, result->sg_namp))
diff --git a/nss/nss_files/files-spwd.c b/nss/nss_files/files-spwd.c
index 1825d36102..e227d71275 100644
--- a/nss/nss_files/files-spwd.c
+++ b/nss/nss_files/files-spwd.c
@@ -1,5 +1,5 @@
 /* User file parser in nss_files module.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2011 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
@@ -30,7 +30,7 @@ struct spent_data {};
 #include "files-parse.c"
 #include GENERIC
 
-DB_LOOKUP (spnam, 1 + strlen (name), (".%s", name),
+DB_LOOKUP (spnam, '.', 0, ("%s", name),
 	   {
 	     if (name[0] != '+' && name[0] != '-'
 		 && ! strcmp (name, result->sp_namp))