xref: /freebsd/usr.sbin/ypserv/Makefile.yp (revision 80fc33c35fe19f2977752771068182f0b3edafe7)
1778c7b1cSBill Paul#
2778c7b1cSBill Paul# Makefile for the NIS databases
3778c7b1cSBill Paul#
497d92980SPeter Wemm# $FreeBSD$
5778c7b1cSBill Paul#
6778c7b1cSBill Paul# This Makefile should only be run on the NIS master server of a domain.
7778c7b1cSBill Paul# All updated maps will be pushed to all NIS slave servers listed in the
8778c7b1cSBill Paul# /var/yp/ypservers file. Please make sure that the hostnames of all
9778c7b1cSBill Paul# NIS servers in your domain are listed in /var/yp/ypservers.
10778c7b1cSBill Paul#
11778c7b1cSBill Paul# This Makefile can be modified to support more NIS maps if desired.
12778c7b1cSBill Paul#
13778c7b1cSBill Paul
14778c7b1cSBill Paul# If this machine is an NIS master, comment out this next line so
15778c7b1cSBill Paul# that changes to the NIS maps can be propagated to the slave servers.
16778c7b1cSBill Paul# (By default we assume that we are only serving a small domain with
17778c7b1cSBill Paul# only one server.)
18778c7b1cSBill Paul#
19778c7b1cSBill PaulNOPUSH = "True"
20778c7b1cSBill Paul
21778c7b1cSBill Paul# If you want to use a FreeBSD NIS server to serve non-FreeBSD clients
22778c7b1cSBill Paul# (i.e. clients who expect the password field in the passwd maps to be
23778c7b1cSBill Paul# valid) then uncomment this line. This will cause $YPDIR/passwd to
24778c7b1cSBill Paul# be generated with valid password fields. This is insecure: FreeBSD
25778c7b1cSBill Paul# normally only serves the master.passwd maps (which have real encrypted
26778c7b1cSBill Paul# passwords in them) to the superuser on other FreeBSD machines, but
27778c7b1cSBill Paul# non-FreeBSD clients (e.g. SunOS, Solaris (without NIS+), IRIX, HP-UX,
28778c7b1cSBill Paul# etc...) will only work properly in 'unsecure' mode.
29778c7b1cSBill Paul#
30778c7b1cSBill Paul#UNSECURE = "True"
31778c7b1cSBill Paul
3244519760SBill Paul# The following line encodes the YP_INTERDOMAIN key into the hosts.byname
3344519760SBill Paul# and hosts.byaddr maps so that ypserv(8) will do DNS lookups to resolve
3444519760SBill Paul# hosts not in the current domain. Commenting this line out will disable
3544519760SBill Paul# the DNS lookups.
3644519760SBill PaulB=-b
3744519760SBill Paul
3844519760SBill Paul# Normally, the master.passwd.* maps are guarded against access from
3944519760SBill Paul# non-privileged users. By commenting out the following line, the YP_SECURE
4044519760SBill Paul# key will be removed from these maps, allowing anyone to access them.
4144519760SBill PaulS=-s
4244519760SBill Paul
43778c7b1cSBill Paul# These are commands which this Makefile needs to properly rebuild the
44778c7b1cSBill Paul# NIS databases. Don't change these unless you have a good reason. Also
45778c7b1cSBill Paul# be sure not to place an @ in front of /usr/bin/awk: it isn't necessary
46778c7b1cSBill Paul# and it'll break everything in sight.
47778c7b1cSBill Paul#
48778c7b1cSBill PaulAWK = /usr/bin/awk
49778c7b1cSBill PaulRM  = @/bin/rm -f
50b2264be8SBill PaulMV  = @/bin/mv -f
511754677bSBill PaulRMV  = /bin/mv -f
52778c7b1cSBill PaulRCAT = /bin/cat
53778c7b1cSBill PaulCAT = @$(RCAT)
54778c7b1cSBill Paul
55de88f160SAdam DavidMKDB = /usr/sbin/yp_mkdb
56de88f160SAdam DavidDBLOAD = $(MKDB) -m `hostname`
57778c7b1cSBill PaulMKNETID = /usr/libexec/mknetid
58b2264be8SBill PaulNEWALIASES = /usr/bin/newaliases
591fff226dSBill PaulYPPUSH = /usr/sbin/yppush
60920491cfSBill Paul.if !defined(UPDATE_DOMAIN)
61778c7b1cSBill PaulDOMAIN = `/bin/domainname`
62920491cfSBill Paul.else
63920491cfSBill PaulDOMAIN = $(UPDATE_DOMAIN)
64920491cfSBill Paul.endif
65778c7b1cSBill PaulREVNETGROUP = /usr/libexec/revnetgroup
661754677bSBill PaulTMP = `echo $@.$$$$`
67778c7b1cSBill Paul
68de88f160SAdam David# It is advisable to create a separate directory to contain the
69de88f160SAdam David# source files used to generate your NIS maps. If you intend to
70b2264be8SBill Paul# support multiple domains, something like /src/dir/$DOMAIN
71b2264be8SBill Paul# would work well.
72778c7b1cSBill PaulYPSRCDIR = /etc
7313170f18SBill Paul.if !defined(YP_DIR)
74778c7b1cSBill PaulYPDIR = /var/yp
7513170f18SBill Paul.else
7613170f18SBill PaulYPDIR = $(YP_DIR)
7713170f18SBill Paul.endif
78778c7b1cSBill PaulYPMAPDIR = $(YPDIR)/$(DOMAIN)
79778c7b1cSBill Paul
80778c7b1cSBill Paul# These are the files from which the NIS databases are built. You may edit
81778c7b1cSBill Paul# these to taste in the event that you wish to keep your NIS source files
821a6e52d0SJeroen Ruigrok van der Werven# separate from your NIS server's actual configuration files. Note that the
83778c7b1cSBill Paul# NIS passwd and master.passwd files are stored in /var/yp: the server's
84778c7b1cSBill Paul# real password database is not used by default. However, you may use
85778c7b1cSBill Paul# the real /etc/passwd and /etc/master.passwd files by:
86778c7b1cSBill Paul#
87778c7b1cSBill Paul#
883939bb66SPoul-Henning Kamp# - invoking yppasswdd with `-t /etc/master.passwd' (yppasswdd will do a
893939bb66SPoul-Henning Kamp#   'pwd_mkdb' as needed if /etc/master.passwd is thus specified).
90778c7b1cSBill Paul# - Specifying the location of the master.passwd file using the
91778c7b1cSBill Paul#   MASTER_PASSWD variable, i.e.:
92778c7b1cSBill Paul#
93778c7b1cSBill Paul#   # make MASTER_PASSWD=/path/to/some/other/master.passwd
94778c7b1cSBill Paul#
95778c7b1cSBill Paul# - (optionally): editing this Makefile to change the default location.
96778c7b1cSBill Paul#
97778c7b1cSBill Paul# To add a user, edit $(YPDIR)/master.passwd and type 'make'. The raw
98778c7b1cSBill Paul# passwd file will be generated from the master.passwd file automagically.
99778c7b1cSBill Paul#
100778c7b1cSBill PaulETHERS    = $(YPSRCDIR)/ethers	   # ethernet addresses (for rarpd)
101778c7b1cSBill PaulBOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
102778c7b1cSBill PaulHOSTS     = $(YPSRCDIR)/hosts
103778c7b1cSBill PaulNETWORKS  = $(YPSRCDIR)/networks
104778c7b1cSBill PaulPROTOCOLS = $(YPSRCDIR)/protocols
105778c7b1cSBill PaulRPC 	  = $(YPSRCDIR)/rpc
106778c7b1cSBill PaulSERVICES  = $(YPSRCDIR)/services
10780fc33c3SRobert DrehmelSHELLS    = $(YPSRCDIR)/shells
108778c7b1cSBill PaulGROUP     = $(YPSRCDIR)/group
109a00856a8SGregory Neil ShapiroALIASES   = $(YPSRCDIR)/mail/aliases
110b2264be8SBill PaulNETGROUP  = $(YPDIR)/netgroup
111778c7b1cSBill PaulPASSWD    = $(YPDIR)/passwd
112778c7b1cSBill Paul.if !defined(MASTER_PASSWD)
113778c7b1cSBill PaulMASTER    = $(YPDIR)/master.passwd
114778c7b1cSBill Paul.else
115778c7b1cSBill PaulMASTER	  = $(MASTER_PASSWD)
116778c7b1cSBill Paul.endif
117778c7b1cSBill PaulYPSERVERS = $(YPDIR)/ypservers	# List of all NIS servers for a domain
118778c7b1cSBill PaulPUBLICKEY = $(YPSRCDIR)/publickey
1191fe3e67aSBill PaulNETID     = $(YPSRCDIR)/netid
1203b056022SMark MurrayAMDHOST   = $(YPSRCDIR)/amd.map
121778c7b1cSBill Paul
12213170f18SBill Paul# List of maps that are always built.
12313170f18SBill Paul# If you want to omit some of them, feel free to comment
12413170f18SBill Paul# them out from this list.
12580fc33c3SRobert DrehmelTARGETS= servers hosts networks protocols rpc services shells group
12613170f18SBill Paul#TARGETS+= aliases
12713170f18SBill Paul
12813170f18SBill Paul# Sanity checks: filter out targets we can't build
12913170f18SBill Paul# Note that we don't build the ethers or boorparams maps by default
13013170f18SBill Paul# since /etc/ethers and /etc/bootparams are not likely to be present
13113170f18SBill Paul# on all systems.
13213170f18SBill Paul.if exists($(ETHERS))
13313170f18SBill PaulTARGETS+= ethers
13413170f18SBill Paul.else
13513170f18SBill PaulETHERS= /dev/null
13613170f18SBill Paul.endif
13713170f18SBill Paul
13813170f18SBill Paul.if exists($(BOOTPARAMS))
13913170f18SBill PaulTARGETS+= bootparams
14013170f18SBill Paul.else
14113170f18SBill PaulBOOTPARAMS= /dev/null
14213170f18SBill Paul.endif
14313170f18SBill Paul
14413170f18SBill Paul.if exists($(NETGROUP))
14513170f18SBill PaulTARGETS+= netgrp
14613170f18SBill Paul.else
14713170f18SBill PaulNETGROUP= /dev/null
14813170f18SBill Paul.endif
14913170f18SBill Paul
15013170f18SBill Paul.if exists($(MASTER))
15113170f18SBill PaulTARGETS+= passwd master.passwd netid
15213170f18SBill Paul.else
15313170f18SBill PaulMASTER= /dev/null
15413170f18SBill PaulTARGETS+= nopass
15513170f18SBill Paul.endif
15613170f18SBill Paul
15713170f18SBill Paul.if exists($(PUBLICKEY))
15813170f18SBill PaulTARGETS+= publickey
15913170f18SBill Paul.else
16013170f18SBill PaulPUBLICKEY= /dev/null
16113170f18SBill Paul.endif
16213170f18SBill Paul
16313170f18SBill Paul.if exists($(AMDHOST))
1643b056022SMark MurrayTARGETS+= amd.map
16513170f18SBill Paul.else
16613170f18SBill PaulAMDHOST= /dev/null
16713170f18SBill Paul.endif
16813170f18SBill Paul
169778c7b1cSBill Paultarget:
170778c7b1cSBill Paul	@if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
171920491cfSBill Paul	cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
172778c7b1cSBill Paul	make -f ../Makefile all; echo "NIS Map update completed."
173778c7b1cSBill Paul
17413170f18SBill Paulall: $(TARGETS)
175778c7b1cSBill Paul
176778c7b1cSBill Paulethers:	   ethers.byname ethers.byaddr
177778c7b1cSBill Paulbootparam: bootparams
178778c7b1cSBill Paulhosts:	   hosts.byname hosts.byaddr
179778c7b1cSBill Paulnetworks:  networks.byaddr networks.byname
180778c7b1cSBill Paulprotocols: protocols.bynumber protocols.byname
181778c7b1cSBill Paulrpc:	   rpc.byname rpc.bynumber
182778c7b1cSBill Paulservices:  services.byname
18380fc33c3SRobert Drehmelshells:    shells.list
184778c7b1cSBill Paulpasswd:    passwd.byname passwd.byuid
185778c7b1cSBill Paulgroup:     group.byname group.bygid
186778c7b1cSBill Paulnetgrp:    netgroup
187778c7b1cSBill Paulnetid:	   netid.byname
188778c7b1cSBill Paulservers:   ypservers
189778c7b1cSBill Paulpublickey: publickey.byname
190b2264be8SBill Paulaliases:   mail.aliases
191778c7b1cSBill Paul
192778c7b1cSBill Paulmaster.passwd:	master.passwd.byname master.passwd.byuid
193778c7b1cSBill Paul
194b3e93234SBill Paul#
195b3e93234SBill Paul# This is a special target used only when doing in-place updates with
196b3e93234SBill Paul# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
197b3e93234SBill Paul# server and won't need to be remade. They will have to be pushed to the
198b3e93234SBill Paul# slaves however. Calling this target implicitly insures that this will
199b3e93234SBill Paul# happen.
200b3e93234SBill Paul#
201b3e93234SBill Paulpushpw:
202b3e93234SBill Paul	@$(DBLOAD) -c
203b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
204b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
205b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
206b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
207b3e93234SBill Paul
20813170f18SBill Paulpushmap:
20913170f18SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $(PUSHMAP) ; fi
21013170f18SBill Paul
21113170f18SBill Paulnopass:
21213170f18SBill Paul	@echo ""
21313170f18SBill Paul	@echo "                ********WARNING********"
21413170f18SBill Paul	@echo "  Couldn't find the master.passwd source file. This file"
21513170f18SBill Paul	@echo "  is needed to generate the master.passwd and passwd maps."
21613170f18SBill Paul	@echo "  The default location is /var/yp/master.passwd. You should"
21713170f18SBill Paul	@echo "  edit /var/yp/Makefile and set the MASTER variable to point"
21813170f18SBill Paul	@echo "  to the source file you wish to use for building the passwd"
21913170f18SBill Paul	@echo "  maps, or else invoke make(1) in the following manner:"
22081d30297SNick Hibma	@echo ""
22113170f18SBill Paul	@echo "        make MASTER_PASSWD=/path/to/master.passwd"
22213170f18SBill Paul	@echo ""
22313170f18SBill Paul
224b2264be8SBill Paulmail.aliases: $(ALIASES)
225b2264be8SBill Paul	@echo "Updating $@..."
226de88f160SAdam David	@$(NEWALIASES) -oA$(ALIASES)
227d91013b5SAdam David	@$(MKDB) -u $(ALIASES).db \
2281754677bSBill Paul		| $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP); \
2291754677bSBill Paul		$(RMV) $(TMP) $@
230b2264be8SBill Paul	@$(DBLOAD) -c
231b2264be8SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
232b2264be8SBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
233b2264be8SBill Paul
234778c7b1cSBill Paul
235778c7b1cSBill Paulypservers: $(YPSERVERS)
236778c7b1cSBill Paul	@echo "Updating $@..."
237778c7b1cSBill Paul	$(CAT) $(YPSERVERS) | \
2380f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' $^ \
2391754677bSBill Paul		| $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP); \
2401754677bSBill Paul		$(RMV) $(TMP) $@
241b2264be8SBill Paul	@$(DBLOAD) -c
242778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
243778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
244778c7b1cSBill Paul
245778c7b1cSBill Paulethers.byname: $(ETHERS)
246778c7b1cSBill Paul	@echo "Updating $@..."
24713170f18SBill Paul.if ${ETHERS} == "/dev/null"
24813170f18SBill Paul	@echo "Ethers source file not found -- skipping"
24913170f18SBill Paul.else
250778c7b1cSBill Paul	$(CAT) $(ETHERS) | \
2510f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
252778c7b1cSBill Paul		print $$2"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
2531754677bSBill Paul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
254b2264be8SBill Paul	@$(DBLOAD) -c
255a6dbeb65SPeter Wemm	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
256778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
25713170f18SBill Paul.endif
258778c7b1cSBill Paul
259778c7b1cSBill Paulethers.byaddr: $(ETHERS)
260778c7b1cSBill Paul	@echo "Updating $@..."
26113170f18SBill Paul.if ${ETHERS} == "/dev/null"
26213170f18SBill Paul	@echo "Ethers source file not found -- skipping"
26313170f18SBill Paul.else
264778c7b1cSBill Paul	$(CAT) $(ETHERS) | \
2650f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
266778c7b1cSBill Paul		print $$1"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
2671754677bSBill Paul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
268b2264be8SBill Paul	@$(DBLOAD) -c
269778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
270778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
27113170f18SBill Paul.endif
272778c7b1cSBill Paul
273778c7b1cSBill Paul
274778c7b1cSBill Paulbootparams: $(BOOTPARAMS)
275778c7b1cSBill Paul	@echo "Updating $@..."
27613170f18SBill Paul.if ${BOOTPARAMS} == "/dev/null"
27713170f18SBill Paul	@echo "Bootparams source file not found -- skipping"
27813170f18SBill Paul.else
279778c7b1cSBill Paul	$(CAT) $(BOOTPARAMS) | \
2800f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
281778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(BOOTPARAMS) \
2821754677bSBill Paul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
283b2264be8SBill Paul	@$(DBLOAD) -c
284778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
285778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
28613170f18SBill Paul.endif
287778c7b1cSBill Paul
288778c7b1cSBill Paul
289778c7b1cSBill Paulnetgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
290778c7b1cSBill Paul	@echo "Updating $@..."
29113170f18SBill Paul.if ${NETGROUP} == "/dev/null"
29213170f18SBill Paul	@echo "Netgroup source file not found -- skipping"
29313170f18SBill Paul.else
294778c7b1cSBill Paul	$(CAT) $(NETGROUP) | \
2950f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
296778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
2971754677bSBill Paul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
298b2264be8SBill Paul	@$(DBLOAD) -c
299778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
300778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
301778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
30213170f18SBill Paul.endif
303778c7b1cSBill Paul
304778c7b1cSBill Paul
305778c7b1cSBill Paulnetgroup.byhost: $(NETGROUP)
306778c7b1cSBill Paul	@echo "Updating $@..."
30713170f18SBill Paul.if ${NETGROUP} == "/dev/null"
30813170f18SBill Paul	@echo "Netgroup source file not found -- skipping"
30913170f18SBill Paul.else
310778c7b1cSBill Paul	$(CAT) $(NETGROUP) | $(REVNETGROUP) -h -f $(NETGROUP) | \
3110f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
312778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
3131754677bSBill Paul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
314b2264be8SBill Paul	@$(DBLOAD) -c
315778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
316778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
31713170f18SBill Paul.endif
318778c7b1cSBill Paul
319778c7b1cSBill Paul
320778c7b1cSBill Paulnetgroup.byuser: $(NETGROUP)
321778c7b1cSBill Paul	@echo "Updating $@..."
32213170f18SBill Paul.if ${NETGROUP} == "/dev/null"
32313170f18SBill Paul	@echo "Netgroup source file not found -- skipping"
32413170f18SBill Paul.else
325778c7b1cSBill Paul	$(CAT) $(NETGROUP) | $(REVNETGROUP) -u -f $(NETGROUP) | \
3260f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
327778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
3281754677bSBill Paul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
329b2264be8SBill Paul	@$(DBLOAD) -c
330778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
331778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
33213170f18SBill Paul.endif
333778c7b1cSBill Paul
334778c7b1cSBill Paul
335778c7b1cSBill Paulhosts.byname: $(HOSTS)
336778c7b1cSBill Paul	@echo "Updating $@..."
337778c7b1cSBill Paul	$(CAT) $(HOSTS) | \
3380f87b00dSSteve Price	$(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
33958dc1574SBill Paul		print $$n"\t"$$0 }' $^ | $(DBLOAD) ${B} -i $(HOSTS)  \
3401754677bSBill Paul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
341b2264be8SBill Paul	@$(DBLOAD) -c
342778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
343778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
344778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
345778c7b1cSBill Paul
346b2264be8SBill Paul
347778c7b1cSBill Paulhosts.byaddr: $(HOSTS)
348778c7b1cSBill Paul	@echo "Updating $@..."
349778c7b1cSBill Paul	$(CAT) $(HOSTS) | \
3500f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$0 }' $^ \
3511754677bSBill Paul		| $(DBLOAD) ${B} -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP); \
3521754677bSBill Paul		$(RMV) $(TMP) $@
353b2264be8SBill Paul	@$(DBLOAD) -c
354778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
355778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
356778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
357778c7b1cSBill Paul
358778c7b1cSBill Paul
359778c7b1cSBill Paulnetworks.byname: $(NETWORKS)
360778c7b1cSBill Paul	@echo "Updating $@..."
361778c7b1cSBill Paul	$(CAT) $(NETWORKS) | \
362778c7b1cSBill Paul	$(AWK) \
3630f87b00dSSteve Price	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
3640f87b00dSSteve Price			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
365778c7b1cSBill Paul			      print $$n"\t"$$0 \
3661754677bSBill Paul		}' $^ | $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
3671754677bSBill Paul		$(RMV) $(TMP) $@
368b2264be8SBill Paul	@$(DBLOAD) -c
369778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
370778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
371778c7b1cSBill Paul
372778c7b1cSBill Paul
373778c7b1cSBill Paulnetworks.byaddr: $(NETWORKS)
374778c7b1cSBill Paul	@echo "Updating $@..."
375778c7b1cSBill Paul	$(CAT) $(NETWORKS) | \
3760f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
3771754677bSBill Paul		| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
3781754677bSBill Paul		$(RMV) $(TMP) $@
379b2264be8SBill Paul	@$(DBLOAD) -c
380778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
381778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
382778c7b1cSBill Paul
383778c7b1cSBill Paul
384778c7b1cSBill Paulprotocols.byname: $(PROTOCOLS)
385778c7b1cSBill Paul	@echo "Updating $@..."
386778c7b1cSBill Paul	$(CAT) $(PROTOCOLS) | \
387778c7b1cSBill Paul	$(AWK) \
3880f87b00dSSteve Price	   '$$1 !~ "^#.*"	{ print $$1"\t"$$0; \
3890f87b00dSSteve Price			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
390778c7b1cSBill Paul			      print $$n"\t"$$0 \
391778c7b1cSBill Paul			}' $^ | $(DBLOAD) -i $(PROTOCOLS) \
3921754677bSBill Paul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
393b2264be8SBill Paul	@$(DBLOAD) -c
394778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
395778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
396778c7b1cSBill Paul
397778c7b1cSBill Paul
398778c7b1cSBill Paulprotocols.bynumber: $(PROTOCOLS)
399778c7b1cSBill Paul	@echo "Updating $@..."
400778c7b1cSBill Paul	$(CAT) $(PROTOCOLS) | \
4010f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
4021754677bSBill Paul		| $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP); \
4031754677bSBill Paul		$(RMV) $(TMP) $@
404b2264be8SBill Paul	@$(DBLOAD) -c
405778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
406778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
407778c7b1cSBill Paul
408778c7b1cSBill Paul
409778c7b1cSBill Paulrpc.byname: $(RPC)
410778c7b1cSBill Paul	@echo "Updating $@..."
411778c7b1cSBill Paul	$(CAT) $(RPC) | \
412778c7b1cSBill Paul	$(AWK) \
4130f87b00dSSteve Price	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
4140f87b00dSSteve Price			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
415778c7b1cSBill Paul			      print $$n"\t"$$0 \
4161754677bSBill Paul		}' $^ | $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
4171754677bSBill Paul		$(RMV) $(TMP) $@
418b2264be8SBill Paul	@$(DBLOAD) -c
419778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
420778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
421778c7b1cSBill Paul
422778c7b1cSBill Paul
423778c7b1cSBill Paulrpc.bynumber: $(RPC)
424778c7b1cSBill Paul	@echo "Updating $@..."
425778c7b1cSBill Paul	$(CAT) $(RPC) | \
4260f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
4271754677bSBill Paul		| $(DBLOAD)  -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
4281754677bSBill Paul		$(RMV) $(TMP) $@
429b2264be8SBill Paul	@$(DBLOAD) -c
430778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
431778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
432778c7b1cSBill Paul
433778c7b1cSBill Paul
434778c7b1cSBill Paulservices.byname: $(SERVICES)
435778c7b1cSBill Paul	@echo "Updating $@..."
436778c7b1cSBill Paul	$(CAT) $(SERVICES) | \
437778c7b1cSBill Paul	$(AWK) \
4380f87b00dSSteve Price	   '$$1 !~ "^#.*"  { for (n=1; n<=NF && $$n !~ "^#.*"; n++) { \
439f44298dfSBill Paul				if (split($$2, t, "/")) { \
440f44298dfSBill Paul					printf("%s/%s", $$n, t[2]) }; \
4419ac2a83aSBill Paul					print "\t"$$0;	\
44288b4ff3cSPeter Wemm					if (n == 1) n = 2; \
44388b4ff3cSPeter Wemm			   } ; print $$2"\t"$$0 ; \
4441754677bSBill Paul		}' $^ | $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP); \
4451754677bSBill Paul		$(RMV) $(TMP) $@
446b2264be8SBill Paul	@$(DBLOAD) -c
447778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
448778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
449778c7b1cSBill Paul
45080fc33c3SRobert Drehmelshells.list: $(SHELLS)
45180fc33c3SRobert Drehmel	@echo "Updating $@..."
45280fc33c3SRobert Drehmel	$(CAT) $(SHELLS) | \
45380fc33c3SRobert Drehmel	   $(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' $^ | \
45480fc33c3SRobert Drehmel	   $(DBLOAD) -i $(SHELLS) -o $(YPMAPDIR)/$@ - $(TMP); \
45580fc33c3SRobert Drehmel	 $(RMV) $(TMP) $@
45680fc33c3SRobert Drehmel	@$(DBLOAD) -c
45780fc33c3SRobert Drehmel	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
45880fc33c3SRobert Drehmel	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
459778c7b1cSBill Paul
460778c7b1cSBill Paulpublickey.byname: $(PUBLICKEY)
461778c7b1cSBill Paul	@echo "Updating $@..."
46213170f18SBill Paul.if ${PUBLICKEY} == "/dev/null"
46313170f18SBill Paul	@echo "Publickey source file not found -- skipping"
46413170f18SBill Paul.else
465aca49be3SBill Paul	$(CAT) $(PUBLICKEY) | \
4660f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$2 }' $^ \
4671754677bSBill Paul		| $(DBLOAD)  -i $(PUBLICKEY) -o $(YPMAPDIR)/$@ - $(TMP); \
4681754677bSBill Paul		$(RMV) $(TMP) $@
469b2264be8SBill Paul	@$(DBLOAD) -c
470778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
471778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
47213170f18SBill Paul.endif
473778c7b1cSBill Paul
474778c7b1cSBill Paul
475778c7b1cSBill Paul$(PASSWD): $(MASTER)
476778c7b1cSBill Paul	@echo "Creating new $@ file from $(MASTER)..."
477778c7b1cSBill Paul	@if [ ! $(UNSECURE) ]; then \
478778c7b1cSBill Paul	$(RCAT) $(MASTER) | \
47903806e0dSBrian Somers	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
480778c7b1cSBill Paul		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
481778c7b1cSBill Paul		> $(PASSWD) ; \
482778c7b1cSBill Paul	else $(RCAT) $(MASTER) | \
48303806e0dSBrian Somers	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
484778c7b1cSBill Paul		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
485778c7b1cSBill Paul		> $(PASSWD) ; fi
486778c7b1cSBill Paul
487778c7b1cSBill Paul
488778c7b1cSBill Paulpasswd.byname: $(PASSWD)
489778c7b1cSBill Paul	@echo "Updating $@..."
490778c7b1cSBill Paul	$(CAT) $(PASSWD) | \
4916874ee73SBrian Somers	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
4926874ee73SBrian Somers		print $$1"\t"$$0 }' $^ \
493b22e036eSBill Paul		| $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
4941754677bSBill Paul		$(RMV) $(TMP) $@
495b2264be8SBill Paul	@$(DBLOAD) -c
496778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
497778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
498778c7b1cSBill Paul
499b2264be8SBill Paul
500778c7b1cSBill Paulpasswd.byuid: $(PASSWD)
501778c7b1cSBill Paul	@echo "Updating $@..."
502778c7b1cSBill Paul	$(CAT) $(PASSWD) | \
5036874ee73SBrian Somers	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
5046874ee73SBrian Somers		print $$3"\t"$$0 }' $^ \
505b22e036eSBill Paul		| $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
5061754677bSBill Paul		$(RMV) $(TMP) $@
507b2264be8SBill Paul	@$(DBLOAD) -c
508778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
509778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
510778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
511778c7b1cSBill Paul
512778c7b1cSBill Paul
513778c7b1cSBill Paulgroup.byname: $(GROUP)
514778c7b1cSBill Paul	@echo "Updating $@..."
515778c7b1cSBill Paul	$(CAT) $(GROUP) | \
5166874ee73SBrian Somers	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
5176874ee73SBrian Somers		print $$1"\t"$$0 }' $^ \
518b22e036eSBill Paul		| $(DBLOAD) -f -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
5191754677bSBill Paul		$(RMV) $(TMP) $@
520b2264be8SBill Paul	@$(DBLOAD) -c
521778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
522778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
523778c7b1cSBill Paul
524778c7b1cSBill Paul
525778c7b1cSBill Paulgroup.bygid: $(GROUP)
526778c7b1cSBill Paul	@echo "Updating $@..."
527778c7b1cSBill Paul	$(CAT) $(GROUP) | \
5286874ee73SBrian Somers	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
5296874ee73SBrian Somers		print $$3"\t"$$0 }' $^ \
530b22e036eSBill Paul		| $(DBLOAD) -f -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
5311754677bSBill Paul		$(RMV) $(TMP) $@
532b2264be8SBill Paul	@$(DBLOAD) -c
533778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
534778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
535778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
536778c7b1cSBill Paul
537778c7b1cSBill Paul
538778c7b1cSBill Paulnetid.byname: $(GROUP) $(PASSWD)
539778c7b1cSBill Paul	@echo "Updating $@..."
5401fe3e67aSBill Paul	@$(MKNETID) -q -p $(PASSWD) -g $(GROUP) -h $(HOSTS) -n $(NETID) \
5411754677bSBill Paul		-d $(DOMAIN) | $(DBLOAD) -o $(YPMAPDIR)/$@ - $(TMP); \
5421754677bSBill Paul		$(RMV) $(TMP) $@
543b2264be8SBill Paul	@$(DBLOAD) -c
544778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
545778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
546778c7b1cSBill Paul
547778c7b1cSBill Paul
548778c7b1cSBill Paulmaster.passwd.byname: $(MASTER)
549778c7b1cSBill Paul	@echo "Updating $@..."
55013170f18SBill Paul.if ${MASTER} == "/dev/null"
55113170f18SBill Paul	@echo "Master.passwd source file not found -- skipping"
55213170f18SBill Paul.else
553778c7b1cSBill Paul	$(CAT) $(MASTER) | \
55403806e0dSBrian Somers	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
55503806e0dSBrian Somers		print $$1"\t"$$0 }' $^ \
556b22e036eSBill Paul		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
5571754677bSBill Paul		$(RMV) $(TMP) $@
558b2264be8SBill Paul	@$(DBLOAD) -c
559778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
560778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
56113170f18SBill Paul.endif
562778c7b1cSBill Paul
563778c7b1cSBill Paul
564778c7b1cSBill Paulmaster.passwd.byuid: $(MASTER)
565778c7b1cSBill Paul	@echo "Updating $@..."
56613170f18SBill Paul.if ${MASTER} == "/dev/null"
56713170f18SBill Paul	@echo "Master.passwd source file not found -- skipping"
56813170f18SBill Paul.else
569778c7b1cSBill Paul	$(CAT) $(MASTER) | \
57003806e0dSBrian Somers	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
57103806e0dSBrian Somers		print $$3"\t"$$0 }' $^ \
572b22e036eSBill Paul		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
5731754677bSBill Paul		$(RMV) $(TMP) $@
574b2264be8SBill Paul	@$(DBLOAD) -c
575778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
576778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
57713170f18SBill Paul.endif
57813170f18SBill Paul
57957948c0bSPeter Wemm
5803b056022SMark Murrayamd.map: $(AMDHOST)
58157948c0bSPeter Wemm	@echo "Updating $@..."
58257948c0bSPeter Wemm	$(CAT) $(AMDHOST) | \
5830f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*"  { \
58457948c0bSPeter Wemm	  for (i = 1; i <= NF; i++) \
58557948c0bSPeter Wemm	  if (i == NF) { \
58657948c0bSPeter Wemm	    if (substr($$i, length($$i), 1) == "\\") \
58757948c0bSPeter Wemm	      printf("%s", substr($$i, 1, length($$i) - 1)); \
58857948c0bSPeter Wemm	    else \
58957948c0bSPeter Wemm	      printf("%s\n", $$i); \
59057948c0bSPeter Wemm	  } \
59157948c0bSPeter Wemm	  else \
59257948c0bSPeter Wemm	    printf("%s ", $$i); \
59357948c0bSPeter Wemm	}' | \
5941754677bSBill Paul	$(DBLOAD) -i $(AMDHOST) -o $(YPMAPDIR)/$@ - $(TMP); \
5951754677bSBill Paul		$(RMV) $(TMP) $@
59657948c0bSPeter Wemm	@$(DBLOAD) -c
59757948c0bSPeter Wemm	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
59857948c0bSPeter Wemm	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
59957948c0bSPeter Wemm
600