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

Re: [patches] Implement new EGLIBC_NSCD option group.



On Tue, Mar 1, 2011 at 2:03 AM, Joseph S. Myers <joseph@xxxxxxxxxxxxxxxx> wrote:
> My technical comments would be:
>
> * We don't generally condition things in Versions files on option groups.
>
> * If you have an option group conditional in a .c or .h file, you need to
> include <gnu/option-groups.h> there; it won't generally be included
> implicitly.

Indeed, I've missed these details.  Thanks.

Below is the next version of the patch.  I've used USE_NSCD for
conditioning the code in .c and .h.  This seems to be an appropriate
way, as GLIBC itself uses this macro exactly for the same purpose.
And OPTION_EGLIBC_NSCD is used in Makefiles.

Then, in the GLIBC code it's forgotten here and there to use USE_NSCD,
and this has been fixed in the patch.  In general, the USE_NSCD-part
of the patch should be commited to GLIBC.  But there is such a feeling
that any USE_NSCD's support is given away completely in GLIBC, and
instead just the hardcoded approach that USE_NSCD is set is used for
GLIBC code.  Somewhere this fact is documented as -DUSE_NSCD=1 and
otherwhere it's just silently assumed.  And no alternative is supposed
at all.

Index: nscd/Makefile
===================================================================
--- nscd/Makefile       (revision 13011)
+++ nscd/Makefile       (working copy)
@@ -23,10 +23,10 @@

 subdir := nscd

-routines-$(OPTION_EGLIBC_INET) += \
+routines-$(OPTION_EGLIBC_NSCD) += \
            nscd_getpw_r nscd_getgr_r nscd_gethst_r nscd_getai \
           nscd_initgroups nscd_getserv_r
-aux-$(OPTION_EGLIBC_INET) += nscd_helper
+aux-$(OPTION_EGLIBC_NSCD) += nscd_helper

 include ../Makeconfig

@@ -46,11 +46,11 @@
 ifeq ($(have-thread-library),yes)

 ifneq (yesyes,$(have-fpie)$(build-shared))
-others-$(OPTION_EGLIBC_INET) += nscd
+others-$(OPTION_EGLIBC_NSCD) += nscd
 endif
-install-sbin-$(OPTION_EGLIBC_INET) += nscd
+install-sbin-$(OPTION_EGLIBC_NSCD) += nscd

-extra-objs-$(OPTION_EGLIBC_INET) += $(nscd-modules:=.o)
+extra-objs-$(OPTION_EGLIBC_NSCD) += $(nscd-modules:=.o)

 endif

Index: grp/Makefile
===================================================================
--- grp/Makefile        (revision 13011)
+++ grp/Makefile        (working copy)
@@ -52,16 +52,16 @@

 ifeq ($(have-thread-library),yes)

-OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
+OPTION_EGLIBC_NSCD-CFLAGS-$(OPTION_EGLIBC_NSCD) = -DUSE_NSCD=1

-CFLAGS-getgrgid_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y) -fexceptions
-CFLAGS-getgrnam_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y) -fexceptions
+CFLAGS-getgrgid_r.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y) -fexceptions
+CFLAGS-getgrnam_r.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y) -fexceptions
 CFLAGS-getgrent_r.c = -fexceptions
 CFLAGS-getgrent.c = -fexceptions
 CFLAGS-fgetgrent.c = -fexceptions
 CFLAGS-fgetgrent_r.c = -fexceptions -D_IO_MTSAFE_IO
 CFLAGS-putgrent.c = -fexceptions -D_IO_MTSAFE_IO
-CFLAGS-initgroups.c = $(OPTION_EGLIBC_INET-CFLAGS-y) -fexceptions
+CFLAGS-initgroups.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y) -fexceptions
 CFLAGS-getgrgid.c = -fexceptions

 endif
Index: pwd/Makefile
===================================================================
--- pwd/Makefile        (revision 13011)
+++ pwd/Makefile        (working copy)
@@ -34,10 +34,10 @@

 ifeq ($(have-thread-library),yes)

-OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
+OPTION_EGLIBC_NSCD-CFLAGS-$(OPTION_EGLIBC_NSCD) = -DUSE_NSCD=1

-CFLAGS-getpwuid_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
-CFLAGS-getpwnam_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
+CFLAGS-getpwuid_r.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y)
+CFLAGS-getpwnam_r.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y)
 CFLAGS-getpwent_r.c = -fexceptions
 CFLAGS-getpwent.c = -fexceptions
 CFLAGS-getpw.c = -fexceptions
Index: posix/Makefile
===================================================================
--- posix/Makefile      (revision 13011)
+++ posix/Makefile      (working copy)
@@ -171,7 +171,7 @@
 endif
 # eglibc: endif

-OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
+OPTION_EGLIBC_NSCD-CFLAGS-$(OPTION_EGLIBC_NSCD) = -DUSE_NSCD=1

 # If we will use the generic uname implementation, we must figure out what
 # it will say by examining the system, and write the results in config-name.h.
@@ -182,7 +182,7 @@
       mv -f $@.new $@

 CFLAGS-regex.c = -Wno-strict-prototypes
-CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions $(OPTION_EGLIBC_INET-CFLAGS-y)
+CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions $(OPTION_EGLIBC_NSCD-CFLAGS-y)
 CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
Index: inet/Makefile
===================================================================
--- inet/Makefile       (revision 13011)
+++ inet/Makefile       (working copy)
@@ -67,11 +67,13 @@

 ifeq ($(have-thread-library),yes)

-CFLAGS-gethstbyad_r.c = -DUSE_NSCD=1 -fexceptions
+OPTION_EGLIBC_NSCD-CFLAGS-$(OPTION_EGLIBC_NSCD) = -DUSE_NSCD=1
+
+CFLAGS-gethstbyad_r.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y) -fexceptions
 CFLAGS-gethstbyad.c = -fexceptions
-CFLAGS-gethstbynm_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-gethstbynm_r.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y) -fexceptions
 CFLAGS-gethstbynm.c = -fexceptions
-CFLAGS-gethstbynm2_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-gethstbynm2_r.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y) -fexceptions
 CFLAGS-gethstbynm2.c = -fexceptions
 CFLAGS-gethstent_r.c = -fexceptions
 CFLAGS-gethstent.c = -fexceptions
@@ -88,8 +90,8 @@
 CFLAGS-getrpcent.c = -fexceptions
 CFLAGS-getservent_r.c = -fexceptions
 CFLAGS-getservent.c = -fexceptions
-CFLAGS-getsrvbynm_r.c = -DUSE_NSCD=1
-CFLAGS-getsrvbypt_r.c = -DUSE_NSCD=1
+CFLAGS-getsrvbynm_r.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y)
+CFLAGS-getsrvbypt_r.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y)
 CFLAGS-getprtent_r.c = -fexceptions
 CFLAGS-getprtent.c = -fexceptions
 CFLAGS-either_ntoh.c = -fexceptions
Index: nss/Makefile
===================================================================
--- nss/Makefile        (revision 13011)
+++ nss/Makefile        (working copy)
@@ -122,6 +122,11 @@

 include ../Rules

+ifeq (y,$(OPTION_EGLIBC_INET))
+OPTION_EGLIBC_NSCD-CFLAGS-$(OPTION_EGLIBC_NSCD) = -DUSE_NSCD=1
+CFLAGS-digits_dots.c = $(OPTION_EGLIBC_NSCD-CFLAGS-y)
+CFLAGS-nsswitch.c    = $(OPTION_EGLIBC_NSCD-CFLAGS-y)
+endif

 ifeq (yes,$(build-static-nss))
 $(objpfx)getent: $(objpfx)libnss_files.a
Index: sysdeps/posix/getaddrinfo.c
===================================================================
--- sysdeps/posix/getaddrinfo.c (revision 13011)
+++ sysdeps/posix/getaddrinfo.c (working copy)
@@ -59,8 +59,10 @@
 #include <nsswitch.h>
 #include <bits/libc-lock.h>
 #include <not-cancel.h>
+#ifdef USE_NSCD
 #include <nscd/nscd-client.h>
 #include <nscd/nscd_proto.h>
+#endif /* USE_NSCD */
 #include <resolv/res_hconf.h>

 #ifdef HAVE_LIBIDN
Index: grp/initgroups.c
===================================================================
--- grp/initgroups.c    (revision 13011)
+++ grp/initgroups.c    (working copy)
@@ -27,11 +27,11 @@
 #include <sys/param.h>
 #include <sys/types.h>
 #include <nsswitch.h>
-
+#ifdef USE_NSCD
 #include "../nscd/nscd-client.h"
 #include "../nscd/nscd_proto.h"
+#endif /* USE_NSCD */

-
 /* Type of the lookup function.  */
 typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t,
                                                   long int *, long int *,
Index: nss/nsswitch.c
===================================================================
--- nss/nsswitch.c      (revision 13011)
+++ nss/nsswitch.c      (working copy)
@@ -40,7 +39,9 @@
 #endif

 #include "nsswitch.h"
+#ifdef USE_NSCD
 #include "../nscd/nscd_proto.h"
+#endif /* USE_NSCD */

 /* When OPTION_EGLIBC_NSSWITCH is disabled, we use fixed tables of
   databases and services, generated at library build time.  Thus:
@@ -799,7 +800,7 @@
 #endif /* __OPTION_EGLIBC_NSSWITCH */


-#if __OPTION_EGLIBC_INET
+#ifdef USE_NSCD
 /* Called by nscd and nscd alone.  */
 void
 __nss_disable_nscd (void)
@@ -810,7 +811,7 @@
  __nss_not_use_nscd_hosts = -1;
  __nss_not_use_nscd_services = -1;
 }
-#endif /* __OPTION_EGLIBC_INET */
+#endif /* USE_NSCD */


 #if __OPTION_EGLIBC_NSSWITCH
Index: nss/nsswitch.h
===================================================================
--- nss/nsswitch.h      (revision 13011)
+++ nss/nsswitch.h      (working copy)
@@ -163,8 +164,10 @@
 libc_hidden_proto (__nss_lookup_function)


+#ifdef USE_NSCD
 /* Called by NSCD to disable recursive calls.  */
 extern void __nss_disable_nscd (void);
+#endif /* USE_NSCD */


 typedef int (*db_lookup_function) (service_user **, const char *, const char *,
Index: option-groups.defaults
===================================================================
--- option-groups.defaults      (revision 13011)
+++ option-groups.defaults      (working copy)
@@ -33,6 +33,7 @@
 OPTION_EGLIBC_LOCALE_CODE = y
 OPTION_EGLIBC_MEMUSAGE = y
 OPTION_EGLIBC_NIS = y
+OPTION_EGLIBC_NSCD = y
 OPTION_EGLIBC_NSSWITCH = y
 OPTION_EGLIBC_RCMD = y
 OPTION_EGLIBC_RTLD_DEBUG = y
Index: option-groups.def
===================================================================
--- option-groups.def   (revision 13011)
+++ option-groups.def   (working copy)
@@ -540,6 +540,13 @@
       This option group depends on the OPTION_EGLIBC_INET option
       group; you must enable that to enable this option group.

+config OPTION_EGLIBC_NSCD
+    bool "Name Service Cache Daemon"
+    depends OPTION_EGLIBC_INET
+    help
+        This option group includes the 'nscd' daemon and its use from
+        EGLIBC.
+
 config OPTION_EGLIBC_NSSWITCH
   bool "Name service switch (nsswitch) support"
   help
Index: ChangeLog.eglibc
===================================================================
--- ChangeLog.eglibc    (revision 13011)
+++ ChangeLog.eglibc    (working copy)
@@ -1,3 +1,26 @@
+2011-02-27  Denis Zaitceff  <zaitceff@xxxxxxxxx>
+
+       Implement the EGLIBC_NSCD option group.
+       * option-groups.def (OPTION_EGLIBC_NSCD): New entry.
+       * option-groups.defaults (OPTION_EGLIBC_NSCD): Initialize.
+       * nscd/Makefile (routines,aux,others,install-sbin,extra-objs): Use
+       new group instead of OPTION_EGLIBC_INET.
+       * grp/Makefile (CFLAGS-...): Ditto.
+       * pwd/Makefile (CFLAGS-...): Ditto.
+       * posix/Makefile (CFLAGS-getaddrinfo.c): Ditto.
+       * inet/Makefile (OPTION_EGLIBC_NSCD-CFLAGS-y): Define and use for
+       CFLAGS-... instead of hardcoded -DUSE_NSCD=1.
+       * nss/Makefile (OPTION_EGLIBC_NSCD-CFLAGS-y): Define as
+       -DUSE_NSCD=1 and use for CFLAGS-{digits_dots,nsswitch}.c
+       * sysdeps/posix/getaddrinfo.c (USE_NSCD): Use for #include
+       NSCD-related headers conditionally.
+       * grp/initgroups.c (USE_NSCD): Ditto.
+       * nss/nsswitch.c (USE_NSCD): Ditto.
+       * nss/nsswitch.c (__nss_disable_nscd): Use USE_NSCD instead of
+       __OPTION_EGLIBC_INET as the condition for compile.
+       * nss/nsswitch.h (__nss_disable_nscd): Use USE_NSCD for
+       conditionalize the declaration.
+
 2011-02-28  Pierre Ynard  <linkfanel@xxxxxxxx>

       [BZ #12492]