[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r4013 - in /trunk/libc: ChangeLog.eglibc grp/Makefile nss/gen-fixed-nsswitch.c option-groups.def posix/Makefile



Author: jimb
Date: Mon Oct 29 14:27:30 2007
New Revision: 4013

Log:
* nss/gen-fixed-nsswitch.c: Don't #include "nsswitch.h".  Instead,
make our own copies of the datatype and enum definitions.  Do
#include "nss.h".
(lookup_actions, service_library, known_function, service_user)
(name_database_entry, name_database): Copy definitions from
nsswitch.c.
* grp/Makefile (LDLIBS-testgrp): Link against the libraries listed
in nss/fixed-nsswitch-libs when OPTION_EGLIBC_NSSWITCH is
disabled.
* posix/Makefile (LDLIBS-globtest): Same.
* option-groups.def (OPTION_EGLIBC_NSSWITCH): Doc fix.

Modified:
    trunk/libc/ChangeLog.eglibc
    trunk/libc/grp/Makefile
    trunk/libc/nss/gen-fixed-nsswitch.c
    trunk/libc/option-groups.def
    trunk/libc/posix/Makefile

Modified: trunk/libc/ChangeLog.eglibc
==============================================================================
--- trunk/libc/ChangeLog.eglibc (original)
+++ trunk/libc/ChangeLog.eglibc Mon Oct 29 14:27:30 2007
@@ -1,3 +1,17 @@
+2007-10-29  Jim Blandy  <jimb@xxxxxxxxxxxxxxxx>
+
+	* nss/gen-fixed-nsswitch.c: Don't #include "nsswitch.h".  Instead,
+	make our own copies of the datatype and enum definitions.  Do
+	#include "nss.h".
+	(lookup_actions, service_library, known_function, service_user)
+	(name_database_entry, name_database): Copy definitions from
+	nsswitch.c.
+	* grp/Makefile (LDLIBS-testgrp): Link against the libraries listed
+	in nss/fixed-nsswitch-libs when OPTION_EGLIBC_NSSWITCH is
+	disabled.
+	* posix/Makefile (LDLIBS-globtest): Same.
+	* option-groups.def (OPTION_EGLIBC_NSSWITCH): Doc fix.
+
 2007-10-23  Jim Blandy  <jimb@xxxxxxxxxxxxxxxx>
 
 	* bits/wchar.h (__WCHAR_MIN): Add missing underscores to name.

Modified: trunk/libc/grp/Makefile
==============================================================================
--- trunk/libc/grp/Makefile (original)
+++ trunk/libc/grp/Makefile Mon Oct 29 14:27:30 2007
@@ -33,6 +33,9 @@
 include ../Makeconfig
 
 tests := testgrp
+ifneq (y,$(OPTION_EGLIBC_NSSWITCH))
+LDLIBS-testgrp += $(shell cat $(common-objpfx)nss/fixed-nsswitch-libs)
+endif
 
 ifeq (yes,$(build-shared))
 test-srcs :=  tst_fgetgrent

Modified: trunk/libc/nss/gen-fixed-nsswitch.c
==============================================================================
--- trunk/libc/nss/gen-fixed-nsswitch.c (original)
+++ trunk/libc/nss/gen-fixed-nsswitch.c Mon Oct 29 14:27:30 2007
@@ -27,10 +27,8 @@
 #include <assert.h>
 #include <ctype.h>
 
-#define libc_hidden_proto(func)
-
-#include "nsswitch.h"
 #include "gnu/lib-names.h"
+#include "nss.h"
 
 
 /* Simple utilities.  */
@@ -79,6 +77,95 @@
 
   return buf;
 }
+
+
+
+/* Data structures representing the configuration file in memory.  */
+
+/* These are copied from nsswitch.h.
+
+   We could simply #include that file, but this program runs on the
+   build machine and links against the build machine's libraries,
+   whereas that header is meant for use by target code; it uses
+   'libc_hidden_proto', 'internal_function', and related hair.  Since
+   we've copied the parsing code, we might as well copy the data
+   structure definitions as well.  */
+
+/* Actions performed after lookup finished.  */
+typedef enum
+{
+  NSS_ACTION_CONTINUE,
+  NSS_ACTION_RETURN
+} lookup_actions;
+
+
+typedef struct service_library
+{
+  /* Name of service (`files', `dns', `nis', ...).  */
+  const char *name;
+  /* Pointer to the loaded shared library.  */
+  void *lib_handle;
+  /* And the link to the next entry.  */
+  struct service_library *next;
+} service_library;
+
+
+/* For mapping a function name to a function pointer.  It is known in
+   nsswitch.c:nss_lookup_function that a string pointer for the lookup key
+   is the first member.  */
+typedef struct
+{
+  const char *fct_name;
+  void *fct_ptr;
+} known_function;
+
+
+typedef struct service_user
+{
+  /* And the link to the next entry.  */
+  struct service_user *next;
+  /* Action according to result.  */
+  lookup_actions actions[5];
+  /* Link to the underlying library object.  */
+  service_library *library;
+  /* Collection of known functions.
+
+     With OPTION_EGLIBC_NSSWITCH enabled, this is the root of a
+     'tsearch'-style tree.
+
+     With OPTION_EGLIBC_NSSWITCH disabled, this is an array of
+     pointers to known_function structures, NULL-terminated.  */
+  union
+  {
+    void *tree;
+    const known_function **array;
+  } known;
+  /* Name of the service (`files', `dns', `nis', ...).  */
+  const char *name;
+} service_user;
+
+/* To access the action based on the status value use this macro.  */
+#define nss_next_action(ni, status) ((ni)->actions[2 + status])
+
+
+typedef struct name_database_entry
+{
+  /* And the link to the next entry.  */
+  struct name_database_entry *next;
+  /* List of service to be used.  */
+  service_user *service;
+  /* Name of the database.  */
+  const char *name;
+} name_database_entry;
+
+
+typedef struct name_database
+{
+  /* List of all known databases.  */
+  name_database_entry *entry;
+  /* List of libraries with service implementation.  */
+  service_library *library;
+} name_database;
 
 
 
@@ -659,7 +746,7 @@
         {
           if (printed_any)
             putc (' ', out);
-          fprintf (out, "libnss_%s.so%s",
+          fprintf (out, "-lnss_%s",
                    functions[i].service,
                    nss_shlib_revision);
           printed_any = 1;

Modified: trunk/libc/option-groups.def
==============================================================================
--- trunk/libc/option-groups.def (original)
+++ trunk/libc/option-groups.def Mon Oct 29 14:27:30 2007
@@ -507,10 +507,9 @@
 
        Note that some nsswitch service libraries require other option
        groups to be enabled; for example, the OPTION_EGLIBC_INET
-       option group must be enabled to use the 'libnss_dns.so.2' or
-       'libnss_nis.so.2' service libraries, which use the Domain Name
-       System and Network Information Service network protocols to
-       answer queries.
+       option group must be enabled to use the 'libnss_dns.so.2'
+       service library, which uses the Domain Name System network
+       protocol to answer queries.
 
 config OPTION_EGLIBC_RCMD
    bool "Support for 'rcmd' and related library functions"

Modified: trunk/libc/posix/Makefile
==============================================================================
--- trunk/libc/posix/Makefile (original)
+++ trunk/libc/posix/Makefile Mon Oct 29 14:27:30 2007
@@ -144,6 +144,7 @@
 $(objpfx)globtest.out: globtest.sh $(objpfx)globtest
 	$(SHELL) -e globtest.sh $(common-objpfx) $(elf-objpfx) \
 		 $(rtld-installed-name) '$(cross-test-wrapper)'
+LDLIBS-globtest += $(shell cat $(common-objpfx)nss/fixed-nsswitch-libs)
 ifeq (y,$(OPTION_EGLIBC_WORDEXP))
 tests: $(objpfx)wordexp-tst.out
 $(objpfx)wordexp-tst.out: wordexp-tst.sh $(objpfx)wordexp-test