1 YPDBDIR=/private/var/yp
12 MAKEDBM=/usr/sbin/makedbm
14 SENDMAIL=/usr/sbin/sendmail
15 STDHOSTS=/usr/sbin/stdhosts
16 STDETHERS=/usr/sbin/stdethers
17 MKALIAS=/usr/sbin/mkalias
18 MKNETID=/usr/sbin/mknetid
19 REVNETGROUP=/usr/sbin/revnetgroup
21 DOMAIN:=`/usr/bin/basename ${.CURDIR}`
22 YPPUSH=/usr/sbin/yppush
24 # Password maps in standard YP is unsecure. This is due to the fact that
25 # passwords are accessable for anyone.
26 # As a solution, maps can be secure (makedbm -s). If a map is secure only
27 # a privileged user can access it.
28 MAKEDBM-S=$(MAKEDBM) -s
31 all: passwd group hosts ethers networks rpc services protocols netid netgroup aliases
33 passwd.time: $(DIR)/master.passwd
34 -@if [ -f $(>) ]; then \
35 if [ ! $(UNSECURE) ]; then \
36 $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 | \
37 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
38 { print $$1, $$1":*:"$$3":"$$4":"$$5":"$$6":"$$7 }' -|\
39 $(MAKEDBM) - passwd.byname; \
40 $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 |\
41 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
42 { print $$3, $$1":*:"$$3":"$$4":"$$5":"$$6":"$$7 }' -|\
43 $(MAKEDBM) - passwd.byuid; \
45 $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 | \
46 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
47 { print $$1, $$0 }' - | $(MAKEDBM) - passwd.byname; \
48 $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 |\
49 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
50 { print $$3, $$0 }' - | $(MAKEDBM) - passwd.byuid; \
53 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
54 { print $$1, $$0 }' - | $(MAKEDBM-S) - master.passwd.byname; \
56 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
57 { print $$3, $$0 }' - | $(MAKEDBM-S) - master.passwd.byuid; \
59 $(ECHO) "updated passwd"; \
60 if [ ! $(NOPUSH) ]; then \
61 $(YPPUSH) -d $(DOMAIN) passwd.byname; \
62 $(YPPUSH) -d $(DOMAIN) passwd.byuid; \
63 $(YPPUSH) -d $(DOMAIN) master.passwd.byname; \
64 $(YPPUSH) -d $(DOMAIN) master.passwd.byuid; \
65 $(ECHO) "pushed passwd"; \
70 $(ECHO) "couldn't find $(>)"; \
74 group.time: $(DIR)/group
75 -@if [ -f $(>) ]; then \
76 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
77 { print $$1, $$0 }' $(>) | \
78 $(MAKEDBM) - group.byname; \
79 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
80 { print $$3, $$0 }' $(>) | \
81 $(MAKEDBM) - group.bygid; \
83 $(ECHO) "updated group"; \
84 if [ ! $(NOPUSH) ]; then \
85 $(YPPUSH) -d $(DOMAIN) group.byname; \
86 $(YPPUSH) -d $(DOMAIN) group.bygid; \
87 $(ECHO) "pushed group"; \
92 $(ECHO) "couldn't find $(>)"; \
95 hosts.time: $(DIR)/hosts
96 -@if [ -f $(DIR)/hosts ]; then \
97 $(STDHOSTS) $(>) | $(SED) -e s/#.*$$// | \
98 $(AWK) '{for (i = 2; i <= NF; i++) print $$i, $$0 }' | \
99 $(MAKEDBM) - hosts.byname; \
101 $(AWK) 'BEGIN { OFS="\t"; } { print $$1, $$0 }' | \
102 $(MAKEDBM) - hosts.byaddr; \
104 $(ECHO) "updated hosts"; \
105 if [ ! $(NOPUSH) ]; then \
106 $(YPPUSH) -d $(DOMAIN) hosts.byname; \
107 $(YPPUSH) -d $(DOMAIN) hosts.byaddr; \
108 $(ECHO) "pushed hosts"; \
113 $(ECHO) "couldn't find $(>)"; \
116 ethers.time: $(DIR)/ethers
117 -@if [ -f $(DIR)/ethers ]; then \
118 $(STDETHERS) $(>) | $(SED) -e s/#.*$$// | \
119 $(AWK) 'BEGIN { FS="\t"; OFS="\t"; } { print $$1, $$0 }' | \
120 $(MAKEDBM) - ethers.byaddr; \
121 $(STDETHERS) $(>) | \
122 $(AWK) 'BEGIN { FS="\t"; OFS="\t"; } { print $$2, $$0 }' | \
123 $(MAKEDBM) - ethers.byname; \
125 $(ECHO) "updated ethers"; \
126 if [ ! $(NOPUSH) ]; then \
127 $(YPPUSH) -d $(DOMAIN) ethers.byaddr; \
128 $(YPPUSH) -d $(DOMAIN) ethers.byname; \
129 $(ECHO) "pushed ethers"; \
134 $(ECHO) "couldn't find $(>)"; \
137 networks.time: $(DIR)/networks
138 -@if [ -f $(>) ]; then \
139 $(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
140 $(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
141 $(MAKEDBM) - networks.byname; \
142 $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
143 $(MAKEDBM) - networks.byaddr; \
145 $(ECHO) "updated networks"; \
146 if [ ! $(NOPUSH) ]; then \
147 $(YPPUSH) -d $(DOMAIN) networks.byname; \
148 $(YPPUSH) -d $(DOMAIN) networks.byaddr; \
149 $(ECHO) "pushed networks"; \
154 $(ECHO) "couldn't find $(>)"; \
158 -@if [ -f $(>) ]; then \
159 $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
160 $(MAKEDBM) - rpc.bynumber; \
161 $(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
162 $(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
163 $(MAKEDBM) - rpc.byname; \
165 $(ECHO) "updated rpc"; \
166 if [ ! $(NOPUSH) ]; then \
167 $(YPPUSH) -d $(DOMAIN) rpc.bynumber; \
168 $(YPPUSH) -d $(DOMAIN) rpc.byname; \
169 $(ECHO) "pushed rpc"; \
174 $(ECHO) "couldn't find $(>)"; \
178 services.time: $(DIR)/services
179 -@if [ -f $(>) ]; then \
180 $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
181 $(MAKEDBM) - services.byname; \
183 $(ECHO) "updated services"; \
184 if [ ! $(NOPUSH) ]; then \
185 $(YPPUSH) -d $(DOMAIN) services.byname; \
186 $(ECHO) "pushed services"; \
191 $(ECHO) "couldn't find $(>)"; \
195 protocols.time: $(DIR)/protocols
196 -@if [ -f $(>) ]; then \
197 $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
198 $(MAKEDBM) - protocols.bynumber; \
199 $(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
200 $(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
201 $(MAKEDBM) - protocols.byname; \
203 $(ECHO) "updated protocols"; \
204 if [ ! $(NOPUSH) ]; then \
205 $(YPPUSH) -d $(DOMAIN) protocols.bynumber; \
206 $(YPPUSH) -d $(DOMAIN) protocols.byname; \
207 $(ECHO) "pushed protocols"; \
212 $(ECHO) "couldn't find $(>)"; \
216 netid.time: $(DIR)/passwd $(DIR)/group $(DIR)/hosts $(DIR)/netid
217 -@$(MKNETID) -q -d $(DOMAIN) -p $(DIR)/passwd -g $(DIR)/group -h $(DIR)/hosts -m $(DIR)/netid | \
218 $(MAKEDBM) - netid.byname; \
220 $(ECHO) "updated netid"; \
221 if [ ! $(NOPUSH) ]; then \
222 $(YPPUSH) -d $(DOMAIN) netid.byname; \
223 $(ECHO) "pushed netid"; \
229 netgroup.time: $(DIR)/netgroup
230 -@if [ -f $(>) ]; then \
231 $(CAT) $(>) | $(MAKEDBM) - netgroup; \
232 $(CAT) $(>) | $(REVNETGROUP) -u -f - | \
233 $(MAKEDBM) - netgroup.byuser; \
234 $(CAT) $(>) | $(REVNETGROUP) -h -f - | \
235 $(MAKEDBM) - netgroup.byhost; \
237 $(ECHO) "updated netgroup"; \
238 if [ ! $(NOPUSH) ]; then \
239 $(YPPUSH) -d $(DOMAIN) netgroup; \
240 $(YPPUSH) -d $(DOMAIN) netgroup.byuser; \
241 $(YPPUSH) -d $(DOMAIN) netgroup.byhost; \
242 $(ECHO) "pushed netgroup"; \
247 $(ECHO) "couldn't find $(>)"; \
251 amd.home.time: $(AMDDIR)/amd.home
252 -@if [ -f $(>) ]; then \
253 $(SED) -e "s/#.*$$//" -e "/^$$/d" $(>) | \
255 for (i = 1; i <= NF; i++) \
257 if (substr($$i, length($$i), 1) == "\\") { \
258 printf("%s", substr($$i, 1, length($$i) - 1)); \
261 printf("%s\n", $$i); \
264 printf("%s ", $$i); \
266 $(MAKEDBM) - amd.home; \
268 $(ECHO) "updated amd.home"; \
269 if [ ! $(NOPUSH) ]; then \
270 $(YPPUSH) -d $(DOMAIN) amd.home; \
271 $(ECHO) "pushed amd.home"; \
276 $(ECHO) "couldn't find $(>)"; \
280 aliases.time: $(DIR)/aliases
281 -@if [ -f $(>) ]; then \
282 $(CP) -p $(>) $(DOMAIN)-aliases; \
283 $(SENDMAIL) -bi -oA$(PWD)/$(DOMAIN)-aliases; \
284 $(MAKEDBM) -U $(DOMAIN)-aliases | $(MAKEDBM) - mail.aliases; \
285 $(MKALIAS) mail.aliases mail.byaddr; \
287 $(RM) $(DOMAIN)-aliases.db $(DOMAIN)-aliases; \
288 $(ECHO) "updated aliases"; \
289 if [ ! $(NOPUSH) ]; then \
290 $(YPPUSH) -d $(DOMAIN) mail.aliases; \
291 $(YPPUSH) -d $(DOMAIN) mail.byaddr; \
292 $(ECHO) "pushed aliases"; \
297 $(ECHO) "couldn't find $(>)"; \
306 networks: networks.time
308 services: services.time
309 protocols: protocols.time
311 netgroup: netgroup.time
312 amd.home: amd.home.time
313 aliases: aliases.time
323 $(DIR)/master.passwd: