+2012-08-22 Roland McGrath <roland@hack.frob.com>
+
+ [BZ# 13696]
+ * configure.in (use_nscd): New substituted variable, set by
+ --disable-nscd. If enabled, define USE_NSCD.
+ * configure: Regenerated.
+ * config.h.in: Add USE_NSCD.
+ * config.make.in (use-nscd): New substituted variable.
+ * inet/Makefile (CFLAGS-gethstbyad_r.c): Likewise.
+ (CFLAGS-gethstbynm_r.c, CFLAGS-gethstbynm2_r.c): Likewise.
+ (CFLAGS-getsrvbynm_r.c, CFLAGS-getsrvbypt_r.c): Variables removed.
+ * grp/Makefile (CFLAGS-getgrgid_r.c): Remove -DUSE_NSCD.
+ (CFLAGS-getgrnam_r.c): Likewise.
+ (CFLAGS-initgroups.c): Likewise.
+ * posix/Makefile (CFLAGS-getaddrinfo.c): Remove -DUSE_NSCD.
+ * pwd/Makefile (CFLAGS-getpwuid_r.c, CFLAGS-getpwnam_r.c):
+ Variables removed.
+ * inet/getnetgrent_r.c
+ (nscd_setnetgrent): New function, broken out of ...
+ (setnetgrent): ... here. Call it.
+ (innetgr): Conditionalize nscd bits on [USE_NSCD].
+ (nscd_getnetgrent): Conditionalize on [USE_NSCD].
+ (__internal_getnetgrent_r): Conditionalize its use on [USE_NSCD].
+ * nscd/Makefile (routines, aux): Move definitions after include of
+ Makeconfig. Conditionalize on [$(use-nscd) != no].
+ * nss/nsswitch.c (nss_load_all_libraries, __nss_disable_nscd):
+ Conditionalize on [USE_NSCD].
+ (is_nscd, nscd_init_cb): Likewise.
+ (nss_load_library): Conditionalize init callback on [USE_NSCD].
+ * nss/nss_files/files-init.c: Conditionalize body on [USE_NSCD].
+ * nss/nss_db/db-init.c: Likewise.
+ * nscd/nscd.c (main): Conditionalize __nss_disable_nscd call on
+ [USE_NSCD].
+ * sysdeps/unix/sysv/linux/check_pf.c (get_nl_timestamp): New function.
+ (make_request): Use it.
+ (cache_valid_p): New function.
+ (__check_pf): Use it.
+ * NEWS: Add item for --disable-nscd.
+
2012-08-22 Dmitry V. Levin <ldv@altlinux.org>
* configure.in (SED): Update AC_CHECK_PROG_VER's version extract regexp
* The following bugs are resolved with this release:
- 6778, 6808, 9685, 11607, 13717, 13939, 14042, 14090, 14166, 14150, 14151,
- 14154, 14157, 14166, 14173, 14195, 14252, 14283, 14298, 14303, 14307,
- 14328, 14331, 14336, 14337, 14347, 14349, 14505
+ 6778, 6808, 9685, 11607, 13717, 13696, 13939, 14042, 14090, 14166, 14150,
+ 14151, 14154, 14157, 14166, 14173, 14195, 14252, 14283, 14298, 14303,
+ 14307, 14328, 14331, 14336, 14337, 14347, 14349, 14505
* Support for STT_GNU_IFUNC symbols added for s390 and s390x.
Optimized versions of memcpy, memset, and memcmp added for System z10 and
* Optimizations of string functions memchr, wcschr, wcscpy, and wcsrchr for
powerpc POWER7. Implemented by Will Schmidt.
+* New configure option --disable-nscd builds the C library such that it
+ never attempts to contact the Name Service Caching Daemon (nscd).
+
\f
Version 2.16
/* Define if Systemtap <sys/sdt.h> probes should be defined. */
#undef USE_STAP_PROBE
+/* Define if library functions should try to contact the nscd daemon. */
+#undef USE_NSCD
+
/*
\f */
cross-compiling = @cross_compiling@
force-install = @force_install@
link-obsolete-rpc = @link_obsolete_rpc@
+use-nscd = @use_nscd@
# Build tools.
CC = @CC@
libc_cv_localedir
libc_cv_slibdir
old_glibc_headers
+use_nscd
libc_cv_gcc_unwind_find_fde
libc_extra_cflags
CPPUNDEFS
enable_nss_crypt
enable_obsolete_rpc
enable_systemtap
+enable_nscd
with_cpu
'
ac_precious_vars='build_alias
--enable-obsolete-rpc build and install the obsolete RPC code for
link-time usage
--enable-systemtap enable systemtap static probe points [default=no]
+ --disable-nscd library functions will not contact the nscd daemon
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
fi
fi
+# Note the use of $use_nscd is near the bottom of the file.
+# Check whether --enable-nscd was given.
+if test "${enable_nscd+set}" = set; then :
+ enableval=$enable_nscd; use_nscd=$enableval
+else
+ use_nscd=yes
+fi
+
+
# The way shlib-versions is used to generate soversions.mk uses a
# fairly simplistic model for name recognition that can't distinguish
# i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
fi
+# This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
+# configure fragment can override the value to prevent this AC_DEFINE.
+
+if test "x$use_nscd" != xno; then
+ $as_echo "#define USE_NSCD 1" >>confdefs.h
+
+fi
+
# Test for old glibc 2.0.x headers so that they can be removed properly
# Search only in includedir.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for old glibc 2.0.x headers" >&5
fi
fi
+# Note the use of $use_nscd is near the bottom of the file.
+AC_ARG_ENABLE([nscd],
+ [AS_HELP_STRING([--disable-nscd],
+ [library functions will not contact the nscd daemon])],
+ [use_nscd=$enableval],
+ [use_nscd=yes])
+
# The way shlib-versions is used to generate soversions.mk uses a
# fairly simplistic model for name recognition that can't distinguish
# i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
fi
AC_SUBST(libc_cv_gcc_unwind_find_fde)
+# This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
+# configure fragment can override the value to prevent this AC_DEFINE.
+AC_SUBST(use_nscd)
+if test "x$use_nscd" != xno; then
+ AC_DEFINE([USE_NSCD])
+fi
+
# Test for old glibc 2.0.x headers so that they can be removed properly
# Search only in includedir.
AC_MSG_CHECKING(for old glibc 2.0.x headers)
ifeq ($(have-thread-library),yes)
-CFLAGS-getgrgid_r.c = -DUSE_NSCD=1 -fexceptions
-CFLAGS-getgrnam_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-getgrgid_r.c = -fexceptions
+CFLAGS-getgrnam_r.c = -fexceptions
CFLAGS-getgrent_r.c = -fexceptions
CFLAGS-getgrent.c = -fexceptions
CFLAGS-fgetgrent.c = -fexceptions
CFLAGS-fgetgrent_r.c = -fexceptions $(libio-mtsafe)
CFLAGS-putgrent.c = -fexceptions $(libio-mtsafe)
-CFLAGS-initgroups.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-initgroups.c = -fexceptions
CFLAGS-getgrgid.c = -fexceptions
endif
ifeq ($(have-thread-library),yes)
-CFLAGS-gethstbyad_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-gethstbyad_r.c = -fexceptions
CFLAGS-gethstbyad.c = -fexceptions
-CFLAGS-gethstbynm_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-gethstbynm_r.c = -fexceptions
CFLAGS-gethstbynm.c = -fexceptions
-CFLAGS-gethstbynm2_r.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-gethstbynm2_r.c = -fexceptions
CFLAGS-gethstbynm2.c = -fexceptions
CFLAGS-gethstent_r.c = -fexceptions
CFLAGS-gethstent.c = -fexceptions
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-getprtent_r.c = -fexceptions
CFLAGS-getprtent.c = -fexceptions
CFLAGS-either_ntoh.c = -fexceptions
}
libc_hidden_def (__internal_setnetgrent)
-int
-setnetgrent (const char *group)
+static int
+nscd_setnetgrent (const char *group)
{
- int result;
-
- __libc_lock_lock (lock);
-
+#ifdef USE_NSCD
if (__nss_not_use_nscd_netgroup > 0
&& ++__nss_not_use_nscd_netgroup > NSS_NSCD_RETRY)
__nss_not_use_nscd_netgroup = 0;
if (!__nss_not_use_nscd_netgroup
&& !__nss_database_custom[NSS_DBSIDX_netgroup])
- {
- result = __nscd_setnetgrent (group, &dataset);
- if (result >= 0)
- goto out;
- }
+ return __nscd_setnetgrent (group, &dataset);
+#endif
+ return -1;
+}
- result = __internal_setnetgrent (group, &dataset);
+int
+setnetgrent (const char *group)
+{
+ int result;
+
+ __libc_lock_lock (lock);
+
+ result = nscd_setnetgrent (group);
+ if (result < 0)
+ result = __internal_setnetgrent (group, &dataset);
- out:
__libc_lock_unlock (lock);
return result;
__libc_lock_unlock (lock);
}
-
+#ifdef USE_NSCD
static enum nss_status
nscd_getnetgrent (struct __netgrent *datap, char *buffer, size_t buflen,
int *errnop)
return NSS_STATUS_SUCCESS;
}
-
+#endif
int
internal_function
int no_more = datap->nip == NULL;
if (! no_more)
{
+#ifdef USE_NSCD
+ /* This bogus function pointer is a special marker left by
+ __nscd_setnetgrent to tell us to use the data it left
+ before considering any modules. */
if (datap->nip == (service_user *) -1l)
fct = nscd_getnetgrent;
else
+#endif
{
fct = __nss_lookup_function (datap->nip, "getnetgrent_r");
no_more = fct == NULL;
innetgr (const char *netgroup, const char *host, const char *user,
const char *domain)
{
+#ifdef USE_NSCD
if (__nss_not_use_nscd_netgroup > 0
&& ++__nss_not_use_nscd_netgroup > NSS_NSCD_RETRY)
__nss_not_use_nscd_netgroup = 0;
if (result >= 0)
return result;
}
+#endif
union
{
#
subdir := nscd
+include ../Makeconfig
+
+ifneq ($(use-nscd),no)
routines := nscd_getpw_r nscd_getgr_r nscd_gethst_r nscd_getai \
nscd_initgroups nscd_getserv_r nscd_netgroup
aux := nscd_helper
-
-include ../Makeconfig
+endif
# To find xmalloc.c
vpath %.c ../locale/programs
# endif
#endif
+#ifdef USE_NSCD
/* Make sure we do not get recursive calls. */
__nss_disable_nscd (register_traced_file);
+#endif
/* Init databases. */
nscd_init ();
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifdef USE_NSCD
+
#include <paths.h>
#include <nscd/nscd.h>
#include <string.h>
strcpy (serv_traced_file.file.fname, _PATH_VARDB "services.db");
cb (servdb, &serv_traced_file.file);
}
+
+#endif
/* Initialization in nss_files module.
- Copyright (C) 2011 Free Software Foundation, Inc.
+ Copyright (C) 2011-2012 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
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifdef USE_NSCD
+
#include <nscd/nscd.h>
cb (netgrdb, &netgr_traced_file.file);
}
+
+#endif
static name_database_entry *defconfig_entries;
+#ifdef USE_NSCD
/* Nonzero if this is the nscd process. */
static bool is_nscd;
/* The callback passed to the init functions when nscd is used. */
static void (*nscd_init_cb) (size_t, struct traced_file *);
+#endif
/* -1 == database not found
ni->library->lib_handle = (void *) -1l;
__set_errno (saved_errno);
}
+# ifdef USE_NSCD
else if (is_nscd)
{
/* Call the init function when nscd is used. */
if (ifct != NULL)
{
void (*cb) (size_t, struct traced_file *) = nscd_init_cb;
-# ifdef PTR_DEMANGLE
+# ifdef PTR_DEMANGLE
PTR_DEMANGLE (cb);
-# endif
+# endif
ifct (cb);
}
}
+# endif
}
return 0;
}
-#ifdef SHARED
+#if defined SHARED && defined USE_NSCD
/* Load all libraries for the service. */
static void
nss_load_all_libraries (const char *service, const char *def)
mv -f $@.new $@
CFLAGS-regex.c = -Wno-strict-prototypes
-CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions -DUSE_NSCD
+CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions
CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
ifeq ($(have-thread-library),yes)
-CFLAGS-getpwuid_r.c = -DUSE_NSCD=1
-CFLAGS-getpwnam_r.c = -DUSE_NSCD=1
CFLAGS-getpwent_r.c = -fexceptions
CFLAGS-getpwent.c = -fexceptions
CFLAGS-getpw.c = -fexceptions
}
#endif
+static inline uint32_t
+get_nl_timestamp (void)
+{
+#ifdef IS_IN_nscd
+ return nl_timestamp;
+#elif defined USE_NSCD
+ return __nscd_get_nl_timestamp ();
+#else
+ return 0;
+#endif
+}
+
+static inline bool
+cache_valid_p (void)
+{
+ if (cache != NULL)
+ {
+ uint32_t timestamp = get_nl_timestamp ();
+ return timestamp != 0 && cache->timestamp == timestamp;
+ }
+ return false;
+}
+
static struct cached_data *
make_request (int fd, pid_t pid)
if (result == NULL)
goto out_fail;
-#ifdef IS_IN_nscd
- result->timestamp = nl_timestamp;
-#else
- result->timestamp = __nscd_get_nl_timestamp ();
-#endif
+ result->timestamp = get_nl_timestamp ();
result->usecnt = 2;
result->seen_ipv4 = seen_ipv4;
result->seen_ipv6 = true;
__libc_lock_lock (lock);
-#ifdef IS_IN_nscd
-# define cache_valid() nl_timestamp != 0 && cache->timestamp == nl_timestamp
-#else
-# define cache_valid() \
- ({ uint32_t val = __nscd_get_nl_timestamp (); \
- val != 0 && cache->timestamp == val; })
-#endif
- if (cache != NULL && cache_valid ())
+ if (cache_valid_p ())
{
data = cache;
atomic_increment (&cache->usecnt);