xref: /freebsd/usr.sbin/ypserv/Makefile.yp (revision e627b39baccd1ec9129690167cf5e6d860509655)
1#
2# Makefile for the NIS databases
3#
4# $Id: Makefile.yp,v 1.11 1996/07/25 19:32:37 peter Exp $
5#
6# This Makefile should only be run on the NIS master server of a domain.
7# All updated maps will be pushed to all NIS slave servers listed in the
8# /var/yp/ypservers file. Please make sure that the hostnames of all
9# NIS servers in your domain are listed in /var/yp/ypservers.
10#
11# This Makefile can be modified to support more NIS maps if desired.
12#
13
14# If this machine is an NIS master, comment out this next line so
15# that changes to the NIS maps can be propagated to the slave servers.
16# (By default we assume that we are only serving a small domain with
17# only one server.)
18#
19NOPUSH = "True"
20
21# If you want to use a FreeBSD NIS server to serve non-FreeBSD clients
22# (i.e. clients who expect the password field in the passwd maps to be
23# valid) then uncomment this line. This will cause $YPDIR/passwd to
24# be generated with valid password fields. This is insecure: FreeBSD
25# normally only serves the master.passwd maps (which have real encrypted
26# passwords in them) to the superuser on other FreeBSD machines, but
27# non-FreeBSD clients (e.g. SunOS, Solaris (without NIS+), IRIX, HP-UX,
28# etc...) will only work properly in 'unsecure' mode.
29#
30#UNSECURE = "True"
31
32# These are commands which this Makefile needs to properly rebuild the
33# NIS databases. Don't change these unless you have a good reason. Also
34# be sure not to place an @ in front of /usr/bin/awk: it isn't necessary
35# and it'll break everything in sight.
36#
37AWK = /usr/bin/awk
38RM  = @/bin/rm -f
39MV  = @/bin/mv -f
40RCAT = /bin/cat
41CAT = @$(RCAT)
42
43MKDB = /usr/sbin/yp_mkdb
44DBLOAD = $(MKDB) -m `hostname`
45MKNETID = /usr/libexec/mknetid
46NEWALIASES = /usr/bin/newaliases
47YPPUSH = /usr/sbin/yppush
48.if !defined(UPDATE_DOMAIN)
49DOMAIN = `/bin/domainname`
50.else
51DOMAIN = $(UPDATE_DOMAIN)
52.endif
53REVNETGROUP = /usr/libexec/revnetgroup
54NFILE = /tmp/ypmake
55TMP = `$(RCAT) $(NFILE)`
56
57# It is advisable to create a separate directory to contain the
58# source files used to generate your NIS maps. If you intend to
59# support multiple domains, something like /src/dir/$DOMAIN
60# would work well.
61YPSRCDIR = /etc
62YPDIR = /var/yp
63YPMAPDIR = $(YPDIR)/$(DOMAIN)
64
65# These are the files from which the NIS databases are built. You may edit
66# these to taste in the event that you wish to keep your NIS source files
67# seperate from your NIS server's actual configuration files. Note that the
68# NIS passwd and master.passwd files are stored in /var/yp: the server's
69# real password database is not used by default. However, you may use
70# the real /etc/passwd and /etc/master.passwd files by:
71#
72#
73# - invoking yppasswdd without the -m option (yppasswdd will use
74#   /etc/master.passwd if no alternate master.passwd file is specified
75#   and do a 'pwd_mkdb' as needed).
76# - Specifying the location of the master.passwd file using the
77#   MASTER_PASSWD variable, i.e.:
78#
79#   # make MASTER_PASSWD=/path/to/some/other/master.passwd
80#
81# - (optionally): editing this Makefile to change the default location.
82#
83# To add a user, edit $(YPDIR)/master.passwd and type 'make'. The raw
84# passwd file will be generated from the master.passwd file automagically.
85#
86ETHERS    = $(YPSRCDIR)/ethers	   # ethernet addresses (for rarpd)
87BOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
88HOSTS     = $(YPSRCDIR)/hosts
89NETWORKS  = $(YPSRCDIR)/networks
90PROTOCOLS = $(YPSRCDIR)/protocols
91RPC 	  = $(YPSRCDIR)/rpc
92SERVICES  = $(YPSRCDIR)/services
93GROUP     = $(YPSRCDIR)/group
94ALIASES   = $(YPSRCDIR)/aliases
95NETGROUP  = $(YPDIR)/netgroup
96PASSWD    = $(YPDIR)/passwd
97.if !defined(MASTER_PASSWD)
98MASTER    = $(YPDIR)/master.passwd
99.else
100MASTER	  = $(MASTER_PASSWD)
101.endif
102YPSERVERS = $(YPDIR)/ypservers	# List of all NIS servers for a domain
103PUBLICKEY = $(YPSRCDIR)/publickey
104NETID     = $(YPSRCDIR)/netid
105AMDHOST   = $(YPSRCDIR)/amd.host
106
107target:
108	@$(RM) $(NFILE)
109	@if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
110	cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
111	make -f ../Makefile all; echo "NIS Map update completed."
112
113# If you don't want some of these maps built, feel free to comment
114# them out from this list.
115# Note that we don't build the ethers or boorparams maps by default
116# since /etc/ethers and /etc/bootparams are not likely to be present
117# on all systems.
118#
119
120all:  master.passwd passwd hosts group networks protocols rpc \
121      services servers netid
122      # aliases publickey netgrp ethers bootparam amd.host
123
124ethers:	   ethers.byname ethers.byaddr
125bootparam: bootparams
126hosts:	   hosts.byname hosts.byaddr
127networks:  networks.byaddr networks.byname
128protocols: protocols.bynumber protocols.byname
129rpc:	   rpc.byname rpc.bynumber
130services:  services.byname
131passwd:    passwd.byname passwd.byuid
132group:     group.byname group.bygid
133netgrp:    netgroup
134netid:	   netid.byname
135servers:   ypservers
136publickey: publickey.byname
137aliases:   mail.aliases
138
139master.passwd:	master.passwd.byname master.passwd.byuid
140
141#
142# This is a special target used only when doing in-place updates with
143# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
144# server and won't need to be remade. They will have to be pushed to the
145# slaves however. Calling this target implicitly insures that this will
146# happen.
147#
148pushpw:
149	@$(DBLOAD) -c
150	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
151	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
152	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
153	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
154
155mail.aliases: $(ALIASES)
156	@echo "Updating $@..."
157	@echo $@.$$$$ > $(NFILE)
158	@$(NEWALIASES) -oA$(ALIASES)
159	@$(MKDB) -u $(ALIASES).db \
160		| $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP)
161	@$(MV) $(TMP) $@
162	@$(DBLOAD) -c
163	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
164	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
165
166
167ypservers: $(YPSERVERS)
168	@echo "Updating $@..."
169	@echo $@.$$$$ > $(NFILE)
170	$(CAT) $(YPSERVERS) | \
171	$(AWK) '{ if ($$1 != "" && $$1 != "#") print $$0"\t"$$0 }' $^ \
172		| $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP)
173	@$(MV) $(TMP) $@
174	@$(DBLOAD) -c
175	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
176	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
177
178
179ethers.byname: $(ETHERS)
180	@echo "Updating $@..."
181	@echo $@.$$$$ > $(NFILE)
182	$(CAT) $(ETHERS) | \
183	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
184		print $$2"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
185						-o $(YPMAPDIR)/$@ - $(TMP)
186	@$(MV) $(TMP) $@
187	@$(DBLOAD) -c
188	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
189	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
190
191
192ethers.byaddr: $(ETHERS)
193	@echo "Updating $@..."
194	@echo $@.$$$$ > $(NFILE)
195	$(CAT) $(ETHERS) | \
196	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
197		print $$1"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
198						-o $(YPMAPDIR)/$@ - $(TMP)
199	@$(MV) $(TMP) $@
200	@$(DBLOAD) -c
201	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
202	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
203
204
205bootparams: $(BOOTPARAMS)
206	@echo "Updating $@..."
207	@echo $@.$$$$ > $(NFILE)
208	$(CAT) $(BOOTPARAMS) | \
209	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
210		print $$0 }' $^ | $(DBLOAD) -i $(BOOTPARAMS) \
211						-o $(YPMAPDIR)/$@ - $(TMP)
212	@$(MV) $(TMP) $@
213	@$(DBLOAD) -c
214	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
215	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
216
217
218netgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
219	@echo "Updating $@..."
220	@echo $@.$$$$ > $(NFILE)
221	$(CAT) $(NETGROUP) | \
222	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
223		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
224						-o $(YPMAPDIR)/$@ - $(TMP)
225	@$(MV) $(TMP) $@
226	@$(DBLOAD) -c
227	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
228	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
229	@$(MAKE) -f ../Makefile netid
230
231
232netgroup.byhost: $(NETGROUP)
233	@echo "Updating $@..."
234	@echo $@.$$$$ > $(NFILE)
235	$(CAT) $(NETGROUP) | $(REVNETGROUP) -h -f $(NETGROUP) | \
236	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
237		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
238						-o $(YPMAPDIR)/$@ - $(TMP)
239	@$(MV) $(TMP) $@
240	@$(DBLOAD) -c
241	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
242	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
243
244
245netgroup.byuser: $(NETGROUP)
246	@echo "Updating $@..."
247	@echo $@.$$$$ > $(NFILE)
248	$(CAT) $(NETGROUP) | $(REVNETGROUP) -u -f $(NETGROUP) | \
249	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
250		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
251						-o $(YPMAPDIR)/$@ - $(TMP)
252	@$(MV) $(TMP) $@
253	@$(DBLOAD) -c
254	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
255	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
256
257
258hosts.byname: $(HOSTS)
259	@echo "Updating $@..."
260	@echo $@.$$$$ > $(NFILE)
261	$(CAT) $(HOSTS) | \
262	$(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "#"; n++) \
263		print $$n"\t"$$0 }' $^ | $(DBLOAD) -i $(HOSTS)  \
264						-o $(YPMAPDIR)/$@ - $(TMP)
265	@$(MV) $(TMP) $@
266	@$(DBLOAD) -c
267	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
268	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
269	@$(MAKE) -f ../Makefile netid
270
271
272hosts.byaddr: $(HOSTS)
273	@echo "Updating $@..."
274	@echo $@.$$$$ > $(NFILE)
275	$(CAT) $(HOSTS) | \
276	$(AWK) '$$1 !~ "#" { print $$1"\t"$$0 }' $^ \
277		| $(DBLOAD) -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP)
278	@$(MV) $(TMP) $@
279	@$(DBLOAD) -c
280	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
281	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
282	@$(MAKE) -f ../Makefile netid
283
284
285networks.byname: $(NETWORKS)
286	@echo "Updating $@..."
287	@echo $@.$$$$ > $(NFILE)
288	$(CAT) $(NETWORKS) | \
289	$(AWK) \
290	   '$$1 !~ "#"  { print $$1"\t"$$0; \
291			  for (n=3; n<=NF && $$n !~ "#"; n++) \
292			      print $$n"\t"$$0 \
293		}' $^ | $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP)
294	@$(MV) $(TMP) $@
295	@$(DBLOAD) -c
296	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
297	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
298
299
300networks.byaddr: $(NETWORKS)
301	@echo "Updating $@..."
302	@echo $@.$$$$ > $(NFILE)
303	$(CAT) $(NETWORKS) | \
304	$(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \
305		| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP)
306	@$(MV) $(TMP) $@
307	@$(DBLOAD) -c
308	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
309	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
310
311
312protocols.byname: $(PROTOCOLS)
313	@echo "Updating $@..."
314	@echo $@.$$$$ > $(NFILE)
315	$(CAT) $(PROTOCOLS) | \
316	$(AWK) \
317	   '$$1 !~ "#"	{ print $$1"\t"$$0; \
318			  for (n=3; n<=NF && $$n !~ "#"; n++) \
319			      print $$n"\t"$$0 \
320			}' $^ | $(DBLOAD) -i $(PROTOCOLS) \
321						-o $(YPMAPDIR)/$@ - $(TMP)
322	@$(MV) $(TMP) $@
323	@$(DBLOAD) -c
324	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
325	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
326
327
328protocols.bynumber: $(PROTOCOLS)
329	@echo "Updating $@..."
330	@echo $@.$$$$ > $(NFILE)
331	$(CAT) $(PROTOCOLS) | \
332	$(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \
333		| $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP)
334	@$(MV) $(TMP) $@
335	@$(DBLOAD) -c
336	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
337	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
338
339
340rpc.byname: $(RPC)
341	@echo "Updating $@..."
342	@echo $@.$$$$ > $(NFILE)
343	$(CAT) $(RPC) | \
344	$(AWK) \
345	   '$$1 !~ "#"  { print $$1"\t"$$0; \
346			  for (n=3; n<=NF && $$n !~ "#"; n++) \
347			      print $$n"\t"$$0 \
348		}' $^ | $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP)
349	@$(MV) $(TMP) $@
350	@$(DBLOAD) -c
351	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
352	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
353
354
355rpc.bynumber: $(RPC)
356	@echo "Updating $@..."
357	@echo $@.$$$$ > $(NFILE)
358	$(CAT) $(RPC) | \
359	$(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \
360		| $(DBLOAD)  -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP)
361	@$(MV) $(TMP) $@
362	@$(DBLOAD) -c
363	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
364	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
365
366
367services.byname: $(SERVICES)
368	@echo "Updating $@..."
369	@echo $@.$$$$ > $(NFILE)
370	$(CAT) $(SERVICES) | \
371	$(AWK) \
372	   '$$1 !~ "#"  { for (n=1; n<=NF && $$n !~ "#"; n++) { \
373			    if (index($$2,"udp")) { printf("%s/udp",$$n) } \
374			    else { printf("%s/tcp",$$n) }; print "\t"$$0 ; \
375			    if (n == 1) n = 2; \
376			  } ; print $$2"\t"$$0 ; \
377		}' $^ | $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP)
378	@$(MV) $(TMP) $@
379	@$(DBLOAD) -c
380	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
381	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
382
383
384publickey.byname: $(PUBLICKEY)
385	@echo "Updating $@..."
386	@echo $@.$$$$ > $(NFILE)
387	$(TMP) = `$(RCAT) $(NFILE)`
388	$(AWK) '$$1 !~ "#" { print $$1"\t"$$2 }' $^ \
389		| $(DBLOAD)  -i $(PUBLICKEY) -o $(YPMAPDIR)/$@ - $(TMP)
390	@$(MV) $(TMP) $@
391	@$(DBLOAD) -c
392	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
393	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
394
395
396$(PASSWD): $(MASTER)
397	@echo "Creating new $@ file from $(MASTER)..."
398	@if [ ! $(UNSECURE) ]; then \
399	$(RCAT) $(MASTER) | \
400	$(AWK) -F: '{if ($$1 != "+") \
401		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
402		> $(PASSWD) ; \
403	else $(RCAT) $(MASTER) | \
404	$(AWK) -F: '{if ($$1 != "+") \
405		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
406		> $(PASSWD) ; fi
407
408
409passwd.byname: $(PASSWD)
410	@echo "Updating $@..."
411	@echo $@.$$$$ > $(NFILE)
412	$(CAT) $(PASSWD) | \
413	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
414		| $(DBLOAD) -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP)
415	@$(MV) $(TMP) $@
416	@$(DBLOAD) -c
417	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
418	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
419
420
421passwd.byuid: $(PASSWD)
422	@echo "Updating $@..."
423	@echo $@.$$$$ > $(NFILE)
424	$(CAT) $(PASSWD) | \
425	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
426		| $(DBLOAD) -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP)
427	@$(MV) $(TMP) $@
428	@$(DBLOAD) -c
429	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
430	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
431	@$(MAKE) -f ../Makefile netid
432
433
434group.byname: $(GROUP)
435	@echo "Updating $@..."
436	@echo $@.$$$$ > $(NFILE)
437	$(CAT) $(GROUP) | \
438	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
439		| $(DBLOAD) -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP)
440	@$(MV) $(TMP) $@
441	@$(DBLOAD) -c
442	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
443	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
444
445
446group.bygid: $(GROUP)
447	@echo "Updating $@..."
448	@echo $@.$$$$ > $(NFILE)
449	$(CAT) $(GROUP) | \
450	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
451		| $(DBLOAD) -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP)
452	@$(MV) $(TMP) $@
453	@$(DBLOAD) -c
454	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
455	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
456	@$(MAKE) -f ../Makefile netid
457
458
459netid.byname: $(GROUP) $(PASSWD)
460	@echo "Updating $@..."
461	@echo $@.$$$$ > $(NFILE)
462	@$(MKNETID) -q -p $(PASSWD) -g $(GROUP) -h $(HOSTS) -n $(NETID) \
463		-d $(DOMAIN) | $(DBLOAD) -o $(YPMAPDIR)/$@ - $(TMP)
464	@$(MV) $(TMP) $@
465	@$(DBLOAD) -c
466	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
467	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
468
469
470master.passwd.byname: $(MASTER)
471	@echo "Updating $@..."
472	@echo $@.$$$$ > $(NFILE)
473	$(CAT) $(MASTER) | \
474	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
475		| $(DBLOAD) -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP)
476	@$(MV) $(TMP) $@
477	@$(DBLOAD) -c
478	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
479	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
480
481
482master.passwd.byuid: $(MASTER)
483	@echo "Updating $@..."
484	@echo $@.$$$$ > $(NFILE)
485	$(CAT) $(MASTER) | \
486	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
487		| $(DBLOAD) -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP)
488	@$(MV) $(TMP) $@
489	@$(DBLOAD) -c
490	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
491	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
492
493amd.host: $(AMDHOST)
494	@echo "Updating $@..."
495	@echo $@.$$$$ > $(NFILE)
496	$(CAT) $(AMDHOST) | \
497	$(AWK) '$$1 !~ "#"  { \
498	  for (i = 1; i <= NF; i++) \
499	  if (i == NF) { \
500	    if (substr($$i, length($$i), 1) == "\\") \
501	      printf("%s", substr($$i, 1, length($$i) - 1)); \
502	    else \
503	      printf("%s\n", $$i); \
504	  } \
505	  else \
506	    printf("%s ", $$i); \
507	}' | \
508	$(DBLOAD) -i $(AMDHOST) -o $(YPMAPDIR)/$@ - $(TMP)
509	@$(MV) $(TMP) $@
510	@$(DBLOAD) -c
511	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
512	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
513
514