update from main archive 960829
authordrepper <drepper>
Fri, 30 Aug 1996 00:56:00 +0000 (00:56 +0000)
committerdrepper <drepper>
Fri, 30 Aug 1996 00:56:00 +0000 (00:56 +0000)
nss/Makefile
nss/db-Makefile [new file with mode: 0644]
nss/nsswitch.c
nss/nsswitch.conf [new file with mode: 0644]

index 4a36dcf..b900e96 100644 (file)
@@ -66,10 +66,9 @@ libnss_db-inhibit-o  = $(filter-out .so,$(object-suffixes))
 include ../Rules
 
 
-$(objpfx)libnss_dns.so: $(firstword $(objdir) $(..)resolv)/libresolv.so
+$(objpfx)libnss_dns.so: $(common-objpfx)resolv/libresolv.so
 
-$(objpfx)libnss_db.so: $(firstword $(objdir) $(..)db)/libdb.so \
-                      $(objpfx)libnss_files.so
+$(objpfx)libnss_db.so: $(common-objpfx)db/libdb.so $(objpfx)libnss_files.so
 
 $(libnss_db-routines:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
        @rm -f $@.new
diff --git a/nss/db-Makefile b/nss/db-Makefile
new file mode 100644 (file)
index 0000000..881cabf
--- /dev/null
@@ -0,0 +1,68 @@
+DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
+                      /etc/rpc /etc/services /etc/shadow)
+
+VAR_DB = /var/db
+
+AWK = awk
+MAKEDB = makedb --quiet
+
+all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
+
+
+$(VAR_DB)/passwd.db: /etc/passwd
+       @echo -n "$(patsubst %.db,%,$(@F))... "
+       @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
+                /^[^#]/ { printf ".%s ", $$1; print; \
+                          printf "=%s ", $$3; print }' $^ | \
+       $(MAKEDB) -o $@ -
+       @echo "done."
+
+$(VAR_DB)/group.db: /etc/group
+       @echo -n "$(patsubst %.db,%,$(@F))... "
+       @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
+                /^[^#]/ { printf ".%s ", $$1; print; \
+                          printf "=%s ", $$3; print }' $^ | \
+       $(MAKEDB) -o $@ -
+       @echo "done."
+
+$(VAR_DB)/ethers.db: /etc/ethers
+       @echo -n "$(patsubst %.db,%,$(@F))... "
+       @$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
+                          printf "=%s ", $$2; print }' $^ | \
+       $(MAKEDB) -o $@ -
+       @echo "done."
+
+$(VAR_DB)/protocols.db: /etc/protocols
+       @echo -n "$(patsubst %.db,%,$(@F))... "
+       @$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
+                          printf "=%s ", $$2; print; \
+                          for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
+                            { printf ".%s ", $$i; print } }' $^ | \
+       $(MAKEDB) -o $@ -
+       @echo "done."
+
+$(VAR_DB)/rpc.db: /etc/rpc
+       @echo -n "$(patsubst %.db,%,$(@F))... "
+       @$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
+                          printf "=%s ", $$2; print; \
+                          for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
+                            { printf ".%s ", $$i; print } }' $^ | \
+       $(MAKEDB) -o $@ -
+       @echo "done."
+
+$(VAR_DB)/services.db: /etc/services
+       @echo -n "$(patsubst %.db,%,$(@F))... "
+       @$(AWK) 'BEGIN { FS="[ \t/]+" } \
+                /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
+                          printf "=%s/%s ", $$2, $$3; print; \
+                          for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
+                            { printf ".%s/%s ", $$i, $$3; print } }' $^ | \
+       $(MAKEDB) -o $@ -
+       @echo "done."
+
+$(VAR_DB)/shadow.db: /etc/shadow
+       @echo -n "$(patsubst %.db,%,$(@F))... "
+       @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
+                /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
+       $(MAKEDB) -o $@ -
+       @echo "done."
index 16e1caf..79c9d27 100644 (file)
@@ -235,12 +235,17 @@ __nss_configure_lookup (const char *dbname, const char *service_line)
 static int
 nss_dlerror_run (void (*operate) (void))
 {
-  const char *last_errstring = NULL;
+  char *last_errstring = NULL;
   const char *last_object_name = NULL;
+  int result;
 
   (void) _dl_catch_error (&last_errstring, &last_object_name, operate);
 
-  return last_errstring != NULL;
+  result = last_errstring != NULL;
+  if (result)
+    free (last_errstring);
+
+  return result;
 }
 
 
diff --git a/nss/nsswitch.conf b/nss/nsswitch.conf
new file mode 100644 (file)
index 0000000..08bd96e
--- /dev/null
@@ -0,0 +1,16 @@
+# /etc/nsswitch.conf
+#
+# Example configuration of GNU Name Service Switch functionality.
+#
+
+passwd:                db files
+group:         db files
+shadow:                db files
+
+hosts:         files dns
+networks:      files dns
+
+protocols:     db files
+services:      db files
+ethers:                db files
+rpc:           db files