xref: /freebsd/usr.sbin/ypserv/Makefile.yp (revision f39bffc62c1395bde25d152c7f68fdf7cbaab414)
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, reset this variable (NOPUSH=)
15# in Makefile.local so that changes to the NIS maps can be propagated to
16# the slave servers.  (By default we assume that we are only serving a
17# small domain with only one server.)
18#
19NOPUSH = "True"
20
21# If this machine does not wish to generate a linux-style shadow map
22# from the master.passwd file, reset this variable (SHADOW=) in
23# Makefile.local.
24SHADOW = "True"
25
26# If you want to use a FreeBSD NIS server to serve non-FreeBSD clients
27# (i.e. clients who expect the password field in the passwd maps to be
28# valid) then set this variable (UNSECURE="True") in Makefile.local.
29# This will cause $YPDIR/passwd to be generated with valid password
30# fields.  This is insecure: FreeBSD normally only serves the
31# master.passwd and shadow maps (which have real encrypted passwords
32# in them) to the superuser on other FreeBSD machines, but non-FreeBSD
33# clients (e.g. SunOS, Solaris (without NIS+), IRIX, HP-UX, etc...)
34# will only work properly in 'unsecure' mode.
35#
36#UNSECURE = "True"
37
38# The following line encodes the YP_INTERDOMAIN key into the hosts.byname
39# and hosts.byaddr maps so that ypserv(8) will do DNS lookups to resolve
40# hosts not in the current domain.  Resetting this variable in
41# Makefile.local (B=) will disable the DNS lookups.
42B=-b
43
44# Normally, the master.passwd.* and shadow.* maps are guarded against access
45# from non-privileged users.  By resetting S in Makefile.local (S=), the
46# YP_SECURE key will be removed from these maps, allowing anyone to access
47# them.
48S=-s
49
50# These are commands which this Makefile needs to properly rebuild the
51# NIS databases. Don't change these unless you have a good reason. Also
52# be sure not to place an @ in front of /usr/bin/awk: it isn't necessary
53# and it'll break everything in sight.
54#
55AWK = /usr/bin/awk
56RM  = @/bin/rm -f
57MV  = @/bin/mv -f
58RMV  = /bin/mv -f
59
60MKDB = /usr/sbin/yp_mkdb
61DBLOAD = $(MKDB) -m `hostname`
62MKNETID = /usr/libexec/mknetid
63NEWALIASES = /usr/bin/newaliases
64YPPUSH = /usr/sbin/yppush
65.if !defined(UPDATE_DOMAIN)
66DOMAIN = `/bin/domainname`
67.else
68DOMAIN = $(UPDATE_DOMAIN)
69.endif
70REVNETGROUP = /usr/libexec/revnetgroup
71TMP = `echo $@.$$$$`
72
73# It is advisable to create a separate directory to contain the
74# source files used to generate your NIS maps. If you intend to
75# support multiple domains, something like /src/dir/$DOMAIN
76# would work well.
77YPSRCDIR = /etc
78.if !defined(YP_DIR)
79YPDIR = /var/yp
80.else
81YPDIR = $(YP_DIR)
82.endif
83YPMAPDIR = $(YPDIR)/$(DOMAIN)
84
85# These are the files from which the NIS databases are built. You may edit
86# these to taste in the event that you wish to keep your NIS source files
87# separate from your NIS server's actual configuration files. Note that the
88# NIS passwd and master.passwd files are stored in /var/yp: the server's
89# real password database is not used by default. However, you may use
90# the real /etc/passwd and /etc/master.passwd files by:
91#
92#
93# - invoking yppasswdd with `-t /etc/master.passwd' (yppasswdd will do a
94#   'pwd_mkdb' as needed if /etc/master.passwd is thus specified).
95# - Specifying the location of the master.passwd file using the
96#   MASTER_PASSWD variable, i.e.:
97#
98#   # make MASTER_PASSWD=/path/to/some/other/master.passwd
99#
100# - (optionally): editing this Makefile to change the default location.
101#
102# To add a user, edit $(YPDIR)/master.passwd and type 'make'. The raw
103# passwd file will be generated from the master.passwd file automagically.
104#
105ETHERS    = $(YPSRCDIR)/ethers	   # ethernet addresses (for rarpd)
106EUI64     = $(YPSRCDIR)/eui64	   # eui64 addresses (for firewire)
107BOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
108HOSTS     = $(YPSRCDIR)/hosts
109IPNODES   = $(YPDIR)/ipnodes
110NETWORKS  = $(YPSRCDIR)/networks
111PROTOCOLS = $(YPSRCDIR)/protocols
112RPC 	  = $(YPSRCDIR)/rpc
113SERVICES  = $(YPSRCDIR)/services
114SHELLS    = $(YPSRCDIR)/shells
115GROUP     = $(YPSRCDIR)/group
116ALIASES   = $(YPSRCDIR)/mail/aliases
117NETGROUP  = $(YPDIR)/netgroup
118PASSWD    = $(YPDIR)/passwd
119.if !defined(MASTER_PASSWD)
120MASTER    = $(YPDIR)/master.passwd
121.else
122MASTER	  = $(MASTER_PASSWD)
123.endif
124YPSERVERS = $(YPDIR)/ypservers	# List of all NIS servers for a domain
125PUBLICKEY = $(YPSRCDIR)/publickey
126NETID     = $(YPSRCDIR)/netid
127AMDHOST   = $(YPSRCDIR)/amd.map
128
129target:
130	@if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
131	cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
132	make -f ../Makefile all; echo "NIS Map update completed."
133
134# Read overrides.  Note, the current directory will be /var/yp/<domain>
135# when 'all' is built.
136.if exists(${YPDIR}/Makefile.local)
137.include "${YPDIR}/Makefile.local"
138.endif
139
140# List of maps that are always built.
141# If you want to omit some of them, feel free to comment
142# them out from this list.
143TARGETS= servers hosts networks protocols rpc services shells group
144TARGETS+= ipnodes
145#TARGETS+= aliases
146
147# Sanity checks: filter out targets we can't build
148# Note that we don't build the ethers, eui64, or boorparams maps by default
149# since /etc/ethers, /etc/eui64 and /etc/bootparams are not likely to be present
150# on all systems.
151.if exists($(ETHERS))
152TARGETS+= ethers
153.else
154ETHERS= /dev/null
155.endif
156
157.if exists($(EUI64))
158TARGETS+= eui64
159.else
160EUI64= /dev/null
161.endif
162
163.if exists($(BOOTPARAMS))
164TARGETS+= bootparams
165.else
166BOOTPARAMS= /dev/null
167.endif
168
169.if exists($(NETGROUP))
170TARGETS+= netgrp
171.else
172NETGROUP= /dev/null
173.endif
174
175.if exists($(MASTER))
176TARGETS+= passwd master.passwd netid
177.if ${SHADOW} == "\"True\""
178TARGETS+= shadow
179.endif
180.else
181MASTER= /dev/null
182TARGETS+= nopass
183.endif
184
185.if exists($(PUBLICKEY))
186TARGETS+= publickey
187.else
188PUBLICKEY= /dev/null
189.endif
190
191.if exists($(AMDHOST))
192TARGETS+= amd.map
193.else
194AMDHOST= /dev/null
195.endif
196
197.if !exists($(IPNODES))
198IPNODES= $(HOSTS)
199.endif
200
201all: $(TARGETS)
202
203ethers:	   ethers.byname ethers.byaddr
204eui64:	   eui64.byname eui64.byid
205bootparam: bootparams
206hosts:	   hosts.byname hosts.byaddr
207ipnodes:   ipnodes.byname ipnodes.byaddr
208networks:  networks.byaddr networks.byname
209protocols: protocols.bynumber protocols.byname
210rpc:	   rpc.byname rpc.bynumber
211services:  services.byname
212passwd:    passwd.byname passwd.byuid
213shadow:    shadow.byname shadow.byuid
214group:     group.byname group.bygid
215netgrp:    netgroup
216netid:	   netid.byname
217servers:   ypservers
218publickey: publickey.byname
219aliases:   mail.aliases
220
221master.passwd:	master.passwd.byname master.passwd.byuid
222
223#
224# This is a special target used only when doing in-place updates with
225# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
226# server and won't need to be remade. They will have to be pushed to the
227# slaves however. Calling this target implicitly insures that this will
228# happen.
229#
230pushpw:
231	@$(DBLOAD) -c
232	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
233	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
234.if ${SHADOW} == "\"True\""
235	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) shadow.byname ; fi
236	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) shadow.byuid ; fi
237.endif
238	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
239	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
240
241pushmap:
242	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $(PUSHMAP) ; fi
243
244nopass:
245	@echo ""
246	@echo "                ********WARNING********"
247	@echo "  Couldn't find the master.passwd source file. This file"
248	@echo "  is needed to generate the master.passwd and passwd maps."
249	@echo "  The default location is /var/yp/master.passwd. You should"
250	@echo "  edit /var/yp/Makefile and set the MASTER variable to point"
251	@echo "  to the source file you wish to use for building the passwd"
252	@echo "  maps, or else invoke make(1) in the following manner:"
253	@echo ""
254	@echo "        make MASTER_PASSWD=/path/to/master.passwd"
255	@echo ""
256
257mail.aliases: $(ALIASES)
258	@echo "Updating $@..."
259	@$(NEWALIASES) -oA$(ALIASES)
260	@$(MKDB) -u $(ALIASES).db \
261		| $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP); \
262		$(RMV) $(TMP) $@
263	@$(DBLOAD) -c
264	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
265	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
266
267
268ypservers: $(YPSERVERS)
269	@echo "Updating $@..."
270	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' \
271		$(YPSERVERS) \
272		| $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP); \
273		$(RMV) $(TMP) $@
274	@$(DBLOAD) -c
275	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
276	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
277
278ethers.byname: $(ETHERS)
279	@echo "Updating $@..."
280.if ${ETHERS} == "/dev/null"
281	@echo "Ethers source file not found -- skipping"
282.else
283	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
284		print $$2"\t"$$0 }' $(ETHERS) | $(DBLOAD) -i $(ETHERS) \
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
291ethers.byaddr: $(ETHERS)
292	@echo "Updating $@..."
293.if ${ETHERS} == "/dev/null"
294	@echo "Ethers source file not found -- skipping"
295.else
296	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
297		print $$1"\t"$$0 }' $(ETHERS) | $(DBLOAD) -i $(ETHERS) \
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
304eui64.byname: $(EUI64)
305	@echo "Updating $@..."
306.if ${EUI64} == "/dev/null"
307	@echo "EUI64 source file not found -- skipping"
308.else
309	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
310		print $$2"\t"$$0 }' $(EUI64) | $(DBLOAD) -i $(EUI64) \
311		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
312	@$(DBLOAD) -c
313	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
314	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
315.endif
316
317eui64.byid: $(EUI64)
318	@echo "Updating $@..."
319.if ${EUI64} == "/dev/null"
320	@echo "EUI64 source file not found -- skipping"
321.else
322	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
323		print $$1"\t"$$0 }' $(EUI64) | $(DBLOAD) -i $(EUI64) \
324		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
325	@$(DBLOAD) -c
326	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
327	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
328.endif
329
330
331bootparams: $(BOOTPARAMS)
332	@echo "Updating $@..."
333.if ${BOOTPARAMS} == "/dev/null"
334	@echo "Bootparams source file not found -- skipping"
335.else
336	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
337		print $$0 }' $(BOOTPARAMS) | $(DBLOAD) -i $(BOOTPARAMS) \
338		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
339	@$(DBLOAD) -c
340	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
341	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
342.endif
343
344
345netgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
346	@echo "Updating $@..."
347.if ${NETGROUP} == "/dev/null"
348	@echo "Netgroup source file not found -- skipping"
349.else
350	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
351		print $$0 }' $(NETGROUP) | $(DBLOAD) -i $(NETGROUP) \
352		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
353	@$(DBLOAD) -c
354	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
355	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
356.endif
357
358
359netgroup.byhost: $(NETGROUP)
360	@echo "Updating $@..."
361.if ${NETGROUP} == "/dev/null"
362	@echo "Netgroup source file not found -- skipping"
363.else
364	@$(REVNETGROUP) -h -f $(NETGROUP) | \
365	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
366		print $$0 }' | $(DBLOAD) -i $(NETGROUP) \
367		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
368	@$(DBLOAD) -c
369	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
370	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
371.endif
372
373
374netgroup.byuser: $(NETGROUP)
375	@echo "Updating $@..."
376.if ${NETGROUP} == "/dev/null"
377	@echo "Netgroup source file not found -- skipping"
378.else
379	@$(REVNETGROUP) -u -f $(NETGROUP) | \
380	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
381		print $$0 }' | $(DBLOAD) -i $(NETGROUP) \
382		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
383	@$(DBLOAD) -c
384	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
385	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
386.endif
387
388
389# Solaris 8 does the following:
390# - /etc/hosts and hosts.{byname,byaddr} are IPv4 only.
391# - /etc/inet/ipnodes and ipnodes.{byname,byaddr} are used for protocol
392#   independent name-to-address mapping.
393#
394# For local name resolution, we made /etc/hosts protocol independent.
395# For NIS name resolution, we obey Solaris 8 practice.
396# - We keep hosts.{byname,byaddr} IPv4 only, to be friendly with Solaris 8
397#   clients.
398# - ipnodes.{byname,byaddr} is used for protocol independent mapping.
399# We generate all the mappings from /etc/hosts unless /var/yp/ipnodes
400# exists, for compatibility with FreeBSD local name resolution.
401#
402hosts.byname: $(HOSTS)
403	@echo "Updating $@..."
404	@$(AWK) '/^[0-9.]+[\t ]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
405		print $$n"\t"$$0 }' $(HOSTS) | $(DBLOAD) ${B} -i $(HOSTS)  \
406		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
407	@$(DBLOAD) -c
408	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
409	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
410
411
412hosts.byaddr: $(HOSTS)
413	@echo "Updating $@..."
414	@$(AWK) '/^[0-9.]+[\t ]/ { print $$1"\t"$$0 }' $(HOSTS) \
415		| $(DBLOAD) ${B} -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP); \
416		$(RMV) $(TMP) $@
417	@$(DBLOAD) -c
418	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
419	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
420
421
422ipnodes.byname: $(IPNODES)
423	@echo "Updating $@..."
424	@$(AWK) '/^[0-9a-fA-F:]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
425		print $$n"\t"$$0 }' $(IPNODES) | $(DBLOAD) ${B} -i $(IPNODES)  \
426		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
427	@$(DBLOAD) -c
428	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
429	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
430
431
432ipnodes.byaddr: $(IPNODES)
433	@echo "Updating $@..."
434	@$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$0 }' $(IPNODES) \
435		| $(DBLOAD) ${B} -i $(IPNODES) -o $(YPMAPDIR)/$@ - $(TMP); \
436		$(RMV) $(TMP) $@
437	@$(DBLOAD) -c
438	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
439	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
440
441
442networks.byname: $(NETWORKS)
443	@echo "Updating $@..."
444	@$(AWK) \
445	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
446			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
447			      print $$n"\t"$$0 \
448		}' $(NETWORKS) \
449		| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
450		$(RMV) $(TMP) $@
451	@$(DBLOAD) -c
452	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
453	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
454
455
456networks.byaddr: $(NETWORKS)
457	@echo "Updating $@..."
458	@$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $(NETWORKS) \
459		| $(DBLOAD) -i $(NETWORKS) -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
465
466protocols.byname: $(PROTOCOLS)
467	@echo "Updating $@..."
468	@$(AWK) \
469	   '$$1 !~ "^#.*"	{ print $$1"\t"$$0; \
470			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
471			      print $$n"\t"$$0 \
472			}' $(PROTOCOLS) | $(DBLOAD) -i $(PROTOCOLS) \
473		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
474	@$(DBLOAD) -c
475	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
476	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
477
478
479protocols.bynumber: $(PROTOCOLS)
480	@echo "Updating $@..."
481	@$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $(PROTOCOLS) \
482		| $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP); \
483		$(RMV) $(TMP) $@
484	@$(DBLOAD) -c
485	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
486	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
487
488
489rpc.byname: $(RPC)
490	@echo "Updating $@..."
491	@$(AWK) \
492	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
493			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
494			      print $$n"\t"$$0 \
495		}' $(RPC) | $(DBLOAD) -i $(RPC) -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
501
502rpc.bynumber: $(RPC)
503	@echo "Updating $@..."
504	@$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $(RPC) \
505		| $(DBLOAD)  -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
506		$(RMV) $(TMP) $@
507	@$(DBLOAD) -c
508	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
509	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
510
511
512services.byname: $(SERVICES)
513	@echo "Updating $@..."
514	@$(AWK) \
515	   '$$1 !~ "^#.*"  { for (n=1; n<=NF && $$n !~ "^#.*"; n++) { \
516				if (split($$2, t, "/")) { \
517					printf("%s/%s", $$n, t[2]) }; \
518					print "\t"$$0;	\
519					if (n == 1) n = 2; \
520			   } ; print $$2"\t"$$0 ; \
521		}' $(SERVICES) \
522		| $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP); \
523		$(RMV) $(TMP) $@
524	@$(DBLOAD) -c
525	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
526	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
527
528shells: $(SHELLS)
529	@echo "Updating $@..."
530	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' \
531		$(SHELLS) \
532		| $(DBLOAD) -i $(SHELLS) -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
538publickey.byname: $(PUBLICKEY)
539	@echo "Updating $@..."
540.if ${PUBLICKEY} == "/dev/null"
541	@echo "Publickey source file not found -- skipping"
542.else
543	@$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$2 }' $(PUBLICKEY) \
544		| $(DBLOAD)  -i $(PUBLICKEY) -o $(YPMAPDIR)/$@ - $(TMP); \
545		$(RMV) $(TMP) $@
546	@$(DBLOAD) -c
547	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
548	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
549.endif
550
551
552$(PASSWD): $(MASTER)
553	@echo "Creating new $@ file from $(MASTER)..."
554	@if [ ! $(UNSECURE) ]; then \
555	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
556		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $(MASTER) \
557		> $(PASSWD) ; \
558	else \
559	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
560		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $(MASTER) \
561		> $(PASSWD) ; fi
562
563
564passwd.byname: $(PASSWD)
565	@echo "Updating $@..."
566	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
567		print $$1"\t"$$0 }' $(PASSWD) \
568		| $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
569		$(RMV) $(TMP) $@
570	@$(DBLOAD) -c
571	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
572	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
573
574
575passwd.byuid: $(PASSWD)
576	@echo "Updating $@..."
577	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
578		print $$3"\t"$$0 }' $(PASSWD) \
579		| $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
580		$(RMV) $(TMP) $@
581	@$(DBLOAD) -c
582	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
583	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
584
585
586group.byname: $(GROUP)
587	@echo "Updating $@..."
588	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
589		print $$1"\t"$$0 }' $(GROUP) \
590		| $(DBLOAD) -f -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
591		$(RMV) $(TMP) $@
592	@$(DBLOAD) -c
593	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
594	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
595
596
597group.bygid: $(GROUP)
598	@echo "Updating $@..."
599	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
600		print $$3"\t"$$0 }' $(GROUP) \
601		| $(DBLOAD) -f -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
602		$(RMV) $(TMP) $@
603	@$(DBLOAD) -c
604	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
605	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
606
607
608netid.byname: $(GROUP) $(PASSWD) $(HOSTS)
609	@echo "Updating $@..."
610	@$(MKNETID) -q -p $(PASSWD) -g $(GROUP) -h $(HOSTS) -n $(NETID) \
611		-d $(DOMAIN) | $(DBLOAD) -o $(YPMAPDIR)/$@ - $(TMP); \
612		$(RMV) $(TMP) $@
613	@$(DBLOAD) -c
614	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
615	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
616
617
618master.passwd.byname: $(MASTER)
619	@echo "Updating $@..."
620.if ${MASTER} == "/dev/null"
621	@echo "Master.passwd source file not found -- skipping"
622.else
623	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
624		print $$1"\t"$$0 }' $(MASTER) \
625		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
626		$(RMV) $(TMP) $@
627	@$(DBLOAD) -c
628	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
629	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
630.endif
631
632
633master.passwd.byuid: $(MASTER)
634	@echo "Updating $@..."
635.if ${MASTER} == "/dev/null"
636	@echo "Master.passwd source file not found -- skipping"
637.else
638	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
639		print $$3"\t"$$0 }' $(MASTER) \
640		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
641		$(RMV) $(TMP) $@
642	@$(DBLOAD) -c
643	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
644	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
645.endif
646
647
648shadow.byname: $(MASTER)
649	@echo "Updating $@..."
650.if ${MASTER} == "/dev/null"
651	@echo "Master.passwd source file not found -- skipping"
652.else
653	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
654		print $$1"\t"$$1":"$$2":12000:0:99999:7:::" }' $(MASTER) \
655		| sed 's/\(	[^:]*:\)\*:/\1!:/' \
656		| $(DBLOAD) ${S} -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
657		$(RMV) $(TMP) $@
658	@$(DBLOAD) -c
659	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
660	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
661.endif
662
663shadow.byuid: $(MASTER)
664	@echo "Updating $@..."
665.if ${MASTER} == "/dev/null"
666	@echo "Master.passwd source file not found -- skipping"
667.else
668	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
669		print $$3"\t"$$1":"$$2":12000:0:99999:7:::" }' $(MASTER) \
670		| sed 's/\(	[^:]*:\)\*:/\1!:/' \
671		| $(DBLOAD) ${S} -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
672		$(RMV) $(TMP) $@
673	@$(DBLOAD) -c
674	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
675	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
676.endif
677
678amd.map: $(AMDHOST)
679	@echo "Updating $@..."
680	@$(AWK) '$$1 !~ "^#.*"  { \
681	  for (i = 1; i <= NF; i++) \
682	  if (i == NF) { \
683	    if (substr($$i, length($$i), 1) == "\\") \
684	      printf("%s", substr($$i, 1, length($$i) - 1)); \
685	    else \
686	      printf("%s\n", $$i); \
687	  } \
688	  else \
689	    printf("%s ", $$i); \
690	}' $(AMDHOST) | \
691	$(DBLOAD) -i $(AMDHOST) -o $(YPMAPDIR)/$@ - $(TMP); \
692		$(RMV) $(TMP) $@
693	@$(DBLOAD) -c
694	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
695	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
696