-/* Copyright (C) 1996-2014 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
#include <dlfcn.h>
#include <errno.h>
#include <netdb.h>
-#include <bits/libc-lock.h>
+#include <libc-lock.h>
#include <search.h>
#include <stdio.h>
#include <stdio_ext.h>
#include "nsswitch.h"
#include "../nscd/nscd_proto.h"
#include <sysdep.h>
+#include <config.h>
+
+#ifdef LINK_OBSOLETE_NSL
+# define DEFAULT_CONFIG "compat [NOTFOUND=return] files"
+# define DEFAULT_DEFCONFIG "nis [NOTFOUND=return] files"
+#else
+# define DEFAULT_CONFIG "files"
+# define DEFAULT_DEFCONFIG "files"
+#endif
/* Prototypes for the local functions. */
-static name_database *nss_parse_file (const char *fname) internal_function;
-static name_database_entry *nss_getline (char *line) internal_function;
-static service_user *nss_parse_service_list (const char *line)
- internal_function;
+static name_database *nss_parse_file (const char *fname);
+static name_database_entry *nss_getline (char *line);
+static service_user *nss_parse_service_list (const char *line);
#if !defined DO_STATIC_NSS || defined SHARED
static service_library *nss_new_service (name_database *database,
- const char *name) internal_function;
+ const char *name);
#endif
/* Declare external database variables. */
#define DEFINE_DATABASE(name) \
- extern service_user *__nss_##name##_database attribute_hidden; \
+ service_user *__nss_##name##_database attribute_hidden; \
weak_extern (__nss_##name##_database)
#include "databases.def"
#undef DEFINE_DATABASE
};
#define ndatabases (sizeof (databases) / sizeof (databases[0]))
+#ifdef USE_NSCD
/* Flags whether custom rules for database is set. */
bool __nss_database_custom[NSS_DBSIDX_max];
+#endif
__libc_lock_define_initialized (static, lock)
static name_database_entry *defconfig_entries;
-#ifdef USE_NSCD
+#if defined USE_NSCD && (!defined DO_STATIC_NSS || defined SHARED)
/* Nonzero if this is the nscd process. */
static bool is_nscd;
/* The callback passed to the init functions when nscd is used. */
or null to use the most common default. */
if (*ni == NULL)
{
- *ni = nss_parse_service_list (defconfig
- ?: "nis [NOTFOUND=return] files");
+ *ni = nss_parse_service_list (defconfig ?: DEFAULT_DEFCONFIG);
if (*ni != NULL)
{
/* Record the memory we've just allocated in defconfig_entries list,
/* Install new rules. */
*databases[cnt].dbp = new_db;
+#ifdef USE_NSCD
__nss_database_custom[cnt] = true;
+#endif
__libc_lock_unlock (lock);
static name_database *
-internal_function
nss_parse_file (const char *fname)
{
FILE *fp;
last = this;
}
}
- while (!feof_unlocked (fp));
+ while (!__feof_unlocked (fp));
/* Free the buffer. */
free (line);
`( <source> ( "[" "!"? (<status> "=" <action> )+ "]" )? )*'
*/
static service_user *
-internal_function
nss_parse_service_list (const char *line)
{
service_user *result = NULL, **nextp = &result;
else if (line - name == 8
&& __strncasecmp (name, "CONTINUE", 8) == 0)
action = NSS_ACTION_CONTINUE;
+ else if (line - name == 5
+ && __strncasecmp (name, "MERGE", 5) == 0)
+ action = NSS_ACTION_MERGE;
else
goto finish;
}
static name_database_entry *
-internal_function
nss_getline (char *line)
{
const char *name;
#if !defined DO_STATIC_NSS || defined SHARED
static service_library *
-internal_function
nss_new_service (name_database *database, const char *name)
{
service_library **currentp = &database->library;
is_nscd = true;
/* Find all the relevant modules so that the init functions are called. */
- nss_load_all_libraries ("passwd", "compat [NOTFOUND=return] files");
- nss_load_all_libraries ("group", "compat [NOTFOUND=return] files");
+ nss_load_all_libraries ("passwd", DEFAULT_CONFIG);
+ nss_load_all_libraries ("group", DEFAULT_CONFIG);
nss_load_all_libraries ("hosts", "dns [!UNAVAIL=return] files");
nss_load_all_libraries ("services", NULL);