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