aboutsummaryrefslogtreecommitdiff
path: root/nss
diff options
context:
space:
mode:
Diffstat (limited to 'nss')
-rw-r--r--nss/Makefile6
-rw-r--r--nss/function.def95
-rw-r--r--nss/getXXbyYY.c2
-rw-r--r--nss/getXXent.c2
-rw-r--r--nss/getXXent_r.c2
-rw-r--r--nss/nss.h2
-rw-r--r--nss/nss_db/db-XXX.c2
-rw-r--r--nss/nss_db/db-alias.c2
-rw-r--r--nss/nss_db/db-netgrp.c2
-rw-r--r--nss/nss_files/files-XXX.c2
-rw-r--r--nss/nss_files/files-alias.c2
-rw-r--r--nss/nsswitch.c58
12 files changed, 165 insertions, 12 deletions
diff --git a/nss/Makefile b/nss/Makefile
index 02af500..90e5521 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -24,7 +24,8 @@ subdir := nss
headers := nss.h
distribute := nsswitch.h XXX-lookup.c getXXbyYY.c getXXbyYY_r.c \
getXXent.c getXXent_r.c databases.def \
- nsswitch.conf db-Makefile digits_dots.c
+ nsswitch.conf db-Makefile digits_dots.c \
+ function.def
# This is the trivial part which goes into libc itself.
routines = nsswitch $(addsuffix -lookup,$(databases))
@@ -59,8 +60,11 @@ generated += $(filter-out db-alias.c db-netgrp.c, \
$(addsuffix .c,$(libnss_db-routines)))
distribute += db-XXX.c
+
+ifneq ($(build-static-nss),yes)
libnss_files-inhibit-o = $(filter-out .so,$(object-suffixes))
libnss_db-inhibit-o = $(filter-out .so,$(object-suffixes))
+endif
include ../Rules
diff --git a/nss/function.def b/nss/function.def
new file mode 100644
index 0000000..430f4fa
--- /dev/null
+++ b/nss/function.def
@@ -0,0 +1,95 @@
+/* List of all functions defined for the NSS in GNU C Library.
+ Copyright (C) 1996, 1997 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* aliases */
+DEFINE_ENT (files, alias)
+DEFINE_GETBY (files, alias, name)
+DEFINE_ENT (db, alias)
+DEFINE_GETBY (db, alias, name)
+
+/* ethers */
+DEFINE_ENT (files, ether)
+DEFINE_ENT (db, ether)
+
+/* group */
+DEFINE_ENT (files, gr)
+DEFINE_GET (files, grgid)
+DEFINE_GET (files, grnam)
+DEFINE_ENT (db, gr)
+DEFINE_GET (db, grgid)
+DEFINE_GET (db, grnam)
+
+/* hosts */
+DEFINE_ENT (files, host)
+DEFINE_GETBY (files, host, addr)
+DEFINE_GETBY (files, host, name)
+DEFINE_GET (files, hostton)
+DEFINE_GET (files, ntohost)
+DEFINE_GETBY (dns, host, addr)
+DEFINE_GETBY (dns, host, name)
+DEFINE_GETBY (dns, host, name2)
+
+/* netgroup */
+DEFINE_ENT (files, netgr)
+DEFINE_ENT (db, netgr)
+
+/* networks */
+DEFINE_ENT (files, net)
+DEFINE_GETBY (files, net, name)
+DEFINE_GETBY (files, net, addr)
+DEFINE_GETBY (dns, net, name)
+DEFINE_GETBY (dns, net, addr)
+
+/* protocols */
+DEFINE_ENT (files, proto)
+DEFINE_GETBY (files, proto, name)
+DEFINE_GETBY (files, proto, number)
+DEFINE_ENT (db, proto)
+DEFINE_GETBY (db, proto, name)
+DEFINE_GETBY (db, proto, number)
+
+/* passwd */
+DEFINE_ENT (files, pw)
+DEFINE_GET (files, pwnam)
+DEFINE_GET (files, pwuid)
+DEFINE_ENT (db, pw)
+DEFINE_GET (db, pwnam)
+DEFINE_GET (db, pwuid)
+
+/* rpc */
+DEFINE_ENT (files, rpc)
+DEFINE_GETBY (files, rpc, name)
+DEFINE_GETBY (files, rpc, number)
+DEFINE_ENT (db, rpc)
+DEFINE_GETBY (db, rpc, name)
+DEFINE_GETBY (db, rpc, number)
+
+/* services */
+DEFINE_ENT (files, serv)
+DEFINE_GETBY (files, serv, name)
+DEFINE_GETBY (files, serv, port)
+DEFINE_ENT (db, serv)
+DEFINE_GETBY (db, serv, name)
+DEFINE_GETBY (db, serv, port)
+
+/* shadow */
+DEFINE_ENT (files, sp)
+DEFINE_GET (files, spnam)
+DEFINE_ENT (db, sp)
+DEFINE_GET (db, spnam)
diff --git a/nss/getXXbyYY.c b/nss/getXXbyYY.c
index f81df05..47df15b 100644
--- a/nss/getXXbyYY.c
+++ b/nss/getXXbyYY.c
@@ -17,7 +17,7 @@
Boston, MA 02111-1307, USA. */
#include <errno.h>
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
#include <stdlib.h>
#include "nsswitch.h"
diff --git a/nss/getXXent.c b/nss/getXXent.c
index eeb03df..491ab4d 100644
--- a/nss/getXXent.c
+++ b/nss/getXXent.c
@@ -17,7 +17,7 @@
Boston, MA 02111-1307, USA. */
#include <errno.h>
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
#include <stdlib.h>
#include "nsswitch.h"
diff --git a/nss/getXXent_r.c b/nss/getXXent_r.c
index 1df51ab..f2cca25 100644
--- a/nss/getXXent_r.c
+++ b/nss/getXXent_r.c
@@ -17,7 +17,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
#include "nsswitch.h"
diff --git a/nss/nss.h b/nss/nss.h
index b36c53d..dc50cf7 100644
--- a/nss/nss.h
+++ b/nss/nss.h
@@ -20,8 +20,8 @@
and for implementors of new services. */
#ifndef _NSS_H
-
#define _NSS_H 1
+
#include <features.h>
diff --git a/nss/nss_db/db-XXX.c b/nss/nss_db/db-XXX.c
index f4ecb98..0c1b1ad 100644
--- a/nss/nss_db/db-XXX.c
+++ b/nss/nss_db/db-XXX.c
@@ -19,7 +19,7 @@
#include <db.h>
#include <fcntl.h>
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
#include "nsswitch.h"
/* These symbols are defined by the including source file:
diff --git a/nss/nss_db/db-alias.c b/nss/nss_db/db-alias.c
index 51a63a8..8b8cb41 100644
--- a/nss/nss_db/db-alias.c
+++ b/nss/nss_db/db-alias.c
@@ -24,7 +24,7 @@
#include <db.h>
#include <errno.h>
#include <fcntl.h>
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
#include <paths.h>
#include <string.h>
diff --git a/nss/nss_db/db-netgrp.c b/nss/nss_db/db-netgrp.c
index c27c8de..e716dd0 100644
--- a/nss/nss_db/db-netgrp.c
+++ b/nss/nss_db/db-netgrp.c
@@ -22,7 +22,7 @@
#include <errno.h>
#include <fcntl.h>
#include <string.h>
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
#include <paths.h>
#include "nsswitch.h"
#include "netgroup.h"
diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c
index 7472496..3281580 100644
--- a/nss/nss_files/files-XXX.c
+++ b/nss/nss_files/files-XXX.c
@@ -21,7 +21,7 @@
#include <ctype.h>
#include <assert.h>
#include <errno.h>
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
#include "nsswitch.h"
/* These symbols are defined by the including source file:
diff --git a/nss/nss_files/files-alias.c b/nss/nss_files/files-alias.c
index 341e9d4..99217fa 100644
--- a/nss/nss_files/files-alias.c
+++ b/nss/nss_files/files-alias.c
@@ -21,7 +21,7 @@
#include <aliases.h>
#include <ctype.h>
#include <errno.h>
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index f36fe96..16cf0e8 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -21,13 +21,16 @@
#include <dlfcn.h>
#include <errno.h>
#include <netdb.h>
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
#include <link.h> /* We need some help from ld.so. */
#include <search.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <gnu/lib-names.h>
+
+#if !defined DO_STATIC_NSS || defined PIC
+# include <gnu/lib-names.h>
+#endif
#include "nsswitch.h"
@@ -64,8 +67,10 @@ static struct
__libc_lock_define_initialized (static, lock)
+#if !defined DO_STATIC_NSS || defined PIC
/* String with revision number of the shared object files. */
static const char *const __nss_shlib_revision = LIBNSS_FILES_SO + 15;
+#endif
/* The root of the whole data base. */
static name_database *service_table;
@@ -240,6 +245,7 @@ __nss_configure_lookup (const char *dbname, const char *service_line)
}
+#if !defined DO_STATIC_NSS || defined PIC
static int
nss_dlerror_run (void (*operate) (void *), void *args)
{
@@ -292,6 +298,7 @@ get_sym (void *a)
args->loadbase = _dl_lookup_symbol (args->name, &args->ref,
scope, args->map->l_name, 0);
}
+#endif
/* Comparison function for searching NI->known tree. */
static int
@@ -363,6 +370,7 @@ nss_lookup_function (service_user *ni, const char *fct_name)
}
}
+#if !defined DO_STATIC_NSS || defined PIC
if (ni->library->lib_handle == NULL)
{
/* Load the shared library. */
@@ -407,6 +415,52 @@ nss_lookup_function (service_user *ni, const char *fct_name)
result = (nss_dlerror_run (get_sym, &args) ? NULL
: (void *) (args.loadbase + args.ref->st_value));
}
+#else
+ /* We can't get function address dynamically in static linking. */
+ {
+# define DEFINE_ENT(h,nm) \
+ extern void _nss_##h##_get##nm##ent_r (void); \
+ extern void _nss_##h##_end##nm##ent (void); \
+ extern void _nss_##h##_set##nm##ent (void);
+# define DEFINE_GET(h,nm) \
+ extern void _nss_##h##_get##nm##_r (void);
+# define DEFINE_GETBY(h,nm,ky) \
+ extern void _nss_##h##_get##nm##by##ky##_r (void);
+# include "functions.def"
+# undef DEFINE_ENT
+# undef DEFINE_GET
+# undef DEFINE_GETBY
+# define DEFINE_ENT(h,nm) \
+ { #h"_get"#nm"ent_r", _nss_##h##_get##nm##ent_r }, \
+ { #h"_end"#nm"ent", _nss_##h##_end##nm##ent }, \
+ { #h"_set"#nm"ent", _nss_##h##_set##nm##ent },
+# define DEFINE_GET(h,nm) \
+ { #h"_get"#nm"_r", _nss_##h##_get##nm##_r },
+# define DEFINE_GETBY(h,nm,ky) \
+ { #h"_get"#nm"by"#ky"_r", _nss_##h##_get##nm##by##ky##_r },
+ static struct fct_tbl { const char *fname; void *fp; } *tp, tbl[] =
+ {
+# include "functions.def"
+ { NULL, NULL }
+ };
+ size_t namlen = (5 + strlen (ni->library->name) + 1
+ + strlen (fct_name) + 1);
+ char name[namlen];
+
+ /* Construct the function name. */
+ __stpcpy (__stpcpy (__stpcpy (name, ni->library->name),
+ "_"),
+ fct_name);
+
+ result = NULL;
+ for (tp = &tbl[0]; tp->fname; tp++)
+ if (strcmp (tp->fname, name) == 0)
+ {
+ result = tp->fp;
+ break;
+ }
+ }
+#endif
/* Remember function pointer for later calls. Even if null, we
record it so a second try needn't search the library again. */