1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
# $OpenBSD: Makefile.yp,v 1.13 2002/11/01 23:54:18 fgsch Exp $
YPDBDIR=/var/yp
DIR=/etc
AMDDIR=/etc/amd
NOPUSH=""
#
AWK=/usr/bin/awk
CAT=/bin/cat
CP=/bin/cp
RM=/bin/rm
CUT=/usr/bin/cut
ECHO=/bin/echo
MAKEDBM=/usr/sbin/makedbm
SED=/usr/bin/sed
SENDMAIL=/usr/sbin/sendmail
STDHOSTS=/usr/sbin/stdhosts
STDETHERS=/usr/sbin/stdethers
MKALIAS=/usr/sbin/mkalias
MKNETID=/usr/sbin/mknetid
REVNETGROUP=/usr/sbin/revnetgroup
TOUCH=/usr/bin/touch
DOMAIN="`/usr/bin/basename ${.CURDIR}`"
YPPUSH=/usr/sbin/yppush
# Password maps in standard YP is unsecure. This is due to the fact that
# passwords are accessable for anyone. FreeBSD and now OpenBSD has a common
# solution to this, maps can be secure (makedbm -s). If a map is secure only
# a privileged user can access it.
# For secure maps, leave UNSECURE blank.
MAKEDBM-S=$(MAKEDBM) -s
UNSECURE="True"
# If you want ypserv to ask DNS for unknown hosts set USEDNS to -b
USEDNS=
all: passwd group hosts ethers networks rpc services protocols netid netgroup amd.home aliases
passwd.time: $(DIR)/master.passwd
-@if [ -f $(>) ]; then \
if [ ! $(UNSECURE) ]; then \
$(CAT) $(>) | $(CUT) -d: -f1-4,8-10 | \
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$1, $$1":*:"$$3":"$$4":"$$5":"$$6":"$$7 }' -|\
$(MAKEDBM) - passwd.byname; \
$(CAT) $(>) | $(CUT) -d: -f1-4,8-10 |\
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$3, $$1":*:"$$3":"$$4":"$$5":"$$6":"$$7 }' -|\
$(MAKEDBM) - passwd.byuid; \
else \
$(CAT) $(>) | $(CUT) -d: -f1-4,8-10 | \
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$1, $$0 }' - | $(MAKEDBM) - passwd.byname; \
$(CAT) $(>) | $(CUT) -d: -f1-4,8-10 |\
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$3, $$0 }' - | $(MAKEDBM) - passwd.byuid; \
fi; \
$(CAT) $(>) | \
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$1, $$0 }' - | $(MAKEDBM-S) - master.passwd.byname; \
$(CAT) $(>) | \
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$3, $$0 }' - | $(MAKEDBM-S) - master.passwd.byuid; \
$(TOUCH) $(@); \
$(ECHO) "updated passwd"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) passwd.byname; \
$(YPPUSH) -d $(DOMAIN) passwd.byuid; \
$(YPPUSH) -d $(DOMAIN) master.passwd.byname; \
$(YPPUSH) -d $(DOMAIN) master.passwd.byuid; \
$(ECHO) "pushed passwd"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
group.time: $(DIR)/group
-@if [ -f $(>) ]; then \
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$1, $$0 }' $(>) | \
$(MAKEDBM) - group.byname; \
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$3, $$0 }' $(>) | \
$(MAKEDBM) - group.bygid; \
$(TOUCH) $(@); \
$(ECHO) "updated group"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) group.byname; \
$(YPPUSH) -d $(DOMAIN) group.bygid; \
$(ECHO) "pushed group"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
hosts.time: $(DIR)/hosts
-@if [ -f $(DIR)/hosts ]; then \
$(STDHOSTS) $(>) | $(SED) -e s/#.*$$// | \
$(AWK) '{for (i = 2; i <= NF; i++) print $$i, $$0 }' | \
$(MAKEDBM) $(USEDNS) - hosts.byname; \
$(STDHOSTS) $(>) | \
$(AWK) 'BEGIN { OFS="\t"; } { print $$1, $$0 }' | \
$(MAKEDBM) $(USEDNS) - hosts.byaddr; \
$(TOUCH) $(@); \
$(ECHO) "updated hosts"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) hosts.byname; \
$(YPPUSH) -d $(DOMAIN) hosts.byaddr; \
$(ECHO) "pushed hosts"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
ethers.time: $(DIR)/ethers
-@if [ -f $(DIR)/ethers ]; then \
$(STDETHERS) $(>) | $(SED) -e s/#.*$$// | \
$(AWK) 'BEGIN { FS="\t"; OFS="\t"; } { print $$1, $$0 }' | \
$(MAKEDBM) - ethers.byaddr; \
$(STDETHERS) $(>) | \
$(AWK) 'BEGIN { FS="\t"; OFS="\t"; } { print $$2, $$0 }' | \
$(MAKEDBM) - ethers.byname; \
$(TOUCH) $(@); \
$(ECHO) "updated ethers"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) ethers.byaddr; \
$(YPPUSH) -d $(DOMAIN) ethers.byname; \
$(ECHO) "pushed ethers"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
networks.time: $(DIR)/networks
-@if [ -f $(>) ]; then \
$(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
$(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
$(MAKEDBM) - networks.byname; \
$(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
$(MAKEDBM) - networks.byaddr; \
$(TOUCH) $(@); \
$(ECHO) "updated networks"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) networks.byname; \
$(YPPUSH) -d $(DOMAIN) networks.byaddr; \
$(ECHO) "pushed networks"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
rpc.time: $(DIR)/rpc
-@if [ -f $(>) ]; then \
$(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
$(MAKEDBM) - rpc.bynumber; \
$(TOUCH) $(@); \
$(ECHO) "updated rpc"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) rpc.bynumber; \
$(ECHO) "pushed rpc"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
services.time: $(DIR)/services
-@if [ -f $(>) ]; then \
$(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
$(MAKEDBM) - services.byname; \
$(TOUCH) $(@); \
$(ECHO) "updated services"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) services.byname; \
$(ECHO) "pushed services"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
protocols.time: $(DIR)/protocols
-@if [ -f $(>) ]; then \
$(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
$(MAKEDBM) - protocols.bynumber; \
$(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
$(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
$(MAKEDBM) - protocols.byname; \
$(TOUCH) $(@); \
$(ECHO) "updated protocols"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) protocols.bynumber; \
$(YPPUSH) -d $(DOMAIN) protocols.byname; \
$(ECHO) "pushed protocols"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
netid.time: $(DIR)/passwd $(DIR)/group $(DIR)/hosts $(DIR)/netid
-@$(MKNETID) -q -d $(DOMAIN) -p $(DIR)/passwd -g $(DIR)/group -h $(DIR)/hosts -m $(DIR)/netid | \
$(MAKEDBM) - netid.byname; \
$(TOUCH) $(@); \
$(ECHO) "updated netid"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) netid.byname; \
$(ECHO) "pushed netid"; \
else \
: ; \
fi
netgroup.time: $(DIR)/netgroup
-@if [ -f $(>) ]; then \
$(CAT) $(>) | $(MAKEDBM) - netgroup; \
$(CAT) $(>) | $(REVNETGROUP) -u -f - | \
$(MAKEDBM) - netgroup.byuser; \
$(CAT) $(>) | $(REVNETGROUP) -h -f - | \
$(MAKEDBM) - netgroup.byhost; \
$(TOUCH) $(@); \
$(ECHO) "updated netgroup"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) netgroup; \
$(YPPUSH) -d $(DOMAIN) netgroup.byuser; \
$(YPPUSH) -d $(DOMAIN) netgroup.byhost; \
$(ECHO) "pushed netgroup"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
amd.home.time: $(AMDDIR)/amd.home
-@if [ -f $(>) ]; then \
$(SED) -e "s/#.*$$//" -e "/^$$/d" $(>) | \
$(AWK) '{ \
for (i = 1; i <= NF; i++) \
if (i == NF) { \
if (substr($$i, length($$i), 1) == "\\") { \
printf("%s", substr($$i, 1, length($$i) - 1)); \
} \
else \
printf("%s\n", $$i); \
} \
else \
printf("%s ", $$i); \
}' | \
$(MAKEDBM) - amd.home; \
$(TOUCH) $(@); \
$(ECHO) "updated amd.home"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) amd.home; \
$(ECHO) "pushed amd.home"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
aliases.time: $(DIR)/mail/aliases
-@if [ -f $(>) ]; then \
$(CP) -p $(>) $(DOMAIN)-aliases; \
$(SENDMAIL) -bi -oA$(PWD)/$(DOMAIN)-aliases; \
$(MAKEDBM) -U $(DOMAIN)-aliases | $(MAKEDBM) - mail.aliases; \
$(MKALIAS) mail.aliases mail.byaddr; \
$(TOUCH) $(@); \
$(RM) $(DOMAIN)-aliases.db $(DOMAIN)-aliases; \
$(ECHO) "updated aliases"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) mail.aliases; \
$(YPPUSH) -d $(DOMAIN) mail.byaddr; \
$(ECHO) "pushed aliases"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
passwd: passwd.time
group: group.time
hosts: hosts.time
ethers: ethers.time
networks: networks.time
rpc: rpc.time
services: services.time
protocols: protocols.time
netid: netid.time
netgroup: netgroup.time
amd.home: amd.home.time
aliases: aliases.time
$(DIR)/passwd:
$(DIR)/group:
$(DIR)/hosts:
$(DIR)/ethers:
$(DIR)/networks:
$(DIR)/rpc:
$(DIR)/services:
$(DIR)/protocols:
$(DIR)/netid:
$(DIR)/master.passwd:
$(DIR)/netgroup:
$(DIR)/mail/aliases:
$(AMDDIR)/amd.home:
|