Makefile.yp revision 33536
1#
2# Makefile for the NIS databases
3#
4# $Id: Makefile.yp,v 1.21 1998/02/13 03:38:41 wpaul 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# The following line encodes the YP_INTERDOMAIN key into the hosts.byname
33# and hosts.byaddr maps so that ypserv(8) will do DNS lookups to resolve
34# hosts not in the current domain. Commenting this line out will disable
35# the DNS lookups.
36B=-b
37
38# Normally, the master.passwd.* maps are guarded against access from
39# non-privileged users. By commenting out the following line, the YP_SECURE
40# key will be removed from these maps, allowing anyone to access them.
41S=-s
42
43# These are commands which this Makefile needs to properly rebuild the
44# NIS databases. Don't change these unless you have a good reason. Also
45# be sure not to place an @ in front of /usr/bin/awk: it isn't necessary
46# and it'll break everything in sight.
47#
48AWK = /usr/bin/awk
49RM  = @/bin/rm -f
50MV  = @/bin/mv -f
51RMV  = /bin/mv -f
52RCAT = /bin/cat
53CAT = @$(RCAT)
54
55MKDB = /usr/sbin/yp_mkdb
56DBLOAD = $(MKDB) -m `hostname`
57MKNETID = /usr/libexec/mknetid
58NEWALIASES = /usr/bin/newaliases
59YPPUSH = /usr/sbin/yppush
60.if !defined(UPDATE_DOMAIN)
61DOMAIN = `/bin/domainname`
62.else
63DOMAIN = $(UPDATE_DOMAIN)
64.endif
65REVNETGROUP = /usr/libexec/revnetgroup
66TMP = `echo $@.$$$$`
67
68# It is advisable to create a separate directory to contain the
69# source files used to generate your NIS maps. If you intend to
70# support multiple domains, something like /src/dir/$DOMAIN
71# would work well.
72YPSRCDIR = /etc
73.if !defined(YP_DIR)
74YPDIR = /var/yp
75.else
76YPDIR = $(YP_DIR)
77.endif
78YPMAPDIR = $(YPDIR)/$(DOMAIN)
79
80# These are the files from which the NIS databases are built. You may edit
81# these to taste in the event that you wish to keep your NIS source files
82# seperate from your NIS server's actual configuration files. Note that the
83# NIS passwd and master.passwd files are stored in /var/yp: the server's
84# real password database is not used by default. However, you may use
85# the real /etc/passwd and /etc/master.passwd files by:
86#
87#
88# - invoking yppasswdd without the -m option (yppasswdd will use
89#   /etc/master.passwd if no alternate master.passwd file is specified
90#   and do a 'pwd_mkdb' as needed).
91# - Specifying the location of the master.passwd file using the
92#   MASTER_PASSWD variable, i.e.:
93#
94#   # make MASTER_PASSWD=/path/to/some/other/master.passwd
95#
96# - (optionally): editing this Makefile to change the default location.
97#
98# To add a user, edit $(YPDIR)/master.passwd and type 'make'. The raw
99# passwd file will be generated from the master.passwd file automagically.
100#
101ETHERS    = $(YPSRCDIR)/ethers	   # ethernet addresses (for rarpd)
102BOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
103HOSTS     = $(YPSRCDIR)/hosts
104NETWORKS  = $(YPSRCDIR)/networks
105PROTOCOLS = $(YPSRCDIR)/protocols
106RPC 	  = $(YPSRCDIR)/rpc
107SERVICES  = $(YPSRCDIR)/services
108GROUP     = $(YPSRCDIR)/group
109ALIASES   = $(YPSRCDIR)/aliases
110NETGROUP  = $(YPDIR)/netgroup
111PASSWD    = $(YPDIR)/passwd
112.if !defined(MASTER_PASSWD)
113MASTER    = $(YPDIR)/master.passwd
114.else
115MASTER	  = $(MASTER_PASSWD)
116.endif
117YPSERVERS = $(YPDIR)/ypservers	# List of all NIS servers for a domain
118PUBLICKEY = $(YPSRCDIR)/publickey
119NETID     = $(YPSRCDIR)/netid
120AMDHOST   = $(YPSRCDIR)/amd.host
121
122# List of maps that are always built.
123# If you want to omit some of them, feel free to comment
124# them out from this list.
125TARGETS= servers hosts networks protocols rpc services group
126#TARGETS+= aliases
127
128# Sanity checks: filter out targets we can't build
129# Note that we don't build the ethers or boorparams maps by default
130# since /etc/ethers and /etc/bootparams are not likely to be present
131# on all systems.
132.if exists($(ETHERS))
133TARGETS+= ethers
134.else
135ETHERS= /dev/null
136.endif
137
138.if exists($(BOOTPARAMS))
139TARGETS+= bootparams
140.else
141BOOTPARAMS= /dev/null
142.endif
143
144.if exists($(NETGROUP))
145TARGETS+= netgrp
146.else
147NETGROUP= /dev/null
148.endif
149
150.if exists($(MASTER))
151TARGETS+= passwd master.passwd netid
152.else
153MASTER= /dev/null
154TARGETS+= nopass
155.endif
156
157.if exists($(PUBLICKEY))
158TARGETS+= publickey
159.else
160PUBLICKEY= /dev/null
161.endif
162
163.if exists($(AMDHOST))
164TARGETS+= amd.host
165.else
166AMDHOST= /dev/null
167.endif
168
169target: 
170	@if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
171	cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
172	make -f ../Makefile all; echo "NIS Map update completed."
173
174all: $(TARGETS)
175
176ethers:	   ethers.byname ethers.byaddr
177bootparam: bootparams
178hosts:	   hosts.byname hosts.byaddr
179networks:  networks.byaddr networks.byname
180protocols: protocols.bynumber protocols.byname
181rpc:	   rpc.byname rpc.bynumber
182services:  services.byname
183passwd:    passwd.byname passwd.byuid
184group:     group.byname group.bygid
185netgrp:    netgroup
186netid:	   netid.byname
187servers:   ypservers
188publickey: publickey.byname
189aliases:   mail.aliases
190
191master.passwd:	master.passwd.byname master.passwd.byuid
192
193#
194# This is a special target used only when doing in-place updates with
195# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
196# server and won't need to be remade. They will have to be pushed to the
197# slaves however. Calling this target implicitly insures that this will
198# happen.
199#
200pushpw:
201	@$(DBLOAD) -c
202	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
203	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
204	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
205	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
206
207pushmap:
208	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $(PUSHMAP) ; fi
209
210nopass:
211	@echo ""
212	@echo "                ********WARNING********"
213	@echo "  Couldn't find the master.passwd source file. This file"
214	@echo "  is needed to generate the master.passwd and passwd maps."
215	@echo "  The default location is /var/yp/master.passwd. You should"
216	@echo "  edit /var/yp/Makefile and set the MASTER variable to point"
217	@echo "  to the source file you wish to use for building the passwd"
218	@echo "  maps, or else invoke make(1) in the following manner:"
219	@echo "
220	@echo "        make MASTER_PASSWD=/path/to/master.passwd"
221	@echo ""
222
223mail.aliases: $(ALIASES)
224	@echo "Updating $@..."
225	@$(NEWALIASES) -oA$(ALIASES)
226	@$(MKDB) -u $(ALIASES).db \
227		| $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP); \
228		$(RMV) $(TMP) $@
229	@$(DBLOAD) -c
230	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
231	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
232
233
234ypservers: $(YPSERVERS)
235	@echo "Updating $@..."
236	$(CAT) $(YPSERVERS) | \
237	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' $^ \
238		| $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP); \
239		$(RMV) $(TMP) $@
240	@$(DBLOAD) -c
241	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
242	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
243
244
245ethers.byname: $(ETHERS)
246	@echo "Updating $@..."
247.if ${ETHERS} == "/dev/null"
248	@echo "Ethers source file not found -- skipping"
249.else
250	$(CAT) $(ETHERS) | \
251	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
252		print $$2"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
253		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
254	@$(DBLOAD) -c
255	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
256	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
257.endif
258
259ethers.byaddr: $(ETHERS)
260	@echo "Updating $@..."
261.if ${ETHERS} == "/dev/null"
262	@echo "Ethers source file not found -- skipping"
263.else
264	$(CAT) $(ETHERS) | \
265	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
266		print $$1"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
267		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
268	@$(DBLOAD) -c
269	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
270	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
271.endif
272
273
274bootparams: $(BOOTPARAMS)
275	@echo "Updating $@..."
276.if ${BOOTPARAMS} == "/dev/null"
277	@echo "Bootparams source file not found -- skipping"
278.else
279	$(CAT) $(BOOTPARAMS) | \
280	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
281		print $$0 }' $^ | $(DBLOAD) -i $(BOOTPARAMS) \
282		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
283	@$(DBLOAD) -c
284	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
285	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
286.endif
287
288
289netgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
290	@echo "Updating $@..."
291.if ${NETGROUP} == "/dev/null"
292	@echo "Netgroup source file not found -- skipping"
293.else
294	$(CAT) $(NETGROUP) | \
295	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
296		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
297		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
298	@$(DBLOAD) -c
299	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
300	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
301	@$(MAKE) -f ../Makefile netid
302.endif
303
304
305netgroup.byhost: $(NETGROUP)
306	@echo "Updating $@..."
307.if ${NETGROUP} == "/dev/null"
308	@echo "Netgroup source file not found -- skipping"
309.else
310	$(CAT) $(NETGROUP) | $(REVNETGROUP) -h -f $(NETGROUP) | \
311	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
312		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
313		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
314	@$(DBLOAD) -c
315	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
316	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
317.endif
318
319
320netgroup.byuser: $(NETGROUP)
321	@echo "Updating $@..."
322.if ${NETGROUP} == "/dev/null"
323	@echo "Netgroup source file not found -- skipping"
324.else
325	$(CAT) $(NETGROUP) | $(REVNETGROUP) -u -f $(NETGROUP) | \
326	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
327		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
328		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
329	@$(DBLOAD) -c
330	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
331	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
332.endif
333
334
335hosts.byname: $(HOSTS)
336	@echo "Updating $@..."
337	$(CAT) $(HOSTS) | \
338	$(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
339		print $$n"\t"$$0 }' $^ | $(DBLOAD) ${B} -i $(HOSTS)  \
340		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
341	@$(DBLOAD) -c
342	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
343	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
344	@$(MAKE) -f ../Makefile netid
345
346
347hosts.byaddr: $(HOSTS)
348	@echo "Updating $@..."
349	$(CAT) $(HOSTS) | \
350	$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$0 }' $^ \
351		| $(DBLOAD) ${B} -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP); \
352		$(RMV) $(TMP) $@
353	@$(DBLOAD) -c
354	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
355	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
356	@$(MAKE) -f ../Makefile netid
357
358
359networks.byname: $(NETWORKS)
360	@echo "Updating $@..."
361	$(CAT) $(NETWORKS) | \
362	$(AWK) \
363	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
364			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
365			      print $$n"\t"$$0 \
366		}' $^ | $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
367		$(RMV) $(TMP) $@
368	@$(DBLOAD) -c
369	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
370	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
371
372
373networks.byaddr: $(NETWORKS)
374	@echo "Updating $@..."
375	$(CAT) $(NETWORKS) | \
376	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
377		| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
378		$(RMV) $(TMP) $@
379	@$(DBLOAD) -c
380	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
381	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
382
383
384protocols.byname: $(PROTOCOLS)
385	@echo "Updating $@..."
386	$(CAT) $(PROTOCOLS) | \
387	$(AWK) \
388	   '$$1 !~ "^#.*"	{ print $$1"\t"$$0; \
389			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
390			      print $$n"\t"$$0 \
391			}' $^ | $(DBLOAD) -i $(PROTOCOLS) \
392		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
393	@$(DBLOAD) -c
394	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
395	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
396
397
398protocols.bynumber: $(PROTOCOLS)
399	@echo "Updating $@..."
400	$(CAT) $(PROTOCOLS) | \
401	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
402		| $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP); \
403		$(RMV) $(TMP) $@
404	@$(DBLOAD) -c
405	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
406	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
407
408
409rpc.byname: $(RPC)
410	@echo "Updating $@..."
411	$(CAT) $(RPC) | \
412	$(AWK) \
413	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
414			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
415			      print $$n"\t"$$0 \
416		}' $^ | $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
417		$(RMV) $(TMP) $@
418	@$(DBLOAD) -c
419	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
420	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
421
422
423rpc.bynumber: $(RPC)
424	@echo "Updating $@..."
425	$(CAT) $(RPC) | \
426	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
427		| $(DBLOAD)  -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
428		$(RMV) $(TMP) $@
429	@$(DBLOAD) -c
430	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
431	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
432
433
434services.byname: $(SERVICES)
435	@echo "Updating $@..."
436	$(CAT) $(SERVICES) | \
437	$(AWK) \
438	   '$$1 !~ "^#.*"  { for (n=1; n<=NF && $$n !~ "^#.*"; n++) { \
439				if (split($$2, t, "/")) { \
440					printf("%s/%s", $$n, t[2]) }; \
441					print "\t"$$0;	\
442					if (n == 1) n = 2; \
443				}
444			   } ; print $$2"\t"$$0 ; \
445		}' $^ | $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP); \
446		$(RMV) $(TMP) $@
447	@$(DBLOAD) -c
448	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
449	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
450
451
452publickey.byname: $(PUBLICKEY)
453	@echo "Updating $@..."
454.if ${PUBLICKEY} == "/dev/null"
455	@echo "Publickey source file not found -- skipping"
456.else
457	$(CAT) $(PUBLICKEY) | \
458	$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$2 }' $^ \
459		| $(DBLOAD)  -i $(PUBLICKEY) -o $(YPMAPDIR)/$@ - $(TMP); \
460		$(RMV) $(TMP) $@
461	@$(DBLOAD) -c
462	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
463	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
464.endif
465
466
467$(PASSWD): $(MASTER)
468	@echo "Creating new $@ file from $(MASTER)..."
469	@if [ ! $(UNSECURE) ]; then \
470	$(RCAT) $(MASTER) | \
471	$(AWK) -F: '{if ($$1 != "+") \
472		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
473		> $(PASSWD) ; \
474	else $(RCAT) $(MASTER) | \
475	$(AWK) -F: '{if ($$1 != "+") \
476		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
477		> $(PASSWD) ; fi
478
479
480passwd.byname: $(PASSWD)
481	@echo "Updating $@..."
482	$(CAT) $(PASSWD) | \
483	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
484		| $(DBLOAD) -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
485		$(RMV) $(TMP) $@
486	@$(DBLOAD) -c
487	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
488	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
489
490
491passwd.byuid: $(PASSWD)
492	@echo "Updating $@..."
493	$(CAT) $(PASSWD) | \
494	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
495		| $(DBLOAD) -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
496		$(RMV) $(TMP) $@
497	@$(DBLOAD) -c
498	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
499	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
500	@$(MAKE) -f ../Makefile netid
501
502
503group.byname: $(GROUP)
504	@echo "Updating $@..."
505	$(CAT) $(GROUP) | \
506	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
507		| $(DBLOAD) -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
508		$(RMV) $(TMP) $@
509	@$(DBLOAD) -c
510	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
511	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
512
513
514group.bygid: $(GROUP)
515	@echo "Updating $@..."
516	$(CAT) $(GROUP) | \
517	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
518		| $(DBLOAD) -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
519		$(RMV) $(TMP) $@
520	@$(DBLOAD) -c
521	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
522	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
523	@$(MAKE) -f ../Makefile netid
524
525
526netid.byname: $(GROUP) $(PASSWD)
527	@echo "Updating $@..."
528	@$(MKNETID) -q -p $(PASSWD) -g $(GROUP) -h $(HOSTS) -n $(NETID) \
529		-d $(DOMAIN) | $(DBLOAD) -o $(YPMAPDIR)/$@ - $(TMP); \
530		$(RMV) $(TMP) $@
531	@$(DBLOAD) -c
532	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
533	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
534
535
536master.passwd.byname: $(MASTER)
537	@echo "Updating $@..."
538.if ${MASTER} == "/dev/null"
539	@echo "Master.passwd source file not found -- skipping"
540.else
541	$(CAT) $(MASTER) | \
542	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
543		| $(DBLOAD) ${S} -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
544		$(RMV) $(TMP) $@
545	@$(DBLOAD) -c
546	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
547	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
548.endif
549
550
551master.passwd.byuid: $(MASTER)
552	@echo "Updating $@..."
553.if ${MASTER} == "/dev/null"
554	@echo "Master.passwd source file not found -- skipping"
555.else
556	$(CAT) $(MASTER) | \
557	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
558		| $(DBLOAD) ${S} -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
559		$(RMV) $(TMP) $@
560	@$(DBLOAD) -c
561	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
562	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
563.endif
564
565
566amd.host: $(AMDHOST)
567	@echo "Updating $@..."
568	$(CAT) $(AMDHOST) | \
569	$(AWK) '$$1 !~ "^#.*"  { \
570	  for (i = 1; i <= NF; i++) \
571	  if (i == NF) { \
572	    if (substr($$i, length($$i), 1) == "\\") \
573	      printf("%s", substr($$i, 1, length($$i) - 1)); \
574	    else \
575	      printf("%s\n", $$i); \
576	  } \
577	  else \
578	    printf("%s ", $$i); \
579	}' | \
580	$(DBLOAD) -i $(AMDHOST) -o $(YPMAPDIR)/$@ - $(TMP); \
581		$(RMV) $(TMP) $@
582	@$(DBLOAD) -c
583	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
584	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
585
586