summaryrefslogtreecommitdiff
path: root/nss/db-Makefile
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-06-14 22:21:51 -0400
committerUlrich Drepper <drepper@gmail.com>2011-06-15 21:06:18 -0400
commit2666d441c2d8107b1987b869714189af64b954c6 (patch)
treec7b8877d691db280202b4c7655907a1165ec84fc /nss/db-Makefile
parent9ee76b5ae861ff9891e5586fc6906c94c447a9e0 (diff)
downloadglibc-2666d441c2d8107b1987b869714189af64b954c6.tar.gz
Reenable nss_db with a completely new implementation
No longer is Berkeley db used. Instead a simple hash function is used. The database files are not updated once they are created and therefore no complicated database is needed.
Diffstat (limited to 'nss/db-Makefile')
-rw-r--r--nss/db-Makefile70
1 files changed, 43 insertions, 27 deletions
diff --git a/nss/db-Makefile b/nss/db-Makefile
index f9c6bd37d7..649e09ced6 100644
--- a/nss/db-Makefile
+++ b/nss/db-Makefile
@@ -1,5 +1,5 @@
# Makefile to (re-)generate db versions of system database files.
-# Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1998, 2011 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
#
@@ -20,7 +20,8 @@
# 02111-1307 USA.
DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
- /etc/rpc /etc/services /etc/shadow /etc/netgroup)
+ /etc/rpc /etc/services /etc/shadow /etc/gshadow \
+ /etc/netgroup)
VAR_DB = /var/db
@@ -32,10 +33,9 @@ all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
$(VAR_DB)/passwd.db: /etc/passwd
@echo -n "$(patsubst %.db,%,$(@F))... "
- @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
+ @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
/^[ \t]*$$/ { next } \
/^[ \t]*#/ { next } \
- { printf "0%u ", cnt++; print } \
/^[^#]/ { printf ".%s ", $$1; print; \
printf "=%s ", $$3; print }' $^ | \
$(MAKEDB) -o $@ -
@@ -43,10 +43,9 @@ $(VAR_DB)/passwd.db: /etc/passwd
$(VAR_DB)/group.db: /etc/group
@echo -n "$(patsubst %.db,%,$(@F))... "
- @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
+ @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
/^[ \t]*$$/ { next } \
/^[ \t]*#/ { next } \
- { printf "0%u ", cnt++; print } \
/^[^#]/ { printf ".%s ", $$1; print; \
printf "=%s ", $$3; print }' $^ | \
$(MAKEDB) -o $@ -
@@ -54,10 +53,8 @@ $(VAR_DB)/group.db: /etc/group
$(VAR_DB)/ethers.db: /etc/ethers
@echo -n "$(patsubst %.db,%,$(@F))... "
- @$(AWK) 'BEGIN { cnt=0 } \
- /^[ \t]*$$/ { next } \
+ @$(AWK) '/^[ \t]*$$/ { next } \
/^[ \t]*#/ { next } \
- { printf "0%u ", cnt++; print } \
/^[^#]/ { printf ".%s ", $$1; print; \
printf "=%s ", $$2; print }' $^ | \
$(MAKEDB) -o $@ -
@@ -65,10 +62,8 @@ $(VAR_DB)/ethers.db: /etc/ethers
$(VAR_DB)/protocols.db: /etc/protocols
@echo -n "$(patsubst %.db,%,$(@F))... "
- @$(AWK) 'BEGIN { cnt=0 } \
- /^[ \t]*$$/ { next } \
+ @$(AWK) '/^[ \t]*$$/ { next } \
/^[ \t]*#/ { next } \
- { printf "0%u ", cnt++; print } \
/^[^#]/ { printf ".%s ", $$1; print; \
printf "=%s ", $$2; print; \
for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
@@ -78,10 +73,8 @@ $(VAR_DB)/protocols.db: /etc/protocols
$(VAR_DB)/rpc.db: /etc/rpc
@echo -n "$(patsubst %.db,%,$(@F))... "
- @$(AWK) 'BEGIN { cnt=0 } \
- /^[ \t]*$$/ { next } \
+ @$(AWK) '/^[ \t]*$$/ { next } \
/^[ \t]*#/ { next } \
- { printf "0%u ", cnt++; print } \
/^[^#]/ { printf ".%s ", $$1; print; \
printf "=%s ", $$2; print; \
for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
@@ -91,26 +84,25 @@ $(VAR_DB)/rpc.db: /etc/rpc
$(VAR_DB)/services.db: /etc/services
@echo -n "$(patsubst %.db,%,$(@F))... "
- @$(AWK) 'BEGIN { FS="[ \t/]+"; cnt=0 } \
+ @$(AWK) 'BEGIN { FS="[ \t/]+" } \
/^[ \t]*$$/ { next } \
/^[ \t]*#/ { next } \
- { printf "0%u ", cnt++; print } \
- /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
- printf ".%s/ ", $$1; print; \
+ /^[^#]/ { sub(/[ \t]*#.*$$/, "");\
+ printf ":%s/%s ", $$1, $$3; print; \
+ printf ":%s/ ", $$1; print; \
printf "=%s/%s ", $$2, $$3; print; \
printf "=%s/ ", $$2; print; \
for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
- { printf ".%s/%s ", $$i, $$3; print; \
- printf ".%s/ ", $$i; print } }' $^ | \
+ { printf ":%s/%s ", $$i, $$3; print; \
+ printf ":%s/ ", $$i; print } }' $^ | \
$(MAKEDB) -o $@ -
@echo "done."
$(VAR_DB)/shadow.db: /etc/shadow
@echo -n "$(patsubst %.db,%,$(@F))... "
- @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
+ @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
/^[ \t]*$$/ { next } \
/^[ \t]*#/ { next } \
- { printf "0%u ", cnt++; print } \
/^[^#]/ { printf ".%s ", $$1; print }' $^ | \
(umask 077 && $(MAKEDB) -o $@ -)
@echo "done."
@@ -126,14 +118,38 @@ $(VAR_DB)/shadow.db: /etc/shadow
echo; \
fi
+$(VAR_DB)/gshadow.db: /etc/gshadow
+ @echo -n "$(patsubst %.db,%,$(@F))... "
+ @$(AWK) 'BEGIN { FS=":"; OFS=":" } \
+ /^[ \t]*$$/ { next } \
+ /^[ \t]*#/ { next } \
+ /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
+ (umask 077 && $(MAKEDB) -o $@ -)
+ @echo "done."
+ @if chgrp shadow $@ 2>/dev/null; then \
+ chmod g+r $@; \
+ else \
+ chown 0 $@; chgrp 0 $@; chmod 600 $@; \
+ echo; \
+ echo "Warning: The shadow group database $@"; \
+ echo "has been set to be readable only by root. You may want"; \
+ echo "to make it readable by the \`shadow' group depending"; \
+ echo "on your configuration."; \
+ echo; \
+ fi
+
$(VAR_DB)/netgroup.db: /etc/netgroup
@echo -n "$(patsubst %.db,%,$(@F))... "
- @$(AWK) 'BEGIN { cnt=0 } \
+ @$(AWK) 'BEGIN { ini=1 } \
/^[ \t]*$$/ { next } \
/^[ \t]*#/ { next } \
- { printf "0%u ", cnt++; print } \
- /^[^#]/ { end=sub(/\\/, " "); \
+ /^[^#]/ { if (sub(/[ \t]*\\$$/, " ") == 0) end="\n"; \
+ else end=""; \
gsub(/[ \t]+/, " "); \
- if(end == 1) printf "%s", $$0; else print }' $^ | \
+ sub(/^[ \t]*/, ""); \
+ if (ini == 0) printf "%s%s", $$0, end; \
+ else printf ".%s %s%s", $$1, $$0, end; \
+ ini=end == "" ? 0 : 1; } \
+ END { if (ini==0) printf "\n" }' $^ | \
$(MAKEDB) -o $@ -
@echo "done."