xref: /freebsd/usr.sbin/ypserv/Makefile.yp (revision 0f87b00d6b41a9a990f3d47e70e4113202c2d3b2)
1778c7b1cSBill Paul#
2778c7b1cSBill Paul# Makefile for the NIS databases
3778c7b1cSBill Paul#
40f87b00dSSteve Price# $Id: Makefile.yp,v 1.18 1997/11/10 22:17:10 wpaul Exp $
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
51778c7b1cSBill PaulRCAT = /bin/cat
52778c7b1cSBill PaulCAT = @$(RCAT)
53778c7b1cSBill Paul
54de88f160SAdam DavidMKDB = /usr/sbin/yp_mkdb
55de88f160SAdam DavidDBLOAD = $(MKDB) -m `hostname`
56778c7b1cSBill PaulMKNETID = /usr/libexec/mknetid
57b2264be8SBill PaulNEWALIASES = /usr/bin/newaliases
581fff226dSBill PaulYPPUSH = /usr/sbin/yppush
59920491cfSBill Paul.if !defined(UPDATE_DOMAIN)
60778c7b1cSBill PaulDOMAIN = `/bin/domainname`
61920491cfSBill Paul.else
62920491cfSBill PaulDOMAIN = $(UPDATE_DOMAIN)
63920491cfSBill Paul.endif
64778c7b1cSBill PaulREVNETGROUP = /usr/libexec/revnetgroup
65b2264be8SBill PaulNFILE = /tmp/ypmake
66b2264be8SBill PaulTMP = `$(RCAT) $(NFILE)`
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
82778c7b1cSBill Paul# seperate 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#
88778c7b1cSBill Paul# - invoking yppasswdd without the -m option (yppasswdd will use
89778c7b1cSBill Paul#   /etc/master.passwd if no alternate master.passwd file is specified
90778c7b1cSBill Paul#   and do a 'pwd_mkdb' as needed).
91778c7b1cSBill Paul# - Specifying the location of the master.passwd file using the
92778c7b1cSBill Paul#   MASTER_PASSWD variable, i.e.:
93778c7b1cSBill Paul#
94778c7b1cSBill Paul#   # make MASTER_PASSWD=/path/to/some/other/master.passwd
95778c7b1cSBill Paul#
96778c7b1cSBill Paul# - (optionally): editing this Makefile to change the default location.
97778c7b1cSBill Paul#
98778c7b1cSBill Paul# To add a user, edit $(YPDIR)/master.passwd and type 'make'. The raw
99778c7b1cSBill Paul# passwd file will be generated from the master.passwd file automagically.
100778c7b1cSBill Paul#
101778c7b1cSBill PaulETHERS    = $(YPSRCDIR)/ethers	   # ethernet addresses (for rarpd)
102778c7b1cSBill PaulBOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
103778c7b1cSBill PaulHOSTS     = $(YPSRCDIR)/hosts
104778c7b1cSBill PaulNETWORKS  = $(YPSRCDIR)/networks
105778c7b1cSBill PaulPROTOCOLS = $(YPSRCDIR)/protocols
106778c7b1cSBill PaulRPC 	  = $(YPSRCDIR)/rpc
107778c7b1cSBill PaulSERVICES  = $(YPSRCDIR)/services
108778c7b1cSBill PaulGROUP     = $(YPSRCDIR)/group
109b2264be8SBill PaulALIASES   = $(YPSRCDIR)/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
12057948c0bSPeter WemmAMDHOST   = $(YPSRCDIR)/amd.host
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.
12513170f18SBill PaulTARGETS= servers hosts networks protocols rpc services 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))
16413170f18SBill PaulTARGETS+= amd.host
16513170f18SBill Paul.else
16613170f18SBill PaulAMDHOST= /dev/null
16713170f18SBill Paul.endif
16813170f18SBill Paul
169778c7b1cSBill Paultarget:
170b2264be8SBill Paul	@$(RM) $(NFILE)
171778c7b1cSBill Paul	@if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
172920491cfSBill Paul	cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
173778c7b1cSBill Paul	make -f ../Makefile all; echo "NIS Map update completed."
17413170f18SBill Paul	@$(RM) $(NFILE)
175778c7b1cSBill Paul
17613170f18SBill Paulall: $(TARGETS)
177778c7b1cSBill Paul
178778c7b1cSBill Paulethers:	   ethers.byname ethers.byaddr
179778c7b1cSBill Paulbootparam: bootparams
180778c7b1cSBill Paulhosts:	   hosts.byname hosts.byaddr
181778c7b1cSBill Paulnetworks:  networks.byaddr networks.byname
182778c7b1cSBill Paulprotocols: protocols.bynumber protocols.byname
183778c7b1cSBill Paulrpc:	   rpc.byname rpc.bynumber
184778c7b1cSBill Paulservices:  services.byname
185778c7b1cSBill Paulpasswd:    passwd.byname passwd.byuid
186778c7b1cSBill Paulgroup:     group.byname group.bygid
187778c7b1cSBill Paulnetgrp:    netgroup
188778c7b1cSBill Paulnetid:	   netid.byname
189778c7b1cSBill Paulservers:   ypservers
190778c7b1cSBill Paulpublickey: publickey.byname
191b2264be8SBill Paulaliases:   mail.aliases
192778c7b1cSBill Paul
193778c7b1cSBill Paulmaster.passwd:	master.passwd.byname master.passwd.byuid
194778c7b1cSBill Paul
195b3e93234SBill Paul#
196b3e93234SBill Paul# This is a special target used only when doing in-place updates with
197b3e93234SBill Paul# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
198b3e93234SBill Paul# server and won't need to be remade. They will have to be pushed to the
199b3e93234SBill Paul# slaves however. Calling this target implicitly insures that this will
200b3e93234SBill Paul# happen.
201b3e93234SBill Paul#
202b3e93234SBill Paulpushpw:
203b3e93234SBill Paul	@$(DBLOAD) -c
204b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
205b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
206b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
207b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
208b3e93234SBill Paul
20913170f18SBill Paulpushmap:
21013170f18SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $(PUSHMAP) ; fi
21113170f18SBill Paul
21213170f18SBill Paulnopass:
21313170f18SBill Paul	@echo ""
21413170f18SBill Paul	@echo "                ********WARNING********"
21513170f18SBill Paul	@echo "  Couldn't find the master.passwd source file. This file"
21613170f18SBill Paul	@echo "  is needed to generate the master.passwd and passwd maps."
21713170f18SBill Paul	@echo "  The default location is /var/yp/master.passwd. You should"
21813170f18SBill Paul	@echo "  edit /var/yp/Makefile and set the MASTER variable to point"
21913170f18SBill Paul	@echo "  to the source file you wish to use for building the passwd"
22013170f18SBill Paul	@echo "  maps, or else invoke make(1) in the following manner:"
22113170f18SBill Paul	@echo "
22213170f18SBill Paul	@echo "        make MASTER_PASSWD=/path/to/master.passwd"
22313170f18SBill Paul	@echo ""
22413170f18SBill Paul
225b2264be8SBill Paulmail.aliases: $(ALIASES)
226b2264be8SBill Paul	@echo "Updating $@..."
227b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
228de88f160SAdam David	@$(NEWALIASES) -oA$(ALIASES)
229d91013b5SAdam David	@$(MKDB) -u $(ALIASES).db \
230b2264be8SBill Paul		| $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP)
231b2264be8SBill Paul	@$(MV) $(TMP) $@
232b2264be8SBill Paul	@$(DBLOAD) -c
233b2264be8SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
234b2264be8SBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
235b2264be8SBill Paul
236778c7b1cSBill Paul
237778c7b1cSBill Paulypservers: $(YPSERVERS)
238778c7b1cSBill Paul	@echo "Updating $@..."
239b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
240778c7b1cSBill Paul	$(CAT) $(YPSERVERS) | \
2410f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' $^ \
242b2264be8SBill Paul		| $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP)
243b2264be8SBill Paul	@$(MV) $(TMP) $@
244b2264be8SBill Paul	@$(DBLOAD) -c
245778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
246778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
247778c7b1cSBill Paul
248b2264be8SBill Paul
249778c7b1cSBill Paulethers.byname: $(ETHERS)
250778c7b1cSBill Paul	@echo "Updating $@..."
25113170f18SBill Paul.if ${ETHERS} == "/dev/null"
25213170f18SBill Paul	@echo "Ethers source file not found -- skipping"
25313170f18SBill Paul.else
254b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
255778c7b1cSBill Paul	$(CAT) $(ETHERS) | \
2560f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
257778c7b1cSBill Paul		print $$2"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
258b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
259b2264be8SBill Paul	@$(MV) $(TMP) $@
260b2264be8SBill Paul	@$(DBLOAD) -c
261a6dbeb65SPeter Wemm	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
262778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
26313170f18SBill Paul.endif
264778c7b1cSBill Paul
265778c7b1cSBill Paulethers.byaddr: $(ETHERS)
266778c7b1cSBill Paul	@echo "Updating $@..."
26713170f18SBill Paul.if ${ETHERS} == "/dev/null"
26813170f18SBill Paul	@echo "Ethers source file not found -- skipping"
26913170f18SBill Paul.else
270b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
271778c7b1cSBill Paul	$(CAT) $(ETHERS) | \
2720f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
273778c7b1cSBill Paul		print $$1"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
274b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
275b2264be8SBill Paul	@$(MV) $(TMP) $@
276b2264be8SBill Paul	@$(DBLOAD) -c
277778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
278778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
27913170f18SBill Paul.endif
280778c7b1cSBill Paul
281778c7b1cSBill Paul
282778c7b1cSBill Paulbootparams: $(BOOTPARAMS)
283778c7b1cSBill Paul	@echo "Updating $@..."
28413170f18SBill Paul.if ${BOOTPARAMS} == "/dev/null"
28513170f18SBill Paul	@echo "Bootparams source file not found -- skipping"
28613170f18SBill Paul.else
287b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
288778c7b1cSBill Paul	$(CAT) $(BOOTPARAMS) | \
2890f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
290778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(BOOTPARAMS) \
291b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
292b2264be8SBill Paul	@$(MV) $(TMP) $@
293b2264be8SBill Paul	@$(DBLOAD) -c
294778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
295778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
29613170f18SBill Paul.endif
297778c7b1cSBill Paul
298778c7b1cSBill Paul
299778c7b1cSBill Paulnetgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
300778c7b1cSBill Paul	@echo "Updating $@..."
30113170f18SBill Paul.if ${NETGROUP} == "/dev/null"
30213170f18SBill Paul	@echo "Netgroup source file not found -- skipping"
30313170f18SBill Paul.else
304b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
305778c7b1cSBill Paul	$(CAT) $(NETGROUP) | \
3060f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
307778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
308b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
309b2264be8SBill Paul	@$(MV) $(TMP) $@
310b2264be8SBill Paul	@$(DBLOAD) -c
311778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
312778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
313778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
31413170f18SBill Paul.endif
315778c7b1cSBill Paul
316778c7b1cSBill Paul
317778c7b1cSBill Paulnetgroup.byhost: $(NETGROUP)
318778c7b1cSBill Paul	@echo "Updating $@..."
31913170f18SBill Paul.if ${NETGROUP} == "/dev/null"
32013170f18SBill Paul	@echo "Netgroup source file not found -- skipping"
32113170f18SBill Paul.else
322b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
323778c7b1cSBill Paul	$(CAT) $(NETGROUP) | $(REVNETGROUP) -h -f $(NETGROUP) | \
3240f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
325778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
326b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
327b2264be8SBill Paul	@$(MV) $(TMP) $@
328b2264be8SBill Paul	@$(DBLOAD) -c
329778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
330778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
33113170f18SBill Paul.endif
332778c7b1cSBill Paul
333778c7b1cSBill Paul
334778c7b1cSBill Paulnetgroup.byuser: $(NETGROUP)
335778c7b1cSBill Paul	@echo "Updating $@..."
33613170f18SBill Paul.if ${NETGROUP} == "/dev/null"
33713170f18SBill Paul	@echo "Netgroup source file not found -- skipping"
33813170f18SBill Paul.else
339b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
340778c7b1cSBill Paul	$(CAT) $(NETGROUP) | $(REVNETGROUP) -u -f $(NETGROUP) | \
3410f87b00dSSteve Price	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
342778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
343b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
344b2264be8SBill Paul	@$(MV) $(TMP) $@
345b2264be8SBill Paul	@$(DBLOAD) -c
346778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
347778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
34813170f18SBill Paul.endif
349778c7b1cSBill Paul
350778c7b1cSBill Paul
351778c7b1cSBill Paulhosts.byname: $(HOSTS)
352778c7b1cSBill Paul	@echo "Updating $@..."
353b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
354778c7b1cSBill Paul	$(CAT) $(HOSTS) | \
3550f87b00dSSteve Price	$(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
35658dc1574SBill Paul		print $$n"\t"$$0 }' $^ | $(DBLOAD) ${B} -i $(HOSTS)  \
357b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
358b2264be8SBill Paul	@$(MV) $(TMP) $@
359b2264be8SBill Paul	@$(DBLOAD) -c
360778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
361778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
362778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
363778c7b1cSBill Paul
364b2264be8SBill Paul
365778c7b1cSBill Paulhosts.byaddr: $(HOSTS)
366778c7b1cSBill Paul	@echo "Updating $@..."
367b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
368778c7b1cSBill Paul	$(CAT) $(HOSTS) | \
3690f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$0 }' $^ \
37058dc1574SBill Paul		| $(DBLOAD) ${B} -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP)
371b2264be8SBill Paul	@$(MV) $(TMP) $@
372b2264be8SBill Paul	@$(DBLOAD) -c
373778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
374778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
375778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
376778c7b1cSBill Paul
377778c7b1cSBill Paul
378778c7b1cSBill Paulnetworks.byname: $(NETWORKS)
379778c7b1cSBill Paul	@echo "Updating $@..."
380b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
381778c7b1cSBill Paul	$(CAT) $(NETWORKS) | \
382778c7b1cSBill Paul	$(AWK) \
3830f87b00dSSteve Price	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
3840f87b00dSSteve Price			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
385778c7b1cSBill Paul			      print $$n"\t"$$0 \
386b2264be8SBill Paul		}' $^ | $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP)
387b2264be8SBill Paul	@$(MV) $(TMP) $@
388b2264be8SBill Paul	@$(DBLOAD) -c
389778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
390778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
391778c7b1cSBill Paul
392778c7b1cSBill Paul
393778c7b1cSBill Paulnetworks.byaddr: $(NETWORKS)
394778c7b1cSBill Paul	@echo "Updating $@..."
395b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
396778c7b1cSBill Paul	$(CAT) $(NETWORKS) | \
3970f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
398b2264be8SBill Paul		| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP)
399b2264be8SBill Paul	@$(MV) $(TMP) $@
400b2264be8SBill Paul	@$(DBLOAD) -c
401778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
402778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
403778c7b1cSBill Paul
404778c7b1cSBill Paul
405778c7b1cSBill Paulprotocols.byname: $(PROTOCOLS)
406778c7b1cSBill Paul	@echo "Updating $@..."
407b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
408778c7b1cSBill Paul	$(CAT) $(PROTOCOLS) | \
409778c7b1cSBill Paul	$(AWK) \
4100f87b00dSSteve Price	   '$$1 !~ "^#.*"	{ print $$1"\t"$$0; \
4110f87b00dSSteve Price			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
412778c7b1cSBill Paul			      print $$n"\t"$$0 \
413778c7b1cSBill Paul			}' $^ | $(DBLOAD) -i $(PROTOCOLS) \
414b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
415b2264be8SBill Paul	@$(MV) $(TMP) $@
416b2264be8SBill Paul	@$(DBLOAD) -c
417778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
418778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
419778c7b1cSBill Paul
420778c7b1cSBill Paul
421778c7b1cSBill Paulprotocols.bynumber: $(PROTOCOLS)
422778c7b1cSBill Paul	@echo "Updating $@..."
423b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
424778c7b1cSBill Paul	$(CAT) $(PROTOCOLS) | \
4250f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
426b2264be8SBill Paul		| $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP)
427b2264be8SBill Paul	@$(MV) $(TMP) $@
428b2264be8SBill Paul	@$(DBLOAD) -c
429778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
430778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
431778c7b1cSBill Paul
432778c7b1cSBill Paul
433778c7b1cSBill Paulrpc.byname: $(RPC)
434778c7b1cSBill Paul	@echo "Updating $@..."
435b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
436778c7b1cSBill Paul	$(CAT) $(RPC) | \
437778c7b1cSBill Paul	$(AWK) \
4380f87b00dSSteve Price	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
4390f87b00dSSteve Price			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
440778c7b1cSBill Paul			      print $$n"\t"$$0 \
441b2264be8SBill Paul		}' $^ | $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP)
442b2264be8SBill Paul	@$(MV) $(TMP) $@
443b2264be8SBill Paul	@$(DBLOAD) -c
444778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
445778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
446778c7b1cSBill Paul
447778c7b1cSBill Paul
448778c7b1cSBill Paulrpc.bynumber: $(RPC)
449778c7b1cSBill Paul	@echo "Updating $@..."
450b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
451778c7b1cSBill Paul	$(CAT) $(RPC) | \
4520f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
453b2264be8SBill Paul		| $(DBLOAD)  -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP)
454b2264be8SBill Paul	@$(MV) $(TMP) $@
455b2264be8SBill Paul	@$(DBLOAD) -c
456778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
457778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
458778c7b1cSBill Paul
459778c7b1cSBill Paul
460778c7b1cSBill Paulservices.byname: $(SERVICES)
461778c7b1cSBill Paul	@echo "Updating $@..."
462b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
463778c7b1cSBill Paul	$(CAT) $(SERVICES) | \
464778c7b1cSBill Paul	$(AWK) \
4650f87b00dSSteve Price	   '$$1 !~ "^#.*"  { for (n=1; n<=NF && $$n !~ "^#.*"; n++) { \
46688b4ff3cSPeter Wemm			    if (index($$2,"udp")) { printf("%s/udp",$$n) } \
46788b4ff3cSPeter Wemm			    else { printf("%s/tcp",$$n) }; print "\t"$$0 ; \
46888b4ff3cSPeter Wemm			    if (n == 1) n = 2; \
46988b4ff3cSPeter Wemm			  } ; print $$2"\t"$$0 ; \
470b2264be8SBill Paul		}' $^ | $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP)
471b2264be8SBill Paul	@$(MV) $(TMP) $@
472b2264be8SBill Paul	@$(DBLOAD) -c
473778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
474778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
475778c7b1cSBill Paul
476778c7b1cSBill Paul
477778c7b1cSBill Paulpublickey.byname: $(PUBLICKEY)
478778c7b1cSBill Paul	@echo "Updating $@..."
47913170f18SBill Paul.if ${PUBLICKEY} == "/dev/null"
48013170f18SBill Paul	@echo "Publickey source file not found -- skipping"
48113170f18SBill Paul.else
482b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
483aca49be3SBill Paul	$(CAT) $(PUBLICKEY) | \
4840f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$2 }' $^ \
485b2264be8SBill Paul		| $(DBLOAD)  -i $(PUBLICKEY) -o $(YPMAPDIR)/$@ - $(TMP)
486b2264be8SBill Paul	@$(MV) $(TMP) $@
487b2264be8SBill Paul	@$(DBLOAD) -c
488778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
489778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
49013170f18SBill Paul.endif
491778c7b1cSBill Paul
492778c7b1cSBill Paul
493778c7b1cSBill Paul$(PASSWD): $(MASTER)
494778c7b1cSBill Paul	@echo "Creating new $@ file from $(MASTER)..."
495778c7b1cSBill Paul	@if [ ! $(UNSECURE) ]; then \
496778c7b1cSBill Paul	$(RCAT) $(MASTER) | \
497778c7b1cSBill Paul	$(AWK) -F: '{if ($$1 != "+") \
498778c7b1cSBill Paul		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
499778c7b1cSBill Paul		> $(PASSWD) ; \
500778c7b1cSBill Paul	else $(RCAT) $(MASTER) | \
501778c7b1cSBill Paul	$(AWK) -F: '{if ($$1 != "+") \
502778c7b1cSBill Paul		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
503778c7b1cSBill Paul		> $(PASSWD) ; fi
504778c7b1cSBill Paul
505778c7b1cSBill Paul
506778c7b1cSBill Paulpasswd.byname: $(PASSWD)
507778c7b1cSBill Paul	@echo "Updating $@..."
508b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
509778c7b1cSBill Paul	$(CAT) $(PASSWD) | \
510778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
511b2264be8SBill Paul		| $(DBLOAD) -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP)
512b2264be8SBill Paul	@$(MV) $(TMP) $@
513b2264be8SBill Paul	@$(DBLOAD) -c
514778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
515778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
516778c7b1cSBill Paul
517b2264be8SBill Paul
518778c7b1cSBill Paulpasswd.byuid: $(PASSWD)
519778c7b1cSBill Paul	@echo "Updating $@..."
520b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
521778c7b1cSBill Paul	$(CAT) $(PASSWD) | \
522778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
523b2264be8SBill Paul		| $(DBLOAD) -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP)
524b2264be8SBill Paul	@$(MV) $(TMP) $@
525b2264be8SBill Paul	@$(DBLOAD) -c
526778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
527778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
528778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
529778c7b1cSBill Paul
530778c7b1cSBill Paul
531778c7b1cSBill Paulgroup.byname: $(GROUP)
532778c7b1cSBill Paul	@echo "Updating $@..."
533b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
534778c7b1cSBill Paul	$(CAT) $(GROUP) | \
535778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
536b2264be8SBill Paul		| $(DBLOAD) -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP)
537b2264be8SBill Paul	@$(MV) $(TMP) $@
538b2264be8SBill Paul	@$(DBLOAD) -c
539778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
540778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
541778c7b1cSBill Paul
542778c7b1cSBill Paul
543778c7b1cSBill Paulgroup.bygid: $(GROUP)
544778c7b1cSBill Paul	@echo "Updating $@..."
545b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
546778c7b1cSBill Paul	$(CAT) $(GROUP) | \
547778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
548b2264be8SBill Paul		| $(DBLOAD) -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP)
549b2264be8SBill Paul	@$(MV) $(TMP) $@
550b2264be8SBill Paul	@$(DBLOAD) -c
551778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
552778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
553778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
554778c7b1cSBill Paul
555778c7b1cSBill Paul
556778c7b1cSBill Paulnetid.byname: $(GROUP) $(PASSWD)
557778c7b1cSBill Paul	@echo "Updating $@..."
558b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
5591fe3e67aSBill Paul	@$(MKNETID) -q -p $(PASSWD) -g $(GROUP) -h $(HOSTS) -n $(NETID) \
5601fe3e67aSBill Paul		-d $(DOMAIN) | $(DBLOAD) -o $(YPMAPDIR)/$@ - $(TMP)
561b2264be8SBill Paul	@$(MV) $(TMP) $@
562b2264be8SBill Paul	@$(DBLOAD) -c
563778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
564778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
565778c7b1cSBill Paul
566778c7b1cSBill Paul
567778c7b1cSBill Paulmaster.passwd.byname: $(MASTER)
568778c7b1cSBill Paul	@echo "Updating $@..."
56913170f18SBill Paul.if ${MASTER} == "/dev/null"
57013170f18SBill Paul	@echo "Master.passwd source file not found -- skipping"
57113170f18SBill Paul.else
572b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
573778c7b1cSBill Paul	$(CAT) $(MASTER) | \
574778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
57558dc1574SBill Paul		| $(DBLOAD) ${S} -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP)
576b2264be8SBill Paul	@$(MV) $(TMP) $@
577b2264be8SBill Paul	@$(DBLOAD) -c
578778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
579778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
58013170f18SBill Paul.endif
581778c7b1cSBill Paul
582778c7b1cSBill Paul
583778c7b1cSBill Paulmaster.passwd.byuid: $(MASTER)
584778c7b1cSBill Paul	@echo "Updating $@..."
58513170f18SBill Paul.if ${MASTER} == "/dev/null"
58613170f18SBill Paul	@echo "Master.passwd source file not found -- skipping"
58713170f18SBill Paul.else
588b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
589778c7b1cSBill Paul	$(CAT) $(MASTER) | \
590778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
59158dc1574SBill Paul		| $(DBLOAD) ${S} -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP)
592b2264be8SBill Paul	@$(MV) $(TMP) $@
593b2264be8SBill Paul	@$(DBLOAD) -c
594778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
595778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
59613170f18SBill Paul.endif
59713170f18SBill Paul
59857948c0bSPeter Wemm
59957948c0bSPeter Wemmamd.host: $(AMDHOST)
60057948c0bSPeter Wemm	@echo "Updating $@..."
60157948c0bSPeter Wemm	@echo $@.$$$$ > $(NFILE)
60257948c0bSPeter Wemm	$(CAT) $(AMDHOST) | \
6030f87b00dSSteve Price	$(AWK) '$$1 !~ "^#.*"  { \
60457948c0bSPeter Wemm	  for (i = 1; i <= NF; i++) \
60557948c0bSPeter Wemm	  if (i == NF) { \
60657948c0bSPeter Wemm	    if (substr($$i, length($$i), 1) == "\\") \
60757948c0bSPeter Wemm	      printf("%s", substr($$i, 1, length($$i) - 1)); \
60857948c0bSPeter Wemm	    else \
60957948c0bSPeter Wemm	      printf("%s\n", $$i); \
61057948c0bSPeter Wemm	  } \
61157948c0bSPeter Wemm	  else \
61257948c0bSPeter Wemm	    printf("%s ", $$i); \
61357948c0bSPeter Wemm	}' | \
61457948c0bSPeter Wemm	$(DBLOAD) -i $(AMDHOST) -o $(YPMAPDIR)/$@ - $(TMP)
61557948c0bSPeter Wemm	@$(MV) $(TMP) $@
61657948c0bSPeter Wemm	@$(DBLOAD) -c
61757948c0bSPeter Wemm	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
61857948c0bSPeter Wemm	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
61957948c0bSPeter Wemm
620