]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - usr.sbin/ypserv/Makefile.yp
MFC r363988:
[FreeBSD/stable/9.git] / usr.sbin / ypserv / Makefile.yp
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 #
19 NOPUSH = "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.
24 SHADOW = "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.
42 B=-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.
48 S=-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 #
55 AWK = /usr/bin/awk
56 RM  = @/bin/rm -f
57 MV  = @/bin/mv -f
58 RMV  = /bin/mv -f
59
60 MKDB = /usr/sbin/yp_mkdb
61 DBLOAD = $(MKDB) -m `hostname`
62 MKNETID = /usr/libexec/mknetid
63 NEWALIASES = /usr/bin/newaliases
64 YPPUSH = /usr/sbin/yppush
65 .if !defined(UPDATE_DOMAIN)
66 DOMAIN = `/bin/domainname`
67 .else
68 DOMAIN = $(UPDATE_DOMAIN)
69 .endif
70 REVNETGROUP = /usr/libexec/revnetgroup
71 TMP = `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.
77 YPSRCDIR = /etc
78 .if !defined(YP_DIR)
79 YPDIR = /var/yp
80 .else
81 YPDIR = $(YP_DIR)
82 .endif
83 YPMAPDIR = $(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 #
105 ETHERS    = $(YPSRCDIR)/ethers     # ethernet addresses (for rarpd)
106 BOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
107 HOSTS     = $(YPSRCDIR)/hosts
108 IPNODES   = $(YPDIR)/ipnodes
109 NETWORKS  = $(YPSRCDIR)/networks
110 PROTOCOLS = $(YPSRCDIR)/protocols
111 RPC       = $(YPSRCDIR)/rpc
112 SERVICES  = $(YPSRCDIR)/services
113 SHELLS    = $(YPSRCDIR)/shells
114 GROUP     = $(YPSRCDIR)/group
115 ALIASES   = $(YPSRCDIR)/mail/aliases
116 NETGROUP  = $(YPDIR)/netgroup
117 PASSWD    = $(YPDIR)/passwd
118 .if !defined(MASTER_PASSWD)
119 MASTER    = $(YPDIR)/master.passwd
120 .else
121 MASTER    = $(MASTER_PASSWD)
122 .endif
123 YPSERVERS = $(YPDIR)/ypservers  # List of all NIS servers for a domain
124 PUBLICKEY = $(YPSRCDIR)/publickey
125 NETID     = $(YPSRCDIR)/netid
126 AMDHOST   = $(YPSRCDIR)/amd.map
127
128 target: 
129         @if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
130         cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
131         make -f ../Makefile all; echo "NIS Map update completed."
132
133 # Read overrides.  Note, the current directory will be /var/yp/<domain>
134 # when 'all' is built.
135 .if exists(${YPDIR}/Makefile.local)
136 .include "${YPDIR}/Makefile.local"
137 .endif
138
139 # List of maps that are always built.
140 # If you want to omit some of them, feel free to comment
141 # them out from this list.
142 TARGETS= servers hosts networks protocols rpc services shells group
143 TARGETS+= ipnodes
144 #TARGETS+= aliases
145
146 # Sanity checks: filter out targets we can't build
147 # Note that we don't build the ethers or boorparams maps by default
148 # since /etc/ethers and /etc/bootparams are not likely to be present
149 # on all systems.
150 .if exists($(ETHERS))
151 TARGETS+= ethers
152 .else
153 ETHERS= /dev/null
154 .endif
155
156 .if exists($(BOOTPARAMS))
157 TARGETS+= bootparams
158 .else
159 BOOTPARAMS= /dev/null
160 .endif
161
162 .if exists($(NETGROUP))
163 TARGETS+= netgrp
164 .else
165 NETGROUP= /dev/null
166 .endif
167
168 .if exists($(MASTER))
169 TARGETS+= passwd master.passwd netid
170 .if ${SHADOW} == "\"True\""
171 TARGETS+= shadow
172 .endif
173 .else
174 MASTER= /dev/null
175 TARGETS+= nopass
176 .endif
177
178 .if exists($(PUBLICKEY))
179 TARGETS+= publickey
180 .else
181 PUBLICKEY= /dev/null
182 .endif
183
184 .if exists($(AMDHOST))
185 TARGETS+= amd.map
186 .else
187 AMDHOST= /dev/null
188 .endif
189
190 .if !exists($(IPNODES))
191 IPNODES= $(HOSTS)
192 .endif
193
194 all: $(TARGETS)
195
196 ethers:    ethers.byname ethers.byaddr
197 bootparam: bootparams
198 hosts:     hosts.byname hosts.byaddr
199 ipnodes:   ipnodes.byname ipnodes.byaddr
200 networks:  networks.byaddr networks.byname
201 protocols: protocols.bynumber protocols.byname
202 rpc:       rpc.byname rpc.bynumber
203 services:  services.byname
204 passwd:    passwd.byname passwd.byuid
205 shadow:    shadow.byname shadow.byuid
206 group:     group.byname group.bygid
207 netgrp:    netgroup
208 netid:     netid.byname
209 servers:   ypservers
210 publickey: publickey.byname
211 aliases:   mail.aliases
212
213 master.passwd:  master.passwd.byname master.passwd.byuid
214
215 #
216 # This is a special target used only when doing in-place updates with
217 # rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
218 # server and won't need to be remade. They will have to be pushed to the
219 # slaves however. Calling this target implicitly insures that this will
220 # happen.
221 #
222 pushpw:
223         @$(DBLOAD) -c
224         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
225         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
226 .if ${SHADOW} == "\"True\""
227         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) shadow.byname ; fi
228         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) shadow.byuid ; fi
229 .endif
230         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
231         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
232
233 pushmap:
234         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $(PUSHMAP) ; fi
235
236 nopass:
237         @echo ""
238         @echo "                ********WARNING********"
239         @echo "  Couldn't find the master.passwd source file. This file"
240         @echo "  is needed to generate the master.passwd and passwd maps."
241         @echo "  The default location is /var/yp/master.passwd. You should"
242         @echo "  edit /var/yp/Makefile and set the MASTER variable to point"
243         @echo "  to the source file you wish to use for building the passwd"
244         @echo "  maps, or else invoke make(1) in the following manner:"
245         @echo ""
246         @echo "        make MASTER_PASSWD=/path/to/master.passwd"
247         @echo ""
248
249 mail.aliases: $(ALIASES)
250         @echo "Updating $@..."
251         @$(NEWALIASES) -oA$(ALIASES)
252         @$(MKDB) -u $(ALIASES).db \
253                 | $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP); \
254                 $(RMV) $(TMP) $@
255         @$(DBLOAD) -c
256         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
257         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
258
259
260 ypservers: $(YPSERVERS)
261         @echo "Updating $@..."
262         @$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' \
263                 $(YPSERVERS) \
264                 | $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP); \
265                 $(RMV) $(TMP) $@
266         @$(DBLOAD) -c
267         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
268         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
269
270 ethers.byname: $(ETHERS)
271         @echo "Updating $@..."
272 .if ${ETHERS} == "/dev/null"
273         @echo "Ethers source file not found -- skipping"
274 .else
275         @$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
276                 print $$2"\t"$$0 }' $(ETHERS) | $(DBLOAD) -i $(ETHERS) \
277                 -o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
278         @$(DBLOAD) -c
279         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
280         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
281 .endif
282
283 ethers.byaddr: $(ETHERS)
284         @echo "Updating $@..."
285 .if ${ETHERS} == "/dev/null"
286         @echo "Ethers source file not found -- skipping"
287 .else
288         @$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
289                 print $$1"\t"$$0 }' $(ETHERS) | $(DBLOAD) -i $(ETHERS) \
290                 -o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
291         @$(DBLOAD) -c
292         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
293         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
294 .endif
295
296
297 bootparams: $(BOOTPARAMS)
298         @echo "Updating $@..."
299 .if ${BOOTPARAMS} == "/dev/null"
300         @echo "Bootparams source file not found -- skipping"
301 .else
302         @$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
303                 print $$0 }' $(BOOTPARAMS) | $(DBLOAD) -i $(BOOTPARAMS) \
304                 -o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
305         @$(DBLOAD) -c
306         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
307         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
308 .endif
309
310
311 netgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
312         @echo "Updating $@..."
313 .if ${NETGROUP} == "/dev/null"
314         @echo "Netgroup source file not found -- skipping"
315 .else
316         @$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
317                 print $$0 }' $(NETGROUP) | $(DBLOAD) -i $(NETGROUP) \
318                 -o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
319         @$(DBLOAD) -c
320         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
321         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
322 .endif
323
324
325 netgroup.byhost: $(NETGROUP)
326         @echo "Updating $@..."
327 .if ${NETGROUP} == "/dev/null"
328         @echo "Netgroup source file not found -- skipping"
329 .else
330         @$(REVNETGROUP) -h -f $(NETGROUP) | \
331         $(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
332                 print $$0 }' | $(DBLOAD) -i $(NETGROUP) \
333                 -o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
334         @$(DBLOAD) -c
335         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
336         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
337 .endif
338
339
340 netgroup.byuser: $(NETGROUP)
341         @echo "Updating $@..."
342 .if ${NETGROUP} == "/dev/null"
343         @echo "Netgroup source file not found -- skipping"
344 .else
345         @$(REVNETGROUP) -u -f $(NETGROUP) | \
346         $(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
347                 print $$0 }' | $(DBLOAD) -i $(NETGROUP) \
348                 -o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
349         @$(DBLOAD) -c
350         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
351         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
352 .endif
353
354
355 # Solaris 8 does the following:
356 # - /etc/hosts and hosts.{byname,byaddr} are IPv4 only.
357 # - /etc/inet/ipnodes and ipnodes.{byname,byaddr} are used for protocol
358 #   independent name-to-address mapping.
359 #
360 # For local name resolution, we made /etc/hosts protocol independent.
361 # For NIS name resolution, we obey Solaris 8 practice.
362 # - We keep hosts.{byname,byaddr} IPv4 only, to be friendly with Solaris 8
363 #   clients.
364 # - ipnodes.{byname,byaddr} is used for protocol independent mapping.
365 # We generate all the mappings from /etc/hosts unless /var/yp/ipnodes
366 # exists, for compatibility with FreeBSD local name resolution.
367 #
368 hosts.byname: $(HOSTS)
369         @echo "Updating $@..."
370         @$(AWK) '/^[0-9.]+[\t ]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
371                 print $$n"\t"$$0 }' $(HOSTS) | $(DBLOAD) ${B} -i $(HOSTS)  \
372                 -o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
373         @$(DBLOAD) -c
374         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
375         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
376
377
378 hosts.byaddr: $(HOSTS)
379         @echo "Updating $@..."
380         @$(AWK) '/^[0-9.]+[\t ]/ { print $$1"\t"$$0 }' $(HOSTS) \
381                 | $(DBLOAD) ${B} -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP); \
382                 $(RMV) $(TMP) $@
383         @$(DBLOAD) -c
384         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
385         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
386
387
388 ipnodes.byname: $(IPNODES)
389         @echo "Updating $@..."
390         @$(AWK) '/^[0-9a-fA-F:]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
391                 print $$n"\t"$$0 }' $(IPNODES) | $(DBLOAD) ${B} -i $(IPNODES)  \
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
398 ipnodes.byaddr: $(IPNODES)
399         @echo "Updating $@..."
400         @$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$0 }' $(IPNODES) \
401                 | $(DBLOAD) ${B} -i $(IPNODES) -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
408 networks.byname: $(NETWORKS)
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                 }' $(NETWORKS) \
415                 | $(DBLOAD) -i $(NETWORKS) -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
422 networks.byaddr: $(NETWORKS)
423         @echo "Updating $@..."
424         @$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $(NETWORKS) \
425                 | $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
426                 $(RMV) $(TMP) $@
427         @$(DBLOAD) -c
428         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
429         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
430
431
432 protocols.byname: $(PROTOCOLS)
433         @echo "Updating $@..."
434         @$(AWK) \
435            '$$1 !~ "^#.*"       { print $$1"\t"$$0; \
436                           for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
437                               print $$n"\t"$$0 \
438                         }' $(PROTOCOLS) | $(DBLOAD) -i $(PROTOCOLS) \
439                 -o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
440         @$(DBLOAD) -c
441         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
442         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
443
444
445 protocols.bynumber: $(PROTOCOLS)
446         @echo "Updating $@..."
447         @$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $(PROTOCOLS) \
448                 | $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP); \
449                 $(RMV) $(TMP) $@
450         @$(DBLOAD) -c
451         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
452         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
453
454
455 rpc.byname: $(RPC)
456         @echo "Updating $@..."
457         @$(AWK) \
458            '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
459                           for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
460                               print $$n"\t"$$0 \
461                 }' $(RPC) | $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
462                 $(RMV) $(TMP) $@
463         @$(DBLOAD) -c
464         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
465         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
466
467
468 rpc.bynumber: $(RPC)
469         @echo "Updating $@..."
470         @$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $(RPC) \
471                 | $(DBLOAD)  -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
472                 $(RMV) $(TMP) $@
473         @$(DBLOAD) -c
474         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
475         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
476
477
478 services.byname: $(SERVICES)
479         @echo "Updating $@..."
480         @$(AWK) \
481            '$$1 !~ "^#.*"  { for (n=1; n<=NF && $$n !~ "^#.*"; n++) { \
482                                 if (split($$2, t, "/")) { \
483                                         printf("%s/%s", $$n, t[2]) }; \
484                                         print "\t"$$0;  \
485                                         if (n == 1) n = 2; \
486                            } ; print $$2"\t"$$0 ; \
487                 }' $(SERVICES) \
488                 | $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP); \
489                 $(RMV) $(TMP) $@
490         @$(DBLOAD) -c
491         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
492         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
493
494 shells: $(SHELLS)
495         @echo "Updating $@..."
496         @$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' \
497                 $(SHELLS) \
498                 | $(DBLOAD) -i $(SHELLS) -o $(YPMAPDIR)/$@ - $(TMP); \
499          $(RMV) $(TMP) $@
500         @$(DBLOAD) -c
501         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
502         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
503
504 publickey.byname: $(PUBLICKEY)
505         @echo "Updating $@..."
506 .if ${PUBLICKEY} == "/dev/null"
507         @echo "Publickey source file not found -- skipping"
508 .else
509         @$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$2 }' $(PUBLICKEY) \
510                 | $(DBLOAD)  -i $(PUBLICKEY) -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 .endif
516
517
518 $(PASSWD): $(MASTER)
519         @echo "Creating new $@ file from $(MASTER)..."
520         @if [ ! $(UNSECURE) ]; then \
521         $(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
522                 print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $(MASTER) \
523                 > $(PASSWD) ; \
524         else \
525         $(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
526                 print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $(MASTER) \
527                 > $(PASSWD) ; fi
528
529
530 passwd.byname: $(PASSWD)
531         @echo "Updating $@..."
532         @$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
533                 print $$1"\t"$$0 }' $(PASSWD) \
534                 | $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
535                 $(RMV) $(TMP) $@
536         @$(DBLOAD) -c
537         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
538         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
539
540
541 passwd.byuid: $(PASSWD)
542         @echo "Updating $@..."
543         @$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
544                 print $$3"\t"$$0 }' $(PASSWD) \
545                 | $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
546                 $(RMV) $(TMP) $@
547         @$(DBLOAD) -c
548         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
549         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
550
551
552 group.byname: $(GROUP)
553         @echo "Updating $@..."
554         @$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
555                 print $$1"\t"$$0 }' $(GROUP) \
556                 | $(DBLOAD) -f -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
557                 $(RMV) $(TMP) $@
558         @$(DBLOAD) -c
559         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
560         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
561
562
563 group.bygid: $(GROUP)
564         @echo "Updating $@..."
565         @$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
566                 print $$3"\t"$$0 }' $(GROUP) \
567                 | $(DBLOAD) -f -i $(GROUP) -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
573
574 netid.byname: $(GROUP) $(PASSWD) $(HOSTS)
575         @echo "Updating $@..."
576         @$(MKNETID) -q -p $(PASSWD) -g $(GROUP) -h $(HOSTS) -n $(NETID) \
577                 -d $(DOMAIN) | $(DBLOAD) -o $(YPMAPDIR)/$@ - $(TMP); \
578                 $(RMV) $(TMP) $@
579         @$(DBLOAD) -c
580         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
581         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
582
583
584 master.passwd.byname: $(MASTER)
585         @echo "Updating $@..."
586 .if ${MASTER} == "/dev/null"
587         @echo "Master.passwd source file not found -- skipping"
588 .else
589         @$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
590                 print $$1"\t"$$0 }' $(MASTER) \
591                 | $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
592                 $(RMV) $(TMP) $@
593         @$(DBLOAD) -c
594         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
595         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
596 .endif
597
598
599 master.passwd.byuid: $(MASTER)
600         @echo "Updating $@..."
601 .if ${MASTER} == "/dev/null"
602         @echo "Master.passwd source file not found -- skipping"
603 .else
604         @$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
605                 print $$3"\t"$$0 }' $(MASTER) \
606                 | $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
607                 $(RMV) $(TMP) $@
608         @$(DBLOAD) -c
609         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
610         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
611 .endif
612
613
614 shadow.byname: $(MASTER)
615         @echo "Updating $@..."
616 .if ${MASTER} == "/dev/null"
617         @echo "Master.passwd source file not found -- skipping"
618 .else
619         @$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
620                 print $$1"\t"$$1":"$$2":12000:0:99999:7:::" }' $(MASTER) \
621                 | sed 's/\(     [^:]*:\)\*:/\1!:/' \
622                 | $(DBLOAD) ${S} -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
623                 $(RMV) $(TMP) $@
624         @$(DBLOAD) -c
625         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
626         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
627 .endif
628
629 shadow.byuid: $(MASTER)
630         @echo "Updating $@..."
631 .if ${MASTER} == "/dev/null"
632         @echo "Master.passwd source file not found -- skipping"
633 .else
634         @$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
635                 print $$3"\t"$$1":"$$2":12000:0:99999:7:::" }' $(MASTER) \
636                 | sed 's/\(     [^:]*:\)\*:/\1!:/' \
637                 | $(DBLOAD) ${S} -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
638                 $(RMV) $(TMP) $@
639         @$(DBLOAD) -c
640         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
641         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
642 .endif
643
644 amd.map: $(AMDHOST)
645         @echo "Updating $@..."
646         @$(AWK) '$$1 !~ "^#.*"  { \
647           for (i = 1; i <= NF; i++) \
648           if (i == NF) { \
649             if (substr($$i, length($$i), 1) == "\\") \
650               printf("%s", substr($$i, 1, length($$i) - 1)); \
651             else \
652               printf("%s\n", $$i); \
653           } \
654           else \
655             printf("%s ", $$i); \
656         }' $(AMDHOST) | \
657         $(DBLOAD) -i $(AMDHOST) -o $(YPMAPDIR)/$@ - $(TMP); \
658                 $(RMV) $(TMP) $@
659         @$(DBLOAD) -c
660         @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
661         @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi