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