mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 19:34:43 +01:00
Compare commits
778
Commits
stable/9
...
releng/5.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8723db212b | ||
|
|
eae9de64eb | ||
|
|
3ad2363949 | ||
|
|
5bd46f35d7 | ||
|
|
518f8407ec | ||
|
|
86fcd2acb8 | ||
|
|
6c2f24c880 | ||
|
|
9d247711af | ||
|
|
69e48a4731 | ||
|
|
2c82120cef | ||
|
|
7393d7b5b5 | ||
|
|
1cdc31cf59 | ||
|
|
79315b47bd | ||
|
|
a0b6de1c4f | ||
|
|
6a0d191c9c | ||
|
|
7f30c17915 | ||
|
|
8ad39d2c89 | ||
|
|
bd990f4896 | ||
|
|
fb3ea47225 | ||
|
|
d87c3541fe | ||
|
|
681614024c | ||
|
|
e12769c3cf | ||
|
|
0661094c6f | ||
|
|
8ce93286c3 | ||
|
|
9be1408548 | ||
|
|
87c0973d9e | ||
|
|
e0b23d9f85 | ||
|
|
d90b28be41 | ||
|
|
0752f9e3ef | ||
|
|
cfba578f82 | ||
|
|
1eb4f66564 | ||
|
|
3ba520e893 | ||
|
|
59ca7ea8d6 | ||
|
|
b4bd4006ca | ||
|
|
a750b6376a | ||
|
|
79cea67456 | ||
|
|
20e46ec32e | ||
|
|
f8d4987d72 | ||
|
|
b9cef19b93 | ||
|
|
fff5c2eb7b | ||
|
|
891921eee7 | ||
|
|
3d85fb0d3f | ||
|
|
80083f9e6f | ||
|
|
aea51f27c2 | ||
|
|
e84dac32d3 | ||
|
|
a554298d88 | ||
|
|
fa859363fe | ||
|
|
63f872fa99 | ||
|
|
69769f91f1 | ||
|
|
82d4c1675e | ||
|
|
ca8592a606 | ||
|
|
a936ce1f0e | ||
|
|
ab74188ed6 | ||
|
|
a90991d829 | ||
|
|
2d32bfc09e | ||
|
|
8ef493b6bc | ||
|
|
2cadbb916e | ||
|
|
2b44df41d5 | ||
|
|
a424f330df | ||
|
|
215cd1e94a | ||
|
|
ae78dbb3d2 | ||
|
|
c19ac7f749 | ||
|
|
1197436f1f | ||
|
|
f1d4b4220a | ||
|
|
8e935883b3 | ||
|
|
09df75ee8e | ||
|
|
49fdbbfb0e | ||
|
|
aeb3936fe4 | ||
|
|
8141e3844b | ||
|
|
ef622a479c | ||
|
|
71b9c515ce | ||
|
|
1666d9d51f | ||
|
|
5ffeeec163 | ||
|
|
fb031efd86 | ||
|
|
2ee36fda29 | ||
|
|
15e3d4c64e | ||
|
|
8730a0b39f | ||
|
|
b2c1163ace | ||
|
|
3be9b7094a | ||
|
|
25a37d4a42 | ||
|
|
c514221a8d | ||
|
|
09369e8c22 | ||
|
|
db3d677568 | ||
|
|
0e07fcb33b | ||
|
|
8972517206 | ||
|
|
5ec0ccb230 | ||
|
|
819c44ef93 | ||
|
|
e59706e664 | ||
|
|
81dbbd4a0c | ||
|
|
3b23b9351e | ||
|
|
492ec059cf | ||
|
|
bd00f0f74e | ||
|
|
9803afcf5c | ||
|
|
56a8ff8f67 | ||
|
|
fc5d102fb2 | ||
|
|
19fd54b49e | ||
|
|
2fed94e845 | ||
|
|
0013210c70 | ||
|
|
e9461d4fe1 | ||
|
|
16bbcfcff1 | ||
|
|
221edcfcad | ||
|
|
689a28d661 | ||
|
|
47a63880ae | ||
|
|
bbdf1d5a08 | ||
|
|
5c5cd6c8e7 | ||
|
|
9f37b70b3f | ||
|
|
20553be303 | ||
|
|
19a139fcd0 | ||
|
|
7d8d75eaf7 | ||
|
|
263f139a1f | ||
|
|
98609fcf7f | ||
|
|
e06b1220a2 | ||
|
|
fce542146e | ||
|
|
42b4c9a38a | ||
|
|
185be6a972 | ||
|
|
055c411970 | ||
|
|
79ccfda5c9 | ||
|
|
29a3a29747 | ||
|
|
e4f50cc9a8 | ||
|
|
05479a2356 | ||
|
|
32fff7bf29 | ||
|
|
dd87d9ed57 | ||
|
|
9462332e2e | ||
|
|
8f2c005f6c | ||
|
|
c90829029e | ||
|
|
38c321d26d | ||
|
|
aa951cbffb | ||
|
|
7baefd1c1d | ||
|
|
ff9b961e77 | ||
|
|
638b61200f | ||
|
|
b0a2e65f0c | ||
|
|
e9aabbae95 | ||
|
|
752ec5cffa | ||
|
|
cd21f49289 | ||
|
|
0cd9c85b15 | ||
|
|
6a16abfad2 | ||
|
|
5e3b4d5e06 | ||
|
|
36b768ef90 | ||
|
|
9dc161731f | ||
|
|
bdaf0e69b1 | ||
|
|
b9323a6215 | ||
|
|
3cb254ea13 | ||
|
|
2c3c9533c8 | ||
|
|
95b65b8064 | ||
|
|
e86ddd2dee | ||
|
|
83c262f9e5 | ||
|
|
8aee1e03d2 | ||
|
|
f6ebdf929c | ||
|
|
8f10d45525 | ||
|
|
71b4941454 | ||
|
|
7f7385c91c | ||
|
|
ce5cbe3110 | ||
|
|
c72cf713dc | ||
|
|
df9cff8adf | ||
|
|
1f9bc317de | ||
|
|
aebb1d386e | ||
|
|
64eaf74c00 | ||
|
|
f280b9cff1 | ||
|
|
81db75342c | ||
|
|
38629e467a | ||
|
|
202a0686f4 | ||
|
|
8458030113 | ||
|
|
537561cd79 | ||
|
|
e7e4a1c2e4 | ||
|
|
e4d22827fe | ||
|
|
a56aeb1e8c | ||
|
|
aec9a222f0 | ||
|
|
c559df2d8b | ||
|
|
267b92e122 | ||
|
|
4633ee43ac | ||
|
|
65279a2aa9 | ||
|
|
5479451b43 | ||
|
|
38345c1381 | ||
|
|
d172341696 | ||
|
|
1dbd1d711a | ||
|
|
8da0d088ff | ||
|
|
bf6fa6f9e7 | ||
|
|
5d1e011ac8 | ||
|
|
d64cde7e8c | ||
|
|
9d0490b436 | ||
|
|
e2fff36150 | ||
|
|
1c35693966 | ||
|
|
902f60828b | ||
|
|
199531033f | ||
|
|
89a256681a | ||
|
|
4e8e4b2f0c | ||
|
|
23db2fa1df | ||
|
|
8bc61b56c6 | ||
|
|
101596b827 | ||
|
|
ec63867897 | ||
|
|
8cf0e32cc8 | ||
|
|
91ffc81a50 | ||
|
|
e55314ae08 | ||
|
|
27e841da15 | ||
|
|
42a57be305 | ||
|
|
e6cea8cec4 | ||
|
|
b95b5a2615 | ||
|
|
bafd6c1297 | ||
|
|
407a8b0126 | ||
|
|
b36b34021c | ||
|
|
61914022cf | ||
|
|
8bf9eef549 | ||
|
|
d50283a682 | ||
|
|
935dc23b53 | ||
|
|
43dd15c596 | ||
|
|
8c6692c2d8 | ||
|
|
3b64e3a9ce | ||
|
|
3a747a825e | ||
|
|
975988841c | ||
|
|
e0b3822434 | ||
|
|
6c9c9885d4 | ||
|
|
4bc0bb0d9c | ||
|
|
f3b79d12bc | ||
|
|
35bb263cd0 | ||
|
|
e5e8534624 | ||
|
|
07230173a0 | ||
|
|
1177d8025a | ||
|
|
22df69f32e | ||
|
|
fd683be6a0 | ||
|
|
ed1644befb | ||
|
|
cde8dc440b | ||
|
|
65945eee6f | ||
|
|
7b90437e8f | ||
|
|
67983d4fa3 | ||
|
|
5d7337f641 | ||
|
|
f6e359d651 | ||
|
|
dcfd75385d | ||
|
|
45f7a05629 | ||
|
|
fce950a8b5 | ||
|
|
fb51f417b5 | ||
|
|
52258cdf39 | ||
|
|
4ab6959667 | ||
|
|
3afbd543d1 | ||
|
|
4c0c736c6f | ||
|
|
eb46786666 | ||
|
|
7e4406e1bc | ||
|
|
18daca5ed7 | ||
|
|
e28dbfbc37 | ||
|
|
f4d2cf692b | ||
|
|
62cba610e1 | ||
|
|
831d4a7340 | ||
|
|
9a7ef35e6b | ||
|
|
3c1ac75bcb | ||
|
|
4b8fdd5f35 | ||
|
|
18e4890963 | ||
|
|
767028da93 | ||
|
|
59a296cfd3 | ||
|
|
c8f8fba370 | ||
|
|
b7a3cc40a0 | ||
|
|
94d10b137d | ||
|
|
d00a8dfe6d | ||
|
|
29e240ed5e | ||
|
|
eadfc8bd2f | ||
|
|
089c498f6c | ||
|
|
dad92355de | ||
|
|
16cc82ae62 | ||
|
|
f0c7816e23 | ||
|
|
5a538c424e | ||
|
|
40f4a63f15 | ||
|
|
eddb6c4dfe | ||
|
|
f53011f81c | ||
|
|
0d0f7ad215 | ||
|
|
dc4bdce238 | ||
|
|
7bf4601022 | ||
|
|
0aed82619b | ||
|
|
982dd1f437 | ||
|
|
58f4ac2371 | ||
|
|
bd458ee118 | ||
|
|
ae105f029c | ||
|
|
7d5d9d24e2 | ||
|
|
11b1149885 | ||
|
|
5aa47f29a4 | ||
|
|
075812e1be | ||
|
|
d03c7f1236 | ||
|
|
1c9205d5b1 | ||
|
|
2980b924b0 | ||
|
|
87cbbb528b | ||
|
|
864638b2cf | ||
|
|
7ca614564a | ||
|
|
45c00a9c9b | ||
|
|
6c4df367e9 | ||
|
|
3e2b1e8029 | ||
|
|
16a37a0c80 | ||
|
|
43b9d77d53 | ||
|
|
afbc624eb4 | ||
|
|
81201e86ad | ||
|
|
6ed001f09d | ||
|
|
3ee69ec107 | ||
|
|
64ed36026a | ||
|
|
ee9c05f424 | ||
|
|
0cecbc6d45 | ||
|
|
b2d4521e84 | ||
|
|
afbcd7ff3c | ||
|
|
5a3eb174dc | ||
|
|
4ecfa4c49b | ||
|
|
9614790463 | ||
|
|
e32cddc5e0 | ||
|
|
583d94860f | ||
|
|
fda7ada791 | ||
|
|
0b6599ed28 | ||
|
|
9fcb683ee2 | ||
|
|
cf78e84cf2 | ||
|
|
9d8ad05697 | ||
|
|
d409cd1ce4 | ||
|
|
ba3c188c63 | ||
|
|
ad45983508 | ||
|
|
a26d6cf4da | ||
|
|
7dfe289ead | ||
|
|
bd5f3ec4b9 | ||
|
|
8cdda268f6 | ||
|
|
a5be299352 | ||
|
|
8eae629e32 | ||
|
|
5a4d5a1efd | ||
|
|
66ca21b807 | ||
|
|
bb0588b613 | ||
|
|
9a7db3558d | ||
|
|
e6f37f7d0c | ||
|
|
ff53e7433f | ||
|
|
a2685fbbb8 | ||
|
|
180903d464 | ||
|
|
a47070a438 | ||
|
|
0a220c3523 | ||
|
|
ab4bbc5742 | ||
|
|
2966b552b3 | ||
|
|
bb99f8d5c3 | ||
|
|
307fb30b32 | ||
|
|
02a6768365 | ||
|
|
091f761e09 | ||
|
|
2df97dc1ef | ||
|
|
906924251e | ||
|
|
88c2867de0 | ||
|
|
081fbeda64 | ||
|
|
d7023b21b4 | ||
|
|
570beb56a9 | ||
|
|
ac87519da9 | ||
|
|
5555d4ff84 | ||
|
|
ae8e67f5a9 | ||
|
|
e0b30b76dc | ||
|
|
2f1adf5f66 | ||
|
|
a45c9b3aa4 | ||
|
|
b920345dd3 | ||
|
|
b31d7d7b9d | ||
|
|
cc11402a79 | ||
|
|
6407b85f54 | ||
|
|
68ae0f75ae | ||
|
|
59667fbaec | ||
|
|
433166bbb7 | ||
|
|
e2f1d06379 | ||
|
|
014bcdcd02 | ||
|
|
792ce47108 | ||
|
|
5cc0bb100b | ||
|
|
094b7dea2e | ||
|
|
fdc7477127 | ||
|
|
48b449941a | ||
|
|
0416dc070c | ||
|
|
518f8f2412 | ||
|
|
ae2577258c | ||
|
|
cf0c52297b | ||
|
|
9804b9acaf | ||
|
|
c77ffd3815 | ||
|
|
59ffe07149 | ||
|
|
08499ac1bd | ||
|
|
a1aad6f869 | ||
|
|
cd6225a233 | ||
|
|
bc5c63e4d4 | ||
|
|
21d600c925 | ||
|
|
6614e43718 | ||
|
|
2684ee6037 | ||
|
|
f7320def1a | ||
|
|
a74ff8b7aa | ||
|
|
c03c61d1fe | ||
|
|
1190cc3302 | ||
|
|
0005e2b297 | ||
|
|
ae0a866cea | ||
|
|
f38019d8e1 | ||
|
|
c6bcdd00f4 | ||
|
|
dae045f54a | ||
|
|
e287dce8fa | ||
|
|
ba744977cd | ||
|
|
45491ecc39 | ||
|
|
8b080d54dd | ||
|
|
9272e696ca | ||
|
|
c098407bf3 | ||
|
|
6fcc17644d | ||
|
|
9c55cc61b3 | ||
|
|
700a0c3e62 | ||
|
|
d5f9ccf669 | ||
|
|
557d539d81 | ||
|
|
ed2d6c2907 | ||
|
|
39a7ee8a8f | ||
|
|
6f75bb7b79 | ||
|
|
df30dc6d13 | ||
|
|
98a7fa0d18 | ||
|
|
d5ceef605b | ||
|
|
5d78bd5889 | ||
|
|
31c480f8c5 | ||
|
|
3673e1850d | ||
|
|
ef07017573 | ||
|
|
ddfca1f496 | ||
|
|
4f616cc117 | ||
|
|
9bd3617a3b | ||
|
|
84dfbb4d3a | ||
|
|
3a4a30ca26 | ||
|
|
891000d3ed | ||
|
|
ef863641fd | ||
|
|
05f508e403 | ||
|
|
e685a2b8de | ||
|
|
e4caf644a8 | ||
|
|
ec00f1ce85 | ||
|
|
fe2366221b | ||
|
|
6861e85ed1 | ||
|
|
4c2400db0c | ||
|
|
eb15d69f4e | ||
|
|
605f292ed9 | ||
|
|
c29d01eeb3 | ||
|
|
088248bfcb | ||
|
|
c5bdd4707c | ||
|
|
4765a4b42a | ||
|
|
8257b2d6bd | ||
|
|
470a3bd12b | ||
|
|
5c7e31ecd0 | ||
|
|
eb8cf9e06f | ||
|
|
9fa2abb294 | ||
|
|
9d9ed367f3 | ||
|
|
f491148e57 | ||
|
|
9b0a98356b | ||
|
|
db0995da74 | ||
|
|
788dc74519 | ||
|
|
7b86e0ed24 | ||
|
|
002e4c4141 | ||
|
|
ff1a1f03a2 | ||
|
|
95295864fd | ||
|
|
9f4f8af6e3 | ||
|
|
64ccf2d9b2 | ||
|
|
dadcccfcb1 | ||
|
|
86bd0bf390 | ||
|
|
d9bc81284e | ||
|
|
7d1d8c5cb8 | ||
|
|
3a1523a3cc | ||
|
|
cde96b5955 | ||
|
|
10f3b14993 | ||
|
|
4c4c887c5f | ||
|
|
a95b55520c | ||
|
|
a03863ace2 | ||
|
|
63a988ddd7 | ||
|
|
499da048df | ||
|
|
30211e0e22 | ||
|
|
cc209855ae | ||
|
|
e54a448ebf | ||
|
|
e87d45ff1e | ||
|
|
7adcca8152 | ||
|
|
44c386b4d6 | ||
|
|
5ac5ca6a0e | ||
|
|
0309e87755 | ||
|
|
eb74eca7cd | ||
|
|
4d99136918 | ||
|
|
46be224b52 | ||
|
|
9c9e80578a | ||
|
|
75ff176185 | ||
|
|
b71457fff5 | ||
|
|
b614ccc836 | ||
|
|
4f51bf59c2 | ||
|
|
1e51a43e80 | ||
|
|
a5f762227c | ||
|
|
4bb5e8f0f7 | ||
|
|
fdc5041768 | ||
|
|
2739847920 | ||
|
|
4dcc4bdcc3 | ||
|
|
5d52260d42 | ||
|
|
d30d78c5bc | ||
|
|
41c53ad350 | ||
|
|
826733a10b | ||
|
|
97a66196ca | ||
|
|
8acd78faaf | ||
|
|
a6038a202c | ||
|
|
086d41ae98 | ||
|
|
ed191906f2 | ||
|
|
e7310c68db | ||
|
|
6f68b7a73f | ||
|
|
8a4fdb58b2 | ||
|
|
4e3f8d7d39 | ||
|
|
041694b017 | ||
|
|
8957bf0f48 | ||
|
|
4776820aad | ||
|
|
af5afe2fad | ||
|
|
4ca8103d1b | ||
|
|
5f0e790ab2 | ||
|
|
01e25adc2e | ||
|
|
766fd5aa5d | ||
|
|
211e6e1706 | ||
|
|
b4d5f155fb | ||
|
|
c263fb4249 | ||
|
|
d3efcab04e | ||
|
|
38d5bbcf51 | ||
|
|
69ba7f5969 | ||
|
|
9a18838a2b | ||
|
|
61baafe02c | ||
|
|
3e1e27e576 | ||
|
|
152806cc30 | ||
|
|
735ae3ffee | ||
|
|
e566188a20 | ||
|
|
41ea0fb9ee | ||
|
|
231bcb4dc9 | ||
|
|
bd2d744509 | ||
|
|
b15a933694 | ||
|
|
6049dd52f4 | ||
|
|
acf211c2c8 | ||
|
|
f9d23bab62 | ||
|
|
c8e6cd3c03 | ||
|
|
345c71eefb | ||
|
|
c09dea4baa | ||
|
|
631a78a6b9 | ||
|
|
aa8d040b6a | ||
|
|
bc53cd71f6 | ||
|
|
1bf70e5e30 | ||
|
|
292f4f3c4a | ||
|
|
ab9b1e86a3 | ||
|
|
22d3d6d45b | ||
|
|
be5742d42c | ||
|
|
44d74aa93c | ||
|
|
232d436df4 | ||
|
|
3ec1c97ea9 | ||
|
|
6dd135995d | ||
|
|
18fe52f978 | ||
|
|
4cfbf8b65f | ||
|
|
a4a90ebd9d | ||
|
|
f42281b08e | ||
|
|
479045bba7 | ||
|
|
0fb4284cf4 | ||
|
|
95bacb62ac | ||
|
|
98b193d337 | ||
|
|
3ba69f0503 | ||
|
|
6b3505f430 | ||
|
|
caf16af507 | ||
|
|
5ce26d28c9 | ||
|
|
44c39b2035 | ||
|
|
6817c14401 | ||
|
|
ff92be2bfc | ||
|
|
df09f37367 | ||
|
|
46d669b180 | ||
|
|
2905d562ef | ||
|
|
b620ee0a5b | ||
|
|
34f8a51ad0 | ||
|
|
3e0b157d74 | ||
|
|
fef2e1cab2 | ||
|
|
633a11001d | ||
|
|
72fc3a09fa | ||
|
|
a18b42013c | ||
|
|
414966098b | ||
|
|
9e70475186 | ||
|
|
cbe6275995 | ||
|
|
0cdc5f02b1 | ||
|
|
f97eaf9988 | ||
|
|
c4f959448c | ||
|
|
ee72ccd524 | ||
|
|
26d96cec4a | ||
|
|
7e514ae93d | ||
|
|
75d6e45ca3 | ||
|
|
293edd811d | ||
|
|
f200fb18f8 | ||
|
|
e80df11f01 | ||
|
|
39a323d20e | ||
|
|
8c4db076ba | ||
|
|
e505962ca3 | ||
|
|
2fb71ebed1 | ||
|
|
4209fafb30 | ||
|
|
09e74c5391 | ||
|
|
cc1307ecae | ||
|
|
6036b5df8d | ||
|
|
c6d58104ab | ||
|
|
bde114cec5 | ||
|
|
e35509ebd2 | ||
|
|
4f46c95bdd | ||
|
|
1607cb9b00 | ||
|
|
091f6197ed | ||
|
|
6394edbe97 | ||
|
|
7b2ee40615 | ||
|
|
ff417efc44 | ||
|
|
79e75bb1aa | ||
|
|
8edc6a6bf0 | ||
|
|
3e47c1221a | ||
|
|
6cecded8c3 | ||
|
|
3889a464df | ||
|
|
91c32bf803 | ||
|
|
b6579cbd62 | ||
|
|
17d4a0f84d | ||
|
|
b6f818b6d1 | ||
|
|
4b6a0516dc | ||
|
|
6006529f5f | ||
|
|
b19be55c83 | ||
|
|
a091bc3d86 | ||
|
|
c5a96d10b8 | ||
|
|
c7c2c2c99f | ||
|
|
8485cf1abd | ||
|
|
5f413aa136 | ||
|
|
2a70c9aa08 | ||
|
|
b797728961 | ||
|
|
c8572d7518 | ||
|
|
88dcd5eb01 | ||
|
|
807af07c3b | ||
|
|
d9f18728d4 | ||
|
|
3b5693d1cc | ||
|
|
08bd148c0e | ||
|
|
ab3462326f | ||
|
|
7c7515754d | ||
|
|
53ec2be364 | ||
|
|
56c038053c | ||
|
|
bfba777dba | ||
|
|
6d8298727f | ||
|
|
242bb9f6dc | ||
|
|
649e5e0536 | ||
|
|
f132146a87 | ||
|
|
683a7ba55d | ||
|
|
1f15a28a91 | ||
|
|
3aabf91be8 | ||
|
|
e2d62cc52e | ||
|
|
bffabda316 | ||
|
|
db0a650c5a | ||
|
|
b9d08cf8b5 | ||
|
|
bd04aba61f | ||
|
|
e2689070ce | ||
|
|
1ee968c296 | ||
|
|
8ae7881d15 | ||
|
|
6a3e188652 | ||
|
|
8afb903bde | ||
|
|
1c3d4ccd17 | ||
|
|
3f77e4d948 | ||
|
|
2373981121 | ||
|
|
8f204636b9 | ||
|
|
bbee142b17 | ||
|
|
226a384ac3 | ||
|
|
0ffe4a33d8 | ||
|
|
f15b0466fa | ||
|
|
05ba583756 | ||
|
|
c4a4217ea1 | ||
|
|
0bb5c1d3fb | ||
|
|
e2867b05ae | ||
|
|
9c077ee25d | ||
|
|
a96ee3d394 | ||
|
|
951d35d8bb | ||
|
|
692bfb5b28 | ||
|
|
07261a9cf0 | ||
|
|
9ad35d0cf5 | ||
|
|
10f1868849 | ||
|
|
518a9fdb22 | ||
|
|
995c28950b | ||
|
|
2542e8ec5a | ||
|
|
e3d998abca | ||
|
|
f8ca9a36b7 | ||
|
|
09b4ca36cb | ||
|
|
18206eb7c1 | ||
|
|
0cd77e3704 | ||
|
|
b44abde8b0 | ||
|
|
3f59b86286 | ||
|
|
18a7add041 | ||
|
|
6acac06358 | ||
|
|
dd894fd77c | ||
|
|
50c5fbddf2 | ||
|
|
5dcb7e5fa5 | ||
|
|
c1ad05d25f | ||
|
|
15c54a5c94 | ||
|
|
994dea634c | ||
|
|
47d4a517de | ||
|
|
98e9f47def | ||
|
|
5a238fce1c | ||
|
|
263b16ce45 | ||
|
|
756b5e9447 | ||
|
|
40a8901f07 | ||
|
|
a1827b1cd5 | ||
|
|
937a276639 | ||
|
|
5c1ab3ca52 | ||
|
|
fd57ea57e3 | ||
|
|
a1ba67e437 | ||
|
|
96c0da5e7f | ||
|
|
0fbc30b1be | ||
|
|
0664539edf | ||
|
|
2f77e00d8b | ||
|
|
3ec024f402 | ||
|
|
aa0d3a68cc | ||
|
|
173d5d7457 | ||
|
|
a4f5df9443 | ||
|
|
82219f6dbb | ||
|
|
ebd3ecd4ba | ||
|
|
8f57ee5f80 | ||
|
|
58f73d5a80 | ||
|
|
1c3f901675 | ||
|
|
438b1408f1 | ||
|
|
44651eda08 | ||
|
|
f06e159db1 | ||
|
|
06d368af39 | ||
|
|
0cb8fd6b22 | ||
|
|
051efa7a1b | ||
|
|
65cdc248f8 | ||
|
|
1f00bb32bc | ||
|
|
d9d851b84d | ||
|
|
93495516da | ||
|
|
e2ab11b1af | ||
|
|
7f6cdd5d49 | ||
|
|
0fdacc2ca0 | ||
|
|
013564995c | ||
|
|
5e3f006a10 | ||
|
|
37c923c53c | ||
|
|
d38bc58c5a | ||
|
|
a60267028d | ||
|
|
6355e714bc | ||
|
|
297c82c367 | ||
|
|
8401c4c7a2 | ||
|
|
fb0f2d1d89 | ||
|
|
772718e237 | ||
|
|
bdba4ec4db | ||
|
|
83ad145904 | ||
|
|
3b566faf6a | ||
|
|
84720dbdcc | ||
|
|
8e2a6e7ee6 | ||
|
|
3d3f509a49 | ||
|
|
e3cc39760c | ||
|
|
b9ce284c1b | ||
|
|
b9842735ab | ||
|
|
f6ecb8c7ca | ||
|
|
ca0f222e6c | ||
|
|
8478e1329a | ||
|
|
57a0f89fec | ||
|
|
56e1d5b0f4 | ||
|
|
4b94139fe7 | ||
|
|
0adea32d6e | ||
|
|
bddc00305f | ||
|
|
c98b14ff25 | ||
|
|
2e7e0a541c | ||
|
|
25c1cd280a | ||
|
|
77ac826188 | ||
|
|
6bfb601ea6 | ||
|
|
4260b7d878 | ||
|
|
8c287bc943 | ||
|
|
48071798f9 | ||
|
|
a0bfcdf3a5 | ||
|
|
b8fc5ee458 | ||
|
|
94e0e2ab72 | ||
|
|
2b4977857a | ||
|
|
8f4099bd65 | ||
|
|
7ae76fabdd | ||
|
|
69960b5121 | ||
|
|
24c3bfd048 | ||
|
|
66cdc59f0e | ||
|
|
32258d2705 | ||
|
|
48c6f8857d | ||
|
|
1957b76ac6 | ||
|
|
137359b142 | ||
|
|
230c15f4dc | ||
|
|
504a359052 | ||
|
|
f516b2168e | ||
|
|
edab4dc37e | ||
|
|
0434278e1e | ||
|
|
64441263db | ||
|
|
e7f3346566 | ||
|
|
9e40a6a64c | ||
|
|
7b2806c921 | ||
|
|
4e8277362c | ||
|
|
493e51b106 | ||
|
|
541e468618 | ||
|
|
7e012e7ce2 | ||
|
|
906ba70bcc | ||
|
|
449c31a012 | ||
|
|
e9321d3dbd | ||
|
|
cc8aee3c73 | ||
|
|
0972ec5e1f | ||
|
|
db1420c3fa | ||
|
|
0bc877a749 | ||
|
|
26f8d10781 | ||
|
|
cafb646a91 | ||
|
|
559a3f8117 | ||
|
|
6f218ff374 | ||
|
|
782b39c1fe | ||
|
|
a4446fcbbf | ||
|
|
9a49abc426 | ||
|
|
66ffd88f6b | ||
|
|
55de171837 | ||
|
|
33b165b331 | ||
|
|
3c9270175d |
No files matched your search
+14
-2
@@ -276,6 +276,10 @@ _worldtmp:
|
||||
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
|
||||
-p ${WORLDTMP}/usr/include >/dev/null
|
||||
ln -sf ${.CURDIR}/sys ${WORLDTMP}
|
||||
.if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
|
||||
mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
|
||||
-p ${WORLDTMP}/usr/include >/dev/null
|
||||
.endif
|
||||
_legacy:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@@ -662,7 +666,7 @@ update:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${CVS} -R -q update -A -P -d
|
||||
cd ${.CURDIR}; ${CVS} -R -q update -rRELENG_5_3 -P -d
|
||||
.endif
|
||||
|
||||
#
|
||||
@@ -788,7 +792,6 @@ build-tools:
|
||||
bin/csh \
|
||||
bin/sh \
|
||||
${_rescue} \
|
||||
gnu/usr.bin/cc/cc_tools \
|
||||
lib/libncurses \
|
||||
${_share} \
|
||||
${_aicasm} \
|
||||
@@ -801,6 +804,7 @@ build-tools:
|
||||
${MAKE} DIRPRFX=${_tool}/ build-tools
|
||||
.endfor
|
||||
.for _tool in \
|
||||
gnu/usr.bin/cc/cc_tools \
|
||||
${_kerberos5_tools}
|
||||
${_+_}@${ECHODIR} "===> ${_tool}"; \
|
||||
cd ${.CURDIR}/${_tool}; \
|
||||
@@ -906,6 +910,14 @@ _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
|
||||
|
||||
lib/libopie__L lib/libtacplus__L: lib/libmd__L
|
||||
|
||||
.if !defined(NO_BIND)
|
||||
.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
|
||||
_prebuild_libs+= lib/libc_r
|
||||
.else
|
||||
_prebuild_libs+= lib/libpthread
|
||||
.endif
|
||||
.endif
|
||||
|
||||
_generic_libs+= lib
|
||||
|
||||
.if !defined(NOCRYPT)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Updating Information for FreeBSD current users
|
||||
Updating Information for FreeBSD stable users
|
||||
|
||||
This file is maintained and copyrighted by M. Warner Losh
|
||||
<[email protected]>. See end of file for further details. For commonly
|
||||
@@ -8,18 +8,305 @@ Items affecting the ports and packages system can be found in
|
||||
/usr/ports/UPDATING. Please read that file before running
|
||||
portupgrade. Important recent entries: 20040724 (default X changes).
|
||||
|
||||
NOTE TO PEOPLE WHO THINK THAT FreeBSD 5.x IS SLOW:
|
||||
FreeBSD 5.x has many debugging features turned on, in
|
||||
both the kernel and userland. These features attempt to detect
|
||||
incorrect use of system primitives, and encourage loud failure
|
||||
through extra sanity checking and fail stop semantics. They
|
||||
also substantially impact system performance. If you want to
|
||||
do performance measurement, benchmarking, and optimization,
|
||||
you'll want to turn them off. This includes various WITNESS-
|
||||
related kernel options, INVARIANTS, malloc debugging flags
|
||||
in userland, and various verbose features in the kernel. Many
|
||||
developers choose to disable these features on build machines
|
||||
to maximize performance.
|
||||
20060930: p37 FreeBSD-SA-06:22.openssh
|
||||
Correct multiple vulnerabilities in sshd(8).
|
||||
|
||||
20060929: p36 FreeBSD-SA-06:23.openssl
|
||||
Correct problem in the 2006-09-28 patch concerning the handling of
|
||||
excessively large DH moduli.
|
||||
|
||||
20060928: p35 FreeBSD-SA-06:23.openssl
|
||||
Correct multiple vulnerabilities in crypto(3).
|
||||
Limit the size of public keys used in order to protect applications
|
||||
from a denial of service via insane key sizes.
|
||||
|
||||
20060919: p34 FreeBSD-SA-06:21.gzip
|
||||
Correct multiple vulnerabilities in gzip(1).
|
||||
|
||||
20060906: p33 FreeBSD-SA-06:19.openssl, FreeBSD-SA-06:20.bind
|
||||
Correct incorrect PKCS#1 v1.5 padding validation in
|
||||
crypto(3). [06:19]
|
||||
|
||||
Correct multiple denial-of-service vulnerabilities in BIND related to
|
||||
SIG Query Processing and Excessive Recursive Queries. [06:20]
|
||||
|
||||
20060823: p32 FreeBSD-SA-06:18.ppp
|
||||
Correct buffer overflow in the handling of LCP options in ppp(4).
|
||||
|
||||
20060614: p31 FreeBSD-SA-06:17.sendmail
|
||||
Correct a bug in the handling of multipart messages by sendmail(8)
|
||||
which can allow a malformed message to crash a sendmail queue
|
||||
processing process.
|
||||
|
||||
20060531: p30 FreeBSD-SA-06:15.ypserv, FreeBSD-SA-06:16.smbfs
|
||||
Enable inadvertantly disabled "securenet" access controls in
|
||||
ypserv. [06:15]
|
||||
|
||||
Correct a bug in the handling of backslash characters in smbfs
|
||||
which can allow an attacker to escape from a chroot(2). [06:16]
|
||||
|
||||
20060419: p29 FreeBSD-SA-06:14.fpu
|
||||
Correct a local information leakage bug affecting AMD FPUs.
|
||||
|
||||
20060322: p28 FreeBSD-SA-06:11.ipsec, FreeBSD-SA-06:12.opie,
|
||||
FreeBSD-SA-06:13.sendmail
|
||||
Add missing code needed for the detection of IPSec packet
|
||||
replays. [06:11]
|
||||
|
||||
Correctly identify the user running opiepasswd(1) when the login
|
||||
name differs from the account name. [06:12]
|
||||
|
||||
Modify timeout handling logic in sendmail(8) to correct a reported
|
||||
signal handling race condition. [06:13]
|
||||
|
||||
20060301: p27 FreeBSD-SA-06:09.openssh, FreeBSD-SA-06:10.nfs
|
||||
Correct a remote DoS in OpenSSH when using PAM and privilege
|
||||
separation. [06:09]
|
||||
|
||||
Correct a remote kernel panic when processing zero-length RPC
|
||||
records via TCP. [06:10]
|
||||
|
||||
20060201: p26 FreeBSD-SA-06:08.sack
|
||||
Avoid an infinite loop in sack scoreboard processing which can
|
||||
result from memory exhaustion.
|
||||
|
||||
20060125: p25 FreeBSD-SA-06:07.pf
|
||||
Correct an error in pf handling of IP packet fragments which
|
||||
could result in a kernel panic. [06:07]
|
||||
|
||||
20060111: p24 FreeBSD-SA-06:01.texindex, FreeBSD-SA-06:02.ee,
|
||||
FreeBSD-SA-06:03.cpio
|
||||
Correct insecure temporary file usage in texindex. [06:01]
|
||||
|
||||
Correct insecure temporary file usage in ee. [06:02]
|
||||
|
||||
Correct a race condition when setting file permissions,
|
||||
sanitize file names by default, and fix a buffer overflow
|
||||
when handling files larger than 4GB in cpio. [06:03]
|
||||
|
||||
20051011: p23 FreeBSD-SA-05:21.openssl
|
||||
Correct a man-in-the-middle SSL version rollback vulnerability.
|
||||
|
||||
20050909: p22 FreeBSD-SA-05:20.cvsbug [revised]
|
||||
Correct additional temporary file usage issues.
|
||||
|
||||
20050907: p21 FreeBSD-SA-05:20.cvsbug
|
||||
Correct insecure temporary file usage.
|
||||
|
||||
20050727: p20 FreeBSD-SA-05:18.zlib, FreeBSD-SA-05:19.ipsec
|
||||
Correct buffer overflow when handling certain deflated data
|
||||
streams.
|
||||
|
||||
Correct errors in the implementation of the AES-XCBC-MAC IPsec
|
||||
authentication algorithm.
|
||||
|
||||
20050720: p19 FreeBSD-SA-05:17.devfs
|
||||
Correct devfs ruleset bypass.
|
||||
|
||||
20050706: p18 FreeBSD-SA-05:16.zlib
|
||||
Correct buffer overflow when handling corrupt deflated data streams.
|
||||
|
||||
20050629: p17 FreeBSD-SA-05:14.bzip2, FreeBSD-SA-05:15.tcp
|
||||
Correct bzip2 denial of service and permission race vulnerabilities.
|
||||
|
||||
Correct TCP connection stall denial of service vulnerabilities.
|
||||
|
||||
20050608: p16 FreeBSD-SA-05:10.tcpdump, FreeBSD-SA-05:11.gzip,
|
||||
FreeBSD-SA-05:12.bind9
|
||||
Correct several denial-of-service vulnerabilities in tcpdump.
|
||||
|
||||
Correct directory traversal and race condition vulnerabilities in gzip.
|
||||
|
||||
Correct BIND 9 DNSSEC remote denial of service vulnerability.
|
||||
|
||||
20050513: p15 FreeBSD-SA-05:09.htt
|
||||
Add a knob for disabling/enabling HTT. Default off due to information
|
||||
disclosure on multi-user systems.
|
||||
|
||||
20050508: p14 FreeBSD-SA-05:08.kmem
|
||||
Correct two issues which were missed from the earlier commit.
|
||||
|
||||
20050506: p13 FreeBSD-SA-05:08.kmem
|
||||
Correct several local kernel memory disclosure bugs.
|
||||
|
||||
20050506: p12 FreeBSD-SA-05:07.ldt
|
||||
Correctly validate inputs to the i386_get_ldt syscall.
|
||||
|
||||
20050506: p11 FreeBSD-SA-05:06.iir
|
||||
Correct overly liberal permissions on /dev/iir.
|
||||
|
||||
20050422: p10 FreeBSD-SA-05:05.cvs
|
||||
Correct several vulnerabilities in CVS.
|
||||
|
||||
20050414: p9 FreeBSD-SA-05:04.ifconf
|
||||
Zero a buffer in ifconf() in order to avoid accidental
|
||||
disclosure of kernel memory to userland.
|
||||
|
||||
20050406: p8 FreeBSD-SA-05:03.amd64
|
||||
Correctly initialize the I/O permission bitmap on amd64.
|
||||
|
||||
20050404: p7 FreeBSD-SA-05:02.sendfile
|
||||
Correct kernel memory disclosure bug in sendfile(2).
|
||||
|
||||
20050328: p6 FreeBSD-SA-05:01.telnet
|
||||
Correct buffer overflows in telnet(1).
|
||||
|
||||
20050114: p5 FreeBSD-EN-05:03.ipi
|
||||
Avoid more than two pending IPI interrupt vectors per local
|
||||
APIC as this may cause deadlocks.
|
||||
|
||||
20050106: p4 FreeBSD-EN-05:02.sk
|
||||
Correct bugs in the sk(4) network driver that could result in
|
||||
data corruption and system crashes on SMP systems.
|
||||
|
||||
20050103: p3 FreeBSD-EN-05:01.nfs
|
||||
Correct a bug in nfsrv_create() where a call to nfsrv_access()
|
||||
might be made while holding the NFS server mutex, which resulted
|
||||
in kernel panics under certain load patterns.
|
||||
|
||||
20041201: p2 FreeBSD-SA-04:17.procfs
|
||||
Fix a tainted pointer dereference in procfs(5) and linprocfs(5)
|
||||
which could allow a local attacker to panic a system and/or read
|
||||
from kernel memory.
|
||||
|
||||
20041118: p1 FreeBSD-SA-04:16.fetch
|
||||
Correct a buffer overflow in fetch(1) which could allow a
|
||||
mallicious server to execute arbitrary code on the client.
|
||||
|
||||
20041104:
|
||||
FreeBSD 5.3-RELEASE
|
||||
|
||||
20041010:
|
||||
The FreeBSD keyword is no longer a requirement for a valid
|
||||
rc.d script. The rc(8) and rc.shutdown(8) scripts no longer check
|
||||
for the existence of this keyword when ordering rc.d scripts.
|
||||
This change touches most of the file in /etc/rc.d; therefore,
|
||||
if you have not modified any files in that directory it may
|
||||
be easier to rm -rf /etc/rc.d and then use the -i switch with
|
||||
mergemaster(8).
|
||||
|
||||
20041009:
|
||||
One of the syscalls the 1:1 threading library libthr uses has
|
||||
changed, thus breaking ABI compatibility. Make sure you rebuild
|
||||
this library with the kernel.
|
||||
|
||||
20041003:
|
||||
The pfil API has gained an additional argument to pass an inpcb.
|
||||
You should rebuild all pfil consuming modules: ipfw, ipfilter
|
||||
and pf.
|
||||
|
||||
20041001:
|
||||
The following libraries had their version number bumped up:
|
||||
/lib/libm.so.2 -> libm.so.3
|
||||
/lib/libreadline.so.4 -> libreadline.so.5
|
||||
/usr/lib/libhistory.so.4 -> libhistory.so.5
|
||||
/usr/lib/libopie.so.2 -> libopie.so.3
|
||||
/usr/lib/libpcap.so.2 -> libpcap.so.3
|
||||
FreeBSD 4.10 versions of these libraries will be added to the
|
||||
compat4x collection. If you expect to be able to run old 4.X
|
||||
executables you will need to remove the old versions of these
|
||||
libraries. However note that any 5.X executables you have built
|
||||
will stop working once you remove those old libraries. You should
|
||||
have all your ports/packages rebuilt before removing the old
|
||||
libraries.
|
||||
|
||||
20040928:
|
||||
If enabled, the default is now to run named in a chroot
|
||||
"sandbox." For users with existing configurations in
|
||||
/etc/namedb the migration should be simple. Upgrade your
|
||||
world as usual, then after installworld but before
|
||||
mergemaster do the following:
|
||||
|
||||
If named is running: /etc/rc.d/named stop
|
||||
cd /etc
|
||||
mv namedb namedb.bak
|
||||
mkdir -p /var/named/etc/namedb
|
||||
cp -Rp namedb.bak/* /var/named/etc/namedb/
|
||||
mergemaster (with your usual options)
|
||||
If using the generated localhost* files:
|
||||
cd /var/named/etc/namedb
|
||||
/bin/sh make-localhost
|
||||
rm -f localhost-v6.rev localhost.rev
|
||||
/etc/rc.d/syslogd restart
|
||||
/etc/rc.d/named start
|
||||
|
||||
If you are using a custom configuration, or if you have
|
||||
customised the named_* variables in /etc/rc.conf[.local]
|
||||
then you may have to adjust the instructions accordingly.
|
||||
It is suggested that you carefully examine the new named
|
||||
variables in /etc/defaults/rc.conf and the options in
|
||||
/var/named/etc/namedb/named.conf to see if they might
|
||||
now be more suitable.
|
||||
|
||||
20040925:
|
||||
BIND 9 has been imported into the base, and is now fully
|
||||
functional. BIND 8 has now been removed. There are numerous
|
||||
differences between BIND 8 and 9, and users with critical
|
||||
named installations should read the migration documentation
|
||||
in /usr/share/doc/bind9/misc/migration. There is also a
|
||||
new instruction manual in /usr/share/doc/bind9/arm.
|
||||
|
||||
The key differences that most users will experience are in
|
||||
how picky BIND 9 is about zone file format. If you are using
|
||||
named as a resolving (caching) name server, you will likely
|
||||
not have trouble.
|
||||
|
||||
The following files are part of the old BIND 8 installation
|
||||
and should be removed:
|
||||
/usr/bin/dnskeygen /usr/bin/dnsquery /usr/libexec/named-xfer
|
||||
/usr/sbin/named.restart /usr/sbin/ndc
|
||||
|
||||
The following files have moved to /usr/bin, and should be
|
||||
removed from their old locations:
|
||||
/usr/sbin/nslookup /usr/sbin/nsupdate
|
||||
|
||||
20040922:
|
||||
PFIL_HOOKS are a fixed part of the network stack now and do not
|
||||
need to be specified in the kernel configuration file anymore.
|
||||
Remove 'options PFIL_HOOKS' from your kernel config file.
|
||||
|
||||
20040914:
|
||||
The format of the pflogd(8) logfile "/var/log/pflog" has changed for
|
||||
architectures that have a 64 bit long type to make it compatible to
|
||||
the standard pcap format. In order to prevent corruption move away
|
||||
any old logfile before using a new pflogd(8).
|
||||
|
||||
20040913:
|
||||
debug.witness_* has been renamed to debug.witness.*. There are
|
||||
compatibility tunables left in for a few days. Update loader.conf
|
||||
as necessary.
|
||||
|
||||
20040907:
|
||||
The kernel and userland debugging options have been turned off
|
||||
by default.
|
||||
|
||||
20040902:
|
||||
The default configuration for the network stack has been changed
|
||||
such that it now runs without the Giant lock unless configured
|
||||
otherwise. If you experience network-related instability, you
|
||||
may wish to try setting "debug.mpsafenet=0" or compiling the
|
||||
kernel with "options NET_WITH_GIANT". Details on the netperf
|
||||
project may be found at:
|
||||
|
||||
http://www.watson.org/~robert/freebsd/netperf/
|
||||
|
||||
Including the 20040828 announcement of configuration change
|
||||
details.
|
||||
|
||||
20040826:
|
||||
Netgraph changed its message format slightly to align the data
|
||||
portion well on 64 bit machines.
|
||||
Netgraph using utilities (e.g. ngctl, nghook, ppp, mpd,
|
||||
pppoed, bluetooth, ATM) should be recompiled when a new kernel
|
||||
is installed.
|
||||
|
||||
20040817:
|
||||
IPFW has been converted to use PFIL_HOOKS. This change is
|
||||
transparent to userland and preserves the ipfw ABI. The ipfw
|
||||
core packet inspection and filtering functions have not been
|
||||
changed, only how ipfw is invoked is different. Note that
|
||||
"option PFIL_HOOKS" is required to use IPFIREWALL compiled
|
||||
into the kernel or as KLD.
|
||||
|
||||
20040814:
|
||||
The RANDOM_IP_ID option has been replaced by the sysctl
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
/* config.h. Generated by configure. */
|
||||
/*
|
||||
* config.h -- configure various defines for tcsh
|
||||
*
|
||||
* All source files should #include this FIRST.
|
||||
*
|
||||
* Edit this to match your system type.
|
||||
*/
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifndef _h_config
|
||||
#define _h_config
|
||||
/****************** System dependant compilation flags ****************/
|
||||
/*
|
||||
* POSIX This system supports IEEE Std 1003.1-1988 (POSIX).
|
||||
*/
|
||||
#define POSIX
|
||||
|
||||
/*
|
||||
* POSIXJOBS This system supports the optional IEEE Std 1003.1-1988 (POSIX)
|
||||
* job control facilities.
|
||||
*/
|
||||
#define POSIXJOBS
|
||||
|
||||
/*
|
||||
* POSIXSIGS Use the POSIX signal facilities to emulate BSD signals.
|
||||
*/
|
||||
/* #undef POSIXSIGS */
|
||||
|
||||
/*
|
||||
* VFORK This machine has a vfork().
|
||||
* It used to be that for job control to work, this define
|
||||
* was mandatory. This is not the case any more.
|
||||
* If you think you still need it, but you don't have vfork,
|
||||
* define this anyway and then do #define vfork fork.
|
||||
* I do this anyway on a Sun because of yellow pages brain damage,
|
||||
* [should not be needed under 4.1]
|
||||
* and on the iris4d cause SGI's fork is sufficiently "virtual"
|
||||
* that vfork isn't necessary. (Besides, SGI's vfork is weird).
|
||||
* Note that some machines eg. rs6000 have a vfork, but not
|
||||
* with the berkeley semantics, so we cannot use it there either.
|
||||
*/
|
||||
#define VFORK
|
||||
|
||||
/*
|
||||
* BSDJOBS You have BSD-style job control (both process groups and
|
||||
* a tty that deals correctly
|
||||
*/
|
||||
#define BSDJOBS
|
||||
|
||||
/*
|
||||
* BSDSIGS You have 4.2-style signals, rather than USG style.
|
||||
* Note: POSIX systems should not define this unless they
|
||||
* have sigvec() and friends (ie: 4.3BSD-RENO, HP-UX).
|
||||
*/
|
||||
#define BSDSIGS
|
||||
|
||||
/*
|
||||
* BSDTIMES You have BSD-style process time stuff (like rusage)
|
||||
* This may or may not be true. For example, Apple Unix
|
||||
* (OREO) has BSDJOBS and BSDSIGS but not BSDTIMES.
|
||||
*/
|
||||
#define BSDTIMES
|
||||
|
||||
/*
|
||||
* BSDLIMIT You have BSD-style resource limit stuff (getrlimit/setrlimit)
|
||||
*/
|
||||
#define BSDLIMIT
|
||||
|
||||
/*
|
||||
* BSDNICE Your system uses setpriority() instead of nice, to
|
||||
* change a processes scheduling priority
|
||||
*/
|
||||
#define BSDNICE
|
||||
|
||||
/*
|
||||
* TERMIO You have struct termio instead of struct sgttyb.
|
||||
* This is usually the case for SYSV systems, where
|
||||
* BSD uses sgttyb. POSIX systems should define this
|
||||
* anyway, even though they use struct termios.
|
||||
*/
|
||||
#define TERMIO
|
||||
|
||||
/*
|
||||
* SYSVREL Your machine is SYSV based (HPUX, A/UX)
|
||||
* NOTE: don't do this if you are on a Pyramid -- tcsh is
|
||||
* built in a BSD universe.
|
||||
* Set SYSVREL to 1, 2, 3, or 4, depending the version of System V
|
||||
* you are running. Or set it to 0 if you are not SYSV based
|
||||
*/
|
||||
#define SYSVREL 0
|
||||
|
||||
/*
|
||||
* YPBUGS Work around Sun YP bugs that cause expansion of ~username
|
||||
* to send command output to /dev/null
|
||||
*/
|
||||
/* #undef YPBUGS */
|
||||
|
||||
/*
|
||||
* SIGVOID Define this if your signal handlers return void. On older
|
||||
* systems, signal returns int, but on newer ones, it returns void.
|
||||
*/
|
||||
#define SIGVOID
|
||||
|
||||
/*
|
||||
* HAVEDUP2 Define this if your system supports dup2().
|
||||
*/
|
||||
#define HAVEDUP2
|
||||
|
||||
/*
|
||||
* UTHOST Does the utmp file have a host field?
|
||||
*/
|
||||
#define UTHOST
|
||||
|
||||
/*
|
||||
* DIRENT Your system has <dirent.h> instead of <sys/dir.h>
|
||||
*/
|
||||
#define DIRENT
|
||||
/****************** local defines *********************/
|
||||
/****************** configurable hacks ****************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* have been moved to config_f.h */
|
||||
#include "config_f.h"
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#define NLS_BUGS
|
||||
/* we want to use the system malloc when we install as /bin/csh */
|
||||
#define SYSMALLOC
|
||||
#define BSD_STYLE_COLORLS
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#include <sys/param.h>
|
||||
#if __NetBSD_Version__ >= 106030000 /* NetBSD 1.6C */
|
||||
#define HAVEUTMPX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__bsdi__)
|
||||
/*
|
||||
* _PATH_TCSHELL if you've change the installation location (vix)
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
# ifdef _BSDI_VERSION >= 199701
|
||||
# define _PATH_TCSHELL "/bin/tcsh"
|
||||
/* # undef SYSMALLOC */
|
||||
# define SYSMALLOC
|
||||
# else
|
||||
# define _PATH_TCSHELL "/usr/contrib/bin/tcsh"
|
||||
# endif
|
||||
|
||||
/* # undef NLS */
|
||||
/* # undef NLS_CATALOGS */
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
# define SYSMALLOC
|
||||
|
||||
#else
|
||||
# define NLS_CATALOGS
|
||||
#endif
|
||||
|
||||
#endif /* _h_config */
|
||||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
+1
-1
@@ -701,7 +701,7 @@ unsetfunc(char *name)
|
||||
delete_cmd_entry();
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -761,7 +761,7 @@ unsetvar(char *s)
|
||||
}
|
||||
}
|
||||
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= uuidgen
|
||||
WARNS?= 6
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,79 +0,0 @@
|
||||
.\" Copyright (c) 2002 Marcel Moolenaar
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\"
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 23, 2002
|
||||
.Dt UUIDGEN 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm uuidgen
|
||||
.Nd generate universally unique identifiers
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl 1
|
||||
.Op Fl n Ar count
|
||||
.Op Fl o Ar filename
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility by default generates a single universally unique identifier (UUID),
|
||||
also known as a globally unique identifier (GUID).
|
||||
The UUID is written to stdout by default.
|
||||
The following options can be used to change the behaviour of
|
||||
.Nm :
|
||||
.Bl -tag -width indent
|
||||
.It Fl 1
|
||||
This option only has effect if multiple identifiers are to be generated and
|
||||
instructs
|
||||
.Nm
|
||||
to not generate them in batch, but one at a time.
|
||||
.It Fl n
|
||||
This option controls the number of identifiers generated.
|
||||
By default, multiple
|
||||
identifiers are generated in batch.
|
||||
.It Fl o
|
||||
Redirect output to
|
||||
.Ar filename
|
||||
instead of stdout.
|
||||
.El
|
||||
.Pp
|
||||
Batched generation yields a dense set of identifiers in such a way that there
|
||||
is no identifier that is larger than the smallest identifier in the set and
|
||||
smaller than the largest identifier in the set and that is not already in the
|
||||
set.
|
||||
.Pp
|
||||
When generating the identifiers one at a time, the identifiers will be close
|
||||
to each other, but operating system latency and processing time will be
|
||||
reflected in the distance between two successive identifiers.
|
||||
.Sh DIAGNOSTICS
|
||||
.Ex -std
|
||||
.Sh SEE ALSO
|
||||
.Xr uuidgen 2 ,
|
||||
.Xr uuid 3
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
command first appeared in
|
||||
.Fx 5.0 .
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002 Marcel Moolenaar
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <uuid.h>
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr, "usage: uuidgen [-1] [-n count] [-o filename]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fp;
|
||||
uuid_t *store, *uuid;
|
||||
char *p;
|
||||
int ch, count, i, iterate;
|
||||
|
||||
count = -1; /* no count yet */
|
||||
fp = stdout; /* default output file */
|
||||
iterate = 0; /* not one at a time */
|
||||
while ((ch = getopt(argc, argv, "1n:o:")) != -1)
|
||||
switch (ch) {
|
||||
case '1':
|
||||
iterate = 1;
|
||||
break;
|
||||
case 'n':
|
||||
if (count > 0)
|
||||
usage();
|
||||
count = strtol(optarg, &p, 10);
|
||||
if (*p != 0 || count < 1)
|
||||
usage();
|
||||
break;
|
||||
case 'o':
|
||||
if (fp != stdout)
|
||||
errx(1, "multiple output files not allowed");
|
||||
fp = fopen(optarg, "w");
|
||||
if (fp == NULL)
|
||||
err(1, "fopen");
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
|
||||
if (argc)
|
||||
usage();
|
||||
|
||||
if (count == -1)
|
||||
count = 1;
|
||||
|
||||
store = (uuid_t*)malloc(sizeof(uuid_t) * count);
|
||||
if (store == NULL)
|
||||
err(1, "malloc()");
|
||||
|
||||
if (!iterate) {
|
||||
/* Get them all in a single batch */
|
||||
if (uuidgen(store, count) != 0)
|
||||
err(1, "uuidgen()");
|
||||
} else {
|
||||
uuid = store;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (uuidgen(uuid++, 1) != 0)
|
||||
err(1, "uuidgen()");
|
||||
}
|
||||
}
|
||||
|
||||
uuid = store;
|
||||
while (count--) {
|
||||
uuid_to_string(uuid++, &p, NULL);
|
||||
fprintf(fp, "%s\n", p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
free(store);
|
||||
if (fp != stdout)
|
||||
fclose(fp);
|
||||
return (0);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,39 +0,0 @@
|
||||
$Id: DNSSEC,v 8.2 1999/10/12 18:23:27 ogud Exp $
|
||||
|
||||
DNSSEC Notes:
|
||||
|
||||
This file contains description of two interoperabilty problems related
|
||||
to DNSSEC that only affect sites using DNSSEC.
|
||||
|
||||
1. All versions of bind-8 older than 8.2.2
|
||||
|
||||
Between versions 8.2.1 and 8.2.2 the printed format of SIG records
|
||||
changed. As a result, using a signer, named and named-xfer of
|
||||
differrent versions will cause parsing errors on signed zonefiles.
|
||||
Included is an AWK program that converts old signed zone files to new
|
||||
new format, see contrib/dns_signer/add_labels.awk
|
||||
Usage: awk -f <path>/contrib/dns_signer/add_labels.awk <signed_zone >fixed_zone
|
||||
|
||||
2. BIND-8.1 BIND-8.1.1 BIND-8.1.2 Interoperability
|
||||
|
||||
If you wish to use BIND-8.1.x as a master server (either primary or
|
||||
secondary) for DNSSEC signed zone you MUST apply the following patch
|
||||
to the file src/bin/named/db_load.c. It fixes a bug that rejects
|
||||
valid RSA signatures on load.
|
||||
You can patch the file by running following command from this directory
|
||||
patch -d bin/named <DNSSEC
|
||||
|
||||
--- db_load.c.old Mon Oct 11 15:21:24 1999
|
||||
+++ db_load.c Mon Oct 11 15:21:38 1999
|
||||
@@ -1123,9 +1123,6 @@
|
||||
ERRTO("Signature too short");
|
||||
if (siglen > (NS_MD5RSA_MAX_BITS + 7) / 8)
|
||||
ERRTO("Signature too long");
|
||||
- /* We rely on cp from parse */
|
||||
- if (*cp == 0)
|
||||
- ERRTO("Signature starts with zeroes");
|
||||
break;
|
||||
|
||||
case NS_ALG_EXPIRE_ONLY:
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
$FreeBSD$
|
||||
|
||||
1. Create clean import directory.
|
||||
2. Un-tar bind-{src|doc}.tar.gz.
|
||||
3. rm Makefile; mv doc src/
|
||||
(Don't un-tar doc in src, you'll spam the real Makefile.)
|
||||
4. while read pattern; do rm -r src/${pattern} ; done < FREEBSD-Xlist
|
||||
5. find . -name .cvsignore -delete
|
||||
6. chmod 644 src/LICENSE
|
||||
7. Create another clean directory.
|
||||
8. cvs export -rHEAD src/contrib/bind
|
||||
9. diff -ur the two directories and look for 'Only in' to see if
|
||||
there are any new files, or anything gone missing.
|
||||
10. Once you're satisfied, do the import. Replace version strings appropriately:
|
||||
|
||||
cvs import -m"Import of ISC BIND version 8.3.3" src/contrib/bind ISC v8_3_3
|
||||
|
||||
11. Resolve conflicts as needed.
|
||||
|
||||
cvs checkout -jISC:yesterday -jISC src/contrib/bind
|
||||
|
||||
|
||||
Note: bin/nslookup/commands.l needs a different patch for the command line
|
||||
editing customization in -current and RELENG_4.
|
||||
@@ -1,42 +0,0 @@
|
||||
$FreeBSD$
|
||||
.cvsignore
|
||||
LICENSE_RSA
|
||||
OLD*
|
||||
bin/named/ns_parser.[ch]
|
||||
bin/nslookup/commands.c
|
||||
conf*
|
||||
doc/bog
|
||||
doc/notes
|
||||
doc/old
|
||||
doc/rfc
|
||||
doc/tmac
|
||||
doc/*/*.[lp]s[ft][0-9]
|
||||
doc/misc/*.ps
|
||||
lib/bsd*
|
||||
lib/cylink*
|
||||
lib/dnssafe*
|
||||
port/aix32*
|
||||
port/aix4*
|
||||
port/aux3*
|
||||
port/bsdos*
|
||||
port/cygwin*
|
||||
port/darwin*
|
||||
port/decunix*
|
||||
port/hpux*
|
||||
port/irix*
|
||||
port/linux*
|
||||
port/lynxos*
|
||||
port/mpe*
|
||||
port/netbsd*
|
||||
port/next*
|
||||
port/openbsd*
|
||||
port/qnx*
|
||||
port/rhapsody*
|
||||
port/sco*
|
||||
port/solaris*
|
||||
port/sunos*
|
||||
port/ultrix*
|
||||
port/unixware20*
|
||||
port/unixware212*
|
||||
port/unixware7*
|
||||
port/winnt*
|
||||
@@ -1,340 +0,0 @@
|
||||
Systems it is known to compile and run on:
|
||||
|
||||
BSD/OS 3.1, 4.0.1
|
||||
FreeBSD 3.3, 3.4
|
||||
RH Linux 5.2 (don't use "make links" when building, though)
|
||||
Debian GNU/Linux 2.2.9 ("unreleased")
|
||||
Digital UNIX 3.2C, 4.0, 5.0
|
||||
NetBSD/i386 1.3.2, 1.4
|
||||
Darwin 1.x (Mac OS X)
|
||||
SunOS 5.6 (Solaris 2.6), SunOS 5.7 (Solaris 7)
|
||||
SCO UnixWare 7.0, 7.0.1, 7.1
|
||||
IRIX 6.5
|
||||
|
||||
Systems it has been known in the past to compile and run on:
|
||||
|
||||
AIX 4.x
|
||||
A/UX 3.1.1
|
||||
Digital ULTRIX 4.5 (without Compaq's Y2K kit installed)
|
||||
HP MPE
|
||||
HP-UX 9.x, 10.20
|
||||
IRIX 5.3, 6.2, 6.4
|
||||
LynxOS
|
||||
FreeBSD 3.1, 3.2
|
||||
NetBSD 1.2, 1.3
|
||||
OpenBSD 2.1
|
||||
QNX
|
||||
SCO UNIX 3.2v4.2, SCO OSE 5.0.4, UnixWare 2.0.x, 2.1.2
|
||||
SunOS 4.1.4
|
||||
SunOS 5.5 (Solaris 2.5)
|
||||
|
||||
See port/README for information on porting BIND 8 to other systems.
|
||||
|
||||
|
||||
Building
|
||||
|
||||
If you do not have an ANSI/ISO C compiler, give up or get GCC. The
|
||||
one exception is the ULTRIX compiler, which isn't full ANSI C but it
|
||||
has function prototypes and BIND works around the rest. BIND 8 also
|
||||
wants a C library that's ANSI/ISO standard, although it can work
|
||||
around some common failings.
|
||||
|
||||
If you do not have yacc, get byacc or GNU bison. If you do not have
|
||||
lex, get GNU flex. For information on where to get GNU software, see
|
||||
http://www.fsf.org/order/ftp.html.
|
||||
|
||||
If you want to build outside the source pool, then
|
||||
|
||||
make DST=/your/destination/here SRC=`pwd` links
|
||||
cd /your/destination/here
|
||||
|
||||
If you want to use DST=/var/obj/bind, you can simply type
|
||||
|
||||
make stdlinks
|
||||
|
||||
Next, make sure you have no stale trash laying about
|
||||
|
||||
make clean
|
||||
|
||||
Then, update the Makefile dependencies:
|
||||
|
||||
make depend
|
||||
|
||||
NOTE: "make depend" is a NO-OP for some platforms, but always harmless.
|
||||
|
||||
Finally,
|
||||
|
||||
make all
|
||||
|
||||
|
||||
Installation
|
||||
|
||||
To install, type
|
||||
|
||||
make install
|
||||
|
||||
This will copy binaries to the appropriate locations for your system,
|
||||
and install the BIND 8 library and header files under /usr/local/bind.
|
||||
|
||||
The following variables can be used to change where things get
|
||||
installed:
|
||||
|
||||
DESTDIR prefix used in front of all other
|
||||
DEST variables. The default is the
|
||||
empty prefix. (for non-root installs;
|
||||
not equivalent to autoconf's --prefix)
|
||||
|
||||
DESTLIB libraries
|
||||
DESTINC include files
|
||||
DESTBIN ordinary binaries (e.g. dig, nslookup)
|
||||
DESTSBIN system binaries (e.g. named)
|
||||
DESTEXEC helper binaries (e.g. named-xfer)
|
||||
DESTHELP place to put nslookup's help file
|
||||
DESTMAN man file location
|
||||
DESTETC configuration file
|
||||
DESTRUN PID file location and "ndc" control
|
||||
channel location. This cannot be the
|
||||
same directory as DESTSBIN.
|
||||
|
||||
These variables should be specified in the Makefile.set for your
|
||||
port (e.g. if you use Solaris, in src/port/solaris/Makefile.set).
|
||||
|
||||
Before doing 'make install', you must
|
||||
|
||||
rm .settings
|
||||
|
||||
in the top level source directory because the build system caches
|
||||
these variables.
|
||||
|
||||
|
||||
Using BIND 8 Library Routines
|
||||
|
||||
Until a method to update the system's libraries is available,
|
||||
applications wishing to use BIND 8 library routines must include
|
||||
BIND 8 .h files, and must link with libbind.a. E.g.
|
||||
|
||||
cc -I/usr/local/bind/include -c sample.c
|
||||
cc -o sample -L/usr/local/bind/lib sample.o -lbind
|
||||
|
||||
The default locations for libbind.a and .h files in BIND 8.1.1
|
||||
and BIND 8.1.2 are different from those used in BIND 8.1-REL. If
|
||||
you did a 'make install' for BIND 8.1-REL, then you should delete
|
||||
the files it installed. They are:
|
||||
|
||||
/usr/local/lib/libbind.a
|
||||
/usr/local/include/arpa/inet.h
|
||||
/usr/local/include/arpa/nameser.h
|
||||
/usr/local/include/arpa/nameser_compat.h
|
||||
/usr/local/include/netdb.h
|
||||
/usr/local/include/resolv.h
|
||||
/usr/local/include/sys/bitypes.h (if it exists)
|
||||
/usr/local/include/sys/cdefs.h (if it exists)
|
||||
|
||||
|
||||
Operating System Notes
|
||||
|
||||
AIX
|
||||
|
||||
Build problems have been reported with the AIX "make".
|
||||
We recommend using GNU "make" instead.
|
||||
|
||||
AIX4 with Linux Compatibility API
|
||||
|
||||
May need to define HAVE_STRNDUP in
|
||||
port/aix4/include/port_after.h.
|
||||
|
||||
FreeBSD, NetBSD, OpenBSD and BSDI
|
||||
|
||||
The kit should compile even if you have intalled the KAME
|
||||
IPv6 kit.
|
||||
|
||||
HPUX
|
||||
|
||||
If you are using gcc you may have to remove the '-ansi'
|
||||
flag. This is gcc version dependent.
|
||||
|
||||
HPUX 10.20 early versions of the HP C/ANSI C compiler do
|
||||
not work, version B.10.20.15 in known to work.
|
||||
|
||||
IRIX
|
||||
|
||||
build problems have been reported w/ IRIX 6.3, res_debug.c
|
||||
and #include <stdlib.h>. You may need to comment out
|
||||
the #include <stdlib.h> and declare
|
||||
"void *malloc(size_t size)" to get named to compile on 6.3.
|
||||
|
||||
Linux
|
||||
|
||||
"make links" and "make stdlinks" cause problems on
|
||||
some Linux kernels because there are too many levels of
|
||||
symbolic links.
|
||||
|
||||
QNX
|
||||
|
||||
Read src/port/qnx/README before trying to build.
|
||||
|
||||
SCO 5.0.x
|
||||
|
||||
To build using gcc, copy "port/sco50/Makefile.set.gcc" to
|
||||
"port/sco50/Makefile.set". To go back to using SCO's
|
||||
compilers, copy "port/sco50/Makefile.set.sco" to
|
||||
"port/sco50/Makefile.set".
|
||||
|
||||
Solaris
|
||||
|
||||
We've tested with Sun's compilers, yacc, and lex, and also
|
||||
with gcc, byacc, and flex. By default, the build will try
|
||||
to use gcc. If you want to use the Sun compilers, simply
|
||||
copy "port/solaris/Makefile.set.sun" to
|
||||
"port/solaris/Makefile.set". To go back to using gcc, copy
|
||||
"port/solaris/Makefile.set.gcc" to "port/solaris/Makefile.set".
|
||||
|
||||
If you're using a Solaris release earlier than 2.5 and you have
|
||||
a large number of interfaces on your system, you many need to
|
||||
use a script to "limit descriptors N" (where 'N' is a
|
||||
suitably large number) before execing "named". On Solaris
|
||||
2.5 and later, the server will do this itself.
|
||||
|
||||
SunOS 4.1.4
|
||||
|
||||
An ANSI/ISO C compiler is required; we used gcc 2.7.2.1.
|
||||
|
||||
NeXT
|
||||
|
||||
Read src/port/next/README.FIRST before trying to build.
|
||||
|
||||
MPE/iX IPv6 is *not* supported. src/port/mpe/recvfrom.c needs to
|
||||
be re-written to support IPv6 if and when the OS supports
|
||||
IPv6.
|
||||
|
||||
Certain older versions of FreeBSD, NetBSD and BSD/OS
|
||||
|
||||
These systems have a /bin/sh based on "ash", which doesn't
|
||||
handle POSIX-style quoting correctly. Using "bash" will fix
|
||||
the problem. Either run make with "SH=bash" on the command
|
||||
line, or edit src/Makefile and change "SH=sh" to "SH=bash".
|
||||
|
||||
FD_SETSIZE
|
||||
|
||||
The highest numbered file descriptor that the server and the resolver
|
||||
can utilize is determined by the FD_SETSIZE value of the system. Some
|
||||
systems set FD_SETSIZE much smaller than the actual number of files
|
||||
that can be opened. On such systems, create an "fd_setsize.h" file
|
||||
that sets FD_SETSIZE appropriately in the port's include directory.
|
||||
|
||||
|
||||
User and Group ID
|
||||
|
||||
Specifying "-u" followed by a username or numeric user id on the
|
||||
"named" command line will cause the server to give up all
|
||||
privileges and become that user after the initial load of the
|
||||
configuation file is complete. "-g" may be used similarly to set
|
||||
the group id. If "-u" is specified but "-g" is not, the group
|
||||
used will be the given user's primary group.
|
||||
|
||||
Here are some hints:
|
||||
|
||||
Because the server will have no privileges after changing
|
||||
its user id, you must restart the server if you change the
|
||||
interfaces and ports that the server is listening on, or if
|
||||
you add an interface.
|
||||
|
||||
If you log to files, you should create all of the log files
|
||||
in advance (e.g. with "touch"), and make sure they are owned
|
||||
by the user and group "named" will be running as.
|
||||
|
||||
You'll have to edit "ndc" to get it to start the server
|
||||
with the appropriate flags.
|
||||
|
||||
Note: this feature is still experimental.
|
||||
|
||||
|
||||
Chroot
|
||||
|
||||
"-t" followed by a directory path on the "named" command line will
|
||||
cause the server to chroot() to that directory before it starts
|
||||
loading the configuration file.
|
||||
|
||||
Setting up a chrooted area varies somewhat by operating system. Some
|
||||
experimentation may be necessary. Here are some hints:
|
||||
|
||||
Don't forget to install named-xfer.
|
||||
|
||||
Either don't use shared libraries when you build, or do
|
||||
whatever is required on your OS to allow shared libraries
|
||||
to be used after a chroot().
|
||||
|
||||
syslog() is often troublesome after chrooting. Use the
|
||||
"logging" statement and log to a file instead.
|
||||
|
||||
/dev/null should be in the chroot directory hierarchy. You
|
||||
can usually find out the mknod parameters for a null device by
|
||||
looking in /dev/MAKEDEV.
|
||||
|
||||
You'll have to edit "ndc" to get it to start the server
|
||||
with the appropriate flags, and to use the right pid file.
|
||||
|
||||
Note: this feature is still experimental.
|
||||
|
||||
|
||||
Using the Server
|
||||
|
||||
Note that /etc/named.boot is long gone. You need to make yourself an
|
||||
/etc/named.conf (note, that ends in "conf" rather than "boot") file.
|
||||
This file looks a lot like a C program or a modern gated.conf file;
|
||||
there are lots of {curly braces} and it takes some getting used to.
|
||||
You may get a lot more help from the example file (which is
|
||||
bin/named/named.conf) than from the documentation (see ../doc/html).
|
||||
You can convert your named.boot file to a named.conf file using
|
||||
bin/named-bootconf/named-bootconf.
|
||||
|
||||
e.g.
|
||||
named-bootconf < /etc/named.boot > /etc/named.conf
|
||||
|
||||
All the files that used to be created in /var/tmp, e.g. named.run,
|
||||
will now be created in the directory specified in the options
|
||||
statement. If debugging is turned on using the "-d" flag on server
|
||||
startup, then named.run will be created in the current directory.
|
||||
|
||||
|
||||
Known Dynamic DNS Bugs
|
||||
|
||||
If the server is master for a zone and authoritative for a child of
|
||||
that zone, then a dynamic update to the parent will destroy the
|
||||
delegation to the child when the parent zone is written to disk.
|
||||
This problem will be fixed in a future release. The only workaround
|
||||
is to not be authoritative for child zones of a dynamic zone.
|
||||
|
||||
Slave servers do not forward update requests to the primary master
|
||||
correctly. This will be fixed in a future release. In the meantime,
|
||||
slaves will refuse dynamic updates.
|
||||
|
||||
|
||||
Shared Libraries
|
||||
|
||||
Absolutely no support exists for editing the system's shared
|
||||
libraries to update the resolver. If you want to do that you
|
||||
probably want to look at BIND Version 4 (see http://www.isc.org/isc/)
|
||||
or wait a while or help out a lot. This means you probably do not
|
||||
want to install the library or include files into /usr/lib or
|
||||
/usr/include, and this kit helpfully puts everything into
|
||||
/usr/local/lib and /usr/local/include for that reason among others.
|
||||
|
||||
|
||||
Notes about contrib and doc
|
||||
|
||||
The BIND 8 "doc" package includes HTML documentation as well as all
|
||||
the RFC's, Internet Drafts, and "man" pages we can think of. You may
|
||||
need to install the doc/tmac files in your nroff/troff support
|
||||
directory since we use the newer BSD "mandoc" system for our "man"
|
||||
pages.
|
||||
|
||||
The BIND 8 "contrib" package is full of junk that you may want to
|
||||
take a look at. Feel free to send us more junk for future releases.
|
||||
|
||||
|
||||
Bugs
|
||||
|
||||
Please report bugs to
|
||||
|
||||
[email protected]
|
||||
@@ -1,22 +0,0 @@
|
||||
## Copyright (c) 1993-2000 by Internet Software Consortium, Inc.
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
Internet Software Consortium
|
||||
950 Charter Street
|
||||
Redwood City, CA 94063
|
||||
Tel: 1-888-868-1001 (toll free in U.S.)
|
||||
Tel: 1-650-779-7091
|
||||
Fax: 1-650-779-7055
|
||||
Email: <[email protected]>
|
||||
@@ -1,68 +0,0 @@
|
||||
## Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.52 2000/11/21 12:54:37 marka Exp $
|
||||
|
||||
TOP=
|
||||
SUBDIRS= include port lib bin
|
||||
|
||||
SH=sh
|
||||
|
||||
default: all
|
||||
|
||||
all clean depend install distclean:: FRC
|
||||
@set -e; \
|
||||
version=`cat ${TOP}Version`; \
|
||||
systype=`${SH} ${TOP}port/systype ${TOP}.systype`; \
|
||||
if [ $$systype = "unknown" ]; then \
|
||||
echo "There is no BIND port for this system in this kit."; \
|
||||
else \
|
||||
settings=`${SH} ${TOP}port/settings ${TOP}.settings \
|
||||
< ${TOP}port/$$systype/Makefile.set`; \
|
||||
PATH=`pwd`/port/$$systype/bin:$$PATH; export PATH; \
|
||||
for x in ${SUBDIRS}; do \
|
||||
( cd $$x; pwd; \
|
||||
eval "${MAKE} $$settings ${MARGS} SYSTYPE=$$systype \
|
||||
VER=$$version \
|
||||
$@"; \
|
||||
) || exit 1; \
|
||||
done \
|
||||
fi
|
||||
|
||||
clean distclean::
|
||||
rm -f .systype .settings
|
||||
|
||||
links: FRC
|
||||
@set -e; mkdir ${DST}; cd ${DST}; pwd; ln -s ${SRC} SRC; \
|
||||
ln -s SRC/Version .; cp SRC/Makefile .; chmod +w Makefile; \
|
||||
systype=`${SH} SRC/port/systype`; \
|
||||
for x in ${SUBDIRS} ; do \
|
||||
( mkdir $$x; cd $$x; pwd; ln -s ../SRC/$$x SRC; \
|
||||
cp SRC/Makefile Makefile; chmod +w Makefile; \
|
||||
${MAKE} ${MARGS} SYSTYPE=$$systype links; \
|
||||
) || exit 1; \
|
||||
done
|
||||
|
||||
stdlinks: FRC
|
||||
if [ ! -d /var/obj ]; then \
|
||||
mkdir /var/obj; \
|
||||
fi
|
||||
${MAKE} ${MARGS} SRC=`pwd` DST=/var/obj/bind links
|
||||
|
||||
uplinks: FRC
|
||||
@set -e; systype=`${SH} ${TOP}port/systype`; pwd=`pwd`; \
|
||||
${MAKE} ${MARGS} SRC=../`basename $$pwd` "DST=../$$systype" links
|
||||
|
||||
FRC:
|
||||
@@ -1,259 +0,0 @@
|
||||
This is the source portion of BIND version 8. Its companions are "doc" and
|
||||
"contrib" so you are probably not missing anything.
|
||||
|
||||
See the CHANGES file for a detailed listing of all changes. See the INSTALL
|
||||
file for information on building and installing BIND.
|
||||
|
||||
See the SUPPORT file for information on obtaining commercial support for ISC
|
||||
artifacts including BIND, INN, and DHCP.
|
||||
|
||||
Note that BIND 8 is in "end-of-life", having been replaced by BIND 9. See
|
||||
http://www.isc.org/ for more details.
|
||||
|
||||
BIND 8.3.7 Highlights
|
||||
Security release.
|
||||
|
||||
BIND 8.3.6 Highlights
|
||||
Maintenance release.
|
||||
|
||||
BIND 8.3.5 Highlights
|
||||
Maintenance release.
|
||||
|
||||
BIND 8.3.4 Highlights
|
||||
Security Fix DoS and buffer overrun.
|
||||
|
||||
BIND 8.3.3 Highlights
|
||||
Security Fix libbind. All applications linked against libbind
|
||||
need to relinked.
|
||||
'rndc restart' now preserves named's arguements
|
||||
|
||||
BIND 8.3.2 Highlights
|
||||
dig, nslookup, host and nsupdate have improved IPv6 support.
|
||||
|
||||
BIND 8.3.1 Highlights
|
||||
Critical bug fix to prevent DNS storms. If you have BIND 8.3.0 you
|
||||
need to upgrade.
|
||||
|
||||
BIND 8.3.0 Highlights
|
||||
IPv6 transport support in resolver (from KAME).
|
||||
Opaque rdata support.
|
||||
EDNS0 support.
|
||||
Glue ordering to help non-ENDS0 aware clients (servers) cope with
|
||||
larger responses as a result of IPv6 by allowing A records to be added
|
||||
first to the additional section. IPv6 capable clients are expected to
|
||||
use EDNS0 to allow larger responses to be sent.
|
||||
Bug Fixes, includes BIND 8.2.5 changes.
|
||||
|
||||
BIND 8.2.4 Highlights
|
||||
NSAP processing was not RFC 1706 compliant. NOTE: OLD MASTER FILES
|
||||
NEED TO BE CORRECTED AND CACHE FILES REMOVED.
|
||||
Fixes long-standing protocol incompatibility in DNSSEC support.
|
||||
Avoids fwd'ing to root name servers if response will be rejected.
|
||||
new port/cygwin contributed by [email protected].
|
||||
new contrib/mdnkit (V1.3) from author.
|
||||
new contrib/adm from official ftp site.
|
||||
new contrib/host from author.
|
||||
new contrib/dnsp from author.
|
||||
fixed file descriptor leak in resolver.
|
||||
fixed a major memory leak in the processing of dynamic updates.
|
||||
numerous portability improvements.
|
||||
numerous bug fixes.
|
||||
|
||||
BIND 8.2.3 Highlights
|
||||
|
||||
Improved support for Windows NT and Windows 2000.
|
||||
Host stats are no longer required to track the source of a record.
|
||||
IXFR improvements.
|
||||
Forwarders track and use RTT to select fastest.
|
||||
Unix domain sockets implementions that require the directory
|
||||
to be secure, are now secured.
|
||||
Many minor problems fixed.
|
||||
Linux DoS removed.
|
||||
|
||||
BIND 8.2.2 patchlevel 5 Highlights
|
||||
|
||||
Bug in named-xfer (from patchlevel 4).
|
||||
Portability to IPv6 versions of FreeBSD, OpenBSD, NetBSD.
|
||||
Portability improvements (A/UX, AIX, IRIX, NetBSD, SCO, MPE/IX, NT).
|
||||
"also-notify" option could cause memory allocation errors.
|
||||
IXFR improvements (though client-side is still disabled).
|
||||
Contributed software upgraded (including TIS's "dns_signer").
|
||||
Several latent denial-of-service bugs fixed (from audits, not abuse).
|
||||
New "make noesw" top-level target for removing encumbered components.
|
||||
|
||||
BIND 8.2.2 Highlights
|
||||
|
||||
Interoperability with MS-Win2K has been improved.
|
||||
Server-side IXFR is now known to work even under high load.
|
||||
Support for Windows/NT (thanks to BayNetworks).
|
||||
More fixes, especially to DNSSEC, TSIG, IXFR, and selective forwarding.
|
||||
More portability improvements and lint removal (A/UX 3.1.1, SCO 5.0).
|
||||
Better NOTIFY behaviour, especially with large update volume.
|
||||
Better UPDATE handling, including SRV RR support and RFC compliance.
|
||||
Fix for "ndc reload ZONENAME" (specific zone reload) problems.
|
||||
Fix for round robin when multiple CNAMEs are in use.
|
||||
New "min-roots" (MINROOTS) and "serial-queries" (MAXQSERIAL) options.
|
||||
Log files are no longer auto-rotated every time the server starts up.
|
||||
New "ndc reconfig" command only finds new/deleted zones, no stat()ing.
|
||||
New global options for "transfer-source" and "also-notify".
|
||||
$GENERATE now supports more record types, and options.
|
||||
|
||||
BIND 8.2.1 Highlights
|
||||
|
||||
Bug fixes, especially to DNSSEC, TSIG, IXFR, and selective forwarding.
|
||||
Portability improvements and lint removal.
|
||||
Use best SOA rather than first-better when selecting an AXFR master.
|
||||
$TTL now accepts symbolic time values (such as "$TTL 1h30m").
|
||||
"ndc reload" now accepts a zone argument, for single-zone reloads.
|
||||
ndc is better behaved; is verbose or quiet when appropriate.
|
||||
event and error reporting improvements.
|
||||
|
||||
BIND 8.2 Highlights
|
||||
|
||||
RFC 2308 (Negative Caching)
|
||||
RFC 2181 (DNS Clarifications)
|
||||
RFC 2065 (DNS Security)
|
||||
TSIG (Transaction SIGnatures)
|
||||
support for multiple virtual name servers
|
||||
NDC uses a "control channel" now (no more signals)
|
||||
"Split DNS" via zone type "forward".
|
||||
|
||||
Many bug fixes
|
||||
Documentation improvements
|
||||
Performance enhancements
|
||||
|
||||
BIND 8.1.2 Highlights
|
||||
|
||||
Security fixes for a number of problems including:
|
||||
|
||||
An attacker could overwrite the stack if inverse query support
|
||||
was enabled.
|
||||
|
||||
A number of denial of service attacks where malformed packets
|
||||
could cause the server to crash.
|
||||
|
||||
The server was willing to answer queries on its forwarding
|
||||
sockets.
|
||||
|
||||
Several memory leaks have been plugged.
|
||||
|
||||
The server no longer panics if a periodic interface scan fails due
|
||||
to no file descriptors being available.
|
||||
|
||||
Updates to a number of ports. New ports for QNX, LynxOS, HP-UX 9.x,
|
||||
and HP MPE.
|
||||
|
||||
"files unlimited" now works as expected on systems where setting
|
||||
an infinite rlim_max for RLIMIT_NOFILE works.
|
||||
|
||||
Adding and deleting the same record in the same dynamic update no
|
||||
longer crashes the server.
|
||||
|
||||
If a dynamic update fails, rollback is now done in LIFO order instead
|
||||
of FIFO order.
|
||||
|
||||
Better behavior when priming of the root servers fails.
|
||||
|
||||
purge_zone() didn't work correctly for the root zone, allowing
|
||||
old data to persist after loading the zone.
|
||||
|
||||
Improved handling of oversized UDP packets.
|
||||
|
||||
All hosts on the also-notify list are now notified.
|
||||
|
||||
The meaning of the count returned by select() varies somewhat by
|
||||
operating system, and this could cause previous releases of the
|
||||
server to spin.
|
||||
|
||||
Per-host statistics may be disabled by specifying 'host-statistics no'
|
||||
in named.conf.
|
||||
|
||||
The maximum number of zones has been increased from 32768 to 65536.
|
||||
|
||||
query-source may specify an address and port that the server is
|
||||
already listening on. BIND 8.1.1 required that either the address
|
||||
or port be wild. E.g., you can now say:
|
||||
|
||||
listen-on port 53 { 10.0.0.1; };
|
||||
query-source address 10.0.0.1 port 53;
|
||||
|
||||
The value of FD_SETSIZE to use may be specified.
|
||||
|
||||
Experimental -u (set user id), -g (set group id), and -t (chroot)
|
||||
command line options. See the INSTALL file for details.
|
||||
|
||||
BIND 8 Features
|
||||
|
||||
-> DNS Dynamic Updates (RFC 2136)
|
||||
|
||||
-> DNS Change Notification (RFC 1996)
|
||||
|
||||
-> Completely new configuration syntax
|
||||
|
||||
-> Flexible, categorized logging system
|
||||
|
||||
-> IP-address-based access control for queries, zone transfers, and
|
||||
updates that may be specified on a zone-by-zone basis
|
||||
|
||||
-> More efficient zone transfers
|
||||
|
||||
-> Improved performance for servers with thousands of zones
|
||||
|
||||
-> The server no longer forks for outbound zone transfers
|
||||
|
||||
-> Many bug fixes
|
||||
|
||||
File and Directory Overview
|
||||
|
||||
CHANGES history of added features and
|
||||
fixed bugs
|
||||
|
||||
INSTALL how to build and install
|
||||
|
||||
README this file
|
||||
|
||||
TODO features planned but not yet written
|
||||
|
||||
Version the version number of this release
|
||||
|
||||
bin/* source for executables, including
|
||||
the nameserver
|
||||
|
||||
include/* public .h files
|
||||
|
||||
lib/* the resolver and various BIND
|
||||
support libraries
|
||||
|
||||
port/* ports to various operating systems
|
||||
|
||||
|
||||
Kits, Questions, Comments, and Bug Reports
|
||||
|
||||
<URL:ftp://ftp.isc.org/isc/bind/src/cur> current non-test release
|
||||
<URL:ftp://ftp.isc.org/isc/bind/src/testing> latest public test kit
|
||||
|
||||
<URL:usenet:comp.protocols.dns.bind> using BIND
|
||||
<URL:usenet:comp.protocols.dns.ops> DNS operations in general
|
||||
<URL:usenet:comp.protocols.dns.std> DNS standards in general
|
||||
|
||||
<URL:mailto:[email protected]> gw'd to u:c.p.d.bind
|
||||
<URL:mailto:[email protected]> gw'd to u:c.p.d.std
|
||||
<URL:mailto:[email protected]> code warriors only please
|
||||
|
||||
<URL:http://www.isc.org/bind.html> the BIND home page
|
||||
<URL:mailto:[email protected]> bug reports
|
||||
|
||||
To Support the Effort
|
||||
|
||||
Note that BIND is supported by the Internet Software Consortium, and
|
||||
although it is free for use and redistribution and incorporation into
|
||||
vendor products and export and anything else you can think of, it
|
||||
costs money to produce. That money comes from ISPs, hardware and
|
||||
software vendors, companies who make extensive use of the software,
|
||||
and generally kind hearted folk such as yourself.
|
||||
|
||||
The Internet Software Consortium has also commissioned a DHCP server
|
||||
implementation, has taken over official support/release of the INN
|
||||
system, and has supported the Kerberos Version 5 effort at MIT. You
|
||||
can learn more about the ISC's goals and accomplishments from the web
|
||||
page at <URL:http://www.isc.org/>.
|
||||
@@ -1,9 +0,0 @@
|
||||
The Internet Software Consortium offers, through certified providers, support,
|
||||
training, and consulting for BIND and DHCP. These programs are documented on
|
||||
our web page at:
|
||||
|
||||
http://www.isc.org/support.html
|
||||
|
||||
Discussion about programs to meet your needs is welcome at [email protected].
|
||||
Please forward your questions there or call us at +1 650 779-7018 to speak
|
||||
with the Director of Client Services.
|
||||
@@ -1,27 +0,0 @@
|
||||
These are not in priority order.
|
||||
|
||||
-> "make" should work in any subdirectory as it does in the top level.
|
||||
|
||||
-> "make distclean" should remove .depend files, "make clean" shouldn't.
|
||||
|
||||
-> NT port
|
||||
|
||||
-> DNS Security (RFC 2065)
|
||||
|
||||
-> IXFR
|
||||
|
||||
-> Enhanced forwarding
|
||||
|
||||
-> Command protocol
|
||||
|
||||
-> IPv6 transport
|
||||
|
||||
-> named-xfer elimination
|
||||
|
||||
-> asynchronous resolver
|
||||
|
||||
-> new database -- DB 2.0?
|
||||
|
||||
-> move man pages from doc/man/* into src/.
|
||||
|
||||
-> fix dynamic DNS delegation loss problem
|
||||
@@ -1 +0,0 @@
|
||||
8.3.7-REL
|
||||
@@ -1,94 +0,0 @@
|
||||
## Copyright (c) 1996,1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.31 2001/08/14 05:57:57 marka Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ..
|
||||
O=o
|
||||
A=a
|
||||
INCL = ${TOP}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.${A}
|
||||
LIBPORT = ${TOP}/port/libport.${A}
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LEX = lex -I
|
||||
YACC = yacc
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
AR= ar cru
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
LDFLAGS=
|
||||
|
||||
MARGS = "SYSTYPE=${SYSTYPE}" "SHELL=${SHELL}" "A=${A}" "O=${O}" \
|
||||
"CC=${CC}" "LEX=${LEX}" "YACC=${YACC}" "CDEBUG=${CDEBUG}" \
|
||||
"SYSLIBS=${SYSLIBS}" "LDFLAGS=${LDFLAGS}" \
|
||||
"DESTDIR=${DESTDIR}" "DESTMAN=${DESTMAN}" \
|
||||
"DESTBIN=${DESTBIN}" "DESTSBIN=${DESTSBIN}" "DESTEXEC=${DESTEXEC}" \
|
||||
"DESTLIB=${DESTLIB}" "DESTINC=${DESTINC}" "DESTETC=${DESTETC}" \
|
||||
"DESTRUN=${DESTRUN}" "DESTHELP=${DESTHELP}" \
|
||||
"RANLIB=${RANLIB}" "AR=${AR}" "ARPREF=${ARPREF}" "ARSUFF=${ARSUFF}" \
|
||||
"INCL=../${INCL}" "PORTINCL=../${PORTINCL}" "EXE=${EXE}" \
|
||||
"LIBBIND=../${LIBBIND}" "LIBPORT=../${LIBPORT}" \
|
||||
"INSTALL=${INSTALL}" "TOP=../${TOP}" \
|
||||
"VER=${VER}" "STRIP=${STRIP}" "PS=${PS}" "INSTALL_LIB=${INSTALL_LIB}" \
|
||||
"INSTALL_EXEC=${INSTALL_EXEC}" "BOUNDS=${BOUNDS}"
|
||||
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL}
|
||||
|
||||
SUBDIRS = addr nslookup dig dnsquery host named named-xfer ndc nsupdate \
|
||||
mkservdb irpd dnskeygen named-bootconf
|
||||
|
||||
all:
|
||||
@for x in ${SUBDIRS}; do \
|
||||
(cd $$x; pwd; ${MAKE} ${MARGS} $@) || exit 1; \
|
||||
done
|
||||
|
||||
install depend tags clean distclean::
|
||||
@for x in ${SUBDIRS}; do \
|
||||
(cd $$x; pwd; ${MAKE} ${MARGS} $@) || exit 1; \
|
||||
done
|
||||
|
||||
distclean:: clean
|
||||
|
||||
clean::
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
links: FRC
|
||||
@set -e; \
|
||||
for x in $(SUBDIRS); do \
|
||||
( mkdir $$x; cd $$x; pwd; ln -s ../SRC/$$x SRC; \
|
||||
cp SRC/Makefile Makefile; chmod +w Makefile; \
|
||||
$(MAKE) $(MARGS) links; \
|
||||
) || exit 1; \
|
||||
done
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
@@ -1,85 +0,0 @@
|
||||
## Copyright (c) 1996,1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.27 2000/12/23 08:02:49 vixie Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
EXE=
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL}
|
||||
|
||||
PROG= addr
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${PROG}${EXE}
|
||||
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags *.[ch]
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
@@ -1,168 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: addr.c,v 8.9 2002/05/21 02:26:21 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "port_after.h"
|
||||
|
||||
static const char *prog = "addr";
|
||||
|
||||
#define BIGGEST_ADDRESS IN6ADDRSZ
|
||||
|
||||
static void
|
||||
usage() {
|
||||
fprintf(stderr,
|
||||
"usage: %s [-4] [-6] [-n hexstring] [-p address]\n",
|
||||
prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Warning: this scribbles on `dst' even if it's going to return `0'. */
|
||||
static int
|
||||
hexstring(const char *src, u_char *dst, int len) {
|
||||
static const char xdigits[] = "0123456789abcdef";
|
||||
u_char *ptr = dst, *end = dst + len;
|
||||
u_int val;
|
||||
int ch, digits;
|
||||
|
||||
val = 0;
|
||||
digits = 0;
|
||||
memset(dst, 0, len);
|
||||
while ((ch = *src++) != '\0') {
|
||||
if (ch == '0' && (*src == 'x' || *src == 'X')) {
|
||||
src++;
|
||||
continue;
|
||||
}
|
||||
if (isascii(ch) && (isspace(ch) || ispunct(ch))) {
|
||||
if (digits > 0) {
|
||||
if (ptr == end)
|
||||
return (0);
|
||||
*ptr++ = (u_char) (val & 0xff);
|
||||
val = 0;
|
||||
digits = 0;
|
||||
}
|
||||
digits = 0;
|
||||
continue;
|
||||
}
|
||||
if (!isascii(ch) || !isxdigit(ch))
|
||||
return (0);
|
||||
if (isupper(ch))
|
||||
ch = tolower(ch);
|
||||
/* Clock it in using little endian arithmetic. */
|
||||
val <<= 4;
|
||||
val |= (strchr(xdigits, ch) - xdigits);
|
||||
if (++digits == 2) {
|
||||
if (ptr == end)
|
||||
return (0);
|
||||
*ptr++ = (u_char) (val & 0xff);
|
||||
digits = 0;
|
||||
val = 0;
|
||||
}
|
||||
}
|
||||
if (digits > 0) {
|
||||
if (ptr == end)
|
||||
return (0);
|
||||
*ptr++ = (u_char) (val & 0xff);
|
||||
}
|
||||
return ((ptr - dst) == len);
|
||||
}
|
||||
|
||||
static void
|
||||
display(const char *input, int af, const u_char *addr, int len) {
|
||||
static int before = 0;
|
||||
char p[sizeof "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255"];
|
||||
int i;
|
||||
|
||||
if (before)
|
||||
putchar('\n');
|
||||
else
|
||||
before++;
|
||||
|
||||
printf("Input: \"%s\"\n", input);
|
||||
printf("Network: [af%d len%d]", af, len);
|
||||
for (i = 0; i < len; i++)
|
||||
printf(" %02x", addr[i]);
|
||||
putchar('\n');
|
||||
printf("Presentation: \"%s\"\n", inet_ntop(af, addr, p, sizeof p));
|
||||
}
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
u_char addr[BIGGEST_ADDRESS];
|
||||
int optchr, af, len, some;
|
||||
|
||||
prog = argv[0];
|
||||
af = AF_INET;
|
||||
len = INADDRSZ;
|
||||
some = 0;
|
||||
while ((optchr = getopt(argc, argv, "46n:p:")) != -1) {
|
||||
switch (optchr) {
|
||||
case '4':
|
||||
af = AF_INET;
|
||||
len = INADDRSZ;
|
||||
break;
|
||||
case '6':
|
||||
af = AF_INET6;
|
||||
len = IN6ADDRSZ;
|
||||
break;
|
||||
case 'n':
|
||||
if (!hexstring(optarg, addr, len)) {
|
||||
fprintf(stderr, "bad hex string: \"%s\"\n",
|
||||
optarg);
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
display(optarg, af, addr, len);
|
||||
some++;
|
||||
break;
|
||||
case 'p':
|
||||
if (inet_pton(af, optarg, addr) <= 0) {
|
||||
fprintf(stderr, "bad address: \"%s\"\n",
|
||||
optarg);
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
display(optarg, af, addr, len);
|
||||
some++;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
if (!some)
|
||||
usage();
|
||||
exit(0);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
## Copyright (c) 1996,1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.27 2000/12/23 08:02:50 vixie Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
EXE=
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL}
|
||||
|
||||
NSLOOKUP_OBJS= \
|
||||
../nslookup/subr.${O} ../nslookup/send.${O} \
|
||||
../nslookup/list.${O} ../nslookup/debug.${O}
|
||||
|
||||
PROG= dig
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: ${OBJS} ${NSLOOKUP_OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
|
||||
${NSLOOKUP_OBJS} ${LIBBIND} ${SYSLIBS}
|
||||
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${PROG}${EXE}
|
||||
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags *.[ch]
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,86 +0,0 @@
|
||||
## Copyright (c) 1996,1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 1.7 2000/12/23 08:02:50 vixie Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
AR= ar cru
|
||||
INSTALL= install
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
PS=ps
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL}
|
||||
|
||||
PROG= dnskeygen
|
||||
SRCS= dnskeygen.c
|
||||
OBJS= dnskeygen.${O}
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTEXEC}:
|
||||
mkdir -p ${DESTDIR}${DESTEXEC}
|
||||
|
||||
install: ${DESTDIR}${DESTEXEC} ${PROG}${EXE}
|
||||
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTEXEC}/${PROG}${EXE}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags ${SRCS} *.h
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
@@ -1,321 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: dnskeygen.c,v 1.14 2001/09/25 04:50:14 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1995-1999 by TISLabs at Network Associates, Inc.
|
||||
*
|
||||
* Permission to use, copy modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND NETWORK ASSOCIATES
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* TRUSTED INFORMATION SYSTEMS BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "arpa/nameser.h"
|
||||
|
||||
#include <isc/dst.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#define PRINT_SUPPORTED 2
|
||||
#ifndef PATH_SEP
|
||||
#define PATH_SEP '/'
|
||||
#endif
|
||||
|
||||
static void usage(const char *str, int full);
|
||||
|
||||
static short dsa_sizes[] = {512, 576, 640, 704, 768, 832, 896, 960, 1024, 0};
|
||||
static char *prog;
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
DST_KEY *pubkey;
|
||||
char *name=NULL;
|
||||
int ch;
|
||||
char str[128];
|
||||
int alg = 0;
|
||||
int zone_key = 0, user_key = 0, end_key = 0, key_type = 0;
|
||||
int size = -1, exp = 0;
|
||||
int no_auth = 0, no_conf = 0;
|
||||
int sign_val = 0, flags = 0, protocol = -1;
|
||||
int i, err = 0;
|
||||
extern char *optarg;
|
||||
|
||||
dst_init();
|
||||
if ((prog = strrchr(argv[0], PATH_SEP)) == NULL)
|
||||
prog = strdup(argv[0]);
|
||||
else
|
||||
prog = strdup(++prog);
|
||||
|
||||
/* process input arguments */
|
||||
while ((ch = getopt(argc, argv, "achiuzn:s:p:D:H:R:F"))!= -1) {
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
no_auth = NS_KEY_NO_AUTH;
|
||||
break;
|
||||
case 'c':
|
||||
no_conf = NS_KEY_NO_CONF;
|
||||
break;
|
||||
case 'F':
|
||||
exp=1;
|
||||
break;
|
||||
case 'n':
|
||||
if (optarg)
|
||||
name = strdup(optarg);
|
||||
else
|
||||
usage("-n not followed by name", 0);
|
||||
i = strlen(name);
|
||||
if (name[i-1] != '.') {
|
||||
printf("** Adding dot to the name to make it"
|
||||
" fully qualified domain name**\n");
|
||||
free(name);
|
||||
name = malloc(i+2);
|
||||
strcpy(name, optarg);
|
||||
strcat(name, ".");
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
if (optarg && isdigit(optarg[0]))
|
||||
protocol = atoi(optarg);
|
||||
else
|
||||
usage("-p flag not followed by a number", 0);
|
||||
break;
|
||||
case 's':
|
||||
/* Default: not signatory key */
|
||||
if (optarg && isdigit(optarg[0]))
|
||||
sign_val = (int) atoi(optarg);
|
||||
else
|
||||
usage("-s flag requires a value",0);
|
||||
break;
|
||||
case 'h':
|
||||
end_key = NS_KEY_NAME_ENTITY;
|
||||
key_type++;
|
||||
break;
|
||||
case 'u' :
|
||||
user_key = NS_KEY_NAME_USER;
|
||||
key_type++;
|
||||
break ;
|
||||
case 'z':
|
||||
zone_key = NS_KEY_NAME_ZONE;
|
||||
key_type++;
|
||||
break;
|
||||
case 'H':
|
||||
if (optarg && isdigit(optarg[0]))
|
||||
size = (int) atoi(optarg);
|
||||
else
|
||||
usage("-H flag requires a size",0);
|
||||
if (alg != 0)
|
||||
usage("Only ONE alg can be specified", 1);
|
||||
alg = KEY_HMAC_MD5;
|
||||
if (!dst_check_algorithm(alg))
|
||||
usage("Algorithm HMAC-MD5 not available",
|
||||
PRINT_SUPPORTED);
|
||||
break;
|
||||
case 'R':
|
||||
if (optarg && isdigit(optarg[0]))
|
||||
size = (int) atoi(optarg);
|
||||
else
|
||||
usage("-R flag requires a size",0);
|
||||
if (alg != 0)
|
||||
usage("Only ONE alg can be specified", 1);
|
||||
alg = NS_ALG_MD5RSA;
|
||||
if (!dst_check_algorithm(alg))
|
||||
usage("Algorithm RSA not available",
|
||||
PRINT_SUPPORTED);
|
||||
break;
|
||||
case 'D':
|
||||
if (optarg && isdigit(optarg[0]))
|
||||
size = (int) atoi(optarg);
|
||||
else
|
||||
usage("-D flag requires a size", 0);
|
||||
if (alg != 0)
|
||||
usage("Only ONE alg can be specified", 1);
|
||||
alg = NS_ALG_DSS;
|
||||
if (dst_check_algorithm(alg) == 0)
|
||||
usage("Algorithm DSS not available",
|
||||
PRINT_SUPPORTED);
|
||||
break;
|
||||
default:
|
||||
err++;
|
||||
} /* switch */
|
||||
} /* while (getopt) */
|
||||
|
||||
/*
|
||||
* Command line parsed make sure required parameters are present
|
||||
*/
|
||||
if (name == NULL)
|
||||
usage("No key name specified -n <name>", 1);
|
||||
|
||||
if (alg == 0)
|
||||
usage("No algorithm specififed -{DHR}", 1);
|
||||
|
||||
if (key_type == 0)
|
||||
usage("Key type -{zhu} must be specified", 1);
|
||||
else if (key_type > 1)
|
||||
usage("Only one key type -{zhu} must be specified", 1);
|
||||
|
||||
if (alg == NS_ALG_DSS)
|
||||
no_conf = NS_KEY_NO_CONF; /* dss keys can not encrypt */
|
||||
|
||||
if (protocol == -1) {
|
||||
if (zone_key || end_key)
|
||||
protocol = NS_KEY_PROT_DNSSEC;
|
||||
else
|
||||
protocol = NS_KEY_PROT_EMAIL;
|
||||
}
|
||||
if (protocol < 0 || protocol > 255)
|
||||
usage("Protocol value out of range [0..255]", 0);
|
||||
|
||||
if (sign_val < 0 || sign_val > 15) {
|
||||
sprintf(str, "%s: Signatory value %d out of range[0..15]\n",
|
||||
prog, sign_val);
|
||||
usage(str, 0);
|
||||
}
|
||||
/* if any of bits 321 is set bit 0 can not be set*/
|
||||
if (sign_val & 0xe)
|
||||
sign_val &= 0xe;
|
||||
|
||||
/* if a zone key make sure at least one of the signer flags is set */
|
||||
if ((protocol == NS_KEY_PROT_DNSSEC) && (sign_val == 0))
|
||||
sign_val = 0x01;
|
||||
|
||||
if (no_auth && no_conf) { /* null key specified */
|
||||
if (sign_val > 0)
|
||||
sign_val = 0x0; /* null key can not sign */
|
||||
if (size > 0)
|
||||
size = 0; /* null key must have size 0 */
|
||||
}
|
||||
|
||||
if (size > 0) {
|
||||
if (alg == NS_ALG_MD5RSA){
|
||||
if (size < 512 || size > 4096)
|
||||
usage("Size out of range", 1);
|
||||
}
|
||||
else if (exp)
|
||||
usage("-F can only be specified with -R", 0);
|
||||
if (alg == NS_ALG_DSS) {
|
||||
for (i = 0; dsa_sizes[i]; i++)
|
||||
if (size <= dsa_sizes[i])
|
||||
break;
|
||||
if (size != dsa_sizes[i])
|
||||
usage("Invalid DSS key size", 1);
|
||||
}
|
||||
}
|
||||
else if (size < 0)
|
||||
usage("No size specified", 0);
|
||||
else /* size == 0 */
|
||||
sign_val = 0;
|
||||
|
||||
if (err)
|
||||
usage("errors encountered/unknown flag", 1);
|
||||
|
||||
flags = no_conf | no_auth | end_key | user_key | zone_key | sign_val;
|
||||
|
||||
/* process defaults */
|
||||
#ifdef WARN_NONZONE_SIGNER
|
||||
if (signer && (user_key | end_key))
|
||||
printf("Warning: User/End key is allowed to sign\n");
|
||||
#endif
|
||||
|
||||
/* create a public/private key pair */
|
||||
if (alg == NS_ALG_MD5RSA)
|
||||
printf("Generating %d bit RSA Key for %s\n\n",size, name);
|
||||
else if (alg == NS_ALG_DSS)
|
||||
printf("Generating %d bit DSS Key for %s\n\n",size, name);
|
||||
else if (alg == KEY_HMAC_MD5)
|
||||
printf("Generating %d bit HMAC-MD5 Key for %s\n\n",
|
||||
size, name);
|
||||
|
||||
/* Make the key
|
||||
* dst_generate_key_pair will place result in files that it
|
||||
* knows about K<name><foot>.public and K<name><foot>.private
|
||||
*/
|
||||
pubkey = dst_generate_key(name, size, exp, flags, protocol, alg);
|
||||
|
||||
if (pubkey == NULL) {
|
||||
printf("Failed generating key for %s\n", name);
|
||||
exit(12);
|
||||
}
|
||||
|
||||
if (dst_write_key(pubkey, DST_PRIVATE) < 0) {
|
||||
printf ("Failed to write private key for %s %d %d\n",
|
||||
name, pubkey->dk_id, pubkey->dk_alg);
|
||||
exit(12);
|
||||
}
|
||||
|
||||
if (dst_write_key(pubkey, DST_PUBLIC) <= 0) {
|
||||
if (access(name, F_OK))
|
||||
printf("Not allowed to overwrite existing file\n");
|
||||
else
|
||||
printf("Failed to write public key for %s %d %d\n",
|
||||
name, pubkey->dk_id, pubkey->dk_alg);
|
||||
exit(12);
|
||||
}
|
||||
|
||||
printf("Generated %d bit Key for %s id=%d alg=%d flags=%d\n\n",
|
||||
size, name, pubkey->dk_id, pubkey->dk_alg,
|
||||
pubkey->dk_flags);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(const char *str, int flag) {
|
||||
int i;
|
||||
|
||||
printf("\nNo key generated\n");
|
||||
if (*str != '\0')
|
||||
printf("Usage:%s: %s\n",prog, str);
|
||||
printf("Usage:%s -{DHR} <size> [-F] -{zhu} [-ac] [-p <no>]"
|
||||
" [-s <no>] -n name\n", prog);
|
||||
if (flag == 0)
|
||||
exit(2);
|
||||
printf("\t-D generate DSA/DSS KEY: size must be one of following:\n");
|
||||
printf("\t\t");
|
||||
for(i = 0; dsa_sizes[i] > 0; i++)
|
||||
printf(" %d,", dsa_sizes[i]);
|
||||
printf("\n");
|
||||
printf("\t-H generate HMAC-MD5 KEY: size in the range [1..512]:\n");
|
||||
printf("\t-R generate RSA KEY: size in the range [512..4096]\n");
|
||||
printf("\t-F RSA KEYS only: use large exponent\n");
|
||||
|
||||
printf("\t-z Zone key \n");
|
||||
printf("\t-h Host/Entity key \n");
|
||||
printf("\t-u User key \n");
|
||||
|
||||
printf("\t-a Key CANNOT be used for authentication\n");
|
||||
printf("\t-c Key CANNOT be used for encryption\n");
|
||||
|
||||
printf("\t-p Set protocol field to <no>\n");
|
||||
printf("\t\t default: 2 (email) for Host keys, 3 (dnssec) for all others\n");
|
||||
printf("\t-s Strength value this key signs DNS records with\n");
|
||||
printf("\t\t default: 1 for Zone keys, 0 for all others\n");
|
||||
printf("\t-n name: the owner of the key\n");
|
||||
|
||||
if (flag == PRINT_SUPPORTED) {
|
||||
printf("Available algorithms are:");
|
||||
if (dst_check_algorithm(NS_ALG_MD5RSA) == 1)
|
||||
printf(" RSA");
|
||||
if (dst_check_algorithm(NS_ALG_DSS) == 1)
|
||||
printf(" DSS");
|
||||
if (dst_check_algorithm(KEY_HMAC_MD5) == 1)
|
||||
printf(" HMAC-MD5");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
exit (3);
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
## Copyright (c) 1996,1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.26 2000/12/23 08:02:51 vixie Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
EXE=
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL}
|
||||
|
||||
PROG= dnsquery
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${PROG}${EXE}
|
||||
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags *.[ch]
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
@@ -1,232 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: dnsquery.c,v 8.19.10.1 2003/06/02 09:15:45 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include <resolv.h>
|
||||
|
||||
extern int errno;
|
||||
extern int h_errno;
|
||||
extern char *h_errlist[];
|
||||
|
||||
struct __res_state res;
|
||||
|
||||
static int
|
||||
newserver(char *srv, union res_sockaddr_union *u, int ns, int max) {
|
||||
struct addrinfo *answer = NULL;
|
||||
struct addrinfo *cur = NULL;
|
||||
struct addrinfo hint;
|
||||
short port = htons(NAMESERVER_PORT);
|
||||
|
||||
memset(&hint, 0, sizeof(hint));
|
||||
hint.ai_socktype = SOCK_DGRAM;
|
||||
if (!getaddrinfo(srv, NULL, &hint, &answer)) {
|
||||
for (cur = answer; cur != NULL; cur = cur->ai_next) {
|
||||
if (ns >= max)
|
||||
break;
|
||||
switch (cur->ai_addr->sa_family) {
|
||||
case AF_INET6:
|
||||
u[ns].sin6 =
|
||||
*(struct sockaddr_in6*)cur->ai_addr;
|
||||
u[ns++].sin6.sin6_port = port;
|
||||
break;
|
||||
case AF_INET:
|
||||
u[ns].sin = *(struct sockaddr_in*)cur->ai_addr;
|
||||
u[ns++].sin6.sin6_port = port;
|
||||
break;
|
||||
}
|
||||
}
|
||||
freeaddrinfo(answer);
|
||||
} else {
|
||||
fprintf(stderr, "Bad nameserver (%s)\n", srv);
|
||||
exit(1);
|
||||
}
|
||||
return (ns);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
char name[MAXDNAME];
|
||||
u_char answer[8*1024];
|
||||
int c, n;
|
||||
int nameservers = 0, class, type, len;
|
||||
union res_sockaddr_union q_nsaddr[MAXNS];
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
int stream = 0, debug = 0;
|
||||
|
||||
/* set defaults */
|
||||
len = MAXDNAME;
|
||||
gethostname(name, len);
|
||||
class = C_IN;
|
||||
type = T_ANY;
|
||||
|
||||
/* if no args, exit */
|
||||
if (argc == 1) {
|
||||
fprintf(stderr, "Usage: %s [-h] host [-n ns] [-t type] [-c class] [-r retry] [-p period] [-s] [-v] [-d] [-a]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* handle args */
|
||||
while ((c = getopt(argc, argv, "c:dh:n:p:r:st:u:v")) != -1) {
|
||||
switch (c) {
|
||||
|
||||
case 'r' : res.retry = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'p' : res.retrans = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'h' : if (strlen(optarg) >= sizeof(name)) {
|
||||
fprintf(stderr,
|
||||
"Domain name too long (%s)\n", optarg);
|
||||
exit(1);
|
||||
} else
|
||||
strcpy(name, optarg);
|
||||
break;
|
||||
|
||||
case 'c' : {
|
||||
int success, proto_class;
|
||||
|
||||
proto_class = sym_ston(__p_class_syms,
|
||||
optarg, &success);
|
||||
if (success)
|
||||
class = proto_class;
|
||||
else {
|
||||
fprintf(stderr, "Bad class (%s)\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 't' : {
|
||||
int success, proto_type;
|
||||
|
||||
proto_type = sym_ston(__p_type_syms,
|
||||
optarg, &success);
|
||||
if (success)
|
||||
type = proto_type;
|
||||
else {
|
||||
fprintf(stderr, "Bad type (%s)\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd' : debug++;
|
||||
break;
|
||||
|
||||
case 's' :
|
||||
case 'v' : stream++;
|
||||
break;
|
||||
|
||||
case 'n' :
|
||||
/*
|
||||
* If we set some nameservers here without
|
||||
* using gethostbyname() first, then they will
|
||||
* get overwritten when we do the first query.
|
||||
* So, we must init the resolver before any
|
||||
* of this.
|
||||
*/
|
||||
if (!(res.options & RES_INIT))
|
||||
if (res_ninit(&res) == -1) {
|
||||
fprintf(stderr,
|
||||
"res_ninit() failed\n"
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
nameservers = newserver(optarg, q_nsaddr,
|
||||
nameservers, MAXNS);
|
||||
break;
|
||||
|
||||
default : fprintf(stderr,
|
||||
"\tUsage: %s [-n ns] [-h host] [-t type] [-c class] [-r retry] [-p period] [-s] [-v] [-d] [-a]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (optind < argc) {
|
||||
if (strlen(argv[optind]) >= sizeof(name)) {
|
||||
fprintf(stderr,
|
||||
"Domain name too long (%s)\n", argv[optind]);
|
||||
exit(1);
|
||||
} else {
|
||||
strcpy(name, argv[optind]);
|
||||
}
|
||||
}
|
||||
|
||||
len = sizeof(answer);
|
||||
|
||||
if (!(res.options & RES_INIT))
|
||||
if (res_ninit(&res) == -1) {
|
||||
fprintf(stderr, "res_ninit() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* set these here so they aren't set for a possible call to
|
||||
* gethostbyname above
|
||||
*/
|
||||
if (debug)
|
||||
res.options |= RES_DEBUG;
|
||||
if (stream)
|
||||
res.options |= RES_USEVC;
|
||||
|
||||
/* if the -n flag was used, add them to the resolver's list */
|
||||
if (nameservers != 0)
|
||||
res_setservers(&res, q_nsaddr, nameservers);
|
||||
|
||||
/*
|
||||
* if the -h arg is fully-qualified, use res_query() since
|
||||
* using res_search() will lead to use of res_querydomain()
|
||||
* which will strip the trailing dot
|
||||
*/
|
||||
if (name[strlen(name) - 1] == '.') {
|
||||
n = res_nquery(&res, name, class, type, answer, len);
|
||||
if (n < 0) {
|
||||
fprintf(stderr, "Query failed (h_errno = %d) : %s\n",
|
||||
h_errno, h_errlist[h_errno]);
|
||||
exit(1);
|
||||
}
|
||||
} else if ((n = res_nsearch(&res, name, class, type,
|
||||
answer, len)) < 0) {
|
||||
fprintf(stderr, "Query failed (h_errno = %d) : %s\n",
|
||||
h_errno, h_errlist[h_errno]);
|
||||
exit(1);
|
||||
}
|
||||
res_pquery(&res, answer, n, stdout);
|
||||
exit(0);
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
## Copyright (c) 1996,1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.26 2000/12/23 08:02:51 vixie Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
EXE=
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL}
|
||||
|
||||
PROG= host
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${PROG}${EXE}
|
||||
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags *.[ch]
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,101 +0,0 @@
|
||||
## Copyright (c) 1996, 1997 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 1.7 2000/12/23 08:02:52 vixie Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
EXE=
|
||||
LEX = lex -I
|
||||
YACC = yacc -d
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
DESTETC= /etc
|
||||
DESTRUN= /var/run
|
||||
AR= ar cru
|
||||
INSTALL= install
|
||||
STRIP=-s
|
||||
|
||||
PS=ps
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL} -I${TOP}/lib/irs ${DEFS}
|
||||
|
||||
VER= LOCAL-`date +%y%m%d.%H%M%S`
|
||||
HOSTNAMECMD= hostname || uname -n
|
||||
|
||||
PROG= irpd
|
||||
HDRS=
|
||||
SRCS= irpd.c
|
||||
OBJS= irpd.${O}
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: irpd.${O} tmp_version.${O} ${LIBBIND}
|
||||
${CC} ${CDEBUG} ${LDFLAGS} -o ${PROG}${EXE} ${OBJS} tmp_version.${O} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
tmp_version.${O}: tmp_version.c
|
||||
|
||||
tmp_version.c: version.c Makefile ../Makefile ${SRCS} ${HDRS}
|
||||
(u=$${USER-root} d=`pwd` h=`${HOSTNAMECMD}` t=`date`; \
|
||||
sed -e "s|%WHEN%|$${t}|" -e "s|%VERSION%|"${VER}"|" \
|
||||
-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
|
||||
< version.c > tmp_version.c); sleep 1
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
rm -f tmp_version.c tmp_version.${O}
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} -I${TOP}/lib/irs ${DEFS} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTSBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTSBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTSBIN} ${PROG}${EXE}
|
||||
${INSTALL} ${STRIP} -c -m 755 ${PROG}${EXE} ${DESTDIR}${DESTSBIN}/${PROG}${EXE}
|
||||
|
||||
links: FRC
|
||||
@ln -s SRC/*.[chy] SRC/test .; rm -f ns_parser.[ch]
|
||||
|
||||
tags: FRC
|
||||
ctags ${SRCS} *.h
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +0,0 @@
|
||||
# Private irs config file for irpd so that it doesn't get configured to
|
||||
# talk to itself.
|
||||
passwd local
|
||||
group local
|
||||
services local
|
||||
protocols local
|
||||
hosts dns continue
|
||||
hosts local
|
||||
networks dns continue
|
||||
networks local
|
||||
netgroup local
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char sccsid[] = "@(#)named %VERSION% %WHEN% %WHOANDWHERE%";
|
||||
char rcsid[] = "$Id: version.c,v 1.1 1999/01/18 07:47:17 vixie Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
char Version[] = "named %VERSION% %WHEN%\n\t%WHOANDWHERE%";
|
||||
char ShortVersion[] = "%VERSION%";
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
## Copyright (c) 1998,1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 1.8 2000/12/23 08:02:52 vixie Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL}
|
||||
|
||||
PROG= mkservdb
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${PROG}${EXE}
|
||||
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags *.[ch]
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
@@ -1,176 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: mkservdb.c,v 1.10 2001/06/18 14:42:46 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#ifdef IRS_LCL_SV_DB
|
||||
#include <db.h>
|
||||
#include <err.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../../include/irs.h"
|
||||
#include "../../lib/irs/irs_p.h"
|
||||
#include "../../include/isc/misc.h"
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#ifdef SPRINTF_CHAR
|
||||
# define SPRINTF(x) strlen(sprintf/**/x)
|
||||
#else
|
||||
# define SPRINTF(x) ((size_t)sprintf x)
|
||||
#endif
|
||||
|
||||
#ifndef IRS_LCL_SV_DB
|
||||
main(int argc, char **argv) {
|
||||
fprintf(stderr, "%s: not supported on this architecture\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define _PATH_SERVICES_DB_TMP _PATH_SERVICES_DB ".new"
|
||||
|
||||
struct servent *getnextent(FILE *);
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
DB *db;
|
||||
DBT key;
|
||||
DBT data;
|
||||
const char *filename = _PATH_SERVICES;
|
||||
const char *tmpdatabase = _PATH_SERVICES_DB_TMP;
|
||||
const char *database = _PATH_SERVICES_DB;
|
||||
char dbuf[1024];
|
||||
char kbuf[512];
|
||||
u_short *ports;
|
||||
struct lcl_sv lcl_sv;
|
||||
struct servent *sv;
|
||||
int n, r;
|
||||
char *p;
|
||||
|
||||
unlink(tmpdatabase);
|
||||
|
||||
if (argc > 1)
|
||||
filename = argv[1];
|
||||
|
||||
lcl_sv.fp = fopen(filename, "r");
|
||||
if (lcl_sv.fp == NULL)
|
||||
err(1, "%s", filename);
|
||||
|
||||
db = dbopen(tmpdatabase, O_CREAT|O_RDWR, 0444, DB_BTREE, NULL);
|
||||
if (db == NULL)
|
||||
err(1, "%s", tmpdatabase);
|
||||
|
||||
while ((sv = irs_lclsv_fnxt(&lcl_sv)) != NULL) {
|
||||
if (sv->s_proto == NULL)
|
||||
continue;
|
||||
|
||||
key.data = kbuf;
|
||||
data.data = dbuf;
|
||||
|
||||
/* Note that (sizeof "/") == 2. */
|
||||
if (strlen(sv->s_name) + sizeof "/" + strlen(sv->s_proto)
|
||||
> sizeof kbuf)
|
||||
continue;
|
||||
key.size = SPRINTF((kbuf, "%s/%s", sv->s_name, sv->s_proto))+1;
|
||||
|
||||
((u_short *)dbuf)[0] = sv->s_port;
|
||||
p = dbuf;
|
||||
p += sizeof(u_short);
|
||||
if (sv->s_aliases)
|
||||
for (n = 0; sv->s_aliases[n]; ++n) {
|
||||
strcpy(p, sv->s_aliases[n]);
|
||||
p += strlen(p) + 1;
|
||||
}
|
||||
data.size = p - dbuf;
|
||||
|
||||
if ((r = db->put(db, &key, &data, R_NOOVERWRITE))) {
|
||||
if (r < 0)
|
||||
errx(1, "failed to write %s", (char *)key.data);
|
||||
else
|
||||
warnx("will not overwrite %s", (char *)key.data);
|
||||
}
|
||||
for (n = 0; sv->s_aliases[n]; ++n) {
|
||||
if (strlen(sv->s_aliases[n]) + sizeof "/"
|
||||
+ strlen(sv->s_proto) > sizeof kbuf)
|
||||
continue;
|
||||
key.size = SPRINTF((kbuf, "%s/%s",
|
||||
sv->s_aliases[n], sv->s_proto))+1;
|
||||
if ((r = db->put(db, &key, &data, R_NOOVERWRITE))) {
|
||||
if (r < 0)
|
||||
errx(1, "failed to write %s",
|
||||
(char *)key.data);
|
||||
else
|
||||
warnx("will not overwrite %s",
|
||||
(char *)key.data);
|
||||
}
|
||||
}
|
||||
|
||||
ports = (u_short *)kbuf;
|
||||
ports[0] = 0;
|
||||
ports[1] = sv->s_port;
|
||||
strcpy((char *)(ports+2), sv->s_proto);
|
||||
key.size = sizeof(u_short) * 2 + strlen((char *)(ports+2)) + 1;
|
||||
|
||||
if (strlen(sv->s_name) + sizeof "/" + strlen(sv->s_proto)
|
||||
> sizeof dbuf)
|
||||
continue;
|
||||
p = dbuf;
|
||||
p += SPRINTF((p, "%s/%s", sv->s_name, sv->s_proto)) + 1;
|
||||
if (sv->s_aliases != NULL)
|
||||
for (n = 0; sv->s_aliases[n] != NULL; n++)
|
||||
if ((p + strlen(sv->s_aliases[n]) + 1) - dbuf
|
||||
<= (int)sizeof dbuf) {
|
||||
strcpy(p, sv->s_aliases[n]);
|
||||
p += strlen(p) + 1;
|
||||
}
|
||||
data.size = p - dbuf;
|
||||
|
||||
if ((r = db->put(db, &key, &data, R_NOOVERWRITE))) {
|
||||
if (r < 0)
|
||||
errx(1, "failed to write %d/%s",
|
||||
ntohs(sv->s_port), sv->s_proto);
|
||||
else
|
||||
warnx("will not overwrite %d/%s",
|
||||
ntohs(sv->s_port), sv->s_proto);
|
||||
}
|
||||
}
|
||||
db->close(db);
|
||||
if (isc_movefile(tmpdatabase, database))
|
||||
err(1, "rename %s -> %s", tmpdatabase, database);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,324 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
## Copyright (c) 1996-1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
## $Id: named-bootconf.pl,v 1.2 1999/01/08 19:27:35 vixie Exp $
|
||||
|
||||
# This is a filter. Input is a named.boot. Output is a named.conf.
|
||||
|
||||
$new_config = "";
|
||||
|
||||
$have_options = 0;
|
||||
%options = ();
|
||||
%options_comments = ();
|
||||
@topology = ();
|
||||
@topology_comments = ();
|
||||
@bogus = ();
|
||||
@bogus_comments = ();
|
||||
@transfer_acl = ();
|
||||
@transfer_comments = ();
|
||||
$logging = "";
|
||||
|
||||
while(<>) {
|
||||
next if /^$/;
|
||||
|
||||
# skip comment-only lines
|
||||
if (/^\s*;+\s*(.*)$/) {
|
||||
$new_config .= "// $1\n";
|
||||
next;
|
||||
}
|
||||
|
||||
# handle continued lines
|
||||
while (/\\$/) {
|
||||
s/\\$/ /;
|
||||
$_ .= <>;
|
||||
}
|
||||
|
||||
chop;
|
||||
|
||||
# deal with lines ending in a coment
|
||||
if (s/\s*;+\s*(.*)$//) {
|
||||
$comment = "// $1";
|
||||
} else {
|
||||
$comment = "";
|
||||
}
|
||||
|
||||
($directive, @rest) = split;
|
||||
|
||||
$class = "";
|
||||
if ($directive =~ /^(.*)\/(.*)$/) {
|
||||
$directive = $1;
|
||||
$class = $2;
|
||||
}
|
||||
|
||||
if ($directive eq "primary") {
|
||||
$zname = shift(@rest);
|
||||
&maybe_print_comment("","\n");
|
||||
$new_config .= "zone \"$zname\" ";
|
||||
if ($class ne "") {
|
||||
$new_config .= "$class ";
|
||||
}
|
||||
$new_config .= "{\n";
|
||||
$new_config .= "\ttype master;\n";
|
||||
$filename = shift(@rest);
|
||||
$new_config .= "\tfile \"$filename\";\n";
|
||||
$new_config .= "};\n\n";
|
||||
} elsif ($directive eq "secondary" || $directive eq "stub") {
|
||||
if ($directive eq "secondary") {
|
||||
$type = "slave";
|
||||
} else {
|
||||
$type = "stub";
|
||||
}
|
||||
$zname = shift(@rest);
|
||||
&maybe_print_comment("","\n");
|
||||
$new_config .= "zone \"$zname\" ";
|
||||
if ($class ne "") {
|
||||
$new_config .= "$class ";
|
||||
}
|
||||
$new_config .= "{\n";
|
||||
$new_config .= "\ttype $type;\n";
|
||||
$filename = pop(@rest);
|
||||
if ($filename =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
|
||||
push(@rest, $filename);
|
||||
$filename = "";
|
||||
} else {
|
||||
$new_config .= "\tfile \"$filename\";\n";
|
||||
}
|
||||
$new_config .= "\tmasters {\n";
|
||||
foreach $master (@rest) {
|
||||
$new_config .= "\t\t$master;\n";
|
||||
}
|
||||
$new_config .= "\t};\n";
|
||||
$new_config .= "};\n\n";
|
||||
} elsif ($directive eq "cache") {
|
||||
$zname = shift(@rest);
|
||||
&maybe_print_comment("","\n");
|
||||
$new_config .= "zone \"$zname\" {\n";
|
||||
$new_config .= "\ttype hint;\n";
|
||||
$filename = shift(@rest);
|
||||
$new_config .= "\tfile \"$filename\";\n";
|
||||
$new_config .= "};\n\n";
|
||||
} elsif ($directive eq "directory") {
|
||||
$options{"directory"} = "\"$rest[0]\"";
|
||||
$options_comments{"directory"} = $comment;
|
||||
$have_options = 1;
|
||||
} elsif ($directive eq "check-names") {
|
||||
$type = shift(@rest);
|
||||
if ($type eq "primary") {
|
||||
$type = "master";
|
||||
} elsif ($type eq "secondary") {
|
||||
$type = "slave";
|
||||
}
|
||||
$action = shift(@rest);
|
||||
$options{"check-names $type"} = $action;
|
||||
$options_comments{"check-names $type"} = $comment;
|
||||
$have_options = 1;
|
||||
} elsif ($directive eq "forwarders") {
|
||||
$options{"forwarders"}="{\n";
|
||||
foreach $forwarder (@rest) {
|
||||
$options{"forwarders"} .= "\t\t$forwarder;\n";
|
||||
}
|
||||
$options{"forwarders"} .= "\t}";
|
||||
$options_comments{"forwarders"} = $comment;
|
||||
$have_options = 1;
|
||||
} elsif ($directive eq "slave") {
|
||||
&handle_options("forward-only");
|
||||
} elsif ($directive eq "options") {
|
||||
&handle_options(@rest);
|
||||
} elsif ($directive eq "limit") {
|
||||
&handle_limit(@rest);
|
||||
} elsif ($directive eq "include") {
|
||||
$new_config .=
|
||||
"// make sure your include is still in the right place\n";
|
||||
$comment = "\t" . $comment;
|
||||
$new_config .= "include \"$rest[0]\";$comment\n\n";
|
||||
} elsif ($directive eq "xfrnets" || $directive eq "tcplist") {
|
||||
if ($comment ne "") {
|
||||
$comment = "\t$comment";
|
||||
}
|
||||
foreach $elt (@rest) {
|
||||
push(@transfer_acl, $elt);
|
||||
push(@transfer_comments, $comment);
|
||||
}
|
||||
$have_options = 1;
|
||||
} elsif ($directive eq "sortlist") {
|
||||
if ($comment ne "") {
|
||||
$comment = "\t$comment";
|
||||
}
|
||||
foreach $elt (@rest) {
|
||||
push(@topology, $elt);
|
||||
push(@topology_comments, $comment);
|
||||
}
|
||||
} elsif ($directive eq "bogusns") {
|
||||
if ($comment ne "") {
|
||||
$comment = "\t$comment";
|
||||
}
|
||||
foreach $elt (@rest) {
|
||||
push(@bogus, $elt);
|
||||
push(@bogus_comments, $comment);
|
||||
}
|
||||
} elsif ($directive eq "max-fetch") {
|
||||
$options{"transfers-in"}=$rest[0];
|
||||
$options_comments{"transfers-in"}=$comment;
|
||||
$have_options = 1;
|
||||
} else {
|
||||
$new_config .= "// NOTE: unconverted directive '$directive @rest'\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "// generated by named-bootconf.pl\n\n";
|
||||
if ($have_options) {
|
||||
print "options {\n";
|
||||
foreach $option (sort(keys(%options))) {
|
||||
print "\t$option $options{$option};";
|
||||
if ($options_comments{$option} ne "") {
|
||||
print "\t$options_comments{$option}";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
if (@transfer_acl > 0) {
|
||||
print "\tallow-transfer {\n";
|
||||
for ($i = 0; $i <= $#transfer_acl; $i++) {
|
||||
&print_maybe_masked("\t\t", $transfer_acl[$i],
|
||||
$transfer_comments[$i]);
|
||||
}
|
||||
print "\t};\n";
|
||||
}
|
||||
print "\t/*
|
||||
\t * If there is a firewall between you and nameservers you want
|
||||
\t * to talk to, you might need to uncomment the query-source
|
||||
\t * directive below. Previous versions of BIND always asked
|
||||
\t * questions using port 53, but BIND 8.1 uses an unprivileged
|
||||
\t * port by default.
|
||||
\t */
|
||||
\t// query-source address * port 53;
|
||||
";
|
||||
|
||||
print "};\n\n";
|
||||
}
|
||||
if ($logging ne "") {
|
||||
print "logging {\n$logging};\n\n";
|
||||
}
|
||||
if (@topology > 0) {
|
||||
print "// Note: the following will be supported in a future release.\n";
|
||||
print "/*\n";
|
||||
print "host { any; } {\n\ttopology {\n";
|
||||
for ($i = 0; $i <= $#topology; $i++) {
|
||||
&print_maybe_masked("\t\t", $topology[$i],
|
||||
$topology_comments[$i]);
|
||||
}
|
||||
print "\t};\n};\n";
|
||||
print "*/\n";
|
||||
print "\n";
|
||||
}
|
||||
if (@bogus > 0) {
|
||||
for ($i = 0; $i <= $#bogus; $i++) {
|
||||
print "server $bogus[$i] { bogus yes; };$bogus_comments[$i]\n";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
print $new_config;
|
||||
|
||||
exit 0;
|
||||
|
||||
sub maybe_print_comment {
|
||||
$prefix = shift;
|
||||
$suffix = shift;
|
||||
if ($comment ne "") {
|
||||
$new_config .= sprintf("%s%s%s", $prefix, $comment, $suffix);
|
||||
}
|
||||
}
|
||||
|
||||
sub handle_options {
|
||||
foreach $option (@_) {
|
||||
if ($option eq "forward-only") {
|
||||
$options{"forward"}="only";
|
||||
$options_comments{"forward"}=$comment;
|
||||
$have_options = 1;
|
||||
} elsif ($option eq "no-recursion") {
|
||||
$options{"recursion"}="no";
|
||||
$options_comments{"recursion"}=$comment;
|
||||
$have_options = 1;
|
||||
} elsif ($option eq "no-fetch-glue") {
|
||||
$options{"fetch-glue"}="no";
|
||||
$options_comments{"fetch-glue"}=$comment;
|
||||
$have_options = 1;
|
||||
} elsif ($option eq "fake-iquery") {
|
||||
$options{"fake-iquery"}="yes";
|
||||
$options_comments{"fake-iquery"}=$comment;
|
||||
$have_options = 1;
|
||||
} elsif ($option eq "query-log") {
|
||||
if ($comment ne "") {
|
||||
$logging .= "\t$comment\n";
|
||||
}
|
||||
$logging .= "\tcategory queries { default_syslog; };\n";
|
||||
} else {
|
||||
$options{"// NOTE: unconverted option '$option'"}="";
|
||||
$options_comments{"// NOTE: unconverted option '$option'"}=
|
||||
$comment;
|
||||
$have_options = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub handle_limit {
|
||||
$limit = shift;
|
||||
if ($limit eq "datasize" || $limit eq "transfers-in"
|
||||
|| $limit eq "transfers-per-ns" || $limit eq "files") {
|
||||
$options{$limit}=$_[0];
|
||||
$options_comments{$limit}=$comment;
|
||||
$have_options = 1;
|
||||
} else {
|
||||
$options{"// NOTE: unconverted limit '$limit @_'"}="";
|
||||
$options_comments{"// NOTE: unconverted limit '$limit @_'"}=$comment;
|
||||
$have_options = 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub print_maybe_masked {
|
||||
# this assumes a contiguous netmask starting at the MSB
|
||||
$prefix = shift;
|
||||
$elt = shift;
|
||||
$elt_comment = shift;
|
||||
if ($elt =~ /^(.*)&(.*)$/) {
|
||||
$address = $1;
|
||||
$mask = $2;
|
||||
($m1,$m2,$m3,$m4) = split(/\./, $mask);
|
||||
$mask_val = ($m1 << 24) + ($m2 << 16) +($m3 << 8) + $m4;
|
||||
$zero_bits = 0;
|
||||
while (($mask_val % 2) == 0) {
|
||||
$mask_val /= 2;
|
||||
$zero_bits++;
|
||||
}
|
||||
$mask_bits = 32 - $zero_bits;
|
||||
} else {
|
||||
$address = $elt;
|
||||
($a1,$a2,$a3,$a4) = split(/\./, $address);
|
||||
if ($a1 < 128) {
|
||||
$mask_bits = 8;
|
||||
} elsif ($a1 < 192) {
|
||||
$mask_bits = 16;
|
||||
} else {
|
||||
$mask_bits = 24;
|
||||
}
|
||||
}
|
||||
|
||||
print "$prefix$address";
|
||||
if ($mask_bits != 32) {
|
||||
print "/$mask_bits";
|
||||
}
|
||||
print ";$elt_comment\n";
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
## Copyright (c) 1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 1.3 2000/12/23 08:02:53 vixie Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL}
|
||||
|
||||
PROG= named-bootconf
|
||||
|
||||
all: ${PROG}
|
||||
|
||||
${PROG}: ${PROG}.sh Makefile
|
||||
cp ${PROG}.sh ${PROG}
|
||||
chmod +x ${PROG}
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend:
|
||||
|
||||
${DESTDIR}${DESTSBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTSBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTSBIN} ${PROG}
|
||||
${INSTALL} -c -m 755 ${PROG} ${DESTDIR}${DESTSBIN}/${PROG}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.sh .
|
||||
|
||||
tags:
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
@@ -1,321 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: named-bootconf.sh,v 1.5 1998/12/15 01:00:53 tron Exp $
|
||||
#
|
||||
# Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Matthias Scheler.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
## Copyright (c) 1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
if [ ${OPTIONFILE-X} = X ]; then
|
||||
OPTIONFILE=/tmp/.options.`date +%s`.$$
|
||||
ZONEFILE=/tmp/.zones.`date +%s`.$$
|
||||
COMMENTFILE=/tmp/.comments.`date +%s`.$$
|
||||
export OPTIONFILE ZONEFILE COMMENTFILE
|
||||
touch $OPTIONFILE $ZONEFILE $COMMENTFILE
|
||||
DUMP=1
|
||||
else
|
||||
DUMP=0
|
||||
fi
|
||||
|
||||
while read CMD ARGS; do
|
||||
class=
|
||||
CMD=`echo "${CMD}" | tr '[A-Z]' '[a-z]'`
|
||||
case $CMD in
|
||||
\; )
|
||||
echo \# $ARGS >>$COMMENTFILE
|
||||
;;
|
||||
cache )
|
||||
set - X $ARGS
|
||||
shift
|
||||
if [ $# -eq 2 ]; then
|
||||
(echo ""
|
||||
cat $COMMENTFILE
|
||||
echo "zone \"$1\" {"
|
||||
echo " type hint;"
|
||||
echo " file \"$2\";"
|
||||
echo "};") >>$ZONEFILE
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
fi
|
||||
;;
|
||||
directory )
|
||||
set - X $ARGS
|
||||
shift
|
||||
if [ $# -eq 1 ]; then
|
||||
(cat $COMMENTFILE
|
||||
echo " directory \"$1\";") >>$OPTIONFILE
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
|
||||
DIRECTORY=$1
|
||||
export DIRECTORY
|
||||
fi
|
||||
;;
|
||||
forwarders )
|
||||
(cat $COMMENTFILE
|
||||
echo " forwarders {"
|
||||
for ARG in $ARGS; do
|
||||
echo " $ARG;"
|
||||
done
|
||||
echo " };") >>$OPTIONFILE
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
;;
|
||||
include )
|
||||
if [ "$ARGS" != "" ]; then
|
||||
(cd ${DIRECTORY-.}; cat $ARGS) | $0
|
||||
fi
|
||||
;;
|
||||
limit )
|
||||
ARGS=`echo "${ARGS}" | tr '[A-Z]' '[a-z]'`
|
||||
set - X $ARGS
|
||||
shift
|
||||
if [ $# -eq 2 ]; then
|
||||
cat $COMMENTFILE >>$OPTIONFILE
|
||||
case $1 in
|
||||
datasize | files | transfers-in | transfers-per-ns )
|
||||
echo " $1 $2;" >>$OPTIONFILE
|
||||
;;
|
||||
esac
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
fi
|
||||
;;
|
||||
options )
|
||||
ARGS=`echo "${ARGS}" | tr '[A-Z]' '[a-z]'`
|
||||
cat $COMMENTFILE >>$OPTIONFILE
|
||||
for ARG in $ARGS; do
|
||||
case $ARG in
|
||||
fake-iquery )
|
||||
echo " fake-iquery yes;" >>$OPTIONFILE
|
||||
;;
|
||||
forward-only )
|
||||
echo " forward only;" >>$OPTIONFILE
|
||||
;;
|
||||
no-fetch-glue )
|
||||
echo " fetch-glue no;" >>$OPTIONFILE
|
||||
;;
|
||||
no-recursion )
|
||||
echo " recursion no;" >>$OPTIONFILE
|
||||
;;
|
||||
no-round-robin ) # HP extention
|
||||
echo " rrset-order {" >>$OPTIONFILE
|
||||
echo " class ANY type ANY name \"*\" order fixed;" >>$OPTIONFILE
|
||||
echo " };" >>$OPTIONFILE
|
||||
;;
|
||||
esac
|
||||
done
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
;;
|
||||
primary|primary/* )
|
||||
case $CMD in
|
||||
primary/chaos )
|
||||
class="chaos "
|
||||
;;
|
||||
primary/hs )
|
||||
class="hesiod "
|
||||
;;
|
||||
esac
|
||||
set - X $ARGS
|
||||
shift
|
||||
if [ $# -eq 2 ]; then
|
||||
(echo ""
|
||||
cat $COMMENTFILE
|
||||
echo "zone \"$1\" ${class}{"
|
||||
echo " type master;"
|
||||
echo " file \"$2\";"
|
||||
echo "};") >>$ZONEFILE
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
fi
|
||||
;;
|
||||
secondary|secondary/* )
|
||||
case $CMD in
|
||||
secondary/chaos )
|
||||
class="chaos "
|
||||
;;
|
||||
secondary/hs )
|
||||
class="hesiod "
|
||||
;;
|
||||
esac
|
||||
set - X $ARGS
|
||||
shift
|
||||
if [ $# -gt 1 ]; then
|
||||
ZONE=$1
|
||||
shift
|
||||
PRIMARIES=""
|
||||
while [ $# -gt 1 ]; do
|
||||
PRIMARIES="$PRIMARIES $1"
|
||||
shift
|
||||
done
|
||||
(echo ""
|
||||
cat $COMMENTFILE
|
||||
echo "zone \"$ZONE\" ${class}{"
|
||||
echo " type slave;"
|
||||
if expr x"$1" : '^x[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' > /dev/null
|
||||
then
|
||||
PRIMARIES="$PRIMARIES $1"
|
||||
else
|
||||
echo " file \"$1\";"
|
||||
fi
|
||||
echo " masters {"
|
||||
for PRIMARY in $PRIMARIES; do
|
||||
echo " $PRIMARY;"
|
||||
done
|
||||
echo " };"
|
||||
echo "};") >>$ZONEFILE
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
fi
|
||||
;;
|
||||
stub|stub/* )
|
||||
case $CMD in
|
||||
stub/chaos )
|
||||
class="chaos "
|
||||
;;
|
||||
stub/hs )
|
||||
class="hesiod "
|
||||
;;
|
||||
esac
|
||||
set - X $ARGS
|
||||
shift
|
||||
if [ $# -gt 1 ]; then
|
||||
ZONE=$1
|
||||
shift
|
||||
PRIMARIES=""
|
||||
while [ $# -gt 1 ]; do
|
||||
PRIMARIES="$PRIMARIES $1"
|
||||
shift
|
||||
done
|
||||
(echo ""
|
||||
cat $COMMENTFILE
|
||||
echo "zone \"$ZONE\" ${class}{"
|
||||
echo " type stub;"
|
||||
if expr x"$1" : '^x[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' > /dev/null
|
||||
then
|
||||
PRIMARIES="$PRIMARIES $1"
|
||||
else
|
||||
echo " file \"$1\";"
|
||||
fi
|
||||
echo " masters {"
|
||||
for PRIMARY in $PRIMARIES; do
|
||||
echo " $PRIMARY;"
|
||||
done
|
||||
echo " };"
|
||||
echo "};") >>$ZONEFILE
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
fi
|
||||
;;
|
||||
slave )
|
||||
cat $COMMENTFILE >>$OPTIONFILE
|
||||
echo " forward only;" >>$OPTIONFILE
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
;;
|
||||
sortlist )
|
||||
(cat $COMMENTFILE
|
||||
echo " topology {"
|
||||
for ARG in $ARGS; do
|
||||
case $ARG in
|
||||
*.0.0.0 )
|
||||
echo " $ARG/8;"
|
||||
;;
|
||||
*.0.0 )
|
||||
echo " $ARG/16;"
|
||||
;;
|
||||
*.0 )
|
||||
echo " $ARG/24;"
|
||||
;;
|
||||
* )
|
||||
echo " $ARG;"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo " };") >>$OPTIONFILE
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
;;
|
||||
tcplist | xfrnets )
|
||||
(cat $COMMENTFILE
|
||||
echo " allow-transfer {"
|
||||
for ARG in $ARGS; do
|
||||
case $ARG in
|
||||
*.0.0.0 )
|
||||
echo " $ARG/8;"
|
||||
;;
|
||||
*.0.0 )
|
||||
echo " $ARG/16;"
|
||||
;;
|
||||
*.0 )
|
||||
echo " $ARG/24;"
|
||||
;;
|
||||
* )
|
||||
echo " $ARG;"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo " };") >>$OPTIONFILE
|
||||
rm -f $COMMENTFILE
|
||||
touch $COMMENTFILE
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $DUMP -eq 1 ]; then
|
||||
echo ""
|
||||
echo "options {"
|
||||
cat $OPTIONFILE
|
||||
echo "};"
|
||||
cat $ZONEFILE $COMMENTFILE
|
||||
|
||||
rm -f $OPTIONFILE $ZONEFILE $COMMENTFILE
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@@ -1,30 +0,0 @@
|
||||
directory /var/named
|
||||
forwarders 1.2.3.4 1.2.3.5
|
||||
limit datasize 10000000
|
||||
limit files 1000
|
||||
limit transfers-in 100
|
||||
limit transfers-per-ns 20
|
||||
; no-round-robin in HP specific
|
||||
options no-round-robin fake-iquery forward-only no-fetch-glue no-recursion
|
||||
slave
|
||||
tcplist 10.0.0.1
|
||||
xfrnets 10.0.0.2
|
||||
cache . rootservers
|
||||
primary example.net example.net.db
|
||||
secondary example.com 127.0.0.1 example.com.db
|
||||
stub example.org 127.0.0.1 example.org.db
|
||||
primary/IN example.net example.net.db
|
||||
secondary/IN example.com 127.0.0.1 example.com.db
|
||||
stub/IN example.org 127.0.0.1 example.org.db
|
||||
secondary/IN example.com 127.0.0.1
|
||||
stub/IN example.org 127.0.0.1
|
||||
primary/CHAOS example.net example.net.db
|
||||
secondary/CHAOS example.com 127.0.0.1 example.com.db
|
||||
stub/CHAOS example.org 127.0.0.1 example.org.db
|
||||
secondary/CHAOS example.com 127.0.0.1
|
||||
stub/CHAOS example.org 127.0.0.1
|
||||
primary/HS example.net example.net.db
|
||||
secondary/HS example.com 127.0.0.1 example.com.db
|
||||
stub/HS example.org 127.0.0.1 example.org.db
|
||||
secondary/HS example.com 127.0.0.1
|
||||
stub/HS example.org 127.0.0.1
|
||||
@@ -1,90 +0,0 @@
|
||||
## Copyright (c) 1996,1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.31 2000/12/23 08:02:54 vixie Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
EXE=
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
AR= ar cru
|
||||
INSTALL= install
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
PS=ps
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL}
|
||||
|
||||
NAMED_OBJS= \
|
||||
../named/db_glue.${O} ../named/ns_glue.${O} ../named/tmp_version.${O}
|
||||
|
||||
PROG= named-xfer
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: ${OBJS} ${NAMED_OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} ${NAMED_OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTEXEC}:
|
||||
mkdir -p ${DESTDIR}${DESTEXEC}
|
||||
|
||||
install: ${DESTDIR}${DESTEXEC} ${PROG}${EXE}
|
||||
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTEXEC}/${PROG}${EXE}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags ${SRCS} *.h
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,134 +0,0 @@
|
||||
## Copyright (c) 1996-2000 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.51 2000/12/23 08:02:53 vixie Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
EXE=
|
||||
YACC = yacc -d
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
DESTETC= /etc
|
||||
DESTRUN= /var/run
|
||||
AR= ar cru
|
||||
INSTALL= install
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
PS=ps
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL} ${DEFS}
|
||||
|
||||
VER= LOCAL-`date +%Y%m%d.%H%M%S`
|
||||
HOSTNAMECMD= hostname || uname -n
|
||||
|
||||
PROG= named
|
||||
HDRS= db_defs.h db_glob.h ns_defs.h ns_glob.h named.h pathnames.h
|
||||
SRCS= db_dump.c db_load.c db_lookup.c db_save.c db_update.c \
|
||||
db_glue.c db_ixfr.c db_sec.c db_tsig.c \
|
||||
ns_parser.c ns_lexer.c ns_parseutil.c ns_ctl.c \
|
||||
ns_forw.c ns_init.c ns_main.c ns_maint.c ns_req.c \
|
||||
ns_resp.c ns_stats.c ns_ncache.c ns_xfr.c ns_glue.c \
|
||||
ns_udp.c ns_config.c ns_update.c ns_ixfr.c ns_signal.c \
|
||||
ns_sort.c ns_notify.c
|
||||
OBJS= db_dump.${O} db_load.${O} db_lookup.${O} db_save.${O} db_update.${O} \
|
||||
db_glue.${O} db_ixfr.${O} db_sec.${O} db_tsig.${O} \
|
||||
ns_parser.${O} ns_lexer.${O} ns_parseutil.${O} ns_ctl.${O} \
|
||||
ns_forw.${O} ns_init.${O} ns_main.${O} ns_maint.${O} ns_req.${O} \
|
||||
ns_resp.${O} ns_stats.${O} ns_ncache.${O} ns_xfr.${O} ns_glue.${O} \
|
||||
ns_udp.${O} ns_config.${O} ns_update.${O} ns_ixfr.${O} ns_signal.${O} \
|
||||
ns_sort.${O} ns_notify.${O}
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: pathnames.h ${OBJS} ${LIBBIND} Makefile tmp_version.${O}
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
|
||||
tmp_version.${O} ${LIBBIND} ${SYSLIBS}
|
||||
|
||||
ns_parser.c ns_parser.h: ns_parser.y
|
||||
${YACC} ns_parser.y
|
||||
mv y.tab.c ns_parser.c
|
||||
mv y.tab.h ns_parser.h
|
||||
|
||||
tmp_version.${O}: tmp_version.c
|
||||
|
||||
tmp_version.c: version.c Makefile ../Makefile ${SRCS} ${HDRS}
|
||||
(u=$${USER-root} d=`pwd` h=`${HOSTNAMECMD}` t=`date`; \
|
||||
sed -e "s|%WHEN%|$${t}|" -e "s|%VERSION%|"${VER}"|" \
|
||||
-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
|
||||
< version.c > tmp_version.c); sleep 1
|
||||
|
||||
pathnames.h: ${TOP}/.settings Makefile pathtemplate.h
|
||||
rm -f pathnames.h
|
||||
sed -e "s|%DESTSBIN%|${DESTSBIN}|" \
|
||||
-e "s|%DESTEXEC%|${DESTEXEC}|" \
|
||||
-e "s|%DESTETC%|${DESTETC}|" \
|
||||
-e "s|%DESTRUN%|${DESTRUN}|" \
|
||||
< pathtemplate.h > pathnames.h
|
||||
|
||||
ns_signal.${O}: ns_signal.c
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} -c $*.c
|
||||
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
distclean: clean
|
||||
rm -f ns_parser.c ns_parser.h
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
rm -f tmp_version.c tmp_version.${O}
|
||||
rm -f pathnames.h y.tab.h y.tab.c
|
||||
|
||||
depend: ${SRCS} pathnames.h
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${DEFS} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTSBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTSBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTSBIN} ${PROG}${EXE}
|
||||
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTSBIN}/${PROG}${EXE}
|
||||
|
||||
links: FRC
|
||||
@ln -s SRC/*.[chy] SRC/test .; rm -f ns_parser.[ch]
|
||||
|
||||
tags: FRC
|
||||
ctags ${SRCS} *.h
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
@@ -1,341 +0,0 @@
|
||||
/*
|
||||
* from db.h 4.16 (Berkeley) 6/1/90
|
||||
* $Id: db_defs.h,v 8.48 2002/11/17 14:51:50 marka Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global definitions for data base routines.
|
||||
*/
|
||||
|
||||
/* max length of data in RR data field */
|
||||
#define MAXDATA (3*MAXDNAME + 5*INT32SZ)
|
||||
|
||||
/* max length of data in a TXT RR segment */
|
||||
#define MAXCHARSTRING 255
|
||||
|
||||
#define DB_ROOT_TIMBUF 3600
|
||||
#define TIMBUF 300
|
||||
|
||||
#define DICT_INDEXBITS 24
|
||||
#define DICT_MAXLENGTH 127
|
||||
#define DICT_INSERT_P 0x0001
|
||||
|
||||
/* Average hash chain depths. */
|
||||
#define AVGCH_MARSHAL 5
|
||||
#define AVGCH_NLOOKUP 3
|
||||
|
||||
/* Nonstandard maximum class to force better packing. */
|
||||
#define ZONE_BITS 24
|
||||
#define CLASS_BITS 8
|
||||
#define ZONE_MAX ((1<<ZONE_BITS)-1)
|
||||
#define CLASS_MAX ((1<<CLASS_BITS)-1)
|
||||
|
||||
/*
|
||||
* Hash table structures.
|
||||
*/
|
||||
/*
|
||||
* XXX
|
||||
* For IPv6 transport support we need a seperate reference counted
|
||||
* database of source addresses and d_addr should become a union with
|
||||
* a pointer into that database. A bit can be robbed from d_rode to
|
||||
* indicate what the union is being used for. This should require less
|
||||
* memory than making d_addr a union of struct in6_addr and struct in_addr.
|
||||
*/
|
||||
#ifdef CHECK_MAGIC
|
||||
#define DATABUF_MAGIC (('D'<<24)|('A'<<16)|('T'<<8)|'A')
|
||||
#endif
|
||||
|
||||
struct databuf {
|
||||
#ifdef CHECK_MAGIC
|
||||
u_int32_t d_magic; /* magic number */
|
||||
#endif
|
||||
struct databuf *d_next; /* linked list */
|
||||
struct in_addr d_addr; /* NS from whence this came */
|
||||
u_int32_t d_ttl; /* time to live */
|
||||
/* if d_zone == DB_Z_CACHE, then
|
||||
* d_ttl is actually the time when
|
||||
* the record will expire.
|
||||
* otherwise (for authoritative
|
||||
* master and slave zones),
|
||||
* d_ttl is the time to live.
|
||||
*/
|
||||
unsigned d_zone :ZONE_BITS; /* zone number or 0 for the cache */
|
||||
unsigned d_class :CLASS_BITS; /* class number (nonstandard limit) */
|
||||
unsigned d_flags :4; /* DB_F_{??????} */
|
||||
unsigned d_secure :2; /* DB_S_{??????} */
|
||||
unsigned d_cred :3; /* DB_C_{??????} */
|
||||
unsigned d_clev :6;
|
||||
unsigned d_rcode :4; /* rcode for negative caching */
|
||||
unsigned d_mark :3; /* place to mark data */
|
||||
unsigned d_noedns :1; /* this server does not support edns */
|
||||
int16_t d_type; /* type number */
|
||||
int16_t d_size; /* size of data area */
|
||||
u_int32_t d_rcnt;
|
||||
#ifdef HITCOUNTS
|
||||
u_int32_t d_hitcnt; /* Number of requests for this data. */
|
||||
#endif /* HITCOUNTS */
|
||||
u_int16_t d_nstime; /* NS response time, milliseconds */
|
||||
u_char d_data[sizeof(void*)]; /* dynamic (padded) */
|
||||
};
|
||||
#define BIND_DATASIZE(n) (sizeof(struct databuf) - sizeof(void*) + n)
|
||||
|
||||
#ifdef HITCOUNTS
|
||||
extern u_int32_t db_total_hits;
|
||||
#endif /* HITCOUNTS */
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
/*
|
||||
* d_mark definitions
|
||||
*/
|
||||
#define D_MARK_DELETED 0x01
|
||||
#define D_MARK_ADDED 0x02
|
||||
#define D_MARK_FOUND 0x04
|
||||
#endif
|
||||
|
||||
/*
|
||||
* d_flags definitions
|
||||
*/
|
||||
#define DB_F_HINT 0x01 /* databuf belongs to fcachetab */
|
||||
#define DB_F_ACTIVE 0x02 /* databuf is linked into a cache */
|
||||
#define DB_F_FREE 0x04 /* databuf has been freed */
|
||||
#define DB_F_LAME 0x08 /* databuf may refer to lame server */
|
||||
|
||||
/*
|
||||
* d_cred definitions
|
||||
*/
|
||||
#define DB_C_ZONE 4 /* authoritative zone - best */
|
||||
#define DB_C_AUTH 3 /* authoritative answer */
|
||||
#define DB_C_ANSWER 2 /* non-authoritative answer */
|
||||
#define DB_C_ADDITIONAL 1 /* additional data */
|
||||
#define DB_C_CACHE 0 /* cache - worst */
|
||||
|
||||
/*
|
||||
* d_secure definitions
|
||||
*/
|
||||
#define DB_S_SECURE 2 /* secure (verified) data */
|
||||
#define DB_S_INSECURE 1 /* insecure data */
|
||||
#define DB_S_FAILED 0 /* data that failed a security check */
|
||||
|
||||
struct namebuf {
|
||||
u_int n_hashval; /* hash value of _n_name */
|
||||
struct namebuf *n_next; /* linked list */
|
||||
struct databuf *n_data; /* data records */
|
||||
struct namebuf *n_parent; /* parent domain */
|
||||
struct hashbuf *n_hash; /* hash table for children */
|
||||
union {
|
||||
char _n_name[sizeof(void*)];
|
||||
unsigned char _n_len[sizeof(void*)];
|
||||
} _n; /* Counted str (dynamic). */
|
||||
};
|
||||
#define NAMESIZE(n) (sizeof(struct namebuf) - sizeof(void*) + 1 + n + 1)
|
||||
#define NAMELEN(nb) ((((nb)._n._n_len))[0])
|
||||
#define NAME(nb) ((nb)._n._n_name + 1)
|
||||
|
||||
struct hashbuf {
|
||||
int h_size; /* size of hash table */
|
||||
int h_cnt; /* number of entries */
|
||||
struct namebuf *h_tab[1]; /* allocated as needed */
|
||||
};
|
||||
#define HASHSIZE(s) (sizeof(struct hashbuf) + (s-1) * sizeof(struct namebuf *))
|
||||
|
||||
#define HASHSHIFT 3
|
||||
#define HASHMASK 0x1f
|
||||
#define HASHROTATE(v) \
|
||||
(((v) << HASHSHIFT) | ((v) >> ((sizeof(v) * 8) - HASHSHIFT)))
|
||||
#define HASHLOWER(c) ((isascii(c) && isupper(c)) ? tolower(c) : (c))
|
||||
#define HASHIMILATE(v,c) ((v) = (HASHROTATE(v)) + (HASHLOWER(c) & HASHMASK))
|
||||
|
||||
#define TSIG_BUF_SIZE 640
|
||||
#define TSIG_SIG_SIZE 20
|
||||
|
||||
struct tsig_record {
|
||||
u_int8_t sig[TSIG_SIG_SIZE];
|
||||
struct dst_key *key;
|
||||
int siglen;
|
||||
int tsig_size;
|
||||
};
|
||||
|
||||
struct sig_record {
|
||||
u_int16_t sig_type_n;
|
||||
u_int8_t sig_alg_n, sig_labels_n;
|
||||
u_int32_t sig_ottl_n, sig_exp_n, sig_time_n;
|
||||
u_int16_t sig_keyid_n;
|
||||
};
|
||||
|
||||
/* This is the wire format size of "struct sig_record", i.e., no padding. */
|
||||
#define SIG_HDR_SIZE 18
|
||||
|
||||
struct dnode {
|
||||
struct databuf *dp;
|
||||
struct dnode *dn_next;
|
||||
int line;
|
||||
const char *file;
|
||||
};
|
||||
|
||||
typedef struct dnode * dlist;
|
||||
|
||||
struct db_rrset {
|
||||
dlist rr_list;
|
||||
dlist rr_sigs;
|
||||
char *rr_name;
|
||||
int16_t rr_class;
|
||||
int16_t rr_type;
|
||||
struct db_rrset *rr_next;
|
||||
};
|
||||
#define DBHASHSIZE(s) (sizeof(struct hashbuf) + \
|
||||
(s-1) * sizeof(struct db_rrset *))
|
||||
|
||||
#define SIG_COVERS(dp) (ns_get16(dp->d_data))
|
||||
|
||||
/*
|
||||
* Flags to updatedb
|
||||
*/
|
||||
#define DB_NODATA 0x01 /* data should not exist */
|
||||
#define DB_MEXIST 0x02 /* data must exist */
|
||||
#define DB_DELETE 0x04 /* delete data if it exists */
|
||||
#define DB_NOTAUTH 0x08 /* must not update authoritative data */
|
||||
#define DB_NOHINTS 0x10 /* don't reflect update in fcachetab */
|
||||
#define DB_PRIMING 0x20 /* is this update the result of priming? */
|
||||
#define DB_MERGE 0x40 /* make no control on rr in db_update (for ixfr) */
|
||||
#define DB_REPLACE 0x80 /* replace data if it exists */
|
||||
|
||||
#define DB_Z_CACHE 0 /* cache-zone-only db_dump() */
|
||||
#define DB_Z_ALL 65535 /* normal db_dump() */
|
||||
#define DB_Z_SPECIAL(z) ((z) == DB_Z_CACHE || (z) == DB_Z_ALL)
|
||||
|
||||
/*
|
||||
* Error return codes
|
||||
*/
|
||||
#define OK 0
|
||||
#define NONAME (-1)
|
||||
#define NOCLASS (-2)
|
||||
#define NOTYPE (-3)
|
||||
#define NODATA (-4)
|
||||
#define DATAEXISTS (-5)
|
||||
#define NODBFILE (-6)
|
||||
#define TOOMANYZONES (-7)
|
||||
#define GOODDB (-8)
|
||||
#define NEWDB (-9)
|
||||
#define AUTH (-10)
|
||||
#ifdef BIND_UPDATE
|
||||
#define SERIAL (-11)
|
||||
#endif
|
||||
#define CNAMEANDOTHER (-12)
|
||||
#define DNSSECFAIL (-13) /* db_set_update */
|
||||
#define NONGLUE (-14)
|
||||
|
||||
/*
|
||||
* getnum() options
|
||||
*/
|
||||
#define GETNUM_NONE 0x00 /* placeholder */
|
||||
#define GETNUM_SERIAL 0x01 /* treat as serial number */
|
||||
#define GETNUM_SCALED 0x02 /* permit "k", "m" suffixes, scale result */
|
||||
|
||||
/*
|
||||
* db_load() options
|
||||
*/
|
||||
#define ISNOTIXFR 0
|
||||
#define ISIXFR 1
|
||||
#define ISAXFRIXFR 2
|
||||
|
||||
/*
|
||||
* Database access abstractions.
|
||||
*/
|
||||
#define foreach_rr(dp, np, ty, cl, zn) \
|
||||
for ((dp) = (np)->n_data; (dp) != NULL; (dp) = (dp)->d_next) \
|
||||
if (!match(dp, (cl), (ty))) \
|
||||
continue; \
|
||||
else if (((zn) == DB_Z_CACHE) \
|
||||
? stale(dp) \
|
||||
: (zn) != (dp)->d_zone) \
|
||||
continue; \
|
||||
else if ((dp)->d_rcode) \
|
||||
continue; \
|
||||
else \
|
||||
/* Caller code follows in sequence. */
|
||||
|
||||
#define DRCNTINC(x) \
|
||||
do { \
|
||||
if (++((x)->d_rcnt) == 0) \
|
||||
ns_panic(ns_log_db, 1, "++d_rcnt == 0"); \
|
||||
} while (0)
|
||||
|
||||
#define DRCNTDEC(x) \
|
||||
do { \
|
||||
if (((x)->d_rcnt)-- == 0) \
|
||||
ns_panic(ns_log_db, 1, "d_rcnt-- == 0"); \
|
||||
} while (0)
|
||||
|
||||
#define ISVALIDGLUE(xdp) ((xdp)->d_type == T_NS || (xdp)->d_type == T_A \
|
||||
|| (xdp)->d_type == T_AAAA || (xdp)->d_type == ns_t_a6)
|
||||
|
||||
@@ -1,702 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)db_dump.c 4.33 (Berkeley) 3/3/91";
|
||||
static const char rcsid[] = "$Id: db_dump.c,v 8.51 2001/06/18 14:42:49 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986, 1988, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1995 by International Business Machines, Inc.
|
||||
*
|
||||
* International Business Machines, Inc. (hereinafter called IBM) grants
|
||||
* permission under its copyrights to use, copy, modify, and distribute this
|
||||
* Software with or without fee, provided that the above copyright notice and
|
||||
* all paragraphs of this notice appear in all copies, and that the name of IBM
|
||||
* not be used in connection with the marketing of any product incorporating
|
||||
* the Software or modifications thereof, without specific, written prior
|
||||
* permission.
|
||||
*
|
||||
* To the extent it has a right to do so, IBM grants an immunity from suit
|
||||
* under its patents, if any, for the use, sale or manufacture of products to
|
||||
* the extent that such products are used for performing Domain Name System
|
||||
* dynamic updates in TCP/IP networks by means of the Software. No immunity is
|
||||
* granted for any product per se or for any other function of any product.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
|
||||
* DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
|
||||
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/misc.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
#ifdef HITCOUNTS
|
||||
u_int32_t db_total_hits;
|
||||
#endif /* HITCOUNTS */
|
||||
|
||||
static const char *MkCredStr(int);
|
||||
|
||||
static int fwd_dump(FILE *fp);
|
||||
|
||||
/*
|
||||
* Dump current data base in a format similar to RFC 883.
|
||||
*/
|
||||
|
||||
void
|
||||
doadump(void) {
|
||||
FILE *fp;
|
||||
|
||||
ns_notice(ns_log_db, "dumping nameserver data");
|
||||
|
||||
if ((fp = write_open(server_options->dump_filename)) == NULL)
|
||||
return;
|
||||
gettime(&tt);
|
||||
#ifdef HITCOUNTS
|
||||
if (NS_OPTION_P(OPTION_HITCOUNT))
|
||||
fprintf(fp, "; Total hits: %d\n",db_total_hits);
|
||||
#endif /* HITCOUNTS */
|
||||
fprintf(fp, "; Dumped at %s", ctimel(tt.tv_sec));
|
||||
if (zones != NULL && nzones != 0)
|
||||
zt_dump(fp);
|
||||
if (fwddata != NULL && fwddata_count != 0)
|
||||
fwd_dump(fp);
|
||||
fputs(
|
||||
"; Note: Cr=(auth,answer,addtnl,cache) tag only shown for non-auth RR's\n",
|
||||
fp);
|
||||
fputs(
|
||||
"; Note: NT=milliseconds for any A RR which we've used as a nameserver\n",
|
||||
fp);
|
||||
fprintf(fp, "; --- Cache & Data ---\n");
|
||||
if (hashtab != NULL)
|
||||
(void) db_dump(hashtab, fp, DB_Z_ALL, "");
|
||||
fprintf(fp, "; --- Hints ---\n");
|
||||
if (fcachetab != NULL)
|
||||
(void) db_dump(fcachetab, fp, DB_Z_ALL, "");
|
||||
(void) my_fclose(fp);
|
||||
ns_notice(ns_log_db, "finished dumping nameserver data");
|
||||
}
|
||||
|
||||
int
|
||||
zt_dump(FILE *fp) {
|
||||
struct zoneinfo *zp;
|
||||
|
||||
fprintf(fp, ";; ++zone table++\n");
|
||||
for (zp = &zones[0]; zp < &zones[nzones]; zp++) {
|
||||
const char *pre;
|
||||
char buf[64];
|
||||
u_int cnt;
|
||||
|
||||
if (!zp->z_origin)
|
||||
continue;
|
||||
|
||||
fprintf(fp, "; %s (type %d, class %d, source %s)\n",
|
||||
zp->z_origin
|
||||
? (*zp->z_origin ? zp->z_origin : ".")
|
||||
: "Nil",
|
||||
zp->z_type, zp->z_class,
|
||||
zp->z_source ? zp->z_source : "Nil");
|
||||
fprintf(fp, ";\ttime=%lu, lastupdate=%lu, serial=%u,\n",
|
||||
(u_long)zp->z_time, (u_long)zp->z_lastupdate,
|
||||
zp->z_serial);
|
||||
fprintf(fp, ";\trefresh=%u, retry=%u, expire=%u, minimum=%u\n",
|
||||
zp->z_refresh, zp->z_retry,
|
||||
zp->z_expire, zp->z_minimum);
|
||||
fprintf(fp, ";\tftime=%lu, xaddrcnt=%d, state=%04x, pid=%d\n",
|
||||
(u_long)zp->z_ftime, zp->z_xaddrcnt,
|
||||
zp->z_flags, (int)zp->z_xferpid);
|
||||
sprintf(buf, ";\tz_addr[%d]: ", zp->z_addrcnt);
|
||||
pre = buf;
|
||||
for (cnt = 0; cnt < zp->z_addrcnt; cnt++) {
|
||||
fprintf(fp, "%s[%s]", pre, inet_ntoa(zp->z_addr[cnt]));
|
||||
pre = ", ";
|
||||
}
|
||||
if (zp->z_addrcnt)
|
||||
fputc('\n', fp);
|
||||
if (zp->z_axfr_src.s_addr != 0)
|
||||
fprintf(fp, ";\tupdate source [%s]\n",
|
||||
inet_ntoa(zp->z_axfr_src));
|
||||
}
|
||||
fprintf(fp, ";; --zone table--\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
fwd_dump(FILE *fp) {
|
||||
int i;
|
||||
|
||||
fprintf(fp, ";; ++forwarders table++\n");
|
||||
for (i = 0; i < fwddata_count; i++) {
|
||||
if (fwddata[i] != NULL)
|
||||
fprintf(fp,"; %s rtt=%d\n",
|
||||
inet_ntoa(fwddata[i]->fwdaddr.sin_addr),
|
||||
fwddata[i]->nsdata->d_nstime);
|
||||
}
|
||||
fprintf(fp, ";; --forwarders table--\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
db_dump(struct hashbuf *htp, FILE *fp, int zone, const char *origin) {
|
||||
struct databuf *dp = NULL;
|
||||
struct namebuf *np;
|
||||
struct namebuf **npp, **nppend;
|
||||
char dname[MAXDNAME];
|
||||
u_int32_t n;
|
||||
int j, i, found_data, tab, printed_origin;
|
||||
u_char *cp, *end;
|
||||
const char *proto, *sep;
|
||||
int16_t type;
|
||||
u_int16_t keyflags;
|
||||
u_char *sigdata, *certdata;
|
||||
u_char *savecp;
|
||||
char temp_base64[NS_MD5RSA_MAX_BASE64];
|
||||
|
||||
found_data = 0;
|
||||
printed_origin = 0;
|
||||
npp = htp->h_tab;
|
||||
nppend = npp + htp->h_size;
|
||||
while (npp < nppend) {
|
||||
for (np = *npp++; np != NULL; np = np->n_next) {
|
||||
if (np->n_data == NULL)
|
||||
continue;
|
||||
/* Blecch - can't tell if there is data here for the
|
||||
* right zone, so can't print name yet
|
||||
*/
|
||||
found_data = 0;
|
||||
/* we want a snapshot in time... */
|
||||
for (dp = np->n_data; dp != NULL; dp = dp->d_next) {
|
||||
/* Is the data for this zone? */
|
||||
if (zone != DB_Z_ALL && dp->d_zone != zone)
|
||||
continue;
|
||||
/* XXX why are we not calling stale() here? */
|
||||
if (dp->d_zone == DB_Z_CACHE &&
|
||||
dp->d_ttl <= (u_int32_t)tt.tv_sec &&
|
||||
(dp->d_flags & DB_F_HINT) == 0)
|
||||
continue;
|
||||
if (!printed_origin) {
|
||||
fprintf(fp, "$ORIGIN %s.\n", origin);
|
||||
printed_origin++;
|
||||
}
|
||||
tab = 0;
|
||||
if (dp->d_rcode == NXDOMAIN ||
|
||||
dp->d_rcode == NOERROR_NODATA) {
|
||||
fputc(';', fp);
|
||||
} else if (found_data == 0 || found_data == 1) {
|
||||
found_data = 2;
|
||||
}
|
||||
if (found_data == 0 || found_data == 2) {
|
||||
if (NAME(*np)[0] == '\0') {
|
||||
if (origin[0] == '\0')
|
||||
fprintf(fp, ".\t");
|
||||
else
|
||||
fprintf(fp, ".%s.\t", origin); /* ??? */
|
||||
} else
|
||||
fprintf(fp, "%s\t", NAME(*np));
|
||||
if (NAMELEN(*np) < (unsigned)8)
|
||||
tab = 1;
|
||||
found_data++;
|
||||
} else {
|
||||
(void) putc('\t', fp);
|
||||
tab = 1;
|
||||
}
|
||||
if (dp->d_zone == DB_Z_CACHE) {
|
||||
if (dp->d_flags & DB_F_HINT &&
|
||||
(int32_t)(dp->d_ttl - tt.tv_sec)
|
||||
< DB_ROOT_TIMBUF)
|
||||
fprintf(fp, "%d\t", DB_ROOT_TIMBUF);
|
||||
else
|
||||
fprintf(fp, "%d\t",
|
||||
(int)(dp->d_ttl - tt.tv_sec));
|
||||
} else if (dp->d_ttl != USE_MINIMUM)
|
||||
fprintf(fp, "%u\t", dp->d_ttl);
|
||||
else
|
||||
fprintf(fp, "%u\t",
|
||||
zones[dp->d_zone].z_minimum);
|
||||
fprintf(fp, "%s\t%s\t",
|
||||
p_class(dp->d_class),
|
||||
p_type(dp->d_type));
|
||||
cp = (u_char *)dp->d_data;
|
||||
sep = "\t;";
|
||||
type = dp->d_type;
|
||||
if (dp->d_rcode == NXDOMAIN ||
|
||||
dp->d_rcode == NOERROR_NODATA) {
|
||||
#ifdef RETURNSOA
|
||||
if (dp->d_size == 0) {
|
||||
#endif
|
||||
|
||||
fprintf(fp, "%s%s-$",
|
||||
(dp->d_rcode == NXDOMAIN)
|
||||
?"NXDOMAIN" :"NODATA",
|
||||
sep);
|
||||
goto eoln;
|
||||
#ifdef RETURNSOA
|
||||
} else {
|
||||
type = T_SOA;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Print type specific data
|
||||
*/
|
||||
/* XXX why are we not using ns_sprintrr() here? */
|
||||
switch (type) {
|
||||
case T_A:
|
||||
switch (dp->d_class) {
|
||||
case C_IN:
|
||||
case C_HS:
|
||||
fputs(inet_ntoa(ina_get(cp)), fp);
|
||||
break;
|
||||
}
|
||||
if (dp->d_nstime) {
|
||||
fprintf(fp, "%sNT=%d",
|
||||
sep, dp->d_nstime);
|
||||
sep = " ";
|
||||
}
|
||||
break;
|
||||
case T_CNAME:
|
||||
case T_MB:
|
||||
case T_MG:
|
||||
case T_MR:
|
||||
case T_PTR:
|
||||
fprintf(fp, "%s.", cp);
|
||||
break;
|
||||
|
||||
case T_NS:
|
||||
cp = (u_char *)dp->d_data;
|
||||
if (cp[0] == '\0')
|
||||
fprintf(fp, ".\t");
|
||||
else
|
||||
fprintf(fp, "%s.", cp);
|
||||
break;
|
||||
|
||||
case T_HINFO:
|
||||
case T_ISDN: {
|
||||
char buf[256];
|
||||
|
||||
if ((n = *cp++) != '\0') {
|
||||
memcpy(buf, cp, n); buf[n] = '\0';
|
||||
fprintf(fp, "\"%.*s\"", (int)n, buf);
|
||||
cp += n;
|
||||
} else
|
||||
fprintf(fp, "\"\"");
|
||||
if ((n = *cp++) != '\0') {
|
||||
memcpy(buf, cp, n); buf[n] = '\0';
|
||||
fprintf(fp, " \"%.*s\"", (int)n, buf);
|
||||
} else
|
||||
fprintf(fp, " \"\"");
|
||||
break;
|
||||
}
|
||||
|
||||
case T_SOA:
|
||||
fprintf(fp, "%s.", cp);
|
||||
cp += strlen((char *)cp) + 1;
|
||||
fprintf(fp, " %s. (\n", cp);
|
||||
#if defined(RETURNSOA)
|
||||
if (dp->d_rcode)
|
||||
fputs(";", fp);
|
||||
#endif
|
||||
cp += strlen((char *)cp) + 1;
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, "\t\t%u", n);
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, " %u", n);
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, " %u", n);
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, " %u", n);
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, " %u )", n);
|
||||
#if defined(RETURNSOA)
|
||||
if (dp->d_rcode) {
|
||||
fprintf(fp,";%s.;%s%s-$",cp,
|
||||
(dp->d_rcode == NXDOMAIN) ?
|
||||
"NXDOMAIN" : "NODATA",
|
||||
sep);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case T_MX:
|
||||
case T_AFSDB:
|
||||
case T_RT:
|
||||
NS_GET16(n, cp);
|
||||
fprintf(fp, "%u", n);
|
||||
fprintf(fp, " %s.", cp);
|
||||
break;
|
||||
|
||||
case T_PX:
|
||||
NS_GET16(n, cp);
|
||||
fprintf(fp, "%u", n);
|
||||
fprintf(fp, " %s.", cp);
|
||||
cp += strlen((char *)cp) + 1;
|
||||
fprintf(fp, " %s.", cp);
|
||||
break;
|
||||
|
||||
case T_X25:
|
||||
if ((n = *cp++) != '\0')
|
||||
fprintf(fp, " \"%.*s\"", (int)n, cp);
|
||||
else
|
||||
fprintf(fp, " \"\"");
|
||||
break;
|
||||
|
||||
case T_TXT:
|
||||
end = (u_char *)dp->d_data + dp->d_size;
|
||||
while (cp < end) {
|
||||
(void) putc('"', fp);
|
||||
if ((n = *cp++) != '\0') {
|
||||
for (j = n ; j > 0 && cp < end ; j--) {
|
||||
if (*cp == '\n' || *cp == '"' || *cp == '\\')
|
||||
(void) putc('\\', fp);
|
||||
(void) putc(*cp++, fp);
|
||||
}
|
||||
}
|
||||
(void) putc('"', fp);
|
||||
if (cp < end)
|
||||
(void) putc(' ', fp);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_NSAP:
|
||||
(void) fputs(inet_nsap_ntoa(dp->d_size,
|
||||
dp->d_data, NULL),
|
||||
fp);
|
||||
break;
|
||||
|
||||
case T_AAAA: {
|
||||
char t[sizeof
|
||||
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"
|
||||
];
|
||||
|
||||
(void) fputs(inet_ntop(AF_INET6, dp->d_data,
|
||||
t, sizeof t),
|
||||
fp);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_LOC: {
|
||||
char t[256];
|
||||
|
||||
(void) fputs(loc_ntoa(dp->d_data, t), fp);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_NAPTR: {
|
||||
u_int32_t order, preference;
|
||||
|
||||
NS_GET16(order, cp);
|
||||
fprintf(fp, "%u", order);
|
||||
|
||||
NS_GET16(preference, cp);
|
||||
fprintf(fp, "%u", preference);
|
||||
|
||||
n = *cp++;
|
||||
fprintf(fp, "\"%.*s\"", (int)n, cp);
|
||||
cp += n;
|
||||
|
||||
n = *cp++;
|
||||
fprintf(fp, "\"%.*s\"", (int)n, cp);
|
||||
cp += n;
|
||||
|
||||
n = *cp++;
|
||||
fprintf(fp, " \"%.*s\"", (int)n, cp);
|
||||
cp += n;
|
||||
|
||||
fprintf(fp, " %s.", cp);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case T_SRV: {
|
||||
u_int priority, weight, port;
|
||||
|
||||
NS_GET16(priority, cp);
|
||||
NS_GET16(weight, cp);
|
||||
NS_GET16(port, cp);
|
||||
fprintf(fp, "\t%u %u %u %s.",
|
||||
priority, weight, port, cp);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_WKS:
|
||||
fputs(inet_ntoa(ina_get(cp)), fp);
|
||||
cp += INADDRSZ;
|
||||
proto = protocolname(*cp);
|
||||
cp += sizeof(char);
|
||||
fprintf(fp, " %s ", proto);
|
||||
i = 0;
|
||||
while(cp < (u_char *)dp->d_data + dp->d_size) {
|
||||
j = *cp++;
|
||||
do {
|
||||
if (j & 0200)
|
||||
fprintf(fp, " %s",
|
||||
servicename(i, proto));
|
||||
j <<= 1;
|
||||
} while (++i & 07);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_MINFO:
|
||||
case T_RP:
|
||||
fprintf(fp, "%s.", cp);
|
||||
cp += strlen((char *)cp) + 1;
|
||||
fprintf(fp, " %s.", cp);
|
||||
break;
|
||||
|
||||
case T_KEY:
|
||||
savecp = cp; /* save the beginning */
|
||||
/*>>> Flags (unsigned_16) */
|
||||
NS_GET16(keyflags,cp);
|
||||
fprintf(fp, "0x%04x ", keyflags);
|
||||
/*>>> Protocol (8-bit decimal) */
|
||||
fprintf(fp, "%3u ", *cp++);
|
||||
/*>>> Algorithm id (8-bit decimal) */
|
||||
fprintf(fp, "%3u ", *cp++);
|
||||
|
||||
/*>>> Public-Key Data (multidigit BASE64) */
|
||||
/* containing ExponentLen, Exponent, and Modulus */
|
||||
i = b64_ntop(cp, dp->d_size - (cp - savecp),
|
||||
temp_base64,
|
||||
sizeof temp_base64);
|
||||
if (i < 0)
|
||||
fprintf(fp, "; BAD BASE64");
|
||||
else
|
||||
fprintf(fp, "%s", temp_base64);
|
||||
break;
|
||||
|
||||
case T_SIG:
|
||||
sigdata = cp;
|
||||
/* RRtype (char *) */
|
||||
NS_GET16(n,cp);
|
||||
fprintf(fp, "%s ", p_type(n));
|
||||
/* Algorithm id (8-bit decimal) */
|
||||
fprintf(fp, "%d ", *cp++);
|
||||
/* Labels (8-bit decimal) */
|
||||
fprintf(fp, "%d ", *cp++);
|
||||
/* OTTL (u_long) */
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, "%u ", n);
|
||||
/* Texp (u_long) */
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, "%s ", p_secstodate (n));
|
||||
/* Tsig (u_long) */
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, "%s ", p_secstodate (n));
|
||||
/* Kfootprint (unsigned_16) */
|
||||
NS_GET16(n, cp);
|
||||
fprintf(fp, "%u ", n);
|
||||
/* Signer's Name (char *) */
|
||||
fprintf(fp, "%s ", cp);
|
||||
cp += strlen((char *)cp) + 1;
|
||||
/* Signature (base64 of any length) */
|
||||
i = b64_ntop(cp, dp->d_size - (cp - sigdata),
|
||||
temp_base64,
|
||||
sizeof temp_base64);
|
||||
if (i < 0)
|
||||
fprintf(fp, "; BAD BASE64");
|
||||
else
|
||||
fprintf(fp, "%s", temp_base64);
|
||||
break;
|
||||
|
||||
case T_NXT:
|
||||
fprintf(fp, "%s.", cp);
|
||||
n = strlen ((char *)cp) + 1;
|
||||
cp += n;
|
||||
i = 8 * (dp->d_size - n); /* How many bits? */
|
||||
for (n = 0; n < (u_int32_t)i; n++) {
|
||||
if (NS_NXT_BIT_ISSET(n, cp))
|
||||
fprintf(fp," %s", p_type(n));
|
||||
}
|
||||
break;
|
||||
|
||||
case ns_t_cert:
|
||||
certdata = cp;
|
||||
NS_GET16(n,cp);
|
||||
fprintf(fp, "%d ", n); /* cert type */
|
||||
|
||||
NS_GET16(n,cp);
|
||||
fprintf(fp, "%d %d ", n, *cp++); /* tag & alg */
|
||||
|
||||
/* Certificate (base64 of any length) */
|
||||
i = b64_ntop(cp,
|
||||
dp->d_size - (cp - certdata),
|
||||
temp_base64, sizeof(temp_base64));
|
||||
if (i < 0)
|
||||
fprintf(fp, "; BAD BASE64");
|
||||
else
|
||||
fprintf(fp, "%s", temp_base64);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(fp, "\\# %u", dp->d_size);
|
||||
if (dp->d_size != 0) {
|
||||
fputs(" ( ", fp);
|
||||
isc_puthexstring(fp, dp->d_data,
|
||||
dp->d_size, 40, 48,
|
||||
"\n\t\t\t\t");
|
||||
fputs(" ) ", fp);
|
||||
}
|
||||
}
|
||||
if (dp->d_cred < DB_C_ZONE) {
|
||||
fprintf(fp, "%sCr=%s",
|
||||
sep, MkCredStr(dp->d_cred));
|
||||
sep = " ";
|
||||
} else {
|
||||
fprintf(fp, "%sCl=%d",
|
||||
sep, dp->d_clev);
|
||||
sep = " ";
|
||||
}
|
||||
if ((dp->d_flags & DB_F_LAME) != 0) {
|
||||
time_t when;
|
||||
getname(np, dname, sizeof(dname));
|
||||
when = db_lame_find(dname, dp);
|
||||
if (when != 0 && when > tt.tv_sec) {
|
||||
fprintf(fp, "%sLAME=%ld",
|
||||
sep, when - tt.tv_sec);
|
||||
sep = " ";
|
||||
}
|
||||
}
|
||||
|
||||
eoln:
|
||||
if (dp->d_addr.s_addr != htonl(0)) {
|
||||
fprintf(fp, "%s[%s]",
|
||||
sep, inet_ntoa(dp->d_addr));
|
||||
sep = " ";
|
||||
}
|
||||
#ifdef HITCOUNTS
|
||||
if (NS_OPTION_P(OPTION_HITCOUNT)) {
|
||||
fprintf(fp, "%shits=%d", sep, dp->d_hitcnt);
|
||||
sep=" ";
|
||||
}
|
||||
#endif /* HITCOUNTS */
|
||||
putc('\n', fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ferror(fp))
|
||||
return (NODBFILE);
|
||||
|
||||
npp = htp->h_tab;
|
||||
nppend = npp + htp->h_size;
|
||||
while (npp < nppend) {
|
||||
for (np = *npp++; np != NULL; np = np->n_next) {
|
||||
if (np->n_hash == NULL)
|
||||
continue;
|
||||
getname(np, dname, sizeof(dname));
|
||||
if (db_dump(np->n_hash, fp, zone, dname) == NODBFILE)
|
||||
return (NODBFILE);
|
||||
}
|
||||
}
|
||||
return (OK);
|
||||
}
|
||||
|
||||
static const char *
|
||||
MkCredStr(int cred) {
|
||||
static char badness[20];
|
||||
|
||||
switch (cred) {
|
||||
case DB_C_ZONE: return "zone";
|
||||
case DB_C_AUTH: return "auth";
|
||||
case DB_C_ANSWER: return "answer";
|
||||
case DB_C_ADDITIONAL: return "addtnl";
|
||||
case DB_C_CACHE: return "cache";
|
||||
default: break;
|
||||
}
|
||||
sprintf(badness, "?%d?", cred);
|
||||
return (badness);
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1985, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1999 by Check Point Software Technologies, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Check Point Software Technologies Incorporated not be used
|
||||
* in advertising or publicity pertaining to distribution of the document
|
||||
* or software without specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND CHECK POINT SOFTWARE TECHNOLOGIES
|
||||
* INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL CHECK POINT SOFTWARE TECHNOLOGIES INCORPRATED
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* db_proc.h - prototypes for functions in db_*.c
|
||||
*
|
||||
* $Id: db_func.h,v 8.46 2001/06/18 14:42:51 marka Exp $
|
||||
*/
|
||||
|
||||
/* ++from db_update.c++ */
|
||||
int db_update(const char *name,
|
||||
struct databuf *odp,
|
||||
struct databuf *newdp,
|
||||
struct databuf **savedpp,
|
||||
int flags,
|
||||
struct hashbuf *htp,
|
||||
struct sockaddr_in from);
|
||||
int db_cmp(const struct databuf *, const struct databuf *);
|
||||
int findMyZone(struct namebuf *np, int class);
|
||||
void fixttl(struct databuf *dp);
|
||||
/* --from db_update.c-- */
|
||||
|
||||
/* ++from db_save.c++ */
|
||||
struct namebuf * savename(const char *, int);
|
||||
struct databuf * savedata(int, int, u_int32_t, u_char *, int);
|
||||
struct hashbuf * savehash(struct hashbuf *);
|
||||
/* --from db_save.c-- */
|
||||
|
||||
/* ++from db_dump.c++ */
|
||||
int db_dump(struct hashbuf *, FILE *, int, const char *),
|
||||
zt_dump(FILE *);
|
||||
void doadump(void);
|
||||
/* --from db_dump.c-- */
|
||||
|
||||
/* ++from db_load.c++ */
|
||||
int makename_ok(char *name, const char *origin, int class,
|
||||
struct zoneinfo *zp,
|
||||
enum transport transport,
|
||||
enum context context,
|
||||
const char *owner, const char *filename,
|
||||
int lineno, int size);
|
||||
void endline(FILE *);
|
||||
int getword(char *, size_t, FILE *, int);
|
||||
int getttl(FILE *, const char *, int, u_int32_t *, int *);
|
||||
int getnum(FILE *, const char *, int, int *);
|
||||
int db_load(const char *, const char *, struct zoneinfo *,
|
||||
const char *, int);
|
||||
int getnonblank(FILE *, const char *, int);
|
||||
int getservices(int, char *, FILE *, const char *);
|
||||
char getprotocol(FILE *, const char *);
|
||||
int makename(char *, const char *, int);
|
||||
void db_err(int, char *, int, const char *, int);
|
||||
int parse_sec_rdata(char *inp, int inp_len, int inp_full,
|
||||
u_char *data, int data_len,
|
||||
FILE *fp, struct zoneinfo *zp,
|
||||
char *domain, u_int32_t ttl,
|
||||
int type, enum context context,
|
||||
enum transport transport,
|
||||
const char **errmsg);
|
||||
/* --from db_load.c-- */
|
||||
|
||||
/* ++from db_glue.c++ */
|
||||
void buildservicelist(void);
|
||||
void destroyservicelist(void);
|
||||
void buildprotolist(void);
|
||||
void destroyprotolist(void);
|
||||
void getname(struct namebuf *, char *, int);
|
||||
int servicenumber(const char *);
|
||||
int protocolnumber(const char *);
|
||||
int get_class(const char *);
|
||||
u_int nhash(const char *);
|
||||
const char * protocolname(int);
|
||||
const char * servicename(u_int16_t, const char *);
|
||||
struct databuf * rm_datum(struct databuf *,
|
||||
struct namebuf *,
|
||||
struct databuf *,
|
||||
struct databuf **);
|
||||
struct namebuf * rm_name(struct namebuf *,
|
||||
struct namebuf **,
|
||||
struct namebuf *);
|
||||
void rm_hash(struct hashbuf *);
|
||||
void db_detach(struct databuf **);
|
||||
void db_lame_add(char *zone, char *server, time_t when);
|
||||
time_t db_lame_find(char *zone, struct databuf *dp);
|
||||
void db_lame_clean(void);
|
||||
void db_lame_destroy(void);
|
||||
/* --from db_glue.c-- */
|
||||
|
||||
/* ++from db_lookup.c++ */
|
||||
struct namebuf * nlookup(const char *, struct hashbuf **,
|
||||
const char **, int);
|
||||
struct namebuf * np_parent(struct namebuf *);
|
||||
int match(struct databuf *, int, int),
|
||||
nxtmatch(const char *, struct databuf *,
|
||||
struct databuf *),
|
||||
rrmatch(const char *, struct databuf *,
|
||||
struct databuf *);
|
||||
/* --from db_lookup.c-- */
|
||||
|
||||
/* ++from db_ixfr.c++ */
|
||||
ns_deltalist * ixfr_get_change_list(struct zoneinfo *, u_int32_t,
|
||||
u_int32_t);
|
||||
int ixfr_have_log(struct zoneinfo *, u_int32_t,
|
||||
u_int32_t);
|
||||
/* --from db_ixfr.c++ */
|
||||
|
||||
/* ++from db_sec.c++ */
|
||||
int add_trusted_key(const char *name, const int flags,
|
||||
const int proto, const int alg,
|
||||
const char *str);
|
||||
int db_set_update(char *name, struct databuf *dp,
|
||||
void **state, int flags,
|
||||
struct hashbuf **htp,
|
||||
struct sockaddr_in from,
|
||||
int *rrcount, int line,
|
||||
const char *file);
|
||||
/* --from db_sec.c-- */
|
||||
|
||||
/* ++from db_tsig.c++ */
|
||||
const char * tsig_alg_name(int value);
|
||||
int tsig_alg_value(char *name);
|
||||
struct dst_key * tsig_key_from_addr(struct in_addr addr);
|
||||
struct tsig_record * new_tsig(struct dst_key *key, u_char *sig, int siglen);
|
||||
void free_tsig(struct tsig_record *tsig);
|
||||
/* --from db_tsig.c-- */
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* from db.h 4.16 (Berkeley) 6/1/90
|
||||
* $Id: db_glob.h,v 8.14 2000/04/21 06:54:02 vixie Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global variables for data base routines.
|
||||
*/
|
||||
|
||||
/* ONE_WEEK maximum ttl */
|
||||
DECL u_int max_cache_ttl INIT(7*24*60*60);
|
||||
|
||||
/* no minimum ttl */
|
||||
DECL u_int min_cache_ttl INIT(0);
|
||||
|
||||
/* current line number */
|
||||
DECL int lineno INIT(0);
|
||||
|
||||
/* root hash table */
|
||||
DECL struct hashbuf *hashtab INIT(NULL);
|
||||
|
||||
/* hash table of cache read from file */
|
||||
DECL struct hashbuf *fcachetab INIT(NULL);
|
||||
|
||||
/* state of ns_reload() and ns_reconfig(). */
|
||||
DECL int reloading INIT(0);
|
||||
DECL int reconfiging INIT(0);
|
||||
DECL int noexpired INIT(0);
|
||||
|
||||
DECL const int hashsizes[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= { 2, 11, 113, 337, 977, 2053, 4073, 8011, 16001, 99887, 0 }
|
||||
#endif
|
||||
;
|
||||
@@ -1,642 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)db_glue.c 4.4 (Berkeley) 6/1/90";
|
||||
static const char rcsid[] = "$Id: db_glue.c,v 8.47 2002/05/18 01:02:54 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986, 1988
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
struct valuelist {
|
||||
struct valuelist * next;
|
||||
struct valuelist * prev;
|
||||
char * name;
|
||||
char * proto;
|
||||
int port;
|
||||
};
|
||||
static struct valuelist *servicelist, *protolist;
|
||||
|
||||
void
|
||||
buildservicelist() {
|
||||
struct servent *sp;
|
||||
struct valuelist *slp;
|
||||
|
||||
#ifdef MAYBE_HESIOD
|
||||
setservent(0);
|
||||
#else
|
||||
setservent(1);
|
||||
#endif
|
||||
while ((sp = getservent()) != NULL) {
|
||||
slp = (struct valuelist *)memget(sizeof(struct valuelist));
|
||||
if (!slp)
|
||||
panic("memget(servent)", NULL);
|
||||
slp->name = savestr(sp->s_name, 1);
|
||||
slp->proto = savestr(sp->s_proto, 1);
|
||||
slp->port = ntohs((u_int16_t)sp->s_port); /* host byt order */
|
||||
slp->next = servicelist;
|
||||
slp->prev = NULL;
|
||||
if (servicelist)
|
||||
servicelist->prev = slp;
|
||||
servicelist = slp;
|
||||
}
|
||||
endservent();
|
||||
}
|
||||
|
||||
void
|
||||
destroyservicelist() {
|
||||
struct valuelist *slp, *slp_next;
|
||||
|
||||
for (slp = servicelist; slp != NULL; slp = slp_next) {
|
||||
slp_next = slp->next;
|
||||
slp->name = freestr(slp->name);
|
||||
slp->proto = freestr(slp->proto);
|
||||
memput(slp, sizeof *slp);
|
||||
}
|
||||
servicelist = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
buildprotolist() {
|
||||
struct protoent *pp;
|
||||
struct valuelist *slp;
|
||||
|
||||
#ifdef MAYBE_HESIOD
|
||||
setprotoent(0);
|
||||
#else
|
||||
setprotoent(1);
|
||||
#endif
|
||||
while ((pp = getprotoent()) != NULL) {
|
||||
slp = (struct valuelist *)memget(sizeof(struct valuelist));
|
||||
if (!slp)
|
||||
panic("memget(protoent)", NULL);
|
||||
slp->name = savestr(pp->p_name, 1);
|
||||
slp->port = pp->p_proto; /* host byte order */
|
||||
slp->next = protolist;
|
||||
slp->prev = NULL;
|
||||
if (protolist)
|
||||
protolist->prev = slp;
|
||||
protolist = slp;
|
||||
}
|
||||
endprotoent();
|
||||
}
|
||||
|
||||
void
|
||||
destroyprotolist() {
|
||||
struct valuelist *plp, *plp_next;
|
||||
|
||||
for (plp = protolist; plp != NULL; plp = plp_next) {
|
||||
plp_next = plp->next;
|
||||
plp->name = freestr(plp->name);
|
||||
memput(plp, sizeof *plp);
|
||||
}
|
||||
protolist = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
findservice(const char *s, struct valuelist **list) {
|
||||
struct valuelist *lp = *list;
|
||||
int n;
|
||||
|
||||
for (; lp != NULL; lp = lp->next)
|
||||
if (strcasecmp(lp->name, s) == 0) {
|
||||
if (lp != *list) {
|
||||
lp->prev->next = lp->next;
|
||||
if (lp->next)
|
||||
lp->next->prev = lp->prev;
|
||||
(*list)->prev = lp;
|
||||
lp->next = *list;
|
||||
*list = lp;
|
||||
}
|
||||
return (lp->port); /* host byte order */
|
||||
}
|
||||
if (sscanf(s, "%d", &n) != 1 || n <= 0)
|
||||
n = -1;
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert service name or (ascii) number to int.
|
||||
*/
|
||||
int
|
||||
servicenumber(const char *p) {
|
||||
return (findservice(p, &servicelist));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert protocol name or (ascii) number to int.
|
||||
*/
|
||||
int
|
||||
protocolnumber(const char *p) {
|
||||
return (findservice(p, &protolist));
|
||||
}
|
||||
|
||||
static struct servent *
|
||||
cgetservbyport(u_int16_t port, const char *proto) { /* Host byte order. */
|
||||
struct valuelist **list = &servicelist;
|
||||
struct valuelist *lp = *list;
|
||||
static struct servent serv;
|
||||
|
||||
port = ntohs(port);
|
||||
for (; lp != NULL; lp = lp->next) {
|
||||
if (port != (u_int16_t)lp->port) /* Host byte order. */
|
||||
continue;
|
||||
if (strcasecmp(lp->proto, proto) == 0) {
|
||||
if (lp != *list) {
|
||||
lp->prev->next = lp->next;
|
||||
if (lp->next)
|
||||
lp->next->prev = lp->prev;
|
||||
(*list)->prev = lp;
|
||||
lp->next = *list;
|
||||
*list = lp;
|
||||
}
|
||||
serv.s_name = lp->name;
|
||||
serv.s_port = htons((u_int16_t)lp->port);
|
||||
serv.s_proto = lp->proto;
|
||||
return (&serv);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static struct protoent *
|
||||
cgetprotobynumber(int proto) { /* Host byte order. */
|
||||
struct valuelist **list = &protolist;
|
||||
struct valuelist *lp = *list;
|
||||
static struct protoent prot;
|
||||
|
||||
for (; lp != NULL; lp = lp->next)
|
||||
if (lp->port == proto) { /* Host byte order. */
|
||||
if (lp != *list) {
|
||||
lp->prev->next = lp->next;
|
||||
if (lp->next)
|
||||
lp->next->prev = lp->prev;
|
||||
(*list)->prev = lp;
|
||||
lp->next = *list;
|
||||
*list = lp;
|
||||
}
|
||||
prot.p_name = lp->name;
|
||||
prot.p_proto = lp->port; /* Host byte order. */
|
||||
return (&prot);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
const char *
|
||||
protocolname(int num) {
|
||||
static char number[8];
|
||||
struct protoent *pp;
|
||||
|
||||
pp = cgetprotobynumber(num);
|
||||
if (pp == 0) {
|
||||
(void) sprintf(number, "%d", num);
|
||||
return (number);
|
||||
}
|
||||
return (pp->p_name);
|
||||
}
|
||||
|
||||
const char *
|
||||
servicename(u_int16_t port, const char *proto) { /* Host byte order. */
|
||||
static char number[8];
|
||||
struct servent *ss;
|
||||
|
||||
ss = cgetservbyport(htons(port), proto);
|
||||
if (ss == 0) {
|
||||
(void) sprintf(number, "%d", port);
|
||||
return (number);
|
||||
}
|
||||
return (ss->s_name);
|
||||
}
|
||||
|
||||
static struct map map_class[] = {
|
||||
{ "in", C_IN },
|
||||
{ "chaos", C_CHAOS },
|
||||
{ "hs", C_HS },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
int
|
||||
get_class(const char *class) {
|
||||
const struct map *mp;
|
||||
|
||||
if (isdigit(*class))
|
||||
return (atoi(class));
|
||||
for (mp = map_class; mp->token != NULL; mp++)
|
||||
if (strcasecmp(class, mp->token) == 0)
|
||||
return (mp->val);
|
||||
return (C_IN);
|
||||
}
|
||||
|
||||
/* rm_datum(dp, np, pdp, savedpp)
|
||||
* remove datum 'dp' from name 'np'. pdp is previous data pointer.
|
||||
* if savedpp is not NULL, and compiled with BIND_UPDATE, save
|
||||
* datum dp there rather than freeing the memory (caller will take
|
||||
* care of freeing it)
|
||||
* return value:
|
||||
* "next" field from removed datum, suitable for relinking
|
||||
*/
|
||||
struct databuf *
|
||||
rm_datum(struct databuf *dp, struct namebuf *np, struct databuf *pdp,
|
||||
struct databuf **savedpp) {
|
||||
struct databuf *ndp = dp->d_next;
|
||||
|
||||
ns_debug(ns_log_db, 3, "rm_datum(%lx, %lx, %lx, %lx) -> %lx",
|
||||
(u_long)dp, (u_long)np->n_data, (u_long)pdp,
|
||||
(u_long)savedpp, (u_long)ndp);
|
||||
if ((dp->d_flags & DB_F_ACTIVE) == 0)
|
||||
panic("rm_datum: DB_F_ACTIVE not set", NULL);
|
||||
if (pdp == NULL)
|
||||
np->n_data = ndp;
|
||||
else
|
||||
pdp->d_next = ndp;
|
||||
if (savedpp != NULL) {
|
||||
/* mark deleted or pending deletion */
|
||||
dp->d_mark |= D_MARK_DELETED;
|
||||
dp->d_next = *savedpp;
|
||||
DRCNTINC(dp);
|
||||
*savedpp = dp;
|
||||
} else
|
||||
dp->d_next = NULL;
|
||||
dp->d_flags &= ~DB_F_ACTIVE;
|
||||
db_detach(&dp);
|
||||
return (ndp);
|
||||
}
|
||||
|
||||
/* rm_name(np, he, pnp)
|
||||
* remove name 'np' from parent 'pp'. pnp is previous name pointer.
|
||||
* return value:
|
||||
* "next" field from removed name, suitable for relinking.
|
||||
*/
|
||||
struct namebuf *
|
||||
rm_name(struct namebuf *np, struct namebuf **pp, struct namebuf *pnp) {
|
||||
struct namebuf *nnp = np->n_next;
|
||||
const char *msg;
|
||||
|
||||
/* verify */
|
||||
if ( (np->n_data != NULL && (msg = "data") != NULL)
|
||||
|| (np->n_hash != NULL && (msg = "hash") != NULL)
|
||||
) {
|
||||
ns_panic(ns_log_db, 1, "rm_name(%p(%s)): non-nil %s pointer",
|
||||
np, NAME(*np), msg);
|
||||
}
|
||||
|
||||
/* unlink */
|
||||
if (pnp)
|
||||
pnp->n_next = nnp;
|
||||
else
|
||||
*pp = nnp;
|
||||
|
||||
/* deallocate */
|
||||
memput(np, NAMESIZE(NAMELEN(*np)));
|
||||
|
||||
/* done */
|
||||
return (nnp);
|
||||
}
|
||||
|
||||
void
|
||||
rm_hash(struct hashbuf *htp) {
|
||||
REQUIRE(htp != NULL);
|
||||
REQUIRE(htp->h_cnt == 0);
|
||||
|
||||
memput(htp, HASHSIZE(htp->h_size));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the domain name of 'np' and put in 'buf'. Bounds checking is done.
|
||||
*/
|
||||
void
|
||||
getname(struct namebuf *np, char *buf, int buflen) {
|
||||
char *cp;
|
||||
int i;
|
||||
|
||||
cp = buf;
|
||||
while (np != NULL) {
|
||||
i = (int) NAMELEN(*np);
|
||||
if (i + 1 >= buflen) {
|
||||
strcpy(buf, "Name_Too_Long");
|
||||
return;
|
||||
}
|
||||
if (cp != buf)
|
||||
*cp++ = '.';
|
||||
memcpy(cp, NAME(*np), i);
|
||||
cp += i;
|
||||
buflen -= i + 1;
|
||||
np = np->n_parent;
|
||||
}
|
||||
*cp = '\0';
|
||||
}
|
||||
|
||||
/* u_int
|
||||
* nhash(name)
|
||||
* compute hash for this name and return it; ignore case differences
|
||||
* note:
|
||||
* this logic is intended to produce the same result as nlookup()'s.
|
||||
*/
|
||||
u_int
|
||||
nhash(const char *name) {
|
||||
u_char ch;
|
||||
u_int hval;
|
||||
|
||||
hval = 0;
|
||||
while ((ch = (u_char)*name++) != (u_char)'\0')
|
||||
HASHIMILATE(hval, ch);
|
||||
return (hval);
|
||||
}
|
||||
|
||||
static void
|
||||
db_freedata(struct databuf *dp) {
|
||||
int bytes = BIND_DATASIZE(dp->d_size);
|
||||
|
||||
if (dp->d_rcnt != 0)
|
||||
panic("db_freedata: d_rcnt != 0", NULL);
|
||||
if ((dp->d_flags & (DB_F_ACTIVE|DB_F_FREE)) != 0)
|
||||
panic("db_freedata: %s set",
|
||||
(dp->d_flags & DB_F_FREE) != 0 ? "DB_F_FREE" :
|
||||
"DB_F_ACTIVE");
|
||||
if (dp->d_next != NULL)
|
||||
panic("db_free: d_next != NULL", NULL);
|
||||
dp->d_flags |= DB_F_FREE;
|
||||
#ifdef CHECK_MAGIC
|
||||
dp->d_magic = 0;
|
||||
#endif
|
||||
memput(dp, bytes);
|
||||
}
|
||||
|
||||
void
|
||||
db_detach(struct databuf **dpp) {
|
||||
struct databuf *dp;
|
||||
|
||||
INSIST(dpp != NULL && *dpp != NULL);
|
||||
dp = *dpp;
|
||||
#ifdef CHECK_MAGIC
|
||||
INSIST(dp->d_magic == DATABUF_MAGIC);
|
||||
#endif
|
||||
|
||||
DRCNTDEC(dp);
|
||||
if (dp->d_rcnt == 0)
|
||||
db_freedata(dp);
|
||||
*dpp = NULL;
|
||||
}
|
||||
|
||||
struct lame_hash {
|
||||
struct lame_hash *next;
|
||||
char *zone;
|
||||
char *server;
|
||||
time_t when;
|
||||
unsigned int hval;
|
||||
} **lame_hash = NULL;
|
||||
|
||||
static int lame_hash_size = 0;
|
||||
static int lame_hash_cnt = 0;
|
||||
|
||||
void
|
||||
db_lame_add(char *zone, char *server, time_t when) {
|
||||
unsigned int hval = nhash(zone);
|
||||
struct lame_hash *last, *this;
|
||||
struct lame_hash **new;
|
||||
int n;
|
||||
int newsize;
|
||||
|
||||
db_lame_clean();
|
||||
|
||||
/* grow / initalise hash table */
|
||||
if (lame_hash_cnt >= lame_hash_size) {
|
||||
if (lame_hash_size == 0)
|
||||
newsize = hashsizes[0];
|
||||
else {
|
||||
for (n = 0; (newsize = hashsizes[n++]) != 0; (void)NULL)
|
||||
if (lame_hash_size == newsize) {
|
||||
newsize = hashsizes[n];
|
||||
break;
|
||||
}
|
||||
if (newsize == 0)
|
||||
newsize = lame_hash_size * 2 + 1;
|
||||
}
|
||||
new = memget(newsize * sizeof this);
|
||||
if (new == NULL)
|
||||
return;
|
||||
memset(new, 0, newsize * sizeof this);
|
||||
for (n = 0 ; n < lame_hash_size; n++) {
|
||||
this = lame_hash[n];
|
||||
while (this) {
|
||||
last = this;
|
||||
this = this->next;
|
||||
last->next = new[hval%newsize];
|
||||
new[hval%newsize] = last;
|
||||
}
|
||||
}
|
||||
if (lame_hash != NULL)
|
||||
memput(lame_hash, lame_hash_size * sizeof this);
|
||||
lame_hash = new;
|
||||
lame_hash_size = newsize;
|
||||
}
|
||||
|
||||
last = NULL;
|
||||
this = lame_hash[hval%lame_hash_size];
|
||||
while (this) {
|
||||
if ((ns_samename(this->server, server) == 1) &&
|
||||
(ns_samename(this->zone, zone) == 1)) {
|
||||
this->when = when;
|
||||
return;
|
||||
}
|
||||
last = this;
|
||||
this = this->next;
|
||||
}
|
||||
this = memget(sizeof *this);
|
||||
if (this == NULL)
|
||||
return;
|
||||
this->server = savestr(server, 0);
|
||||
this->zone = savestr(zone, 0);
|
||||
if (this->server == NULL || this->zone == NULL) {
|
||||
if (this->server != NULL)
|
||||
this->server = freestr(this->server);
|
||||
if (this->zone != NULL)
|
||||
this->zone = freestr(this->zone);
|
||||
memput(this, sizeof *this);
|
||||
return;
|
||||
}
|
||||
this->when = when;
|
||||
this->hval = hval;
|
||||
this->next = NULL;
|
||||
if (last != NULL)
|
||||
last->next = this;
|
||||
else
|
||||
lame_hash[hval%lame_hash_size] = this;
|
||||
lame_hash_cnt++;
|
||||
}
|
||||
|
||||
time_t
|
||||
db_lame_find(char *zone, struct databuf *dp) {
|
||||
unsigned int hval = nhash(zone);
|
||||
struct lame_hash *this;
|
||||
|
||||
if (lame_hash_size == 0) {
|
||||
/* db_lame_destroy() must have been called. */
|
||||
dp->d_flags &= ~DB_F_LAME;
|
||||
return (0);
|
||||
}
|
||||
|
||||
db_lame_clean(); /* Remove expired record so that we can
|
||||
* clear DB_F_LAME when there are no
|
||||
* additions. */
|
||||
|
||||
this = lame_hash[hval % lame_hash_size];
|
||||
while (this) {
|
||||
if ((ns_samename(this->server, (char*)dp->d_data) == 1) &&
|
||||
(ns_samename(this->zone, zone) == 1))
|
||||
return (this->when);
|
||||
this = this->next;
|
||||
}
|
||||
dp->d_flags &= ~DB_F_LAME;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
db_lame_clean(void) {
|
||||
int i;
|
||||
struct lame_hash *last, *this;
|
||||
|
||||
for (i = 0 ; i < lame_hash_size; i++) {
|
||||
last = NULL;
|
||||
this = lame_hash[i];
|
||||
while (this != NULL) {
|
||||
if (this->when < tt.tv_sec) {
|
||||
this->zone = freestr(this->zone);
|
||||
this->server = freestr(this->server);
|
||||
if (last != NULL) {
|
||||
last->next = this->next;
|
||||
memput(this, sizeof *this);
|
||||
this = last->next;
|
||||
} else {
|
||||
lame_hash[i] = this->next;
|
||||
memput(this, sizeof *this);
|
||||
this = lame_hash[i];
|
||||
}
|
||||
lame_hash_cnt--;
|
||||
} else {
|
||||
last = this;
|
||||
this = this->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
db_lame_destroy(void) {
|
||||
int i;
|
||||
struct lame_hash *last, *this;
|
||||
|
||||
if (lame_hash_size == 0)
|
||||
return;
|
||||
|
||||
for (i = 0 ; i < lame_hash_size; i++) {
|
||||
this = lame_hash[i];
|
||||
while (this != NULL) {
|
||||
last = this;
|
||||
this = this->next;
|
||||
last->zone = freestr(last->zone);
|
||||
last->server = freestr(last->server);
|
||||
memput(last, sizeof *this);
|
||||
}
|
||||
}
|
||||
memput(lame_hash, lame_hash_size * sizeof this);
|
||||
lame_hash_cnt = 0;
|
||||
lame_hash_size = 0;
|
||||
lame_hash = NULL;
|
||||
}
|
||||
@@ -1,984 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: db_ixfr.c,v 8.32 2002/07/08 06:26:04 marka Exp $";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1999 by Check Point Software Technologies, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Check Point Software Technologies Incorporated not be used
|
||||
* in advertising or publicity pertaining to distribution of the document
|
||||
* or software without specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND CHECK POINT SOFTWARE TECHNOLOGIES
|
||||
* INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL CHECK POINT SOFTWARE TECHNOLOGIES INCORPRATED
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Manage ixfr transaction log
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <res_update.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
#include <isc/misc.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
#define DBIXFR_ERROR (-1)
|
||||
#define DBIXFR_FOUND_RR 2
|
||||
#define DBIXFR_END 3
|
||||
|
||||
static int ixfr_getdelta(struct zoneinfo *, FILE *, const char *, char *,
|
||||
ns_updque *, u_int32_t *, u_int32_t *);
|
||||
|
||||
ns_deltalist *
|
||||
ixfr_get_change_list(struct zoneinfo *zp,
|
||||
u_int32_t from_serial, u_int32_t to_serial)
|
||||
{
|
||||
FILE * fp = NULL;
|
||||
u_int32_t old_serial, new_serial;
|
||||
char origin[MAXDNAME];
|
||||
ns_deltalist *dlhead = NULL;
|
||||
int ret;
|
||||
ns_updrec *uprec;
|
||||
ns_delta *dl;
|
||||
|
||||
if (SEQ_GT(from_serial, to_serial))
|
||||
return (NULL);
|
||||
|
||||
dlhead = memget(sizeof(*dlhead));
|
||||
if (dlhead == NULL)
|
||||
return (NULL);
|
||||
INIT_LIST(*dlhead);
|
||||
|
||||
if ((fp = fopen(zp->z_ixfr_base, "r")) == NULL) {
|
||||
ns_warning(ns_log_db, "%s: %s",
|
||||
zp->z_ixfr_base, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
strcpy(origin, zp->z_origin);
|
||||
lineno = 1;
|
||||
old_serial = new_serial = 0;
|
||||
|
||||
for (;;) {
|
||||
dl = memget(sizeof *dl);
|
||||
if (dl == NULL) {
|
||||
ns_warning(ns_log_db,
|
||||
"ixfr_get_change_list: out of memory");
|
||||
goto cleanup;
|
||||
}
|
||||
INIT_LINK(dl, d_link);
|
||||
INIT_LIST(dl->d_changes);
|
||||
ret = ixfr_getdelta(zp, fp, zp->z_ixfr_base, origin,
|
||||
&dl->d_changes, &old_serial, &new_serial);
|
||||
switch (ret) {
|
||||
case DBIXFR_ERROR:
|
||||
ns_warning(ns_log_db, "Logical error in %s: unlinking",
|
||||
zp->z_ixfr_base);
|
||||
if (fp != NULL) {
|
||||
(void) my_fclose(fp);
|
||||
fp = NULL;
|
||||
}
|
||||
unlink(zp->z_ixfr_base);
|
||||
goto cleanup;
|
||||
|
||||
case DBIXFR_FOUND_RR:
|
||||
ns_debug(ns_log_default, 4,
|
||||
"ixfr_getdelta DBIXFR_FOUND_RR (%s)",
|
||||
zp->z_origin);
|
||||
if (EMPTY(*dlhead)) {
|
||||
/* skip updates prior to the one we want */
|
||||
uprec = HEAD(dl->d_changes);
|
||||
INSIST(uprec != NULL);
|
||||
if (SEQ_LT(uprec->r_zone, from_serial) ||
|
||||
SEQ_GT(uprec->r_zone, to_serial))
|
||||
{
|
||||
while ((uprec = HEAD(dl->d_changes)) != NULL) {
|
||||
UNLINK(dl->d_changes, uprec, r_link);
|
||||
|
||||
if (uprec->r_dp != NULL)
|
||||
db_detach(&uprec->r_dp);
|
||||
res_freeupdrec(uprec);
|
||||
}
|
||||
memput(dl, sizeof *dl);
|
||||
break;
|
||||
}
|
||||
else if (uprec->r_zone > from_serial) {
|
||||
/* missed the boat */
|
||||
ns_debug(ns_log_default, 3,
|
||||
"ixfr_getdelta first SOA is %d, asked for %d (%s)",
|
||||
uprec->r_zone,
|
||||
from_serial,
|
||||
zp->z_origin);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
ns_debug(ns_log_default, 4,
|
||||
"adding to change list (%s)",
|
||||
zp->z_origin);
|
||||
APPEND(*dlhead, dl, d_link);
|
||||
break;
|
||||
|
||||
case DBIXFR_END:
|
||||
ns_debug(ns_log_default, 4,
|
||||
"ixfr_getdelta DBIXFR_END (%s)",
|
||||
zp->z_origin);
|
||||
(void) my_fclose(fp);
|
||||
memput(dl, sizeof *dl);
|
||||
return (dlhead);
|
||||
|
||||
default:
|
||||
(void) my_fclose(fp);
|
||||
if (dl != NULL)
|
||||
memput(dl, sizeof *dl);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (fp != NULL)
|
||||
(void) my_fclose(fp);
|
||||
|
||||
while ((dl = HEAD(*dlhead)) != NULL) {
|
||||
UNLINK(*dlhead, dl, d_link);
|
||||
while ((uprec = HEAD(dl->d_changes)) != NULL) {
|
||||
UNLINK(dl->d_changes, uprec, r_link);
|
||||
|
||||
if (uprec->r_dp != NULL)
|
||||
db_detach(&uprec->r_dp);
|
||||
uprec->r_dp = NULL;
|
||||
res_freeupdrec(uprec);
|
||||
}
|
||||
memput(dl, sizeof *dl);
|
||||
}
|
||||
memput(dlhead, sizeof *dlhead);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* int ixfr_have_log(struct zoneinfo *zp,u_int32_t from_serial,
|
||||
* u_int32_t to_serial)
|
||||
*
|
||||
* verify that ixfr transaction log contains changes
|
||||
* from from_serial to to_serial
|
||||
*
|
||||
* returns:
|
||||
* 0 = serial number is up to date
|
||||
* 1 = transmission is possible
|
||||
* -1 = error while opening the ixfr transaction log
|
||||
* -2 = error in parameters
|
||||
* -3 = logical error in the history file
|
||||
*/
|
||||
int
|
||||
ixfr_have_log(struct zoneinfo *zp, u_int32_t from_serial, u_int32_t to_serial)
|
||||
{
|
||||
FILE *fp;
|
||||
u_int32_t old_serial = 0, new_serial = 0;
|
||||
u_int32_t last_serial = 0;
|
||||
u_int32_t first_serial = 0;
|
||||
char buf[BUFSIZ];
|
||||
char *cp;
|
||||
struct stat st;
|
||||
int nonempty_lineno = -1, prev_pktdone = 0, cont = 0,
|
||||
inside_next = 0;
|
||||
int err;
|
||||
int first = 0;
|
||||
int rval = 0;
|
||||
int id, rcode = NOERROR;
|
||||
if (SEQ_GT(from_serial, to_serial))
|
||||
return (-2);
|
||||
if (from_serial == to_serial)
|
||||
return (0);
|
||||
/* If there is no log file, just return. */
|
||||
if (zp->z_ixfr_base == NULL || zp->z_updatelog == NULL)
|
||||
return (-1);
|
||||
if (zp->z_serial_ixfr_start > 0) {
|
||||
if (from_serial >= zp->z_serial_ixfr_start)
|
||||
return (1);
|
||||
}
|
||||
if (stat(zp->z_ixfr_base, &st) < 0) {
|
||||
if (errno != ENOENT)
|
||||
ns_error(ns_log_db,
|
||||
"unexpected stat(%s) failure: %s",
|
||||
zp->z_ixfr_base, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
if ((fp = fopen(zp->z_ixfr_base, "r")) == NULL) {
|
||||
ns_warning(ns_log_db, "%s: %s",
|
||||
zp->z_ixfr_base, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
if (fgets(buf, sizeof(buf), fp) == NULL) {
|
||||
ns_error(ns_log_update, "fgets() from %s failed: %s",
|
||||
zp->z_ixfr_base, strerror(errno));
|
||||
fclose(fp);
|
||||
return (-1);
|
||||
}
|
||||
if (strcmp(buf, LogSignature) != 0) {
|
||||
ns_error(ns_log_update, "invalid log file %s",
|
||||
zp->z_ixfr_base);
|
||||
fclose(fp);
|
||||
return (-3);
|
||||
}
|
||||
lineno = 1;
|
||||
first = 1;
|
||||
for (;;) {
|
||||
if (getword(buf, sizeof buf, fp, 0)) {
|
||||
nonempty_lineno = lineno;
|
||||
} else {
|
||||
if (lineno == (nonempty_lineno + 1))
|
||||
continue;
|
||||
inside_next = 0;
|
||||
prev_pktdone = 1;
|
||||
cont = 1;
|
||||
}
|
||||
if (!strcasecmp(buf, "[DYNAMIC_UPDATE]") ||
|
||||
!strcasecmp(buf, "[IXFR_UPDATE]")) {
|
||||
err = 0;
|
||||
rcode = NOERROR;
|
||||
cp = fgets(buf, sizeof buf, fp);
|
||||
if (cp != NULL)
|
||||
lineno++;
|
||||
if (cp == NULL || !sscanf((char *) cp, "id %d", &id))
|
||||
id = -1;
|
||||
inside_next = 1;
|
||||
prev_pktdone = 1;
|
||||
cont = 1;
|
||||
} else if (!strcasecmp(buf, "serial")) {
|
||||
cp = fgets(buf, sizeof buf, fp);
|
||||
if (cp != NULL)
|
||||
lineno++;
|
||||
if (sscanf((char *) cp, "%u", &old_serial)) {
|
||||
if (first == 1) {
|
||||
first = 0;
|
||||
first_serial = old_serial;
|
||||
}
|
||||
last_serial = old_serial;
|
||||
if (from_serial >= old_serial) {
|
||||
rval = 1;
|
||||
}
|
||||
}
|
||||
prev_pktdone = 1;
|
||||
cont = 1;
|
||||
} else if (!strcasecmp(buf, "[INCR_SERIAL]")) {
|
||||
/* XXXRTH not enough error checking here */
|
||||
cp = fgets(buf, sizeof buf, fp);
|
||||
if (cp != NULL)
|
||||
lineno++;
|
||||
if (cp == NULL ||
|
||||
sscanf((char *) cp, "from %u to %u",
|
||||
&old_serial, &new_serial) != 2) {
|
||||
rval = -3;
|
||||
break;
|
||||
} else if (from_serial >= old_serial) {
|
||||
if (first == 1) {
|
||||
first = 0;
|
||||
first_serial = old_serial;
|
||||
}
|
||||
last_serial = old_serial;
|
||||
rval = 1;
|
||||
}
|
||||
}
|
||||
if (prev_pktdone) {
|
||||
prev_pktdone = 0;
|
||||
if (feof(fp))
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
if (last_serial +1 < zp->z_serial) {
|
||||
ns_warning(ns_log_db,
|
||||
"%s: File Deleted. Found gap between serial:"
|
||||
" %d and current serial: %d",
|
||||
zp->z_ixfr_base, last_serial, zp->z_serial);
|
||||
(void) unlink(zp->z_ixfr_base);
|
||||
rval = -3;
|
||||
}
|
||||
if (from_serial < first_serial || from_serial > last_serial)
|
||||
rval = -3;
|
||||
if (rval == 1)
|
||||
zp->z_serial_ixfr_start = first_serial;
|
||||
return (rval);
|
||||
}
|
||||
|
||||
/* from db_load.c */
|
||||
|
||||
static struct map m_section[] = {
|
||||
{"zone", S_ZONE},
|
||||
{"prereq", S_PREREQ},
|
||||
{"update", S_UPDATE},
|
||||
{"reserved", S_ADDT},
|
||||
};
|
||||
#define M_SECTION_CNT (sizeof(m_section) / sizeof(struct map))
|
||||
|
||||
/* from ns_req.c */
|
||||
|
||||
static struct map m_opcode[] = {
|
||||
{"nxdomain", NXDOMAIN},
|
||||
{"yxdomain", YXDOMAIN},
|
||||
{"nxrrset", NXRRSET},
|
||||
{"yxrrset", YXRRSET},
|
||||
{"delete", DELETE},
|
||||
{"add", ADD},
|
||||
};
|
||||
#define M_OPCODE_CNT (sizeof(m_opcode) / sizeof(struct map))
|
||||
|
||||
/* XXXRTH workaround map difficulties */
|
||||
#define M_CLASS_CNT m_class_cnt
|
||||
#define M_TYPE_CNT m_type_cnt
|
||||
|
||||
/*
|
||||
* read a line from the history of a zone.
|
||||
*
|
||||
* returns:
|
||||
*
|
||||
* DBIXFR_ERROR = an error occured
|
||||
* DBIXFR_FOUND_RR = a rr encountered
|
||||
* DBIXFR_END = end of file
|
||||
*/
|
||||
static int
|
||||
ixfr_getdelta(struct zoneinfo *zp, FILE *fp, const char *filename, char *origin,
|
||||
ns_updque *listuprec, u_int32_t *old_serial,
|
||||
u_int32_t *new_serial)
|
||||
{
|
||||
char data[MAXDATA], dnbuf[MAXDNAME], sclass[3];
|
||||
char *dname, *cp, *cp1;
|
||||
char buf[MAXDATA];
|
||||
long unsigned lutmp;
|
||||
u_int32_t serial = 0, ttl;
|
||||
u_int32_t current_serial = 0;
|
||||
int nonempty_lineno = -1, prev_pktdone = 0, cont = 0,
|
||||
inside_next = 0;
|
||||
int id;
|
||||
int i, c, section, opcode, matches, zonenum, err, multiline;
|
||||
int type, class;
|
||||
u_int32_t n;
|
||||
enum transport transport;
|
||||
struct map *mp;
|
||||
int zonelist[MAXDNAME];
|
||||
struct in_addr ina;
|
||||
int datasize;
|
||||
ns_updrec * rrecp;
|
||||
u_long l;
|
||||
|
||||
#define ERRTO(msg) if (1) { errtype = msg; goto err; } else (void)NULL
|
||||
|
||||
err = 0;
|
||||
transport = primary_trans;
|
||||
lineno = 1;
|
||||
zonenum = 0;
|
||||
|
||||
/*
|
||||
* Look for serial if "first" call othewise use new_serial to
|
||||
* for current_serial.
|
||||
*/
|
||||
if (*old_serial == *new_serial && *old_serial == 0)
|
||||
current_serial = 0;
|
||||
else
|
||||
current_serial = *new_serial;
|
||||
|
||||
for (;;) {
|
||||
dname = NULL;
|
||||
if (!getword(buf, sizeof buf, fp, 0)) {
|
||||
if (lineno == (nonempty_lineno + 1) && !(feof(fp))) {
|
||||
/*
|
||||
* End of a nonempty line inside an update
|
||||
* packet or not inside an update packet.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Empty line or EOF.
|
||||
*/
|
||||
if (feof(fp))
|
||||
break;
|
||||
inside_next = 0;
|
||||
cont = 1;
|
||||
} else {
|
||||
nonempty_lineno = lineno;
|
||||
}
|
||||
|
||||
if (!strcasecmp(buf, "[DYNAMIC_UPDATE]") ||
|
||||
!strcasecmp(buf, "[IXFR_UPDATE]")) {
|
||||
cp = fgets(buf, sizeof buf, fp);
|
||||
if (cp != NULL)
|
||||
lineno++;
|
||||
if (cp == NULL || !sscanf((char *) cp, "id %d", &id))
|
||||
id = -1;
|
||||
inside_next = 1;
|
||||
cont = 1;
|
||||
} else if (!strcasecmp(buf, "[INCR_SERIAL]")) {
|
||||
/* XXXRTH not enough error checking here */
|
||||
cp = fgets(buf, sizeof buf, fp);
|
||||
if (cp != NULL)
|
||||
lineno++;
|
||||
if (cp == NULL ||
|
||||
sscanf((char *) cp, "from %u to %u",
|
||||
old_serial, new_serial) != 2) {
|
||||
ns_error(ns_log_update,
|
||||
"incr_serial problem with %s",
|
||||
zp->z_updatelog);
|
||||
} else {
|
||||
serial = get_serial(zp);
|
||||
}
|
||||
cont = 1;
|
||||
} else if (!strcasecmp(buf, "[END_DELTA]")) {
|
||||
prev_pktdone = 1;
|
||||
cont = 1;
|
||||
lineno++;
|
||||
}
|
||||
if (prev_pktdone) {
|
||||
if (!EMPTY(*listuprec)) {
|
||||
n++;
|
||||
return (DBIXFR_FOUND_RR);
|
||||
}
|
||||
prev_pktdone = 0;
|
||||
}
|
||||
if (cont) {
|
||||
cont = 0;
|
||||
continue;
|
||||
}
|
||||
if (!inside_next)
|
||||
continue;
|
||||
/*
|
||||
* inside the same update packet, continue accumulating
|
||||
* records.
|
||||
*/
|
||||
section = -1;
|
||||
n = strlen(buf);
|
||||
if (buf[n - 1] == ':')
|
||||
buf[--n] = '\0';
|
||||
for (mp = m_section; mp < m_section + M_SECTION_CNT; mp++)
|
||||
if (!strcasecmp(buf, mp->token)) {
|
||||
section = mp->val;
|
||||
break;
|
||||
}
|
||||
ttl = 0;
|
||||
type = -1;
|
||||
class = zp->z_class;
|
||||
n = 0;
|
||||
data[0] = '\0';
|
||||
opcode = -1;
|
||||
switch (section) {
|
||||
case S_ZONE:
|
||||
cp = fgets(buf, sizeof buf, fp);
|
||||
if (!cp)
|
||||
*buf = '\0';
|
||||
n = sscanf(cp, "origin %s class %s serial %lu",
|
||||
origin, sclass, &lutmp);
|
||||
serial = lutmp;
|
||||
if (current_serial == 0)
|
||||
current_serial = serial;
|
||||
else if (current_serial != serial) {
|
||||
ns_debug(ns_log_update, 1,
|
||||
"%s:line %d serial # askew %d %d",
|
||||
filename, lineno, serial,
|
||||
current_serial);
|
||||
current_serial = serial;
|
||||
err++;
|
||||
}
|
||||
if (n != 3 || ns_samename(origin, zp->z_origin) != 1)
|
||||
err++;
|
||||
if (cp)
|
||||
lineno++;
|
||||
if (!err && inside_next) {
|
||||
int success;
|
||||
|
||||
dname = origin;
|
||||
type = T_SOA;
|
||||
class = res_nametoclass(sclass, &success);
|
||||
if (!success) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
matches = findzone(dname, class, 0,
|
||||
zonelist, MAXDNAME);
|
||||
if (matches)
|
||||
zonenum = zonelist[0];
|
||||
else
|
||||
err++;
|
||||
}
|
||||
break;
|
||||
case S_PREREQ:
|
||||
case S_UPDATE:
|
||||
/* Operation code. */
|
||||
if (!getword(buf, sizeof buf, fp, 0)) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
if (buf[0] == '{') {
|
||||
n = strlen(buf);
|
||||
for (i = 0; (u_int32_t) i < n; i++)
|
||||
buf[i] = buf[i + 1];
|
||||
if (buf[n - 2] == '}')
|
||||
buf[n - 2] = '\0';
|
||||
}
|
||||
for (mp = m_opcode; mp < m_opcode + M_OPCODE_CNT; mp++)
|
||||
if (!strcasecmp(buf, mp->token)) {
|
||||
opcode = mp->val;
|
||||
break;
|
||||
}
|
||||
if (opcode == -1) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
/* Owner's domain name. */
|
||||
if (!getword((char *) dnbuf, sizeof dnbuf, fp, 0)) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
n = strlen((char *) dnbuf) - 1;
|
||||
if (dnbuf[n] == '.')
|
||||
dnbuf[n] = '\0';
|
||||
dname = dnbuf;
|
||||
ttl = 0;
|
||||
type = -1;
|
||||
class = zp->z_class;
|
||||
n = 0;
|
||||
data[0] = '\0';
|
||||
(void) getword(buf, sizeof buf, fp, 1);
|
||||
if (isdigit(buf[0])) { /* ttl */
|
||||
if (ns_parse_ttl(buf, &l) < 0) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
ttl = l;
|
||||
(void) getword(buf, sizeof buf, fp, 1);
|
||||
}
|
||||
/* possibly class */
|
||||
if (buf[0] != '\0') {
|
||||
int success;
|
||||
int maybe_class;
|
||||
|
||||
maybe_class = res_nametoclass(buf, &success);
|
||||
if (success) {
|
||||
class = maybe_class;
|
||||
(void) getword(buf, sizeof buf, fp, 1);
|
||||
}
|
||||
}
|
||||
/* possibly type */
|
||||
if (buf[0] != '\0') {
|
||||
int success;
|
||||
int maybe_type;
|
||||
|
||||
maybe_type = res_nametotype(buf, &success);
|
||||
|
||||
if (success) {
|
||||
type = maybe_type;
|
||||
(void) getword(buf, sizeof buf, fp, 1);
|
||||
}
|
||||
}
|
||||
if (buf[0] != '\0') /* possibly rdata */
|
||||
/*
|
||||
* Convert the ascii data 'buf' to the proper
|
||||
* format based on the type and pack into
|
||||
* 'data'.
|
||||
*
|
||||
* XXX - same as in db_load(), consolidation
|
||||
* needed
|
||||
*/
|
||||
switch (type) {
|
||||
case T_A:
|
||||
if (!inet_aton(buf, &ina)) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
n = ntohl(ina.s_addr);
|
||||
cp = data;
|
||||
PUTLONG(n, cp);
|
||||
n = INT32SZ;
|
||||
break;
|
||||
case T_HINFO:
|
||||
case T_ISDN:
|
||||
n = strlen(buf);
|
||||
data[0] = n;
|
||||
memcpy(data + 1, buf, n);
|
||||
n++;
|
||||
if (!getword(buf, sizeof buf, fp, 0)) {
|
||||
i = 0;
|
||||
} else {
|
||||
endline(fp);
|
||||
i = strlen(buf);
|
||||
}
|
||||
data[n] = i;
|
||||
n++;
|
||||
memcpy(data + n + 1, buf, i);
|
||||
n += i;
|
||||
break;
|
||||
case T_SOA:
|
||||
case T_MINFO:
|
||||
case T_RP:
|
||||
(void) strcpy(data, buf);
|
||||
cp = data + strlen(data) + 1;
|
||||
if (!getword((char *) cp,
|
||||
sizeof data - (cp - data),
|
||||
fp, 1)) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
cp += strlen((char *) cp) + 1;
|
||||
if (type != T_SOA) {
|
||||
n = cp - data;
|
||||
break;
|
||||
}
|
||||
if (class != zp->z_class ||
|
||||
ns_samename(dname, zp->z_origin) != 1) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
c = getnonblank(fp, zp->z_updatelog, 0);
|
||||
if (c == '(') {
|
||||
multiline = 1;
|
||||
} else {
|
||||
multiline = 0;
|
||||
ungetc(c, fp);
|
||||
}
|
||||
n = getnum(fp, zp->z_updatelog, GETNUM_SERIAL,
|
||||
&multiline);
|
||||
if (getnum_error) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
if (opcode == ADD)
|
||||
*new_serial = n;
|
||||
current_serial = n;
|
||||
PUTLONG(n, cp);
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (!getword(buf, sizeof buf, fp, 1)) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
if (ns_parse_ttl(buf, &l) < 0) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
n = l;
|
||||
PUTLONG(n, cp);
|
||||
}
|
||||
if (multiline) {
|
||||
c = getnonblank(fp, zp->z_updatelog, 1);
|
||||
if (c != ')') {
|
||||
ungetc(c, fp);
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
endline(fp);
|
||||
n = cp - data;
|
||||
break;
|
||||
case T_WKS:
|
||||
if (!inet_aton(buf, &ina)) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
n = ntohl(ina.s_addr);
|
||||
cp = data;
|
||||
PUTLONG(n, cp);
|
||||
*cp = (char) getprotocol(fp, zp->z_updatelog);
|
||||
n = INT32SZ + sizeof(char);
|
||||
n = getservices((int) n, data,
|
||||
fp, zp->z_updatelog);
|
||||
break;
|
||||
case T_NS:
|
||||
case T_CNAME:
|
||||
case T_MB:
|
||||
case T_MG:
|
||||
case T_MR:
|
||||
case T_PTR:
|
||||
(void) strcpy(data, buf);
|
||||
if (makename(data, origin,
|
||||
sizeof(data)) == -1) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
n = strlen(data) + 1;
|
||||
break;
|
||||
case T_MX:
|
||||
case T_AFSDB:
|
||||
case T_RT:
|
||||
n = 0;
|
||||
cp = buf;
|
||||
while (isdigit(*cp))
|
||||
n = n * 10 + (*cp++ - '0');
|
||||
/* catch bad values */
|
||||
cp = data;
|
||||
PUTSHORT((u_int16_t) n, cp);
|
||||
if (!getword(buf, sizeof(buf), fp, 1)) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
(void) strcpy((char *) cp, buf);
|
||||
if (makename((char *) cp, origin,
|
||||
sizeof(data) - (cp - data)) == -1)
|
||||
{
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
/* advance pointer to end of data */
|
||||
cp += strlen((char *) cp) + 1;
|
||||
/* now save length */
|
||||
n = (cp - data);
|
||||
break;
|
||||
case T_PX:
|
||||
n = 0;
|
||||
data[0] = '\0';
|
||||
cp = buf;
|
||||
while (isdigit(*cp))
|
||||
n = n * 10 + (*cp++ - '0');
|
||||
cp = data;
|
||||
PUTSHORT((u_int16_t) n, cp);
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!getword(buf, sizeof(buf), fp, 0))
|
||||
{
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
(void) strcpy((char *) cp, buf);
|
||||
cp += strlen((char *) cp) + 1;
|
||||
}
|
||||
n = cp - data;
|
||||
break;
|
||||
case T_TXT:
|
||||
case T_X25:
|
||||
i = strlen(buf);
|
||||
cp = data;
|
||||
datasize = sizeof data;
|
||||
cp1 = buf;
|
||||
while (i > MAXCHARSTRING) {
|
||||
if (datasize <= MAXCHARSTRING) {
|
||||
ns_error(ns_log_update,
|
||||
"record too big");
|
||||
return (-1);
|
||||
}
|
||||
datasize -= MAXCHARSTRING;
|
||||
*cp++ = (char)MAXCHARSTRING;
|
||||
memcpy(cp, cp1, MAXCHARSTRING);
|
||||
cp += MAXCHARSTRING;
|
||||
cp1 += MAXCHARSTRING;
|
||||
i -= MAXCHARSTRING;
|
||||
}
|
||||
if (datasize < i + 1) {
|
||||
ns_error(ns_log_update,
|
||||
"record too big");
|
||||
return (-1);
|
||||
}
|
||||
*cp++ = i;
|
||||
memcpy(cp, cp1, i);
|
||||
cp += i;
|
||||
n = cp - data;
|
||||
endline(fp);
|
||||
/* XXXVIX: segmented texts 4.9.5 */
|
||||
break;
|
||||
case T_NSAP:
|
||||
n = inet_nsap_addr(buf, (u_char *) data,
|
||||
sizeof data);
|
||||
endline(fp);
|
||||
break;
|
||||
case T_LOC:
|
||||
cp = buf + (n = strlen(buf));
|
||||
*cp = ' ';
|
||||
cp++;
|
||||
while ((i = getc(fp), *cp = i, i != EOF)
|
||||
&& *cp != '\n' && (n < MAXDATA))
|
||||
{
|
||||
cp++;
|
||||
n++;
|
||||
}
|
||||
if (*cp == '\n')
|
||||
ungetc(*cp, fp);
|
||||
*cp = '\0';
|
||||
n = loc_aton(buf, (u_char *) data);
|
||||
if (n == 0) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
endline(fp);
|
||||
break;
|
||||
case ns_t_sig:
|
||||
case ns_t_nxt:
|
||||
case ns_t_key:
|
||||
case ns_t_cert:{
|
||||
const char *errmsg = NULL;
|
||||
|
||||
n = parse_sec_rdata(buf, sizeof(buf), 1,
|
||||
(u_char *) data,
|
||||
sizeof(data),
|
||||
fp, zp, dname, ttl,
|
||||
type, domain_ctx,
|
||||
transport, &errmsg);
|
||||
if (errmsg) {
|
||||
err++;
|
||||
endline(fp);
|
||||
n = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (strcmp(buf, "\\#") != 0) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
if (!getword(buf, sizeof buf, fp, 0) ||
|
||||
!isdigit((unsigned char)buf[0])) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
errno = 0;
|
||||
n = strtoul(buf, &cp, 10);
|
||||
if (errno != 0 || n > 0xffff || *cp != '\0') {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
multiline = 0;
|
||||
i = isc_gethexstring((u_char *)data,
|
||||
sizeof(data), n, fp,
|
||||
&multiline);
|
||||
if (i == -1) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
if (multiline) {
|
||||
c = getnonblank(fp, zp->z_updatelog, 1);
|
||||
if (c != ')') {
|
||||
ungetc(c, fp);
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
multiline = 0;
|
||||
}
|
||||
endline(fp);
|
||||
}
|
||||
if (section == S_PREREQ) {
|
||||
ttl = 0;
|
||||
if (opcode == NXDOMAIN) {
|
||||
class = C_NONE;
|
||||
type = T_ANY;
|
||||
n = 0;
|
||||
} else if (opcode == YXDOMAIN) {
|
||||
class = C_ANY;
|
||||
type = T_ANY;
|
||||
n = 0;
|
||||
} else if (opcode == NXRRSET) {
|
||||
class = C_NONE;
|
||||
n = 0;
|
||||
} else if (opcode == YXRRSET) {
|
||||
if (n == 0)
|
||||
class = C_ANY;
|
||||
}
|
||||
} else {/* section == S_UPDATE */
|
||||
if (opcode == DELETE) {
|
||||
if (n == 0) {
|
||||
class = C_ANY;
|
||||
if (type == -1)
|
||||
type = T_ANY;
|
||||
} else {
|
||||
class = zp->z_class;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case S_ADDT:
|
||||
default:
|
||||
ns_debug(ns_log_update, 1,
|
||||
"cannot interpret section: %d", section);
|
||||
inside_next = 0;
|
||||
err++;
|
||||
}
|
||||
if (err) {
|
||||
inside_next = 0;
|
||||
ns_debug(ns_log_update, 1,
|
||||
"merge of update id %d failed due to error at line %d",
|
||||
id, lineno);
|
||||
return (DBIXFR_ERROR);
|
||||
}
|
||||
rrecp = res_mkupdrec(section, dname, class, type, ttl);
|
||||
if (section != S_ZONE) {
|
||||
struct databuf *dp;
|
||||
dp = savedata(class, type, ttl, (u_char *) data, n);
|
||||
dp->d_zone = zonenum;
|
||||
dp->d_cred = DB_C_ZONE;
|
||||
dp->d_clev = nlabels(zp->z_origin);
|
||||
rrecp->r_dp = dp;
|
||||
rrecp->r_opcode = opcode;
|
||||
} else {
|
||||
rrecp->r_zone = zonenum;
|
||||
rrecp->r_opcode = opcode;
|
||||
}
|
||||
|
||||
/* remove add/delete pairs */
|
||||
if (section == S_UPDATE) {
|
||||
ns_updrec *arp;
|
||||
int foundmatch;
|
||||
|
||||
arp = TAIL(*listuprec);
|
||||
foundmatch = 0;
|
||||
while (arp) {
|
||||
if (arp->r_section == S_UPDATE &&
|
||||
((arp->r_opcode == DELETE &&
|
||||
opcode == ADD) ||
|
||||
(opcode == DELETE &&
|
||||
arp->r_opcode == ADD)) &&
|
||||
arp->r_dp->d_type == rrecp->r_dp->d_type &&
|
||||
arp->r_dp->d_class == rrecp->r_dp->d_class &&
|
||||
arp->r_dp->d_ttl == rrecp->r_dp->d_ttl &&
|
||||
ns_samename(arp->r_dname, dname) == 1 &&
|
||||
db_cmp(arp->r_dp, rrecp->r_dp) == 0) {
|
||||
db_detach(&rrecp->r_dp);
|
||||
db_detach(&arp->r_dp);
|
||||
UNLINK(*listuprec, arp, r_link);
|
||||
res_freeupdrec(arp);
|
||||
res_freeupdrec(rrecp);
|
||||
foundmatch = 1;
|
||||
break;
|
||||
}
|
||||
arp = PREV(arp, r_link);
|
||||
}
|
||||
if (foundmatch)
|
||||
continue;
|
||||
}
|
||||
|
||||
APPEND(*listuprec, rrecp, r_link);
|
||||
/* Override zone number with current zone serial number */
|
||||
rrecp->r_zone = serial;
|
||||
}
|
||||
|
||||
if (err)
|
||||
return (DBIXFR_ERROR);
|
||||
|
||||
return (DBIXFR_END);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,341 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)db_lookup.c 4.18 (Berkeley) 3/21/91";
|
||||
static const char rcsid[] = "$Id: db_lookup.c,v 8.27 2001/06/18 14:42:55 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Table lookup routines.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
/*
|
||||
* Lookup 'name' and return a pointer to the namebuf;
|
||||
* NULL otherwise. If 'insert', insert name into tables.
|
||||
* Wildcard lookups are handled.
|
||||
*/
|
||||
struct namebuf *
|
||||
nlookup(const char *name, struct hashbuf **htpp,
|
||||
const char **fname, int insert)
|
||||
{
|
||||
struct namebuf *np;
|
||||
const char *cp;
|
||||
int c;
|
||||
u_int hval;
|
||||
struct hashbuf *htp;
|
||||
struct namebuf *parent = NULL;
|
||||
int escaped = 0;
|
||||
|
||||
htp = *htpp;
|
||||
hval = 0;
|
||||
*fname = "???";
|
||||
for (cp = name; (c = *cp++) != 0; (void)NULL) {
|
||||
if (!escaped && (c == '.')) {
|
||||
parent = np = nlookup(cp, htpp, fname, insert);
|
||||
if (np == NULL)
|
||||
return (NULL);
|
||||
if (*fname != cp)
|
||||
return (np);
|
||||
if ((htp = np->n_hash) == NULL) {
|
||||
if (!insert) {
|
||||
if (ns_wildcard(NAME(*np)))
|
||||
*fname = name;
|
||||
return (np);
|
||||
}
|
||||
htp = savehash((struct hashbuf *)NULL);
|
||||
np->n_hash = htp;
|
||||
}
|
||||
*htpp = htp;
|
||||
break;
|
||||
}
|
||||
|
||||
HASHIMILATE(hval, c);
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else if (c == '\\')
|
||||
escaped = 1;
|
||||
}
|
||||
cp--;
|
||||
/*
|
||||
* Lookup this label in current hash table.
|
||||
*/
|
||||
for (np = htp->h_tab[hval % htp->h_size];
|
||||
np != NULL;
|
||||
np = np->n_next) {
|
||||
if (np->n_hashval == hval &&
|
||||
((size_t)NAMELEN(*np) == (size_t)(cp - name)) &&
|
||||
(strncasecmp(name, NAME(*np), cp - name) == 0)) {
|
||||
*fname = name;
|
||||
return (np);
|
||||
}
|
||||
}
|
||||
if (!insert) {
|
||||
/*
|
||||
* Look for wildcard in this hash table.
|
||||
* Don't use a cached "*" name as a wildcard,
|
||||
* only authoritative.
|
||||
*/
|
||||
hval = ('*' & HASHMASK) % htp->h_size;
|
||||
for (np = htp->h_tab[hval]; np != NULL; np = np->n_next) {
|
||||
if (ns_wildcard(NAME(*np)) &&
|
||||
np->n_data && np->n_data->d_zone != 0) {
|
||||
*fname = name;
|
||||
return (np);
|
||||
}
|
||||
}
|
||||
return (parent);
|
||||
}
|
||||
np = savename(name, cp - name);
|
||||
np->n_parent = parent;
|
||||
np->n_hashval = hval;
|
||||
hval %= htp->h_size;
|
||||
np->n_next = htp->h_tab[hval];
|
||||
htp->h_tab[hval] = np;
|
||||
/* Increase hash table size. */
|
||||
if (++htp->h_cnt > (htp->h_size * AVGCH_NLOOKUP)) {
|
||||
*htpp = savehash(htp);
|
||||
if (parent == NULL) {
|
||||
if (htp == hashtab) {
|
||||
hashtab = *htpp;
|
||||
} else {
|
||||
fcachetab = *htpp;
|
||||
}
|
||||
}
|
||||
else
|
||||
parent->n_hash = *htpp;
|
||||
htp = *htpp;
|
||||
}
|
||||
*fname = name;
|
||||
return (np);
|
||||
}
|
||||
|
||||
/* struct namebuf *
|
||||
* np_parent(struct namebuf *np)
|
||||
* Find the "parent" namebuf of np.
|
||||
* This is tricky since the parent of "com" is "" and both are stored
|
||||
* in the same hashbuf.
|
||||
* See also:
|
||||
* the AXFR wart description in ns_axfr.c
|
||||
*/
|
||||
struct namebuf *
|
||||
np_parent(struct namebuf *np) {
|
||||
struct hashbuf *htp;
|
||||
struct namebuf *np2;
|
||||
|
||||
if (np->n_parent != NULL || NAME(*np)[0] == '\0')
|
||||
return (np->n_parent);
|
||||
|
||||
/* Try to figure out if np is pointing into the cache or hints. */
|
||||
/* Try the cache first. */
|
||||
htp = hashtab;
|
||||
try_again:
|
||||
/* Search the hash chain that np should be part of. */
|
||||
for (np2 = htp->h_tab[np->n_hashval % htp->h_size];
|
||||
np2 != NULL;
|
||||
np2 = np2->n_next)
|
||||
{
|
||||
if (np == np2) { /* found it! */
|
||||
/* "" hashes into the first bucket */
|
||||
for (np = htp->h_tab[0]; np != NULL; np = np->n_next) {
|
||||
if (NAME(*np)[0] == '\0')
|
||||
/* found the root namebuf */
|
||||
return (np);
|
||||
}
|
||||
/* there are no RR's with a owner name of "." yet */
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
/* Try the hints. */
|
||||
if (htp == hashtab) {
|
||||
htp = fcachetab;
|
||||
goto try_again;
|
||||
}
|
||||
ns_debug(ns_log_db, 1, "np_parent(0x%lx) couldn't find namebuf",
|
||||
(u_long)np);
|
||||
return (NULL); /* XXX shouldn't happen */
|
||||
}
|
||||
|
||||
/* int
|
||||
* match(dp, class, type)
|
||||
* Does data record `dp' match the class and type?
|
||||
* return value:
|
||||
* boolean
|
||||
*/
|
||||
int
|
||||
match(struct databuf *dp, int class, int type) {
|
||||
if (dp->d_class != class && class != C_ANY)
|
||||
return (0);
|
||||
if (dp->d_type != type && dp->d_type != T_SIG && type != T_ANY)
|
||||
return (0);
|
||||
if (type != T_SIG && dp->d_type == T_SIG && (int)SIG_COVERS(dp) != type)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* static int
|
||||
* nxtlower(name, dp)
|
||||
* Is the NXT/SIG NXT record 'lower'?
|
||||
* return value:
|
||||
* boolean
|
||||
*/
|
||||
static int
|
||||
nxtlower(const char *name, struct databuf *dp) {
|
||||
/* An NXT is a lower NXT iff the SOA bit is set in the bitmap */
|
||||
if (dp->d_type == T_NXT) {
|
||||
u_char *nxtbitmap = dp->d_data + strlen((char *)dp->d_data) + 1;
|
||||
return (NS_NXT_BIT_ISSET(T_SOA, nxtbitmap) ? 1 : 0);
|
||||
}
|
||||
/* If it's not an NXT, it's a SIG NXT. An NXT record must be signed
|
||||
* by the zone, so the signer name must be the same as the owner.
|
||||
*/
|
||||
return (ns_samename(name, (char *)dp->d_data + SIG_HDR_SIZE) != 1 ? 0 : 1);
|
||||
}
|
||||
|
||||
/* int
|
||||
* nxtmatch(name, dp1, dp2)
|
||||
* Do NXT/SIG NXT records `dp1' and `dp2' belong to the same NXT set?
|
||||
* return value:
|
||||
* boolean
|
||||
*/
|
||||
int
|
||||
nxtmatch(const char *name, struct databuf *dp1, struct databuf *dp2) {
|
||||
int dp1_lower, dp2_lower;
|
||||
int type1, type2;
|
||||
|
||||
if (dp1->d_type == ns_t_sig)
|
||||
type1 = SIG_COVERS(dp1);
|
||||
else
|
||||
type1 = dp1->d_type;
|
||||
if (dp2->d_type == ns_t_sig)
|
||||
type2 = SIG_COVERS(dp2);
|
||||
else
|
||||
type2 = dp2->d_type;
|
||||
|
||||
if (type1 != ns_t_nxt || type2 != ns_t_nxt)
|
||||
return (0);
|
||||
dp1_lower = nxtlower(name, dp1);
|
||||
dp2_lower = nxtlower(name, dp2);
|
||||
return (dp1_lower == dp2_lower);
|
||||
}
|
||||
|
||||
/* int
|
||||
* rrmatch(name, dp1, dp2)
|
||||
* Do data records `dp1' and `dp2' match in class and type?
|
||||
* If both are NXTs, do they belong in the same NXT set?
|
||||
* If both are SIGs, do the covered types match?
|
||||
* If both are SIG NXTs, do the covered NXTs belong in the same set?
|
||||
* Why is DNSSEC so confusing?
|
||||
* return value:
|
||||
* boolean
|
||||
*/
|
||||
int
|
||||
rrmatch(const char *name, struct databuf *dp1, struct databuf *dp2) {
|
||||
if (dp1->d_class != dp2->d_class &&
|
||||
dp1->d_class != C_ANY && dp2->d_class != C_ANY)
|
||||
return(0);
|
||||
if (dp1->d_type != dp2->d_type &&
|
||||
dp1->d_type != T_ANY && dp2->d_type != T_ANY)
|
||||
return(0);
|
||||
if (dp1->d_type == T_NXT)
|
||||
return(nxtmatch(name, dp1, dp2));
|
||||
if (dp1->d_type != T_SIG)
|
||||
return(1);
|
||||
if (SIG_COVERS(dp1) == SIG_COVERS(dp2)) {
|
||||
if (SIG_COVERS(dp1) == ns_t_nxt)
|
||||
return(nxtmatch(name, dp1, dp2));
|
||||
else
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)db_save.c 4.16 (Berkeley) 3/21/91";
|
||||
static const char rcsid[] = "$Id: db_save.c,v 8.30 2002/05/18 01:02:56 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Buffer allocation and deallocation routines.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
/*
|
||||
* Allocate a name buffer & save name.
|
||||
*/
|
||||
struct namebuf *
|
||||
savename(const char *name, int len) {
|
||||
struct namebuf *np;
|
||||
|
||||
/*
|
||||
* Note that MAXLABEL * 4 < 256, so a single length byte is enough.
|
||||
* Also, we use MAXLABEL * 4 because each label character can
|
||||
* expand into up to four characters when rendered in canonical
|
||||
* form.
|
||||
*/
|
||||
INSIST(len >= 0 && len <= (MAXLABEL * 4));
|
||||
np = (struct namebuf *) memget(NAMESIZE(len));
|
||||
if (np == NULL)
|
||||
panic("savename: memget", NULL);
|
||||
memset(np, 0, NAMESIZE(len));
|
||||
NAMELEN(*np) = (unsigned)len;
|
||||
memcpy(NAME(*np), name, len);
|
||||
NAME(*np)[len] = '\0';
|
||||
return (np);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a data buffer & save data.
|
||||
*/
|
||||
struct databuf *
|
||||
savedata(class, type, ttl, data, size)
|
||||
int class, type;
|
||||
u_int32_t ttl;
|
||||
u_char *data;
|
||||
int size;
|
||||
{
|
||||
struct databuf *dp;
|
||||
int bytes = BIND_DATASIZE(size);
|
||||
|
||||
dp = (struct databuf *)memget(bytes);
|
||||
if (dp == NULL)
|
||||
panic("savedata: memget", NULL);
|
||||
if (class > CLASS_MAX)
|
||||
panic("savedata: bad class", NULL);
|
||||
memset(dp, 0, bytes);
|
||||
dp->d_next = NULL;
|
||||
dp->d_type = type;
|
||||
dp->d_class = class;
|
||||
dp->d_ttl = ttl;
|
||||
dp->d_size = size;
|
||||
dp->d_mark = 0;
|
||||
dp->d_flags = 0;
|
||||
dp->d_cred = 0;
|
||||
dp->d_clev = 0;
|
||||
dp->d_secure = DB_S_INSECURE;
|
||||
dp->d_rcode = NOERROR;
|
||||
dp->d_addr.s_addr = htonl(0);
|
||||
dp->d_nstime = 0;
|
||||
dp->d_rcnt = 1;
|
||||
#ifdef CHECK_MAGIC
|
||||
dp->d_magic = DATABUF_MAGIC;
|
||||
#endif
|
||||
memcpy(dp->d_data, data, dp->d_size);
|
||||
return (dp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a data buffer & save data.
|
||||
*/
|
||||
struct hashbuf *
|
||||
savehash(oldhtp)
|
||||
struct hashbuf *oldhtp;
|
||||
{
|
||||
struct hashbuf *htp;
|
||||
struct namebuf *np, *nnp, **hp;
|
||||
int n, newsize;
|
||||
|
||||
if (oldhtp == NULL)
|
||||
newsize = hashsizes[0];
|
||||
else {
|
||||
for (n = 0; (newsize = hashsizes[n++]) != 0; (void)NULL)
|
||||
if (oldhtp->h_size == newsize) {
|
||||
newsize = hashsizes[n];
|
||||
break;
|
||||
}
|
||||
if (newsize == 0)
|
||||
newsize = oldhtp->h_size * 2 + 1;
|
||||
}
|
||||
ns_debug(ns_log_db, 4, "savehash GROWING to %d", newsize);
|
||||
htp = (struct hashbuf *) memget(HASHSIZE(newsize));
|
||||
if (htp == NULL)
|
||||
ns_panic(ns_log_db, 0, "savehash: %s", strerror(errno));
|
||||
htp->h_size = newsize;
|
||||
memset(htp->h_tab, 0, newsize * sizeof(struct namebuf *));
|
||||
if (oldhtp == NULL) {
|
||||
htp->h_cnt = 0;
|
||||
return (htp);
|
||||
}
|
||||
ns_debug(ns_log_db, 4, "savehash(%#lx) cnt=%d, sz=%d, newsz=%d",
|
||||
(u_long)oldhtp, oldhtp->h_cnt, oldhtp->h_size, newsize);
|
||||
htp->h_cnt = oldhtp->h_cnt;
|
||||
for (n = 0; n < oldhtp->h_size; n++) {
|
||||
for (np = oldhtp->h_tab[n]; np != NULL; np = nnp) {
|
||||
nnp = np->n_next;
|
||||
hp = &htp->h_tab[np->n_hashval % htp->h_size];
|
||||
np->n_next = *hp;
|
||||
*hp = np;
|
||||
}
|
||||
}
|
||||
oldhtp->h_cnt = 0; /* Keep rm_hash() happy. */
|
||||
rm_hash(oldhtp);
|
||||
return (htp);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,158 +0,0 @@
|
||||
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: db_tsig.c,v 8.8 2002/05/21 02:34:32 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
#include <isc/tree.h>
|
||||
|
||||
#include <isc/dst.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
typedef struct {
|
||||
DST_KEY *key;
|
||||
void *ctx;
|
||||
} tsig_axfr_state;
|
||||
|
||||
#define TSIG_ALG_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
|
||||
#define TSIG_ALG_MD5_SHORT "hmac-md5"
|
||||
|
||||
const char *
|
||||
tsig_alg_name(int value) {
|
||||
if (value == KEY_HMAC_MD5)
|
||||
return(TSIG_ALG_MD5);
|
||||
else
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int
|
||||
tsig_alg_value(char *name) {
|
||||
if (ns_samename(name, TSIG_ALG_MD5) == 1 ||
|
||||
strcasecmp(name, TSIG_ALG_MD5_SHORT) == 0)
|
||||
return (KEY_HMAC_MD5);
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
|
||||
DST_KEY *
|
||||
tsig_key_from_addr(struct in_addr addr) {
|
||||
server_info si = find_server(addr);
|
||||
if (si == NULL || si->key_list == NULL || si->key_list->first == NULL)
|
||||
return(NULL);
|
||||
return(si->key_list->first->key);
|
||||
}
|
||||
|
||||
struct tsig_record *
|
||||
new_tsig(DST_KEY *key, u_char *sig, int siglen) {
|
||||
struct tsig_record *tsig;
|
||||
|
||||
if (siglen > TSIG_SIG_SIZE)
|
||||
return(NULL);
|
||||
tsig = memget(sizeof(struct tsig_record));
|
||||
if (tsig == NULL)
|
||||
return(NULL);
|
||||
tsig->key = key;
|
||||
tsig->siglen = siglen;
|
||||
memcpy(tsig->sig, sig, siglen);
|
||||
return(tsig);
|
||||
}
|
||||
|
||||
void
|
||||
free_tsig(struct tsig_record *tsig) {
|
||||
if (tsig == NULL)
|
||||
return;
|
||||
memput(tsig, sizeof(struct tsig_record));
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,462 +0,0 @@
|
||||
/*
|
||||
* This is a worthless, nonrunnable example of a named.conf file that has
|
||||
* every conceivable syntax element in use. We use it to test the parser.
|
||||
* It could also be used as a conceptual template for users of new features.
|
||||
*/
|
||||
|
||||
/*
|
||||
* C-style comments are OK
|
||||
*/
|
||||
|
||||
// So are C++-style comments
|
||||
|
||||
# So are shell-style comments
|
||||
|
||||
// watch out for ";" -- it's important!
|
||||
|
||||
key sample_key { // for TSIG
|
||||
algorithm hmac-md5; // hmac-md5 is the supported algorithm
|
||||
secret "abcdefgh"; // base 64 encoded secret
|
||||
};
|
||||
|
||||
key key2 {
|
||||
algorithm hmac-md5;
|
||||
secret "87654321";
|
||||
};
|
||||
|
||||
options {
|
||||
directory "."; // use current directory
|
||||
named-xfer "/usr/libexec/named-xfer"; // _PATH_XFER
|
||||
dump-file "named_dump.db"; // _PATH_DUMPFILE
|
||||
pid-file "/var/run/named.pid"; // _PATH_PIDFILE
|
||||
statistics-file "named.stats"; // _PATH_STATS
|
||||
memstatistics-file "named.memstats"; // _PATH_MEMSTATS
|
||||
check-names master fail;
|
||||
check-names slave warn;
|
||||
check-names response ignore;
|
||||
host-statistics no;
|
||||
deallocate-on-exit no; // Painstakingly deallocate all
|
||||
// objects when exiting instead of
|
||||
// letting the OS clean up for us.
|
||||
// Useful a memory leak is suspected.
|
||||
// Final statistics are written to the
|
||||
// memstatistics-file.
|
||||
datasize default;
|
||||
stacksize default;
|
||||
coresize default;
|
||||
files unlimited;
|
||||
recursion yes;
|
||||
fetch-glue yes;
|
||||
fake-iquery no;
|
||||
notify yes; // send NOTIFY messages. You can set
|
||||
// notify on a zone-by-zone
|
||||
// basis in the "zone" statement
|
||||
// see (below)
|
||||
// notify explicit; // only sent the notifies to the
|
||||
// also-notify list
|
||||
serial-queries 4; // number of parallel SOA queries
|
||||
// we can have outstanding for master
|
||||
// zone change testing purposes
|
||||
auth-nxdomain yes; // always set AA on NXDOMAIN.
|
||||
// don't set this to 'no' unless
|
||||
// you know what you're doing -- older
|
||||
// servers won't like it.
|
||||
multiple-cnames no; // if yes, then a name my have more
|
||||
// than one CNAME RR. This use
|
||||
// is non-standard and is not
|
||||
// recommended, but it is available
|
||||
// because previous releases supported
|
||||
// it and it was used by large sites
|
||||
// for load balancing.
|
||||
allow-query { any; };
|
||||
allow-transfer { any; };
|
||||
transfers-in 10; // DEFAULT_XFERS_RUNNING, cannot be
|
||||
// set > than MAX_XFERS_RUNNING (20)
|
||||
transfers-per-ns 2; // DEFAULT_XFERS_PER_NS
|
||||
transfers-out 0; // not implemented
|
||||
max-transfer-time-in 120; // MAX_XFER_TIME; the default number
|
||||
// of minutes an inbound zone transfer
|
||||
// may run. May be set on a per-zone
|
||||
// basis.
|
||||
/*
|
||||
* The "transfer-format" option specifies the way outbound zone
|
||||
* transfers (i.e. from us to them) are formatted. Two values are
|
||||
* allowed:
|
||||
*
|
||||
* one-answer Each RR gets its own DNS message.
|
||||
* This format is not very efficient,
|
||||
* but is widely understood. All
|
||||
* versions of BIND prior to 8.1 generate
|
||||
* this format for outbound zone
|
||||
* and require it on inbound transfers.
|
||||
*
|
||||
* many-answers As many RRs as will fit are put into
|
||||
* each DNS message. This format is
|
||||
* the most efficient, but is only known
|
||||
* to work with BIND 8. Patches to
|
||||
* BIND 4.9.5 named-xfer that enable it
|
||||
* to understand 'many-answers' will be
|
||||
* available.
|
||||
*
|
||||
* If you are going to be doing zone transfers to older servers, you
|
||||
* shouldn't use 'many-answers'. 'transfer-format' may also be set
|
||||
* on a host-by-host basis using the 'server' statement (see below).
|
||||
*/
|
||||
transfer-format one-answer;
|
||||
query-source address * port *;
|
||||
/*
|
||||
* The "forward" option is only meaningful if you've defined
|
||||
* forwarders. "first" gives the normal BIND
|
||||
* forwarding behavior, i.e. ask the forwarders first, and if that
|
||||
* doesn't work then do the full lookup. You can also say
|
||||
* "forward only;" which is what used to be specified with
|
||||
* "slave" or "options forward-only". "only" will never attempt
|
||||
* a full lookup; only the forwarders will be used.
|
||||
*/
|
||||
forward first;
|
||||
forwarders { }; // default is no forwarders
|
||||
/*
|
||||
* Here's a forwarders example that isn't trivial
|
||||
*/
|
||||
/*
|
||||
forwarders {
|
||||
1.2.3.4;
|
||||
5.6.7.8;
|
||||
};
|
||||
*/
|
||||
topology { localhost; localnets; }; // prefer local nameservers
|
||||
/*
|
||||
* Here's a more complicated topology example; it's commented out
|
||||
* because only one topology block is allowed.
|
||||
*
|
||||
topology {
|
||||
10/8; // prefer network 10.0.0.0
|
||||
// netmask 255.0.0.0 most
|
||||
!1.2.3/24; // don't like 1.2.3.0 netmask
|
||||
// 255.255.255.0 at all
|
||||
{ 1.2/16; 3/8; }; // like 1.2.0.0 netmask 255.255.0.0
|
||||
// and 3.0.0.0 netmask 255.0.0.0
|
||||
// equally well, but less than 10/8
|
||||
};
|
||||
*/
|
||||
|
||||
listen-on port 53 { any; }; // listen for queries on port 53 on
|
||||
// any interface on the system
|
||||
// (i.e. all interfaces). The
|
||||
// "port 53" is optional; if you
|
||||
// don't specify a port, port 53
|
||||
// is assumed.
|
||||
/*
|
||||
* Multiple listen-on statements are allowed. Here's a more
|
||||
* complicated example:
|
||||
*/
|
||||
/*
|
||||
listen-on { 5.6.7.8; }; // listen on port 53 on interface
|
||||
// 5.6.7.8
|
||||
listen-on port 1234 { // listen on port 1234 on any
|
||||
!1.2.3.4; // interface on network 1.2.3
|
||||
1.2.3/24; // netmask 255.255.255.0, except for
|
||||
}; // interface 1.2.3.4.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Interval Timers
|
||||
*/
|
||||
cleaning-interval 60; // clean the cache of expired RRs
|
||||
// every 'cleaning-interval' minutes
|
||||
interface-interval 60; // scan for new or deleted interfaces
|
||||
// every 'interface-interval' minutes
|
||||
statistics-interval 60; // log statistics every
|
||||
// 'statistics-interval' minutes
|
||||
/*
|
||||
* IXFR options
|
||||
*/
|
||||
maintain-ixfr-base no; // If yes, keep transaction log file for IXFR
|
||||
max-ixfr-log-size 20; // Not implemented, maximum size the
|
||||
// IXFR transaction log file to grow
|
||||
};
|
||||
|
||||
/*
|
||||
* Control listeners, for "ndc". Every nameserver needs at least one.
|
||||
*/
|
||||
controls {
|
||||
inet * port 52 allow { any; }; // a bad idea
|
||||
unix "/var/run/ndc" perm 0600 owner 0 group 0; // the default
|
||||
};
|
||||
|
||||
zone "master.demo.zone" {
|
||||
type master; // what used to be called "primary"
|
||||
file "master.demo.zone";
|
||||
check-names fail;
|
||||
allow-update { none; };
|
||||
allow-transfer { any; };
|
||||
allow-query { any; };
|
||||
// notify yes; // send NOTIFY messages for this
|
||||
// zone? The global option is used
|
||||
// if "notify" is not specified
|
||||
// here.
|
||||
// notify explicit; // only sent the notifies to the
|
||||
// also-notify list
|
||||
also-notify { }; // don't notify any nameservers other
|
||||
// than those on the NS list for this
|
||||
// zone
|
||||
};
|
||||
|
||||
zone "slave.demo.zone" {
|
||||
type slave; // what used to be called "secondary"
|
||||
file "slave.demo.zone";
|
||||
ixfr-base "slave.demo.zone.ixfr"; // File name for IXFR transaction log file
|
||||
masters {
|
||||
1.2.3.4; // where to zone transfer from
|
||||
5.6.7.8 key key2;
|
||||
};
|
||||
transfer-source 10.0.0.53; // fixes multihoming problems
|
||||
check-names warn;
|
||||
allow-update { none; };
|
||||
allow-transfer { any; };
|
||||
allow-query { any; };
|
||||
max-transfer-time-in 120; // if not set, global option is used.
|
||||
also-notify { }; // don't notify any nameservers other
|
||||
// than those on the NS list for this
|
||||
// zone
|
||||
};
|
||||
|
||||
zone "stub.demo.zone" {
|
||||
type stub; // stub zones are like slave zones,
|
||||
// except that only the NS records
|
||||
// are transferred.
|
||||
file "stub.demo.zone";
|
||||
masters {
|
||||
1.2.3.4; // where to zone transfer from
|
||||
5.6.7.8;
|
||||
};
|
||||
check-names warn;
|
||||
allow-update { none; };
|
||||
allow-transfer { any; };
|
||||
allow-query { any; };
|
||||
max-transfer-time-in 120; // if not set, global option is used.
|
||||
};
|
||||
|
||||
zone "." {
|
||||
type hint; // used to be specified w/ "cache"
|
||||
file "cache.db";
|
||||
pubkey 257 255 1 "AQP2fHpZ4VMpKo/jc9Fod821uyfY5p8j5h/Am0V/KpBTMZjdXmp9QJe6yFRoIIzkaNCgTIftASdpXGgCwFB2j2KXP/rick6gvEer5VcDEkLR5Q==";
|
||||
};
|
||||
|
||||
trusted-keys {
|
||||
. 257 255 1 "AQP2fHpZ4VMpKo/jc9Fod821uyfY5p8j5h/Am0V/KpBTMZjdXmp9QJe6yFRoIIzkaNCgTIftASdpXGgCwFB2j2KXP/rick6gvEer5VcDEkLR5Q==";
|
||||
};
|
||||
|
||||
|
||||
acl can_query { !1.2.3/24; any; }; // network 1.2.3.0 mask 255.255.255.0
|
||||
// is disallowed; rest are OK
|
||||
acl can_axfr { 1.2.3.4; can_query; }; // host 1.2.3.4 and any host allowed
|
||||
// by can_query are OK
|
||||
|
||||
zone "non-default-acl.demo.zone" {
|
||||
type master;
|
||||
file "foo";
|
||||
allow-query { can_query; };
|
||||
allow-transfer { can_axfr; };
|
||||
allow-update {
|
||||
1.2.3.4;
|
||||
5.6.7.8;
|
||||
};
|
||||
};
|
||||
|
||||
acl key_acl { key sample_key; }; // a request signed with sample_key
|
||||
|
||||
server 1.2.3.4 {
|
||||
edns no; // if no, we won't send ends queries
|
||||
// to this server
|
||||
bogus no; // if yes, we won't query or listen
|
||||
// to this server
|
||||
transfer-format one-answer; // set transfer format for this
|
||||
// server (see the description of
|
||||
// 'transfer-format' above)
|
||||
// if not specified, the global option
|
||||
// will be used
|
||||
transfers 0; // not implemented
|
||||
keys { sample_key; key2; }; // for TSIG; sign requests to this
|
||||
// server with this key
|
||||
support-ixfr yes; // for IXFR supported by server
|
||||
// if yes, the listed server talks IXFR
|
||||
};
|
||||
|
||||
logging {
|
||||
/*
|
||||
* All log output goes to one or more "channels"; you can make as
|
||||
* many of them as you want.
|
||||
*/
|
||||
|
||||
channel syslog_errors { // this channel will send errors or
|
||||
syslog user; // or worse to syslog (user facility)
|
||||
severity error;
|
||||
};
|
||||
|
||||
/*
|
||||
* Channels have a severity level. Messages at severity levels
|
||||
* greater than or equal to the channel's level will be logged on
|
||||
* the channel. In order of decreasing severity, the levels are:
|
||||
*
|
||||
* critical a fatal error
|
||||
* error
|
||||
* warning
|
||||
* notice a normal, but significant event
|
||||
* info an informational message
|
||||
* debug 1 the least detailed debugging info
|
||||
* ...
|
||||
* debug 99 the most detailed debugging info
|
||||
*/
|
||||
|
||||
/*
|
||||
* Here are the built-in channels:
|
||||
*
|
||||
* channel default_syslog {
|
||||
* syslog daemon;
|
||||
* severity info;
|
||||
* };
|
||||
*
|
||||
* channel default_debug {
|
||||
* file "named.run"; // note: stderr is used instead
|
||||
* // of "named.run" if the server
|
||||
* // is started with the "-f"
|
||||
* // option.
|
||||
* severity dynamic; // this means log debugging
|
||||
* // at whatever debugging level
|
||||
* // the server is at, and don't
|
||||
* // log anything if not
|
||||
* // debugging.
|
||||
* };
|
||||
*
|
||||
* channel null { // this is the bit bucket;
|
||||
* file "/dev/null"; // any logging to this channel
|
||||
* // is discarded.
|
||||
* };
|
||||
*
|
||||
* channel default_stderr { // writes to stderr
|
||||
* file "<stderr>"; // this is illustrative only;
|
||||
* // there's currently no way
|
||||
* // of saying "stderr" in the
|
||||
* // configuration language.
|
||||
* // i.e. don't try this at home.
|
||||
* severity info;
|
||||
* };
|
||||
*
|
||||
* default_stderr only works before the server daemonizes (i.e.
|
||||
* during initial startup) or when it is running in foreground
|
||||
* mode (-f command line option).
|
||||
*/
|
||||
|
||||
/*
|
||||
* There are many categories, so you can send the logs
|
||||
* you want to see wherever you want, without seeing logs you
|
||||
* don't want. Right now the categories are
|
||||
*
|
||||
* default the catch-all. many things still
|
||||
* aren't classified into categories, and
|
||||
* they all end up here. also, if you
|
||||
* don't specify any channels for a
|
||||
* category, the default category is used
|
||||
* instead.
|
||||
* config high-level configuration file
|
||||
* processing
|
||||
* parser low-level configuration file processing
|
||||
* queries what used to be called "query logging"
|
||||
* lame-servers messages like "Lame server on ..."
|
||||
* statistics
|
||||
* panic if the server has to shut itself
|
||||
* down due to an internal problem, it
|
||||
* logs the problem here (as well as
|
||||
* in the problem's native category)
|
||||
* update dynamic update
|
||||
* ncache negative caching
|
||||
* xfer-in zone transfers we're receiving
|
||||
* xfer-out zone transfers we're sending
|
||||
* db all database operations
|
||||
* eventlib debugging info from the event system
|
||||
* (see below)
|
||||
* packet dumps of packets received and sent
|
||||
* (see below)
|
||||
* notify the NOTIFY protocol
|
||||
* cname messages like "XX points to a CNAME"
|
||||
* security approved/unapproved requests
|
||||
* os operating system problems
|
||||
* insist consistency check failures
|
||||
* maintenance periodic maintenance
|
||||
* load zone loading
|
||||
* response-checks messages like
|
||||
* "Malformed response ..."
|
||||
* "wrong ans. name ..."
|
||||
* "unrelated additional info ..."
|
||||
* "invalid RR type ..."
|
||||
* "bad referral ..."
|
||||
*/
|
||||
|
||||
category parser {
|
||||
syslog_errors; // you can log to as many channels
|
||||
default_syslog; // as you want
|
||||
};
|
||||
|
||||
category lame-servers { null; }; // don't log these at all
|
||||
|
||||
channel moderate_debug {
|
||||
severity debug 3; // level 3 debugging to file
|
||||
file "foo"; // foo
|
||||
print-time yes; // timestamp log entries
|
||||
print-category yes; // print category name
|
||||
print-severity yes; // print severity level
|
||||
/*
|
||||
* Note that debugging must have been turned on either
|
||||
* on the command line or with a signal to get debugging
|
||||
* output (non-debugging output will still be written to
|
||||
* this channel).
|
||||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
* If you don't want to see "zone XXXX loaded" messages but do
|
||||
* want to see any problems, you could do the following.
|
||||
*/
|
||||
channel no_info_messages {
|
||||
syslog;
|
||||
severity notice;
|
||||
};
|
||||
|
||||
category load { no_info_messages; };
|
||||
|
||||
/*
|
||||
* You can also define category "default"; it gets used when no
|
||||
* "category" statement has been given for a category.
|
||||
*/
|
||||
category default {
|
||||
default_syslog;
|
||||
moderate_debug;
|
||||
};
|
||||
|
||||
/*
|
||||
* If you don't define category default yourself, the default
|
||||
* default category will be used. It is
|
||||
*
|
||||
* category default { default_syslog; default_debug; };
|
||||
*/
|
||||
|
||||
/*
|
||||
* If you don't define category panic yourself, the default
|
||||
* panic category will be used. It is
|
||||
*
|
||||
* category panic { default_syslog; default_stderr; };
|
||||
*/
|
||||
|
||||
/*
|
||||
* Two categories, 'packet' and 'eventlib', are special. Only one
|
||||
* channel may be assigned to each of them, and it must be a
|
||||
* file channel. If you don't define them yourself, they default to
|
||||
*
|
||||
* category eventlib { default_debug; };
|
||||
*
|
||||
* category packet { default_debug; };
|
||||
*/
|
||||
};
|
||||
|
||||
include "filename"; // can't do within a statement
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Id: named.h,v 8.32 2002/03/15 00:58:16 vixie Exp $
|
||||
*/
|
||||
|
||||
/* Options. Change them at your peril. */
|
||||
#undef NXDOMAIN_ON_DENIAL
|
||||
#define DEBUG
|
||||
#define ADDAUTH
|
||||
#define STUBS
|
||||
#define RETURNSOA
|
||||
#define BOGUSNS
|
||||
#define TRACEROOT
|
||||
#define XFRNETS
|
||||
#define QRYLOG
|
||||
#undef YPKLUDGE
|
||||
#define RENICE
|
||||
#define BIND_IXFR
|
||||
#define BIND_NOTIFY
|
||||
#define BIND_UPDATE
|
||||
#define WANT_PIDFILE
|
||||
#define FWD_LOOP
|
||||
#define DOTTED_SERIAL
|
||||
#define SENSIBLE_DOTS
|
||||
#define ROUND_ROBIN
|
||||
#define DNS_SECURITY
|
||||
#undef RSAREF
|
||||
#undef BSAFE
|
||||
#define ALLOW_LONG_TXT_RDATA
|
||||
#define STRICT_RFC2308
|
||||
#undef BIND_ZXFR
|
||||
#undef LOG_TSIG_BUG
|
||||
#define NOADDITIONAL
|
||||
#undef FORWARD_ALLOWS /* enable allow-query for forward zones. */
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/list.h>
|
||||
#include <isc/ctl.h>
|
||||
|
||||
#include <res_update.h>
|
||||
|
||||
#include "pathnames.h"
|
||||
|
||||
#include "ns_defs.h"
|
||||
#include "db_defs.h"
|
||||
|
||||
#include "ns_glob.h"
|
||||
#include "db_glob.h"
|
||||
|
||||
#include "ns_func.h"
|
||||
#include "db_func.h"
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,935 +0,0 @@
|
||||
/*
|
||||
* from ns.h 4.33 (Berkeley) 8/23/90
|
||||
* $Id: ns_defs.h,v 8.124.6.1 2003/06/02 09:56:34 marka Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1999 by Check Point Software Technologies, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Check Point Software Technologies Incorporated not be used
|
||||
* in advertising or publicity pertaining to distribution of the document
|
||||
* or software without specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND CHECK POINT SOFTWARE TECHNOLOGIES
|
||||
* INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL CHECK POINT SOFTWARE TECHNOLOGIES INCORPRATED
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global definitions for the name server.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Effort has been expended here to make all structure members 32 bits or
|
||||
* larger land on 32-bit boundaries; smaller structure members have been
|
||||
* deliberately shuffled and smaller integer sizes chosen where possible
|
||||
* to make sure this happens. This is all meant to avoid structure member
|
||||
* padding which can cost a _lot_ of memory when you have hundreds of
|
||||
* thousands of entries in your cache.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Timeout time should be around 1 minute or so. Using the
|
||||
* the current simplistic backoff strategy, the sequence
|
||||
* retrys after 4, 8, and 16 seconds. With 3 servers, this
|
||||
* dies out in a little more than a minute.
|
||||
* (sequence RETRYBASE, 2*RETRYBASE, 4*RETRYBASE... for MAXRETRY)
|
||||
*/
|
||||
#define NEWZONES 64 /* how many zones to grow the zone table by */
|
||||
#define INITIALZONES NEWZONES /* how many zones are allocated initially */
|
||||
#define MINROOTS 2 /* min number of root hints */
|
||||
#define NSMAX 16 /* max number of NS addrs to try ([0..255]) */
|
||||
#define RETRYBASE 4 /* base time between retries */
|
||||
#define MAXCLASS 255 /* XXX - may belong elsewhere */
|
||||
#define MAXRETRY 3 /* max number of retries per addr */
|
||||
#define MAXCNAMES 8 /* max # of CNAMES tried per addr */
|
||||
#define MAXQUERIES 20 /* max # of queries to be made */
|
||||
#define MAXQSERIAL 4 /* max # of outstanding QSERIAL's */
|
||||
/* (prevent "recursive" loops) */
|
||||
#define INIT_REFRESH 600 /* retry time for initial slave */
|
||||
/* contact (10 minutes) */
|
||||
#define MIN_REFRESH 2 /* never refresh more frequently than once */
|
||||
/* every MIN_REFRESH seconds */
|
||||
#define MIN_RETRY 1 /* never retry more frequently than once */
|
||||
/* every MIN_RETRY seconds */
|
||||
#define MAX_REFRESH 2419200 /* perform a refresh query at least */
|
||||
/* every 4 weeks*/
|
||||
#define MAX_RETRY 1209600 /* perform a retry after no more than 2 weeks */
|
||||
#define MAX_EXPIRE 31536000 /* expire a zone if we have not talked to */
|
||||
/* the primary in 1 year */
|
||||
#define NADDRECS 20 /* max addt'l rr's per resp */
|
||||
|
||||
#define XFER_TIMER 120 /* named-xfer's connect timeout */
|
||||
#define MAX_XFER_TIME 60*60*2 /* default max seconds for an xfer */
|
||||
#define XFER_TIME_FUDGE 10 /* MAX_XFER_TIME fudge */
|
||||
#define MAX_XFERS_RUNNING 20 /* max value of transfers_in */
|
||||
#define DEFAULT_XFERS_RUNNING 10 /* default value of transfers_in */
|
||||
#define DEFAULT_XFERS_PER_NS 2 /* default # of xfers per peer nameserver */
|
||||
#define XFER_BUFSIZE (16*1024) /* arbitrary but bigger than most MTU's */
|
||||
#define MAX_SYNCDELAY 3 /* Presumed timeout in use by our clients. */
|
||||
#define MAX_SYNCDRAIN 100000 /* How long we'll spin in drain_all_rcvbuf. */
|
||||
#define MAX_SYNCSTORE 500
|
||||
#define NS_MAX_DISTANCE 3 /* maximum nameserver chaining before failure */
|
||||
|
||||
/* maximum time to cache negative answers */
|
||||
#define DEFAULT_MAX_NCACHE_TTL (3*60*60)
|
||||
|
||||
#define ALPHA 0.7 /* How much to preserve of old response time */
|
||||
#define BETA 1.2 /* How much to penalize response time on failure */
|
||||
#define GAMMA 0.98 /* How much to decay unused response times */
|
||||
|
||||
/* What maintainance operations need to be performed sometime soon? */
|
||||
typedef enum need {
|
||||
main_need_zreload = 0, /* ns_zreload() needed. */
|
||||
main_need_reload, /* ns_reload() needed. */
|
||||
main_need_reconfig, /* ns_reconfig() needed. */
|
||||
main_need_endxfer, /* endxfer() needed. */
|
||||
main_need_zoneload, /* loadxfer() needed. */
|
||||
main_need_dump, /* doadump() needed. */
|
||||
main_need_statsdump, /* ns_stats() needed. */
|
||||
main_need_statsdumpandclear, /* ns_stats() needed. */
|
||||
main_need_exit, /* exit() needed. */
|
||||
main_need_qrylog, /* toggle_qrylog() needed. */
|
||||
main_need_debug, /* use_desired_debug() needed. */
|
||||
main_need_restart, /* exec() needed. */
|
||||
main_need_reap, /* need to reap dead children. */
|
||||
main_need_noexpired, /* ns_reconfig() needed w/ noexpired set. */
|
||||
main_need_tryxfer, /* attemt to start a zone transfer. */
|
||||
main_need_num /* MUST BE LAST. */
|
||||
} main_need;
|
||||
|
||||
/* What global options are set? */
|
||||
#define OPTION_NORECURSE 0x00000001 /* Don't recurse even if asked. */
|
||||
#define OPTION_NOFETCHGLUE 0x00000002 /* Don't fetch missing glue. */
|
||||
#define OPTION_FORWARD_ONLY 0x00000004 /* Don't use NS RR's, just forward. */
|
||||
#define OPTION_FAKE_IQUERY 0x00000008 /* Fake up bogus response to IQUERY. */
|
||||
#ifdef BIND_NOTIFY
|
||||
/* #define OPTION_NONOTIFY 0x00000010 */ /* Turn off notify */
|
||||
#define OPTION_SUPNOTIFY_INITIAL 0x00000020 /* Supress initial notify */
|
||||
#endif
|
||||
#define OPTION_NONAUTH_NXDOMAIN 0x00000040 /* Generate non-auth NXDOMAINs? */
|
||||
#define OPTION_MULTIPLE_CNAMES 0x00000080 /* Allow a name to have multiple
|
||||
* CNAME RRs */
|
||||
#define OPTION_HOSTSTATS 0x00000100 /* Maintain per-host statistics? */
|
||||
#define OPTION_DEALLOC_ON_EXIT 0x00000200 /* Deallocate everything on exit? */
|
||||
#define OPTION_NODIALUP 0x00000400 /* Turn off dialup support */
|
||||
#define OPTION_NORFC2308_TYPE1 0x00000800 /* Prevent type1 respones (RFC 2308)
|
||||
* to cached negative respones */
|
||||
#define OPTION_USE_ID_POOL 0x00001000 /* Use the memory hogging query ID */
|
||||
#define OPTION_TREAT_CR_AS_SPACE 0x00002000 /* Treat CR in zone files as
|
||||
* space */
|
||||
#define OPTION_USE_IXFR 0x00004000 /* Use by default ixfr in zone
|
||||
* transfer */
|
||||
#define OPTION_MAINTAIN_IXFR_BASE 0x00008000 /* Part of IXFR file name logic. */
|
||||
#define OPTION_HITCOUNT 0x00010000 /* Keep track of each time an
|
||||
* RR gets hit in the database */
|
||||
|
||||
#define DEFAULT_OPTION_FLAGS (OPTION_NODIALUP|OPTION_NONAUTH_NXDOMAIN|\
|
||||
OPTION_USE_ID_POOL|OPTION_NORFC2308_TYPE1)
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
#define SOAINCRINTVL 300 /* default value for the time after which
|
||||
* the zone serial number must be incremented
|
||||
* after a successful update has occurred */
|
||||
#define DUMPINTVL 3600 /* default interval at which to dump changed zones
|
||||
* randomized, not exact */
|
||||
#define DEFERUPDCNT 100 /* default number of updates that can happen
|
||||
* before the zone serial number will be
|
||||
* incremented */
|
||||
#define UPDATE_TIMER XFER_TIMER
|
||||
#endif /* BIND_UPDATE */
|
||||
|
||||
#define USE_MINIMUM 0xffffffff
|
||||
#define MAXIMUM_TTL 0x7fffffff
|
||||
|
||||
#define CLEAN_TIMER 0x01
|
||||
#define INTERFACE_TIMER 0x02
|
||||
#define STATS_TIMER 0x04
|
||||
#define HEARTBEAT_TIMER 0x08
|
||||
|
||||
/* IP address accessor, network byte order. */
|
||||
#define ina_ulong(ina) (ina.s_addr)
|
||||
|
||||
/* IP address accessor, host byte order, read only. */
|
||||
#define ina_hlong(ina) ntohl(ina.s_addr)
|
||||
|
||||
/* IP address equality. */
|
||||
/* XXX: assumes that network byte order won't affect equality. */
|
||||
#define ina_equal(a, b) (ina_ulong(a) == ina_ulong(b))
|
||||
|
||||
/* IP address equality with a mask. */
|
||||
#define ina_onnet(h, n, m) ((ina_ulong(h) & ina_ulong(m)) == ina_ulong(n))
|
||||
|
||||
/* Sequence space arithmetic. */
|
||||
#define SEQ_GT(a,b) ((int32_t)((a)-(b)) > 0)
|
||||
#define SEQ_LT(a,b) ((int32_t)((a)-(b)) < 0)
|
||||
|
||||
#define NS_OPTION_P(option) ((server_options == NULL) ? \
|
||||
(panic(panic_msg_no_options, NULL), 0) : \
|
||||
((server_options->flags & option) != 0))
|
||||
|
||||
#define NS_ZOPTION_P(zp, option) \
|
||||
(((zp) != NULL && (((zp)->z_optset & option) != 0)) ? \
|
||||
(((zp)->z_options & option) != 0) : NS_OPTION_P(option))
|
||||
|
||||
#define NS_ZFWDTAB(zp) (((zp) == NULL) ? \
|
||||
server_options->fwdtab : (zp)->z_fwdtab)
|
||||
|
||||
#define NS_INCRSTAT(addr, which) \
|
||||
do { \
|
||||
if ((int)which >= (int)nssLast) \
|
||||
ns_panic(ns_log_insist, 1, panic_msg_bad_which, \
|
||||
__FILE__, __LINE__, #which); \
|
||||
else { \
|
||||
if (NS_OPTION_P(OPTION_HOSTSTATS)) { \
|
||||
struct nameser *ns = \
|
||||
nameserFind(addr, NS_F_INSERT); \
|
||||
if (ns != NULL) \
|
||||
ns->stats[(int)which]++; \
|
||||
} \
|
||||
globalStats[(int)which]++; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
enum severity { ignore, warn, fail, not_set };
|
||||
|
||||
#ifdef BIND_NOTIFY
|
||||
enum notify { notify_use_default=0, notify_yes, notify_no, notify_explicit };
|
||||
#endif
|
||||
|
||||
enum zdialup { zdialup_use_default=0, zdialup_yes, zdialup_no };
|
||||
|
||||
enum axfr_format { axfr_use_default=0, axfr_one_answer, axfr_many_answers };
|
||||
|
||||
struct ip_match_direct {
|
||||
struct in_addr address;
|
||||
struct in_addr mask;
|
||||
};
|
||||
|
||||
struct ip_match_indirect {
|
||||
struct ip_match_list *list;
|
||||
};
|
||||
|
||||
struct ip_match_key {
|
||||
struct dst_key *key;
|
||||
};
|
||||
|
||||
typedef enum { ip_match_pattern, ip_match_indirect, ip_match_localhost,
|
||||
ip_match_localnets, ip_match_key } ip_match_type;
|
||||
|
||||
typedef struct ip_match_element {
|
||||
ip_match_type type;
|
||||
u_int flags;
|
||||
union {
|
||||
struct ip_match_direct direct;
|
||||
struct ip_match_indirect indirect;
|
||||
struct ip_match_key key;
|
||||
} u;
|
||||
struct ip_match_element *next;
|
||||
} *ip_match_element;
|
||||
|
||||
/* Flags for ip_match_element */
|
||||
#define IP_MATCH_NEGATE 0x01 /* match means deny access */
|
||||
|
||||
typedef struct ip_match_list {
|
||||
ip_match_element first;
|
||||
ip_match_element last;
|
||||
} *ip_match_list;
|
||||
|
||||
typedef struct ztimer_info {
|
||||
char *name;
|
||||
int class;
|
||||
int type;
|
||||
} *ztimer_info;
|
||||
|
||||
/*
|
||||
* These fields are ordered to maintain word-alignment;
|
||||
* be careful about changing them.
|
||||
*/
|
||||
struct zoneinfo {
|
||||
char *z_origin; /* root domain name of zone */
|
||||
time_t z_time; /* time for next refresh */
|
||||
time_t z_lastupdate; /* time of last soa serial increment */
|
||||
u_int32_t z_refresh; /* refresh interval */
|
||||
u_int32_t z_retry; /* refresh retry interval */
|
||||
u_int32_t z_expire; /* expiration time for cached info */
|
||||
u_int32_t z_minimum; /* minimum TTL value */
|
||||
u_int32_t z_serial; /* changes if zone modified */
|
||||
char *z_source; /* source location of data */
|
||||
time_t z_ftime; /* modification time of source file */
|
||||
struct in_addr z_axfr_src; /* bind() the axfr socket to this */
|
||||
struct in_addr z_addr[NSMAX]; /* list of master servers for zone */
|
||||
struct dst_key * z_keys[NSMAX]; /* tsig key associated with master */
|
||||
u_char z_addrcnt; /* number of entries in z_addr[] */
|
||||
struct in_addr z_xaddr[NSMAX]; /* list of master servers for xfer */
|
||||
u_char z_xaddrcnt; /* number of entries in z_xaddr[] */
|
||||
u_char z_type; /* type of zone; see below */
|
||||
u_int32_t z_flags; /* state bits; see below */
|
||||
pid_t z_xferpid; /* xfer child pid */
|
||||
u_int z_options; /* options set specific to this zone */
|
||||
u_int z_optset; /* which opts override global opts */
|
||||
int z_class; /* class of zone */
|
||||
int z_numxfrs; /* Ref count of concurrent xfrs. */
|
||||
enum severity z_checknames; /* How to handle non-RFC-compliant names */
|
||||
#ifdef BIND_UPDATE
|
||||
time_t z_dumptime; /* randomized time for next zone dump
|
||||
* if Z_NEED_DUMP is set */
|
||||
u_int32_t z_dumpintvl; /* time interval between zone dumps */
|
||||
time_t z_soaincrintvl; /* interval for updating soa serial */
|
||||
time_t z_soaincrtime; /* time for soa increment */
|
||||
u_int32_t z_deferupdcnt; /* max number of updates before SOA
|
||||
* serial number incremented */
|
||||
u_int32_t z_updatecnt; /* number of update requests processed
|
||||
* since the last SOA serial update */
|
||||
char *z_updatelog; /* log file for updates */
|
||||
#endif
|
||||
ip_match_list z_update_acl; /* list of who can issue dynamic
|
||||
updates */
|
||||
ip_match_list z_query_acl; /* sites we'll answer questions for */
|
||||
ip_match_list z_transfer_acl; /* sites that may get a zone transfer
|
||||
from us */
|
||||
long z_max_transfer_time_in; /* max num seconds for AXFR */
|
||||
#ifdef BIND_NOTIFY
|
||||
enum notify z_notify; /* Notify mode */
|
||||
struct in_addr *z_also_notify; /* More nameservers to notify */
|
||||
int z_notify_count;
|
||||
#endif
|
||||
enum zdialup z_dialup; /* secondaries over a dialup link */
|
||||
char *z_ixfr_base; /* where to find the history of the zone */
|
||||
char *z_ixfr_tmp; /* tmp file for the ixfr */
|
||||
int z_maintain_ixfr_base;
|
||||
long z_max_log_size_ixfr;
|
||||
u_int32_t z_serial_ixfr_start;
|
||||
evTimerID z_timer; /* maintenance timer */
|
||||
ztimer_info z_timerinfo; /* UAP associated with timer */
|
||||
time_t z_nextmaint; /* time of next maintenance */
|
||||
u_int16_t z_port; /* perform AXFR to this port */
|
||||
struct fwdinfo *z_fwdtab; /* zone-specific forwarders */
|
||||
LINK(struct zoneinfo) z_freelink; /* if it's on the free list. */
|
||||
LINK(struct zoneinfo) z_reloadlink; /* if it's on the reload list. */
|
||||
};
|
||||
|
||||
/* zone types (z_type) */
|
||||
enum zonetype { z_nil, z_master, z_slave, z_hint, z_stub, z_forward,
|
||||
z_cache, z_any };
|
||||
#define Z_NIL z_nil /* XXX */
|
||||
#define Z_MASTER z_master /* XXX */
|
||||
#define Z_PRIMARY z_master /* XXX */
|
||||
#define Z_SLAVE z_slave /* XXX */
|
||||
#define Z_SECONDARY z_slave /* XXX */
|
||||
#define Z_HINT z_hint /* XXX */
|
||||
#define Z_CACHE z_cache /* XXX */
|
||||
#define Z_STUB z_stub /* XXX */
|
||||
#define Z_FORWARD z_forward /* XXX */
|
||||
#define Z_ANY z_any /* XXX*2 */
|
||||
|
||||
/* zone state bits (32 bits) */
|
||||
#define Z_AUTH 0x00000001 /* zone is authoritative */
|
||||
#define Z_NEED_XFER 0x00000002 /* waiting to do xfer */
|
||||
#define Z_XFER_RUNNING 0x00000004 /* asynch. xfer is running */
|
||||
#define Z_NEED_RELOAD 0x00000008 /* waiting to do reload */
|
||||
#define Z_SYSLOGGED 0x00000010 /* have logged timeout */
|
||||
#define Z_QSERIAL 0x00000020 /* sysquery()'ing for serial number */
|
||||
#define Z_FOUND 0x00000040 /* found in boot file when reloading */
|
||||
#define Z_INCLUDE 0x00000080 /* set if include used in file */
|
||||
#define Z_DB_BAD 0x00000100 /* errors when loading file */
|
||||
#define Z_TMP_FILE 0x00000200 /* backup file for xfer is temporary */
|
||||
#ifdef BIND_UPDATE
|
||||
#define Z_DYNAMIC 0x00000400 /* allow dynamic updates */
|
||||
#define Z_NEED_DUMP 0x00000800 /* zone has changed, needs a dump */
|
||||
#define Z_NEED_SOAUPDATE 0x00001000 /* soa serial number needs increment */
|
||||
#endif /* BIND_UPDATE */
|
||||
#define Z_XFER_ABORTED 0x00002000 /* zone transfer has been aborted */
|
||||
#define Z_XFER_GONE 0x00004000 /* zone transfer process is gone */
|
||||
#define Z_TIMER_SET 0x00008000 /* z_timer contains a valid id */
|
||||
#ifdef BIND_NOTIFY
|
||||
#define Z_NOTIFY 0x00010000 /* has an outbound notify executing */
|
||||
#endif
|
||||
#define Z_NEED_QSERIAL 0x00020000 /* we need to re-call qserial() */
|
||||
#define Z_PARENT_RELOAD 0x00040000 /* we need to reload this as parent */
|
||||
#define Z_FORWARD_SET 0x00080000 /* has forwarders been set */
|
||||
#define Z_EXPIRED 0x00100000 /* expire timer has gone off */
|
||||
#define Z_NEEDREFRESH 0x00200000 /* need to perform a refresh check */
|
||||
|
||||
/* named_xfer exit codes */
|
||||
#define XFER_UPTODATE 0 /* zone is up-to-date */
|
||||
#define XFER_SUCCESS 1 /* performed transfer successfully */
|
||||
#define XFER_TIMEOUT 2 /* no server reachable/xfer timeout */
|
||||
#define XFER_FAIL 3 /* other failure, has been logged */
|
||||
#define XFER_SUCCESSAXFR 4 /* named-xfr recived a xfr */
|
||||
#define XFER_SUCCESSIXFR 5 /* named-xfr recived a ixfr */
|
||||
#define XFER_SUCCESSAXFRIXFRFILE 6 /* named-xfr received AXFR for IXFR */
|
||||
#define XFER_REFUSED 7 /* one master returned REFUSED */
|
||||
#define XFER_ISAXFR -1 /* the last XFR is AXFR */
|
||||
#define XFER_ISIXFR -2 /* the last XFR is IXFR */
|
||||
#define XFER_ISAXFRIXFR -3 /* the last XFR is AXFR but we must create IXFR base */
|
||||
|
||||
struct qserv {
|
||||
struct sockaddr_in
|
||||
ns_addr; /* address of NS */
|
||||
struct databuf *ns; /* databuf for NS record */
|
||||
struct databuf *nsdata; /* databuf for server address */
|
||||
struct timeval stime; /* time first query started */
|
||||
unsigned int forwarder:1; /* this entry is for a forwarder */
|
||||
unsigned int noedns:1; /* don't try edns */
|
||||
unsigned int lame:1; /* this server was lame, try it last */
|
||||
unsigned int nretry:29; /* # of times addr retried */
|
||||
u_int32_t serial; /* valid if Q_ZSERIAL */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure for recording info on forwarded or generated queries.
|
||||
*/
|
||||
struct qinfo {
|
||||
u_int16_t q_id; /* id of query */
|
||||
u_int16_t q_nsid; /* id of forwarded query */
|
||||
struct sockaddr_in
|
||||
q_from; /* requestor's address */
|
||||
u_char *q_msg, /* the message */
|
||||
*q_cmsg; /* the cname message */
|
||||
int16_t q_msglen, /* len of message */
|
||||
q_msgsize, /* allocated size of message */
|
||||
q_cmsglen, /* len of cname message */
|
||||
q_cmsgsize; /* allocated size of cname message */
|
||||
int16_t q_dfd; /* UDP file descriptor */
|
||||
u_int16_t q_udpsize; /* UDP message size */
|
||||
int q_distance; /* distance this query is from the
|
||||
* original query that the server
|
||||
* received. */
|
||||
time_t q_time; /* time to retry */
|
||||
time_t q_expire; /* time to expire */
|
||||
struct qinfo *q_next; /* rexmit list (sorted by time) */
|
||||
struct qinfo *q_link; /* storage list (random order) */
|
||||
struct databuf *q_usedns[NSMAX]; /* databuf for NS that we've tried */
|
||||
struct qserv q_addr[NSMAX]; /* addresses of NS's */
|
||||
#ifdef notyet
|
||||
struct nameser *q_ns[NSMAX]; /* name servers */
|
||||
#endif
|
||||
struct dst_key *q_keys[NSMAX]; /* keys to use with this address */
|
||||
u_char q_naddr; /* number of addr's in q_addr */
|
||||
u_char q_curaddr; /* last addr sent to */
|
||||
u_char q_nusedns; /* number of elements in q_usedns[] */
|
||||
u_int8_t q_flags; /* see below */
|
||||
int16_t q_cname; /* # of cnames found */
|
||||
int16_t q_nqueries; /* # of queries required */
|
||||
struct qstream *q_stream; /* TCP stream, null if UDP */
|
||||
struct zoneinfo *q_zquery; /* Zone query is about (Q_ZSERIAL) */
|
||||
struct zoneinfo *q_fzone; /* Forwarding zone, if any */
|
||||
char *q_domain; /* domain of most enclosing zone cut */
|
||||
char *q_name; /* domain of query */
|
||||
u_int16_t q_class; /* class of query */
|
||||
u_int16_t q_type; /* type of query */
|
||||
#ifdef BIND_NOTIFY
|
||||
int q_notifyzone; /* zone which needs another notify()
|
||||
* when the reply to this comes in.
|
||||
*/
|
||||
#endif
|
||||
struct tsig_record *q_tsig; /* forwarded query's TSIG record */
|
||||
struct tsig_record *q_nstsig; /* forwarded query's TSIG record */
|
||||
};
|
||||
|
||||
/* q_flags bits (8 bits) */
|
||||
#define Q_SYSTEM 0x01 /* is a system query */
|
||||
#define Q_PRIMING 0x02 /* generated during priming phase */
|
||||
#define Q_ZSERIAL 0x04 /* getting zone serial for xfer test */
|
||||
#define Q_USEVC 0x08 /* forward using tcp not udp */
|
||||
#define Q_EDNS 0x10 /* add edns opt record to answer */
|
||||
|
||||
#define Q_NEXTADDR(qp,n) (&(qp)->q_addr[n].ns_addr)
|
||||
|
||||
#define RETRY_TIMEOUT 45
|
||||
|
||||
/*
|
||||
* Return codes from ns_forw:
|
||||
*/
|
||||
#define FW_OK 0
|
||||
#define FW_DUP 1
|
||||
#define FW_NOSERVER 2
|
||||
#define FW_SERVFAIL 3
|
||||
|
||||
typedef void (*sq_closure)(struct qstream *qs);
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
struct fdlist {
|
||||
int fd;
|
||||
struct fdlist *next;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct ns_delta {
|
||||
LINK(struct ns_delta) d_link;
|
||||
ns_updque d_changes;
|
||||
} ns_delta;
|
||||
|
||||
typedef LIST(ns_delta) ns_deltalist;
|
||||
|
||||
typedef struct _interface {
|
||||
int dfd, /* Datagram file descriptor */
|
||||
sfd; /* Stream file descriptor. */
|
||||
time_t gen; /* Generation number. */
|
||||
struct in_addr addr; /* Interface address. */
|
||||
u_int16_t port; /* Interface port. */
|
||||
u_int16_t flags; /* Valid bits for evXXXXID. */
|
||||
evFileID evID_d; /* Datagram read-event. */
|
||||
evConnID evID_s; /* Stream listen-event. */
|
||||
LINK(struct _interface) link;
|
||||
} interface;
|
||||
|
||||
#define INTERFACE_FILE_VALID 0x01
|
||||
#define INTERFACE_CONN_VALID 0x02
|
||||
#define INTERFACE_FORWARDING 0x04
|
||||
|
||||
struct qstream {
|
||||
int s_rfd; /* stream file descriptor */
|
||||
int s_size; /* expected amount of data to rcv */
|
||||
int s_bufsize; /* amount of data received in s_buf */
|
||||
u_char *s_buf; /* buffer of received data */
|
||||
u_char *s_wbuf; /* send buffer */
|
||||
u_char *s_wbuf_send; /* next sendable byte of send buffer */
|
||||
u_char *s_wbuf_free; /* next free byte of send buffer */
|
||||
u_char *s_wbuf_end; /* byte after end of send buffer */
|
||||
sq_closure s_wbuf_closure; /* callback for writable descriptor */
|
||||
struct qstream *s_next; /* next stream */
|
||||
struct sockaddr_in
|
||||
s_from; /* address query came from */
|
||||
interface *s_ifp; /* interface query came from */
|
||||
time_t s_time; /* time stamp of last transaction */
|
||||
int s_refcnt; /* number of outstanding queries */
|
||||
u_char s_temp[HFIXEDSZ];
|
||||
#ifdef BIND_UPDATE
|
||||
int s_opcode; /* type of request */
|
||||
int s_linkcnt; /* number of client connections using
|
||||
* this connection to forward updates
|
||||
* to the primary */
|
||||
struct fdlist *s_fds; /* linked list of connections to the
|
||||
* primaries that have been used by
|
||||
* the server to forward this client's
|
||||
* update requests */
|
||||
#endif
|
||||
evStreamID evID_r; /* read event. */
|
||||
evFileID evID_w; /* writable event handle. */
|
||||
evConnID evID_c; /* connect event handle */
|
||||
u_int flags; /* see below */
|
||||
struct qstream_xfr {
|
||||
enum { s_x_base, s_x_firstsoa, s_x_zone,
|
||||
s_x_lastsoa, s_x_done, s_x_adding,
|
||||
s_x_deleting, s_x_addsoa, s_x_deletesoa }
|
||||
state; /* state of transfer. */
|
||||
u_char *msg, /* current assembly message. */
|
||||
*cp, /* where are we in msg? */
|
||||
*eom, /* end of msg. */
|
||||
*ptrs[128]; /* ptrs for dn_comp(). */
|
||||
int class, /* class of an XFR. */
|
||||
type, /* type of XFR. */
|
||||
id, /* id of an XFR. */
|
||||
opcode; /* opcode of an XFR. */
|
||||
u_int zone; /* zone being XFR'd. */
|
||||
union {
|
||||
struct namebuf *axfr; /* top np of an AXFR. */
|
||||
ns_deltalist *ixfr; /* top udp of an IXFR. */
|
||||
} top;
|
||||
int ixfr_zone;
|
||||
u_int32_t serial; /* serial number requested in IXFR */
|
||||
ns_tcp_tsig_state *tsig_state; /* used by ns_sign_tcp */
|
||||
int tsig_skip; /* skip calling ns_sign_tcp
|
||||
* during the next flush */
|
||||
int tsig_size; /* need to reserve this space
|
||||
* for the tsig. */
|
||||
struct qs_x_lev { /* decompose the recursion. */
|
||||
enum {sxl_ns, sxl_all, sxl_sub}
|
||||
state; /* what's this level doing? */
|
||||
int flags; /* see below (SXL_*). */
|
||||
char dname[MAXDNAME];
|
||||
struct namebuf *np, /* this node. */
|
||||
*nnp, /* next node to process. */
|
||||
**npp, /* subs. */
|
||||
**npe; /* end of subs. */
|
||||
struct databuf *dp; /* current rr. */
|
||||
struct qs_x_lev *next; /* link. */
|
||||
} *lev; /* LIFO. */
|
||||
enum axfr_format transfer_format;
|
||||
} xfr;
|
||||
};
|
||||
#define SXL_GLUING 0x01
|
||||
#define SXL_ZONECUT 0x02
|
||||
|
||||
/* flags */
|
||||
#define STREAM_MALLOC 0x01
|
||||
#define STREAM_WRITE_EV 0x02
|
||||
#define STREAM_READ_EV 0x04
|
||||
#define STREAM_CONNECT_EV 0x08
|
||||
#define STREAM_DONE_CLOSE 0x10
|
||||
#define STREAM_AXFR 0x20
|
||||
#define STREAM_AXFRIXFR 0x40
|
||||
|
||||
#define ALLOW_NETS 0x0001
|
||||
#define ALLOW_HOSTS 0x0002
|
||||
#define ALLOW_ALL (ALLOW_NETS | ALLOW_HOSTS)
|
||||
|
||||
struct fwddata {
|
||||
struct sockaddr_in
|
||||
fwdaddr; /* address of NS */
|
||||
struct databuf *ns; /* databuf for NS record */
|
||||
struct databuf *nsdata; /* databuf for server address */
|
||||
int ref_count; /* how many users of this */
|
||||
};
|
||||
|
||||
struct fwdinfo {
|
||||
struct fwdinfo *next;
|
||||
struct fwddata *fwddata;
|
||||
};
|
||||
|
||||
enum nameserStats { nssRcvdR, /* sent us an answer */
|
||||
nssRcvdNXD, /* sent us a negative response */
|
||||
nssRcvdFwdR, /* sent us a response we had to fwd */
|
||||
nssRcvdDupR, /* sent us an extra answer */
|
||||
nssRcvdFail, /* sent us a SERVFAIL */
|
||||
nssRcvdFErr, /* sent us a FORMERR */
|
||||
nssRcvdErr, /* sent us some other error */
|
||||
nssRcvdAXFR, /* sent us an AXFR */
|
||||
nssRcvdLDel, /* sent us a lame delegation */
|
||||
nssRcvdOpts, /* sent us some IP options */
|
||||
nssSentSysQ, /* sent them a sysquery */
|
||||
nssSentAns, /* sent them an answer */
|
||||
nssSentFwdQ, /* fwdd a query to them */
|
||||
nssSentDupQ, /* sent them a retry */
|
||||
nssSendtoErr, /* error in sendto */
|
||||
nssRcvdQ, /* sent us a query */
|
||||
nssRcvdIQ, /* sent us an inverse query */
|
||||
nssRcvdFwdQ, /* sent us a query we had to fwd */
|
||||
nssRcvdDupQ, /* sent us a retry */
|
||||
nssRcvdTCP, /* sent us a query using TCP */
|
||||
nssSentFwdR, /* fwdd a response to them */
|
||||
nssSentFail, /* sent them a SERVFAIL */
|
||||
nssSentFErr, /* sent them a FORMERR */
|
||||
nssSentNaAns, /* sent them a non autoritative answer */
|
||||
nssSentNXD, /* sent them a negative response */
|
||||
nssRcvdUQ, /* sent us an unapproved query */
|
||||
nssRcvdURQ, /* sent us an unapproved recursive query */
|
||||
nssRcvdUXFR, /* sent us an unapproved AXFR or IXFR */
|
||||
nssRcvdUUpd, /* sent us an unapproved update */
|
||||
nssLast };
|
||||
|
||||
struct nameser {
|
||||
struct in_addr addr; /* key */
|
||||
u_long stats[nssLast]; /* statistics */
|
||||
#ifdef notyet
|
||||
u_int32_t rtt; /* round trip time */
|
||||
/* XXX - need to add more stuff from "struct qserv", and use our rtt */
|
||||
u_int16_t flags; /* see below */
|
||||
u_int8_t xfers; /* #/xfers running right now */
|
||||
#endif
|
||||
};
|
||||
|
||||
enum transport { primary_trans, secondary_trans, response_trans, update_trans,
|
||||
num_trans };
|
||||
|
||||
/* types used by the parser or config routines */
|
||||
|
||||
typedef struct zone_config {
|
||||
void *opaque;
|
||||
} zone_config;
|
||||
|
||||
typedef struct listen_info {
|
||||
u_short port;
|
||||
ip_match_list list;
|
||||
struct listen_info *next;
|
||||
} *listen_info;
|
||||
|
||||
typedef struct listen_info_list {
|
||||
listen_info first;
|
||||
listen_info last;
|
||||
} *listen_info_list;
|
||||
|
||||
#ifndef RLIMIT_TYPE
|
||||
#define RLIMIT_TYPE u_long
|
||||
#endif
|
||||
typedef RLIMIT_TYPE rlimit_type;
|
||||
|
||||
struct control;
|
||||
typedef struct control *control;
|
||||
typedef LIST(struct control) controls;
|
||||
|
||||
enum ordering { unknown_order, fixed_order, cyclic_order, random_order };
|
||||
|
||||
#define DEFAULT_ORDERING cyclic_order
|
||||
|
||||
typedef struct rrset_order_element {
|
||||
int class;
|
||||
int type;
|
||||
char *name;
|
||||
enum ordering order;
|
||||
struct rrset_order_element *next;
|
||||
} *rrset_order_element ;
|
||||
|
||||
typedef struct rrset_order_list {
|
||||
rrset_order_element first;
|
||||
rrset_order_element last;
|
||||
} *rrset_order_list;
|
||||
|
||||
|
||||
typedef struct options {
|
||||
u_int32_t flags;
|
||||
char *hostname;
|
||||
char *version;
|
||||
char *directory;
|
||||
char *dump_filename;
|
||||
char *pid_filename;
|
||||
char *stats_filename;
|
||||
char *memstats_filename;
|
||||
char *named_xfer;
|
||||
int transfers_in;
|
||||
int transfers_per_ns;
|
||||
int transfers_out;
|
||||
int serial_queries;
|
||||
int max_log_size_ixfr;
|
||||
enum axfr_format transfer_format;
|
||||
long max_transfer_time_in;
|
||||
struct sockaddr_in query_source;
|
||||
struct in_addr axfr_src;
|
||||
#ifdef BIND_NOTIFY
|
||||
int notify_count;
|
||||
struct in_addr *also_notify;
|
||||
#endif
|
||||
ip_match_list query_acl;
|
||||
ip_match_list recursion_acl;
|
||||
ip_match_list transfer_acl;
|
||||
ip_match_list blackhole_acl;
|
||||
ip_match_list topology;
|
||||
ip_match_list sortlist;
|
||||
enum severity check_names[num_trans];
|
||||
u_long data_size;
|
||||
u_long stack_size;
|
||||
u_long core_size;
|
||||
u_long files;
|
||||
listen_info_list listen_list;
|
||||
struct fwdinfo *fwdtab;
|
||||
/* XXX need to add forward option */
|
||||
int clean_interval;
|
||||
int interface_interval;
|
||||
int stats_interval;
|
||||
rrset_order_list ordering;
|
||||
int heartbeat_interval;
|
||||
u_int max_ncache_ttl;
|
||||
u_int max_host_stats;
|
||||
u_int lame_ttl;
|
||||
int minroots;
|
||||
u_int16_t preferred_glue;
|
||||
u_int16_t edns_udp_size;
|
||||
enum notify notify;
|
||||
} *options;
|
||||
|
||||
typedef struct key_list_element {
|
||||
struct dst_key *key;
|
||||
struct key_list_element *next;
|
||||
} *key_list_element;
|
||||
|
||||
typedef struct key_info_list {
|
||||
key_list_element first;
|
||||
key_list_element last;
|
||||
} *key_info_list;
|
||||
|
||||
typedef struct topology_config {
|
||||
void *opaque;
|
||||
} topology_config;
|
||||
|
||||
#define UNKNOWN_TOPOLOGY_DISTANCE 9998
|
||||
#define MAX_TOPOLOGY_DISTANCE 9999
|
||||
|
||||
typedef struct topology_distance {
|
||||
ip_match_list patterns;
|
||||
struct topology_distance *next;
|
||||
} *topology_distance;
|
||||
|
||||
typedef struct topology_context {
|
||||
topology_distance first;
|
||||
topology_distance last;
|
||||
} *topology_context;
|
||||
|
||||
typedef struct acl_table_entry {
|
||||
char *name;
|
||||
ip_match_list list;
|
||||
struct acl_table_entry *next;
|
||||
} *acl_table_entry;
|
||||
|
||||
typedef struct server_config {
|
||||
void *opaque;
|
||||
} server_config;
|
||||
|
||||
#define SERVER_INFO_BOGUS 0x01
|
||||
#define SERVER_INFO_SUPPORT_IXFR 0x02
|
||||
#define SERVER_INFO_EDNS 0x04
|
||||
|
||||
typedef struct server_info {
|
||||
struct in_addr address;
|
||||
u_int flags;
|
||||
int transfers;
|
||||
enum axfr_format transfer_format;
|
||||
key_info_list key_list;
|
||||
/* could move statistics to here, too */
|
||||
struct server_info *next;
|
||||
} *server_info;
|
||||
|
||||
/*
|
||||
* enum <--> name translation
|
||||
*/
|
||||
|
||||
struct ns_sym {
|
||||
int number; /* Identifying number, like ns_log_default */
|
||||
const char * name; /* Its symbolic name, like "default" */
|
||||
};
|
||||
|
||||
/*
|
||||
* Logging options
|
||||
*/
|
||||
|
||||
typedef enum ns_logging_categories {
|
||||
ns_log_default = 0,
|
||||
ns_log_config,
|
||||
ns_log_parser,
|
||||
ns_log_queries,
|
||||
ns_log_lame_servers,
|
||||
ns_log_statistics,
|
||||
ns_log_panic,
|
||||
ns_log_update,
|
||||
ns_log_ncache,
|
||||
ns_log_xfer_in,
|
||||
ns_log_xfer_out,
|
||||
ns_log_db,
|
||||
ns_log_eventlib,
|
||||
ns_log_packet,
|
||||
#ifdef BIND_NOTIFY
|
||||
ns_log_notify,
|
||||
#endif
|
||||
ns_log_cname,
|
||||
ns_log_security,
|
||||
ns_log_os,
|
||||
ns_log_insist,
|
||||
ns_log_maint,
|
||||
ns_log_load,
|
||||
ns_log_resp_checks,
|
||||
ns_log_control,
|
||||
ns_log_update_security,
|
||||
ns_log_max_category
|
||||
} ns_logging_categories;
|
||||
|
||||
typedef struct log_config {
|
||||
log_context log_ctx;
|
||||
log_channel eventlib_channel;
|
||||
log_channel packet_channel;
|
||||
int default_debug_active;
|
||||
} *log_config;
|
||||
|
||||
struct map {
|
||||
const char * token;
|
||||
int val;
|
||||
};
|
||||
|
||||
#define NOERROR_NODATA 15 /* only used internally by the server, used for
|
||||
* -ve $ing non-existence of records. 15 is not
|
||||
* a code used as yet anyway.
|
||||
*/
|
||||
|
||||
#define NTTL 600 /* ttl for negative data: 10 minutes? */
|
||||
|
||||
#define VQEXPIRY 900 /* a VQ entry expires in 15*60 = 900 seconds */
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
enum req_action { Finish, Refuse, Return };
|
||||
#endif
|
||||
|
||||
#ifdef INIT
|
||||
error "INIT already defined, check system include files"
|
||||
#endif
|
||||
#ifdef DECL
|
||||
error "DECL already defined, check system include files"
|
||||
#endif
|
||||
|
||||
#ifdef MAIN_PROGRAM
|
||||
#define INIT(x) = x
|
||||
#define DECL
|
||||
#else
|
||||
#define INIT(x)
|
||||
#define DECL extern
|
||||
#endif
|
||||
|
||||
#define EDNS_MESSAGE_SZ 4096
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,528 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1985, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1999 by Check Point Software Technologies, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Check Point Software Technologies Incorporated not be used
|
||||
* in advertising or publicity pertaining to distribution of the document
|
||||
* or software without specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND CHECK POINT SOFTWARE TECHNOLOGIES
|
||||
* INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL CHECK POINT SOFTWARE TECHNOLOGIES INCORPRATED
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* ns_func.h - declarations for ns_*.c's externally visible functions
|
||||
*
|
||||
* $Id: ns_func.h,v 8.120.8.1 2003/06/02 05:19:56 marka Exp $
|
||||
*/
|
||||
|
||||
/* ++from ns_glue.c++ */
|
||||
struct in_addr ina_get(const u_char *data);
|
||||
const char * sin_ntoa(struct sockaddr_in);
|
||||
int ns_wouldlog(int category, int level);
|
||||
void ns_debug(int, int, const char *, ...) ISC_FORMAT_PRINTF(3, 4);
|
||||
void ns_info(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
void ns_notice(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
void ns_warning(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
void ns_error(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
void ns_critical(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
void ns_panic(int, int, const char *, ...) ISC_FORMAT_PRINTF(3, 4);
|
||||
void ns_assertion_failed(const char *file, int line,
|
||||
assertion_type type,
|
||||
const char *cond, int print_errno);
|
||||
void panic(const char *, const void *);
|
||||
void gettime(struct timeval *);
|
||||
int nlabels(const char *);
|
||||
int my_close(int);
|
||||
int my_fclose(FILE *);
|
||||
void * __freestr(char *);
|
||||
char * __newstr(size_t, int);
|
||||
char * __savestr(const char *, int);
|
||||
const char * checked_ctime(const time_t *t);
|
||||
const char * ctimel(long);
|
||||
void * __freestr_record(char *, const char *, int);
|
||||
char * __newstr_record(size_t, int, const char *, int);
|
||||
char * __savestr_record(const char *, int, const char *, int);
|
||||
u_char * ina_put(struct in_addr ina, u_char *data);
|
||||
u_char * savebuf(const u_char *, size_t, int);
|
||||
#ifdef DEBUG_STRINGS
|
||||
char * debug_newstr(size_t, int, const char *, int);
|
||||
char * debug_savestr(const char *, int, const char *, int);
|
||||
void * debug_freestr(char *, const char *, int);
|
||||
#define newstr(l, n) debug_newstr((l), (n), __FILE__, __LINE__)
|
||||
#define savestr(s, n) debug_savestr((s), (n), __FILE__, __LINE__)
|
||||
#define freestr(s) debug_freestr((s), __FILE__, __LINE__)
|
||||
#else
|
||||
#ifdef RECORD_STRINGS
|
||||
#define newstr(l, n) __newstr_record((l), (n), __FILE__, __LINE__)
|
||||
#define savestr(s, n) __savestr_record((s), (n), __FILE__, __LINE__)
|
||||
#define freestr(s) __freestr_record((s), __FILE__, __LINE__)
|
||||
#else
|
||||
#define newstr(l, n) __newstr((l), (n))
|
||||
#define savestr(s, n) __savestr((s), (n))
|
||||
#define freestr(s) __freestr((s))
|
||||
#endif
|
||||
#endif /* DEBUG_STRINGS */
|
||||
/* --from ns_glue.c-- */
|
||||
|
||||
/* ++from ns_notify.c++ */
|
||||
#ifdef BIND_NOTIFY
|
||||
void ns_notify(const char *, ns_class, ns_type);
|
||||
void notify_afterload(void);
|
||||
void ns_unnotify(void);
|
||||
void ns_stopnotify(const char *, ns_class);
|
||||
#endif
|
||||
/* --from ns_notify.c-- */
|
||||
|
||||
/* ++from ns_resp.c++ */
|
||||
void ns_resp(u_char *, int, struct sockaddr_in,
|
||||
struct qstream *);
|
||||
void prime_cache(void);
|
||||
void delete_all(struct namebuf *, int, int);
|
||||
int delete_stale(struct namebuf *);
|
||||
struct qinfo * sysquery(const char *, int, int,
|
||||
struct in_addr *, struct dst_key **keys,
|
||||
int, u_int16_t, int, int);
|
||||
int doupdate(u_char *, u_char *, struct databuf **,
|
||||
int, int, int, u_int, struct sockaddr_in);
|
||||
int send_msg(u_char *, int, struct qinfo *);
|
||||
int findns(struct namebuf **, int,
|
||||
struct databuf **, int *, int);
|
||||
int finddata(struct namebuf *, int, int, HEADER *,
|
||||
char **, int *, int *, int, int);
|
||||
int add_data(struct namebuf *,
|
||||
struct databuf **,
|
||||
u_char *, int, int *);
|
||||
int trunc_adjust(u_char *, int, int);
|
||||
/* --from ns_resp.c-- */
|
||||
|
||||
/* ++from ns_req.c++ */
|
||||
int ns_get_opt(u_char *msg, u_char *eom,
|
||||
u_int8_t *versionp, u_int16_t *rcodep,
|
||||
u_int16_t *flagp, u_int16_t *bufsizep,
|
||||
u_char **optionsp, size_t *optsizep);
|
||||
int ns_add_opt(u_char *msg, u_char *cp, size_t buflen,
|
||||
u_int8_t version, u_int16_t rcode,
|
||||
u_int16_t size, u_int16_t flags,
|
||||
u_char *options, size_t optlen);
|
||||
void ns_req(u_char *, int, int,
|
||||
struct qstream *,
|
||||
struct sockaddr_in,
|
||||
int);
|
||||
void free_addinfo(void);
|
||||
void free_nsp(struct databuf **);
|
||||
int stale(struct databuf *);
|
||||
int make_rr(const char *, struct databuf *,
|
||||
u_char *, int, int,
|
||||
u_char **, u_char **, int);
|
||||
int doaddinfo(HEADER *, u_char *, int);
|
||||
int doaddauth(HEADER *, u_char *, int,
|
||||
struct namebuf *,
|
||||
struct databuf *);
|
||||
#ifdef BIND_NOTIFY
|
||||
int findZonePri(const struct zoneinfo *,
|
||||
const struct sockaddr_in);
|
||||
#endif
|
||||
int drop_port(u_int16_t);
|
||||
/* --from ns_req.c-- */
|
||||
|
||||
/* ++from ns_xfr.c++ */
|
||||
void ns_xfr(struct qstream *qsp, struct namebuf *znp,
|
||||
int zone, int class, int type,
|
||||
int id, int opcode, u_int32_t serial_ixfr,
|
||||
struct tsig_record *in_tsig);
|
||||
void ns_stopxfrs(struct zoneinfo *);
|
||||
void ns_freexfr(struct qstream *);
|
||||
void sx_newmsg(struct qstream *qsp);
|
||||
void sx_sendlev(struct qstream *qsp);
|
||||
void sx_sendsoa(struct qstream *qsp);
|
||||
/* --from ns_xfr.c-- */
|
||||
|
||||
/* ++from ns_ctl.c++ */
|
||||
void ns_ctl_initialize(void);
|
||||
void ns_ctl_shutdown(void);
|
||||
void ns_ctl_defaults(controls *);
|
||||
void ns_ctl_add(controls *, control);
|
||||
control ns_ctl_new_inet(struct in_addr, u_int, ip_match_list);
|
||||
#ifndef NO_SOCKADDR_UN
|
||||
control ns_ctl_new_unix(const char *, mode_t, uid_t, gid_t);
|
||||
#endif
|
||||
void ns_ctl_install(controls *);
|
||||
/* --from ns_ctl.c-- */
|
||||
|
||||
/* ++from ns_ixfr.c++ */
|
||||
void sx_send_ixfr(struct qstream *);
|
||||
int ixfr_log_maint(struct zoneinfo *);
|
||||
/* --from ns_ixfr.c-- */
|
||||
|
||||
/* ++from ns_forw.c++ */
|
||||
time_t retrytime(struct qinfo *);
|
||||
int ns_forw(struct databuf *nsp[],
|
||||
u_char *msg,
|
||||
int msglen,
|
||||
struct sockaddr_in from,
|
||||
struct qstream *qsp,
|
||||
int dfd,
|
||||
struct qinfo **qpp,
|
||||
const char *dname,
|
||||
int class,
|
||||
int type,
|
||||
struct namebuf *np,
|
||||
int use_tcp,
|
||||
struct tsig_record *in_tsig);
|
||||
int haveComplained(u_long, u_long);
|
||||
int nslookup(struct databuf *nsp[],
|
||||
struct qinfo *qp,
|
||||
const char *syslogdname,
|
||||
const char *sysloginfo);
|
||||
int qcomp(struct qserv *, struct qserv *);
|
||||
void schedretry(struct qinfo *, time_t);
|
||||
void unsched(struct qinfo *);
|
||||
void reset_retrytimer(void);
|
||||
void retrytimer(evContext ctx, void *uap,
|
||||
struct timespec due, struct timespec ival);
|
||||
void retry(struct qinfo *, int);
|
||||
void qflush(void);
|
||||
void qremove(struct qinfo *);
|
||||
void ns_freeqns(struct qinfo *);
|
||||
void ns_freeqry(struct qinfo *);
|
||||
void freeComplaints(void);
|
||||
void nsfwdadd(struct qinfo *, struct fwdinfo *);
|
||||
struct qinfo * qfindid(u_int16_t);
|
||||
struct qinfo * qnew(const char *, int, int, int);
|
||||
/* --from ns_forw.c-- */
|
||||
|
||||
/* ++from ns_main.c++ */
|
||||
void toggle_qrylog(void);
|
||||
struct in_addr net_mask(struct in_addr);
|
||||
void sq_remove(struct qstream *);
|
||||
void sq_flushw(struct qstream *);
|
||||
void sq_flush(struct qstream *allbut);
|
||||
void dq_remove_gen(time_t gen);
|
||||
void dq_remove_all(void);
|
||||
void sq_done(struct qstream *);
|
||||
void ns_setproctitle(char *, int);
|
||||
void getnetconf(int);
|
||||
void nsid_init(void);
|
||||
void ns_setoption(int option);
|
||||
void writestream(struct qstream *, const u_char *, int);
|
||||
void ns_need_unsafe(enum need);
|
||||
void ns_need(enum need);
|
||||
void opensocket_f(void);
|
||||
void nsid_hash(u_char *, size_t);
|
||||
u_int16_t nsid_next(void);
|
||||
int sq_openw(struct qstream *, int);
|
||||
int sq_writeh(struct qstream *, sq_closure);
|
||||
int sq_write(struct qstream *, const u_char *, int);
|
||||
int tcp_send(struct qinfo *);
|
||||
int aIsUs(struct in_addr);
|
||||
/* --from ns_main.c-- */
|
||||
|
||||
/* ++from ns_maint.c++ */
|
||||
void zone_maint(struct zoneinfo *);
|
||||
void sched_zone_maint(struct zoneinfo *);
|
||||
void ns_cleancache(evContext ctx, void *uap,
|
||||
struct timespec due,
|
||||
struct timespec inter);
|
||||
void clean_cache_from(char *dname, struct hashbuf *htp);
|
||||
void remove_zone(struct zoneinfo *, const char *);
|
||||
void purge_zone(struct zoneinfo *, struct hashbuf *);
|
||||
void loadxfer(void);
|
||||
void qserial_retrytime(struct zoneinfo *, time_t);
|
||||
void qserial_query(struct zoneinfo *);
|
||||
void qserial_answer(struct qinfo *);
|
||||
#ifdef DEBUG
|
||||
void printzoneinfo(int, int, int);
|
||||
#endif
|
||||
void endxfer(void);
|
||||
void tryxfer(void);
|
||||
void addxfer(struct zoneinfo *);
|
||||
void ns_zreload(void);
|
||||
void ns_reload(void);
|
||||
void ns_reconfig(void);
|
||||
void ns_noexpired(void);
|
||||
#if 0
|
||||
int reload_all_unsafe(void);
|
||||
#endif
|
||||
int zonefile_changed_p(struct zoneinfo *);
|
||||
int reload_master(struct zoneinfo *);
|
||||
const char * deferred_reload_unsafe(struct zoneinfo *);
|
||||
struct namebuf * purge_node(struct hashbuf *htp, struct namebuf *np);
|
||||
int clean_cache(struct hashbuf *, int);
|
||||
void reapchild(void);
|
||||
const char * zoneTypeString(unsigned int);
|
||||
void ns_heartbeat(evContext ctx, void *uap,
|
||||
struct timespec, struct timespec);
|
||||
void make_new_zones(void);
|
||||
void free_zone(struct zoneinfo *);
|
||||
struct zoneinfo * find_auth_zone(const char *, ns_class);
|
||||
int purge_nonglue(struct zoneinfo *, struct hashbuf *htp,
|
||||
int log);
|
||||
/* --from ns_maint.c-- */
|
||||
|
||||
/* ++from ns_sort.c++ */
|
||||
void sort_response(u_char *, u_char *, int,
|
||||
struct sockaddr_in *);
|
||||
/* --from ns_sort.c-- */
|
||||
|
||||
/* ++from ns_init.c++ */
|
||||
void ns_refreshtime(struct zoneinfo *, time_t);
|
||||
void ns_retrytime(struct zoneinfo *, time_t);
|
||||
time_t ns_init(const char *);
|
||||
enum context ns_ptrcontext(const char *owner);
|
||||
enum context ns_ownercontext(int type, enum transport);
|
||||
int ns_nameok(const struct qinfo *qry, const char *name,
|
||||
int class, struct zoneinfo *zp,
|
||||
enum transport, enum context,
|
||||
const char *owner,
|
||||
struct in_addr source);
|
||||
int ns_wildcard(const char *name);
|
||||
void zoneinit(struct zoneinfo *);
|
||||
void do_reload(struct zoneinfo *, int);
|
||||
void ns_shutdown(void);
|
||||
/* --from ns_init.c-- */
|
||||
|
||||
/* ++from ns_ncache.c++ */
|
||||
void cache_n_resp(u_char *, int, struct sockaddr_in,
|
||||
const char *, int, int);
|
||||
/* --from ns_ncache.c-- */
|
||||
|
||||
/* ++from ns_udp.c++ */
|
||||
void ns_udp(void);
|
||||
/* --from ns_udp.c-- */
|
||||
|
||||
/* ++from ns_stats.c++ */
|
||||
void ns_stats(void);
|
||||
void ns_stats_dumpandclear(void);
|
||||
void ns_freestats(void);
|
||||
void ns_logstats(evContext ctx, void *uap,
|
||||
struct timespec, struct timespec);
|
||||
void qtypeIncr(int qtype);
|
||||
struct nameser * nameserFind(struct in_addr addr, int flags);
|
||||
#define NS_F_INSERT 0x0001
|
||||
#define nameserIncr(a,w) NS_INCRSTAT(a,w) /* XXX should change name. */
|
||||
/* --from ns_stats.c-- */
|
||||
|
||||
/* ++from ns_update.c++ */
|
||||
struct databuf * findzonesoa(struct zoneinfo *);
|
||||
void free_rrecp(ns_updque *, int rcode, struct sockaddr_in);
|
||||
int findzone(const char *, int, int, int *, int);
|
||||
u_char * findsoaserial(u_char *data);
|
||||
u_int32_t get_serial_unchecked(struct zoneinfo *zp);
|
||||
u_int32_t get_serial(struct zoneinfo *zp);
|
||||
void set_serial(struct zoneinfo *zp, u_int32_t serial);
|
||||
int schedule_soa_update(struct zoneinfo *, int);
|
||||
int schedule_dump(struct zoneinfo *);
|
||||
int incr_serial(struct zoneinfo *zp);
|
||||
int merge_logs(struct zoneinfo *zp, char *logname);
|
||||
int zonedump(struct zoneinfo *zp, int isixfr);
|
||||
void dynamic_about_to_exit(void);
|
||||
enum req_action req_update(HEADER *hp, u_char *cp, u_char *eom,
|
||||
u_char *msg, struct sockaddr_in from,
|
||||
struct tsig_record *in_tsig);
|
||||
void rdata_dump(struct databuf *dp, FILE *fp);
|
||||
/* --from ns_update.c-- */
|
||||
|
||||
/* ++from ns_config.c++ */
|
||||
void add_to_rrset_order_list(rrset_order_list,
|
||||
rrset_order_element);
|
||||
const char * p_order(int);
|
||||
int set_zone_ixfr_file(zone_config, char *);
|
||||
int set_zone_master_port(zone_config, u_short);
|
||||
int set_zone_max_log_size_ixfr(zone_config, int);
|
||||
int set_zone_dialup(zone_config, int);
|
||||
int set_trusted_key(const char *, const int,
|
||||
const int, const int, const char *);
|
||||
int set_zone_ixfr_tmp(zone_config, char *);
|
||||
void free_zone_timerinfo(struct zoneinfo *);
|
||||
void free_zone_contents(struct zoneinfo *, int);
|
||||
struct zoneinfo * find_zone(const char *, int);
|
||||
zone_config begin_zone(char *, int);
|
||||
void end_zone(zone_config, int);
|
||||
int set_zone_type(zone_config, int);
|
||||
int set_zone_filename(zone_config, char *);
|
||||
int set_zone_checknames(zone_config, enum severity);
|
||||
#ifdef BIND_NOTIFY
|
||||
int set_zone_notify(zone_config, enum notify value);
|
||||
#endif
|
||||
int set_zone_maintain_ixfr_base(zone_config, int value);
|
||||
int set_zone_update_acl(zone_config, ip_match_list);
|
||||
int set_zone_query_acl(zone_config, ip_match_list);
|
||||
int set_zone_transfer_acl(zone_config, ip_match_list);
|
||||
int set_zone_transfer_source(zone_config, struct in_addr);
|
||||
int set_zone_pubkey(zone_config, const int, const int,
|
||||
const int, const char *);
|
||||
int set_zone_transfer_time_in(zone_config, long);
|
||||
int add_zone_master(zone_config, struct in_addr,
|
||||
struct dst_key *);
|
||||
#ifdef BIND_NOTIFY
|
||||
int add_zone_notify(zone_config, struct in_addr);
|
||||
#endif
|
||||
void set_zone_forward(zone_config);
|
||||
void add_zone_forwarder(zone_config, struct in_addr);
|
||||
void set_zone_boolean_option(zone_config, int, int);
|
||||
options new_options(void);
|
||||
void free_options(options);
|
||||
void free_rrset_order_list(rrset_order_list);
|
||||
void set_global_boolean_option(options, int, int);
|
||||
listen_info_list new_listen_info_list(void);
|
||||
void free_listen_info_list(listen_info_list);
|
||||
void add_listen_on(options, u_short, ip_match_list);
|
||||
FILE * write_open(char *filename);
|
||||
void update_pid_file(void);
|
||||
void set_options(options, int);
|
||||
void use_default_options(void);
|
||||
enum ordering lookup_ordering(const char *);
|
||||
rrset_order_list new_rrset_order_list(void);
|
||||
rrset_order_element new_rrset_order_element(int, int, char *, enum ordering);
|
||||
ip_match_list new_ip_match_list(void);
|
||||
void free_ip_match_list(ip_match_list);
|
||||
ip_match_element new_ip_match_pattern(struct in_addr, u_int);
|
||||
ip_match_element new_ip_match_mask(struct in_addr, struct in_addr);
|
||||
ip_match_element new_ip_match_indirect(ip_match_list);
|
||||
ip_match_element new_ip_match_key(struct dst_key *dst_key);
|
||||
ip_match_element new_ip_match_localhost(void);
|
||||
ip_match_element new_ip_match_localnets(void);
|
||||
void ip_match_negate(ip_match_element);
|
||||
void add_to_ip_match_list(ip_match_list, ip_match_element);
|
||||
void dprint_ip_match_list(int, ip_match_list, int,
|
||||
const char *, const char *);
|
||||
int ip_match_address(ip_match_list, struct in_addr);
|
||||
int ip_match_addr_or_key(ip_match_list, struct in_addr,
|
||||
struct dst_key *key);
|
||||
int ip_address_allowed(ip_match_list, struct in_addr);
|
||||
int ip_addr_or_key_allowed(ip_match_list iml,
|
||||
struct in_addr,
|
||||
struct dst_key *key);
|
||||
int ip_match_network(ip_match_list, struct in_addr,
|
||||
struct in_addr);
|
||||
int ip_match_key_name(ip_match_list iml, char *name);
|
||||
int distance_of_address(ip_match_list, struct in_addr);
|
||||
int ip_match_is_none(ip_match_list);
|
||||
#ifdef BIND_NOTIFY
|
||||
void free_also_notify(options);
|
||||
int add_global_also_notify(options, struct in_addr);
|
||||
#endif
|
||||
void add_global_forwarder(options, struct in_addr);
|
||||
void free_forwarders(struct fwdinfo *);
|
||||
server_info find_server(struct in_addr);
|
||||
server_config begin_server(struct in_addr);
|
||||
void end_server(server_config, int);
|
||||
void set_server_option(server_config, int, int);
|
||||
void set_server_transfers(server_config, int);
|
||||
void set_server_transfer_format(server_config,
|
||||
enum axfr_format);
|
||||
void add_server_key_info(server_config, struct dst_key *);
|
||||
struct dst_key *new_key_info(char *, char *, char *);
|
||||
void free_key_info(struct dst_key *);
|
||||
struct dst_key *find_key(char *name, char *algorithm);
|
||||
void dprint_key_info(struct dst_key *);
|
||||
key_info_list new_key_info_list(void);
|
||||
void free_key_info_list(key_info_list);
|
||||
void add_to_key_info_list(key_info_list, struct dst_key *);
|
||||
void dprint_key_info_list(key_info_list);
|
||||
log_config begin_logging(void);
|
||||
void add_log_channel(log_config, int, log_channel);
|
||||
void open_special_channels(void);
|
||||
void set_logging(log_config, int);
|
||||
void end_logging(log_config, int);
|
||||
void use_default_logging(void);
|
||||
void init_logging(void);
|
||||
void shutdown_logging(void);
|
||||
void init_configuration(void);
|
||||
void shutdown_configuration(void);
|
||||
time_t load_configuration(const char *);
|
||||
/* --from ns_config.c-- */
|
||||
|
||||
/* ++from parser.y++ */
|
||||
ip_match_list lookup_acl(const char *);
|
||||
void define_acl(const char *, ip_match_list);
|
||||
struct dst_key *lookup_key(char *);
|
||||
void define_key(const char *, struct dst_key *);
|
||||
time_t parse_configuration(const char *);
|
||||
void parser_initialize(void);
|
||||
void parser_shutdown(void);
|
||||
/* --from parser.y-- */
|
||||
|
||||
/* ++from ns_signal.c++ */
|
||||
void init_signals(void);
|
||||
void block_signals(void);
|
||||
void unblock_signals(void);
|
||||
/* --from ns_signal.c-- */
|
||||
@@ -1,347 +0,0 @@
|
||||
/*
|
||||
* from ns.h 4.33 (Berkeley) 8/23/90
|
||||
* $Id: ns_glob.h,v 8.59 2002/07/19 22:44:08 marka Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global variables for the name server.
|
||||
*/
|
||||
|
||||
/* original argv[] from main() */
|
||||
DECL char **saved_argv;
|
||||
|
||||
#ifdef DEBUG
|
||||
DECL int debug INIT(0);
|
||||
DECL int desired_debug INIT(0);
|
||||
#endif
|
||||
|
||||
/* global event context */
|
||||
DECL evContext ev;
|
||||
|
||||
/* global resolver context. */
|
||||
DECL struct __res_state res;
|
||||
|
||||
/* list of open streams */
|
||||
DECL struct qstream *streamq;
|
||||
|
||||
/* often set to the current time */
|
||||
DECL struct timeval tt;
|
||||
|
||||
/* head of allocated queries */
|
||||
DECL struct qinfo *nsqhead;
|
||||
|
||||
/* datagram socket for sysquery() and ns_forw(). */
|
||||
DECL int ds INIT(-1);
|
||||
|
||||
/* event ID for reads of "ds". */
|
||||
DECL evFileID ds_evID;
|
||||
|
||||
#ifdef QRYLOG
|
||||
/* is query logging turned on? */
|
||||
DECL int qrylog;
|
||||
#endif /*QRYLOG*/
|
||||
|
||||
/* port to which we send queries */
|
||||
DECL u_int16_t ns_port;
|
||||
|
||||
/* Source addr of our internal resolver. */
|
||||
DECL struct sockaddr_in source_addr; /* INITs to <INADDR_ANY, 0>. */
|
||||
|
||||
/* Used by ns_stats */
|
||||
DECL time_t boottime;
|
||||
|
||||
DECL time_t resettime;
|
||||
|
||||
/* next query to retry */
|
||||
DECL struct qinfo *retryqp;
|
||||
|
||||
/* configuration file name */
|
||||
DECL char *conffile;
|
||||
|
||||
/* configuration file mtime */
|
||||
DECL time_t confmtime;
|
||||
|
||||
/* default debug output file */
|
||||
DECL char *debugfile;
|
||||
|
||||
/* zone information */
|
||||
DECL struct zoneinfo *zones;
|
||||
|
||||
/* number of zones allocated */
|
||||
DECL int nzones;
|
||||
|
||||
/* free list of unused zones[] elements. */
|
||||
DECL LIST(struct zoneinfo) freezones;
|
||||
|
||||
/* list of zones that have a reload pending. */
|
||||
DECL LIST(struct zoneinfo) reloadingzones;
|
||||
|
||||
/* set if we need a priming */
|
||||
DECL int needs_prime_cache;
|
||||
|
||||
/* is cache being primed */
|
||||
DECL int priming;
|
||||
|
||||
/* ptrs to dnames in msg for dn_comp */
|
||||
DECL u_char *dnptrs[40];
|
||||
|
||||
/* end pointer for dnptrs */
|
||||
DECL u_char **dnptrs_end
|
||||
INIT(dnptrs + sizeof dnptrs / sizeof(u_char*));
|
||||
|
||||
/* data about all forwarders */
|
||||
DECL struct fwddata **fwddata;
|
||||
/* how many forwarders are there in fwddata? */
|
||||
DECL int fwddata_count;
|
||||
|
||||
/* number of names in addinfo */
|
||||
DECL int addcount;
|
||||
|
||||
/* name of cache file */
|
||||
DECL const char *cache_file;
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
DECL const char * LogSignature INIT(";BIND LOG V8\n");
|
||||
DECL const char * DumpSignature INIT(";BIND DUMP V8\n");
|
||||
DECL const char * DumpSuffix INIT(".dumptmp");
|
||||
#endif
|
||||
|
||||
DECL const char sendtoStr[] INIT("sendto");
|
||||
DECL const char tcpsendStr[] INIT("tcp_send");
|
||||
|
||||
/* defined in version.c, can't use DECL/INIT */
|
||||
extern char Version[];
|
||||
extern char ShortVersion[];
|
||||
|
||||
/* If getnum() has an error, here will be the result. */
|
||||
DECL int getnum_error INIT(0);
|
||||
|
||||
enum context { domain_ctx, owner_ctx, mailname_ctx, hostname_ctx };
|
||||
DECL const char *context_strings[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= { "domain", "owner", "mail", "host", NULL }
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL const char *transport_strings[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= { "primary", "secondary", "response", NULL }
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL const char *severity_strings[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= { "ignore", "warn", "fail", "not_set", NULL }
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL struct in_addr inaddr_any; /* Inits to 0.0.0.0 */
|
||||
|
||||
DECL options server_options INIT(NULL);
|
||||
|
||||
DECL server_info nameserver_info INIT(NULL);
|
||||
DECL key_info_list secretkey_info INIT(NULL);
|
||||
|
||||
DECL ip_match_list bogus_nameservers INIT(NULL);
|
||||
|
||||
DECL log_context log_ctx;
|
||||
DECL int log_ctx_valid INIT(0);
|
||||
|
||||
DECL log_channel syslog_channel INIT(NULL);
|
||||
DECL log_channel debug_channel INIT(NULL);
|
||||
DECL log_channel stderr_channel INIT(NULL);
|
||||
DECL log_channel eventlib_channel INIT(NULL);
|
||||
DECL log_channel packet_channel INIT(NULL);
|
||||
DECL log_channel null_channel INIT(NULL);
|
||||
|
||||
DECL ip_match_list local_addresses INIT(NULL);
|
||||
DECL ip_match_list local_networks INIT(NULL);
|
||||
|
||||
/* are we running in no-fork mode? */
|
||||
DECL int foreground INIT(0);
|
||||
|
||||
DECL const struct ns_sym logging_constants[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= {
|
||||
{ log_info, "info" },
|
||||
{ log_notice, "notice" },
|
||||
{ log_warning, "warning" },
|
||||
{ log_error, "error" },
|
||||
{ log_critical, "critical" },
|
||||
{ 0, NULL }
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL const struct ns_sym syslog_constants[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= {
|
||||
{ LOG_KERN, "kern" },
|
||||
{ LOG_USER, "user" },
|
||||
{ LOG_MAIL, "mail" },
|
||||
{ LOG_DAEMON, "daemon" },
|
||||
{ LOG_AUTH, "auth" },
|
||||
{ LOG_SYSLOG, "syslog" },
|
||||
{ LOG_LPR, "lpr" },
|
||||
#ifdef LOG_NEWS
|
||||
{ LOG_NEWS, "news" },
|
||||
#endif
|
||||
#ifdef LOG_UUCP
|
||||
{ LOG_UUCP, "uucp" },
|
||||
#endif
|
||||
#ifdef LOG_CRON
|
||||
{ LOG_CRON, "cron" },
|
||||
#endif
|
||||
#ifdef LOG_AUTHPRIV
|
||||
{ LOG_AUTHPRIV, "authpriv" },
|
||||
#endif
|
||||
#ifdef LOG_FTP
|
||||
{ LOG_FTP, "ftp" },
|
||||
#endif
|
||||
{ LOG_LOCAL0, "local0"},
|
||||
{ LOG_LOCAL1, "local1"},
|
||||
{ LOG_LOCAL2, "local2"},
|
||||
{ LOG_LOCAL3, "local3"},
|
||||
{ LOG_LOCAL4, "local4"},
|
||||
{ LOG_LOCAL5, "local5"},
|
||||
{ LOG_LOCAL6, "local6"},
|
||||
{ LOG_LOCAL7, "local7"},
|
||||
{ 0, NULL }
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL const struct ns_sym category_constants[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= {
|
||||
{ ns_log_default, "default" },
|
||||
{ ns_log_config, "config" },
|
||||
{ ns_log_parser, "parser" },
|
||||
{ ns_log_queries, "queries" },
|
||||
{ ns_log_lame_servers, "lame-servers" },
|
||||
{ ns_log_statistics, "statistics" },
|
||||
{ ns_log_panic, "panic" },
|
||||
{ ns_log_update, "update" },
|
||||
{ ns_log_ncache, "ncache" },
|
||||
{ ns_log_xfer_in, "xfer-in" },
|
||||
{ ns_log_xfer_out, "xfer-out" },
|
||||
{ ns_log_db, "db" },
|
||||
{ ns_log_eventlib, "eventlib" },
|
||||
{ ns_log_packet, "packet" },
|
||||
#ifdef BIND_NOTIFY
|
||||
{ ns_log_notify, "notify" },
|
||||
#endif
|
||||
{ ns_log_cname, "cname" },
|
||||
{ ns_log_security, "security" },
|
||||
{ ns_log_os, "os" },
|
||||
{ ns_log_insist, "insist" },
|
||||
{ ns_log_maint, "maintenance" },
|
||||
{ ns_log_load, "load" },
|
||||
{ ns_log_resp_checks, "response-checks" },
|
||||
{ ns_log_control, "control" },
|
||||
{ ns_log_update_security, "update-security" },
|
||||
{ 0, NULL }
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL const char panic_msg_no_options[]
|
||||
INIT("no server_options in NS_OPTION_P");
|
||||
|
||||
DECL const char panic_msg_insist_failed[]
|
||||
INIT("%s:%d: insist '%s' failed: %s");
|
||||
|
||||
DECL const char panic_msg_bad_which[]
|
||||
INIT("%s:%d: INCRSTATS(%s): bad \"which\"");
|
||||
|
||||
DECL u_long globalStats[nssLast];
|
||||
|
||||
DECL evTimerID clean_timer;
|
||||
DECL evTimerID interface_timer;
|
||||
DECL evTimerID stats_timer;
|
||||
DECL evTimerID heartbeat_timer;
|
||||
DECL int active_timers INIT(0);
|
||||
|
||||
DECL uid_t user_id;
|
||||
DECL char * user_name INIT(NULL);
|
||||
DECL gid_t group_id;
|
||||
DECL char * group_name INIT(NULL);
|
||||
DECL char * chroot_dir INIT(NULL);
|
||||
DECL char * working_dir INIT(NULL);
|
||||
|
||||
DECL int loading INIT(0);
|
||||
|
||||
DECL int xfers_running INIT(0);
|
||||
DECL int xfers_deferred INIT(0);
|
||||
DECL int qserials_running INIT(0);
|
||||
DECL int initial_configuration INIT(1);
|
||||
@@ -1,469 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_glue.c,v 8.24 2002/01/07 02:54:37 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-2000 by Internet Software Consortium, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <resolv.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
/*
|
||||
* IP address from unaligned octets.
|
||||
*/
|
||||
struct in_addr
|
||||
ina_get(const u_char *data) {
|
||||
struct in_addr ret;
|
||||
u_int32_t i;
|
||||
|
||||
GETLONG(i, data);
|
||||
ina_ulong(ret) = htonl(i);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* IP address to unaligned octets.
|
||||
*/
|
||||
u_char *
|
||||
ina_put(struct in_addr ina, u_char *data) {
|
||||
PUTLONG(ntohl(ina_ulong(ina)), data);
|
||||
return (data);
|
||||
}
|
||||
|
||||
/*
|
||||
* IP address to presentation format.
|
||||
*/
|
||||
const char *
|
||||
sin_ntoa(struct sockaddr_in sin) {
|
||||
static char ret[sizeof "[111.222.333.444].55555"];
|
||||
|
||||
sprintf(ret, "[%s].%u", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Logging Support
|
||||
*/
|
||||
|
||||
int
|
||||
ns_wouldlog(int category, int level) {
|
||||
if (log_ctx_valid)
|
||||
return (log_check(log_ctx, category, level));
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
ns_debug(int category, int level, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_debug(level), format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_info(int category, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_info, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_notice(int category, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_notice, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_warning(int category, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_warning, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_error(int category, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_error, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_critical(int category, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_critical, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_panic(int category, int dump_core, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_critical, format, args);
|
||||
va_end(args);
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, ns_log_panic, log_critical, format, args);
|
||||
va_end(args);
|
||||
if (dump_core)
|
||||
abort();
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
ns_assertion_failed(const char *file, int line, assertion_type type,
|
||||
const char *cond, int print_errno)
|
||||
{
|
||||
ns_panic(ns_log_insist, 1, "%s:%d: %s(%s)%s%s failed.",
|
||||
file, line, assertion_type_to_text(type), cond,
|
||||
(print_errno) ? ": " : "",
|
||||
(print_errno) ? strerror(errno) : "");
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX This is for compatibility and should eventually be removed.
|
||||
*/
|
||||
void
|
||||
panic(const char *msg, const void *arg) {
|
||||
ns_panic(ns_log_default, 1, msg, arg);
|
||||
}
|
||||
|
||||
/*
|
||||
* How many labels in this name?
|
||||
* Note: the root label is not included in the count.
|
||||
*/
|
||||
int
|
||||
nlabels(const char *dname) {
|
||||
int count, i, found, escaped;
|
||||
const char *tmpdname, *end_tmpdname;
|
||||
int tmpdnamelen, c;
|
||||
|
||||
INSIST(dname != NULL);
|
||||
|
||||
count = 0;
|
||||
tmpdname = dname;
|
||||
tmpdnamelen = strlen(tmpdname);
|
||||
/*
|
||||
* Ignore a trailing label separator (i.e. an unescaped dot)
|
||||
* in 'tmpdname'.
|
||||
*/
|
||||
if (tmpdnamelen && tmpdname[tmpdnamelen-1] == '.') {
|
||||
escaped = 0;
|
||||
/* note this loop doesn't get executed if tmpdnamelen==1 */
|
||||
for (i = tmpdnamelen - 2; i >= 0; i--)
|
||||
if (tmpdname[i] == '\\') {
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else
|
||||
escaped = 1;
|
||||
} else
|
||||
break;
|
||||
if (!escaped)
|
||||
tmpdnamelen--;
|
||||
}
|
||||
|
||||
end_tmpdname = tmpdname + tmpdnamelen;
|
||||
|
||||
while(tmpdname != end_tmpdname) {
|
||||
count++;
|
||||
/*
|
||||
* Strip off the first label if we're not already at
|
||||
* the root label.
|
||||
*/
|
||||
for (escaped = found = 0;
|
||||
(tmpdname != end_tmpdname) && !found;
|
||||
tmpdname++) {
|
||||
c = *tmpdname;
|
||||
if (!escaped && (c == '.'))
|
||||
found = 1;
|
||||
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else if (c == '\\')
|
||||
escaped = 1;
|
||||
}
|
||||
}
|
||||
|
||||
ns_debug(ns_log_default, 12, "nlabels of \"%s\" -> %d", dname, count);
|
||||
return (count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get current system time and put it in a global.
|
||||
*/
|
||||
void
|
||||
gettime(struct timeval *ttp) {
|
||||
if (gettimeofday(ttp, NULL) < 0)
|
||||
ns_error(ns_log_default, "gettimeofday: %s", strerror(errno));
|
||||
}
|
||||
|
||||
/*
|
||||
* This is useful for tracking down lost file descriptors.
|
||||
*/
|
||||
int
|
||||
my_close(int fd) {
|
||||
int s;
|
||||
|
||||
do {
|
||||
errno = 0;
|
||||
s = close(fd);
|
||||
} while (s < 0 && errno == EINTR);
|
||||
|
||||
/*
|
||||
* Tru64 UNIX V5.1 can return a spurious EINVAL after connect()
|
||||
* failures.
|
||||
*/
|
||||
if (s < 0 && errno != EBADF && errno != EINVAL)
|
||||
ns_info(ns_log_default, "close(%d) failed: %s", fd,
|
||||
strerror(errno));
|
||||
else
|
||||
ns_debug(ns_log_default, 3, "close(%d) succeeded", fd);
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is useful for tracking down lost file descriptors.
|
||||
*/
|
||||
int
|
||||
my_fclose(FILE *fp) {
|
||||
int fd = fileno(fp),
|
||||
s = fclose(fp);
|
||||
|
||||
if (s < 0)
|
||||
ns_info(ns_log_default, "fclose(%d) failed: %s", fd,
|
||||
strerror(errno));
|
||||
else
|
||||
ns_debug(ns_log_default, 3, "fclose(%d) succeeded", fd);
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Save a counted buffer and return a pointer to it.
|
||||
*/
|
||||
u_char *
|
||||
savebuf(const u_char *buf, size_t len, int needpanic) {
|
||||
u_char *bp = (u_char *)memget(len);
|
||||
|
||||
if (bp == NULL) {
|
||||
if (needpanic)
|
||||
panic("savebuf: memget failed (%s)", strerror(errno));
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
memcpy(bp, buf, len);
|
||||
return (bp);
|
||||
}
|
||||
|
||||
char *
|
||||
__newstr(size_t len, int needpanic) {
|
||||
return (__newstr_record(len, needpanic, __FILE__, __LINE__));
|
||||
}
|
||||
|
||||
char *
|
||||
__savestr(const char *str, int needpanic) {
|
||||
return (__savestr_record(str, needpanic, __FILE__, __LINE__));
|
||||
}
|
||||
|
||||
void *
|
||||
__freestr(char *str) {
|
||||
__freestr_record(str, __FILE__, __LINE__);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STRINGS
|
||||
char *
|
||||
debug_newstr(size_t len, int needpanic, const char *file, int line) {
|
||||
size_t size;
|
||||
|
||||
size = len + 3; /* 2 length bytes + NUL. */
|
||||
printf("%s:%d: newstr %d\n", file, line, size);
|
||||
return (__newstr_record(len, needpanic, file, line));
|
||||
}
|
||||
|
||||
char *
|
||||
debug_savestr(const char *str, int needpanic, const char *file, int line) {
|
||||
size_t len;
|
||||
|
||||
len = strlen(str);
|
||||
len += 3; /* 2 length bytes + NUL. */
|
||||
printf("%s:%d: savestr %d %s\n", file, line, len, str);
|
||||
return (__savestr_record(str, needpanic, file, line));
|
||||
}
|
||||
|
||||
void
|
||||
debug_freestr(char *str, const char *file, int line) {
|
||||
u_char *buf, *bp;
|
||||
size_t len;
|
||||
|
||||
buf = (u_char *)str - 2/*Len*/;
|
||||
bp = buf;
|
||||
NS_GET16(len, bp);
|
||||
len += 3; /* 2 length bytes + NUL. */
|
||||
printf("%s:%d: freestr %d %s\n", file, line, len, str);
|
||||
__freestr_record(str, file, line);
|
||||
return (NULL);
|
||||
}
|
||||
#endif /* DEBUG_STRINGS */
|
||||
|
||||
/*
|
||||
* Return a counted string buffer big enough for a string of length 'len'.
|
||||
*/
|
||||
char *
|
||||
__newstr_record(size_t len, int needpanic, const char *file, int line) {
|
||||
u_char *buf, *bp;
|
||||
|
||||
REQUIRE(len <= 65536);
|
||||
|
||||
buf = (u_char *)__memget_record(2/*Len*/ + len + 1/*Nul*/, file, line);
|
||||
if (buf == NULL) {
|
||||
if (needpanic)
|
||||
panic("savestr: memget failed (%s)", strerror(errno));
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
bp = buf;
|
||||
NS_PUT16(len, bp);
|
||||
return ((char *)bp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Save a NUL terminated string and return a pointer to it.
|
||||
*/
|
||||
char *
|
||||
__savestr_record(const char *str, int needpanic, const char *file, int line) {
|
||||
char *buf;
|
||||
size_t len;
|
||||
|
||||
len = strlen(str);
|
||||
if (len > 65536) {
|
||||
if (needpanic)
|
||||
ns_panic(ns_log_default, 1,
|
||||
"savestr: string too long");
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
buf = __newstr_record(len, needpanic, file, line);
|
||||
memcpy(buf, str, len + 1);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
void *
|
||||
__freestr_record(char *str, const char *file, int line) {
|
||||
u_char *buf, *bp;
|
||||
size_t len;
|
||||
|
||||
buf = (u_char *)str - 2/*Len*/;
|
||||
bp = buf;
|
||||
NS_GET16(len, bp);
|
||||
__memput_record(buf, 2/*Len*/ + len + 1/*Nul*/, file, line);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
checked_ctime(const time_t *t) {
|
||||
const char *ctime_result;
|
||||
|
||||
ctime_result = ctime(t);
|
||||
if (ctime_result == NULL) {
|
||||
ns_error(ns_log_default, "ctime() returned NULL!");
|
||||
ctime_result = "<unknown time>\n";
|
||||
}
|
||||
|
||||
return (ctime_result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Since the fields in a "struct timeval" are longs, and the argument to ctime
|
||||
* is a pointer to a time_t (which might not be a long), here's a bridge.
|
||||
*/
|
||||
const char *
|
||||
ctimel(long l) {
|
||||
time_t t = (time_t)l;
|
||||
|
||||
return (checked_ctime(&t));
|
||||
}
|
||||
|
||||
#ifdef ultrix
|
||||
/*
|
||||
* Some library routines in libc need to be able to see the res_send
|
||||
* and res_close symbols with out __ prefix otherwise we get multiply
|
||||
* defined symbol errors when linking named.
|
||||
*/
|
||||
|
||||
#undef res_send
|
||||
int res_send(const u_char *buf, int buflen, u_char *ans, int anssiz) {
|
||||
return __res_send(buf, buflen, ans, anssiz);
|
||||
}
|
||||
#undef _res_close
|
||||
void _res_close(void) {
|
||||
__res_close();
|
||||
}
|
||||
#endif
|
||||
@@ -1,593 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)ns_init.c 4.38 (Berkeley) 3/21/91";
|
||||
static const char rcsid[] = "$Id: ns_init.c,v 8.77.8.2 2003/09/04 04:09:09 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include <isc/dst.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
static void content_zone(int, int);
|
||||
#endif
|
||||
static void purgeandload(struct zoneinfo *zp);
|
||||
|
||||
/*
|
||||
* Set new refresh time for zone. Use a random number in the last half of
|
||||
* the refresh limit; we want it to be substantially correct while still
|
||||
* preventing slave synchronization.
|
||||
*/
|
||||
void
|
||||
ns_refreshtime(struct zoneinfo *zp, time_t timebase) {
|
||||
u_long refresh = (zp->z_refresh > 0) ? zp->z_refresh : INIT_REFRESH;
|
||||
time_t half = (refresh + 1) / 2;
|
||||
|
||||
if (zp->z_flags & Z_NEEDREFRESH) {
|
||||
zp->z_flags &= ~Z_NEEDREFRESH;
|
||||
zp->z_time = timebase;
|
||||
} else
|
||||
zp->z_time = timebase + half + (rand() % half);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set new retry time for zone.
|
||||
*/
|
||||
void
|
||||
ns_retrytime(struct zoneinfo *zp, time_t timebase) {
|
||||
|
||||
zp->z_flags &= ~Z_NEEDREFRESH;
|
||||
zp->z_time = timebase + zp->z_retry;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read configuration file and save it as internal state.
|
||||
*/
|
||||
time_t
|
||||
ns_init(const char *conffile) {
|
||||
struct zoneinfo *zp;
|
||||
static int loads = 0; /* number of times loaded */
|
||||
time_t mtime;
|
||||
|
||||
ns_debug(ns_log_config, 1, "ns_init(%s)", conffile);
|
||||
gettime(&tt);
|
||||
|
||||
if (loads == 0) {
|
||||
/* Init zone data. */
|
||||
zones = NULL;
|
||||
INIT_LIST(freezones);
|
||||
INIT_LIST(reloadingzones);
|
||||
nzones = 0;
|
||||
make_new_zones();
|
||||
|
||||
/* Init cache. */
|
||||
zones[0].z_type = z_cache;
|
||||
zones[0].z_origin = savestr("", 1);
|
||||
|
||||
/* Allocate cache hash table, formerly the root hash table. */
|
||||
hashtab = savehash((struct hashbuf *)NULL);
|
||||
|
||||
/* Allocate root-hints/file-cache hash table. */
|
||||
fcachetab = savehash((struct hashbuf *)NULL);
|
||||
|
||||
/* Init other misc stuff. */
|
||||
dst_init();
|
||||
init_configuration();
|
||||
} else {
|
||||
/* Mark previous zones as not yet found in boot file. */
|
||||
block_signals();
|
||||
for (zp = &zones[1]; zp < &zones[nzones]; zp++)
|
||||
if (zp->z_type != z_nil) {
|
||||
zp->z_flags &= ~Z_FOUND;
|
||||
if (LINKED(zp, z_reloadlink))
|
||||
UNLINK(reloadingzones, zp,
|
||||
z_reloadlink);
|
||||
}
|
||||
unblock_signals();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug >= 3) {
|
||||
ns_debug(ns_log_config, 3, "content of zones before loading");
|
||||
content_zone(nzones - 1, 3);
|
||||
}
|
||||
#endif
|
||||
|
||||
mtime = load_configuration(conffile);
|
||||
|
||||
/* Erase all old zones that were not found. */
|
||||
for (zp = &zones[0]; zp < &zones[nzones]; zp++) {
|
||||
if (zp->z_type == z_cache)
|
||||
continue;
|
||||
if (zp->z_type != z_nil && (zp->z_flags & Z_FOUND) == 0)
|
||||
remove_zone(zp, "removed");
|
||||
}
|
||||
/* Reload parent zones of zones removed */
|
||||
for (zp = &zones[0]; zp < &zones[nzones]; zp++) {
|
||||
if (zp->z_type == z_cache)
|
||||
continue;
|
||||
if (zp->z_type != z_nil &&
|
||||
(zp->z_flags & Z_PARENT_RELOAD) != 0) {
|
||||
zp->z_flags &= ~Z_PARENT_RELOAD;
|
||||
purgeandload(zp);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug >= 2) {
|
||||
ns_debug(ns_log_config, 2, "content of zones after loading");
|
||||
content_zone(nzones-1, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
ns_debug(ns_log_config, 1, "exit ns_init()");
|
||||
loads++;
|
||||
return (mtime);
|
||||
}
|
||||
|
||||
void
|
||||
zoneinit(struct zoneinfo *zp) {
|
||||
struct stat sb;
|
||||
int result;
|
||||
|
||||
/*
|
||||
* Try to load zone from backup file,
|
||||
* if one was specified and it exists.
|
||||
* If not, or if the data are out of date,
|
||||
* we will refresh the zone from a primary
|
||||
* immediately.
|
||||
*/
|
||||
if (zp->z_source == NULL)
|
||||
return;
|
||||
result = stat(zp->z_source, &sb);
|
||||
if (result != -1) {
|
||||
ns_stopxfrs(zp);
|
||||
purge_zone(zp, hashtab);
|
||||
}
|
||||
if (result == -1 ||
|
||||
db_load(zp->z_source, zp->z_origin, zp, NULL, ISNOTIXFR))
|
||||
{
|
||||
/*
|
||||
* Set zone to be refreshed immediately.
|
||||
*/
|
||||
zp->z_refresh = INIT_REFRESH;
|
||||
zp->z_retry = INIT_REFRESH;
|
||||
if ((zp->z_flags & (Z_QSERIAL|Z_XFER_RUNNING)) == 0) {
|
||||
zp->z_time = tt.tv_sec;
|
||||
sched_zone_maint(zp);
|
||||
}
|
||||
} else {
|
||||
zp->z_flags |= Z_AUTH;
|
||||
zp->z_flags &= ~(Z_NEED_RELOAD|Z_EXPIRED);
|
||||
ns_refreshtime(zp, tt.tv_sec);
|
||||
sched_zone_maint(zp);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Purge the zone and reload all parent zones. This needs to be done when
|
||||
* we unload a zone, since the child zone will have stomped the parent's
|
||||
* delegation to that child when it was first loaded.
|
||||
*/
|
||||
void
|
||||
do_reload(struct zoneinfo *ozp, int mark) {
|
||||
struct zoneinfo *zp;
|
||||
const char *domain = ozp->z_origin;
|
||||
int type = ozp->z_type;
|
||||
int class = ozp->z_class;
|
||||
|
||||
ns_debug(ns_log_config, 1, "do_reload: %s %d %d %d",
|
||||
*domain ? domain : ".", type, class, mark);
|
||||
|
||||
/*
|
||||
* Check if the zone has changed type. If so, we might not need to
|
||||
* do any purging or parent reloading.
|
||||
*
|
||||
* If the new zone is a master zone, then it will have purged the
|
||||
* old data and loaded, so we don't need to do anything.
|
||||
*
|
||||
* If the new zone is a slave or stub zone and has successfully loaded,
|
||||
* then we don't need to do anything either.
|
||||
*
|
||||
* NOTE: we take care not to match ourselves.
|
||||
*/
|
||||
zp = find_zone(domain, class);
|
||||
if (zp != NULL &&
|
||||
((type != z_master && zp->z_type == z_master) ||
|
||||
(type != z_slave && zp->z_type == z_slave && zp->z_serial != 0) ||
|
||||
(type != z_stub && zp->z_type == z_stub && zp->z_serial != 0)))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Clean up any leftover data.
|
||||
*/
|
||||
ns_stopxfrs(zp);
|
||||
if (type == z_hint || (type == z_stub && *domain == 0))
|
||||
purge_zone(ozp, fcachetab);
|
||||
else
|
||||
purge_zone(ozp, hashtab);
|
||||
|
||||
/*
|
||||
* Reload
|
||||
*/
|
||||
while (*domain) {
|
||||
const char *s;
|
||||
int escaped;
|
||||
|
||||
/*
|
||||
* XXX this is presentation level hair and belongs elsewhere.
|
||||
*/
|
||||
escaped = 0;
|
||||
for (s = domain; *s != '\0'; s++) {
|
||||
if (!escaped) {
|
||||
if (*s == '.')
|
||||
break;
|
||||
else if (*s == '\\')
|
||||
escaped = 1;
|
||||
} else
|
||||
escaped = 0;
|
||||
}
|
||||
|
||||
if (*s != '\0')
|
||||
domain = s + 1; /* skip label and its separator */
|
||||
else
|
||||
domain = ""; /* root zone */
|
||||
|
||||
zp = find_zone(domain, class);
|
||||
if (zp != NULL && zp->z_type != Z_HINT) {
|
||||
ns_debug(ns_log_config, 1, "do_reload: matched %s",
|
||||
*domain ? domain : ".");
|
||||
if (mark)
|
||||
zp->z_flags |= Z_PARENT_RELOAD;
|
||||
else
|
||||
purgeandload(zp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
purgeandload(struct zoneinfo *zp) {
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
/*
|
||||
* A dynamic zone might have changed, so we
|
||||
* need to dump it before removing it.
|
||||
*/
|
||||
if (zp->z_type == Z_PRIMARY &&
|
||||
(zp->z_flags & Z_DYNAMIC) != 0 &&
|
||||
((zp->z_flags & Z_NEED_SOAUPDATE) != 0 ||
|
||||
(zp->z_flags & Z_NEED_DUMP) != 0))
|
||||
(void) zonedump(zp, ISNOTIXFR);
|
||||
#endif
|
||||
ns_stopxfrs(zp);
|
||||
|
||||
if (zp->z_type == Z_HINT)
|
||||
purge_zone(zp, fcachetab);
|
||||
else
|
||||
purge_zone(zp, hashtab);
|
||||
|
||||
zp->z_flags &= ~Z_AUTH;
|
||||
|
||||
switch (zp->z_type) {
|
||||
case Z_SECONDARY:
|
||||
case Z_STUB:
|
||||
zoneinit(zp);
|
||||
break;
|
||||
case Z_PRIMARY:
|
||||
if (db_load(zp->z_source, zp->z_origin, zp, 0, ISNOTIXFR) == 0)
|
||||
zp->z_flags |= Z_AUTH;
|
||||
break;
|
||||
case Z_HINT:
|
||||
case Z_CACHE:
|
||||
(void)db_load(zp->z_source, zp->z_origin, zp, 0, ISNOTIXFR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* prints out the content of zones */
|
||||
static void
|
||||
content_zone(int end, int level) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= end; i++) {
|
||||
printzoneinfo(i, ns_log_config, level);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
enum context
|
||||
ns_ptrcontext(owner)
|
||||
const char *owner;
|
||||
{
|
||||
if (ns_samedomain(owner, "in-addr.arpa") ||
|
||||
ns_samedomain(owner, "ip6.int"))
|
||||
return (hostname_ctx);
|
||||
return (domain_ctx);
|
||||
}
|
||||
|
||||
enum context
|
||||
ns_ownercontext(type, transport)
|
||||
int type;
|
||||
enum transport transport;
|
||||
{
|
||||
enum context context = domain_ctx;
|
||||
|
||||
switch (type) {
|
||||
case T_A:
|
||||
case T_WKS:
|
||||
case T_MX:
|
||||
switch (transport) {
|
||||
case update_trans:
|
||||
case primary_trans:
|
||||
case secondary_trans:
|
||||
context = owner_ctx;
|
||||
break;
|
||||
case response_trans:
|
||||
context = hostname_ctx;
|
||||
break;
|
||||
default:
|
||||
panic("impossible condition in ns_ownercontext()",
|
||||
NULL);
|
||||
}
|
||||
break;
|
||||
case T_MB:
|
||||
case T_MG:
|
||||
context = mailname_ctx;
|
||||
break;
|
||||
default:
|
||||
/* Nothing to do. */
|
||||
break;
|
||||
}
|
||||
return (context);
|
||||
}
|
||||
|
||||
int
|
||||
ns_nameok(const struct qinfo *qry, const char *name, int class,
|
||||
struct zoneinfo *zp, enum transport transport,
|
||||
enum context context,
|
||||
const char *owner,
|
||||
struct in_addr source)
|
||||
{
|
||||
enum severity severity = not_set;
|
||||
int ok = 1;
|
||||
|
||||
if (zp != NULL)
|
||||
severity = zp->z_checknames;
|
||||
if (severity == not_set)
|
||||
severity = server_options->check_names[transport];
|
||||
|
||||
if (severity == ignore)
|
||||
return (1);
|
||||
switch (context) {
|
||||
case domain_ctx:
|
||||
ok = (class != C_IN) || res_dnok(name);
|
||||
break;
|
||||
case owner_ctx:
|
||||
ok = (class != C_IN) || res_ownok(name);
|
||||
break;
|
||||
case mailname_ctx:
|
||||
ok = res_mailok(name);
|
||||
break;
|
||||
case hostname_ctx:
|
||||
ok = res_hnok(name);
|
||||
break;
|
||||
default:
|
||||
ns_panic(ns_log_default, 1,
|
||||
"unexpected context %d in ns_nameok", (int)context);
|
||||
}
|
||||
if (!ok) {
|
||||
char *q, *s, *o;
|
||||
|
||||
if (source.s_addr == INADDR_ANY)
|
||||
s = savestr(transport_strings[transport], 0);
|
||||
else {
|
||||
s = newstr(strlen(transport_strings[transport]) +
|
||||
sizeof " from [000.000.000.000] for [000.000.000.000]", 0);
|
||||
if (s != NULL) {
|
||||
if (transport == response_trans && qry != NULL) {
|
||||
if ((qry->q_flags & Q_PRIMING) != 0) {
|
||||
sprintf(s, "%s from [%s] for priming",
|
||||
transport_strings[transport],
|
||||
inet_ntoa(source));
|
||||
} else if ((qry->q_flags & Q_ZSERIAL) != 0) {
|
||||
sprintf(s, "%s from [%s] for soacheck",
|
||||
transport_strings[transport],
|
||||
inet_ntoa(source));
|
||||
} else if ((qry->q_flags & Q_SYSTEM) != 0) {
|
||||
sprintf(s, "%s from [%s] for sysquery",
|
||||
transport_strings[transport],
|
||||
inet_ntoa(source));
|
||||
} else {
|
||||
q=strdup(inet_ntoa(qry->q_from.sin_addr));
|
||||
sprintf(s, "%s from [%s] for [%s]",
|
||||
transport_strings[transport],
|
||||
inet_ntoa(source),
|
||||
q != NULL ? q : "memget failed");
|
||||
free(q);
|
||||
}
|
||||
} else {
|
||||
sprintf(s, "%s from [%s]",
|
||||
(transport == response_trans)
|
||||
? "query"
|
||||
: transport_strings[transport],
|
||||
inet_ntoa(source));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ns_samename(owner, name) == 1)
|
||||
o = savestr("", 0);
|
||||
else {
|
||||
const char *t = (*owner == '\0') ? "." : owner;
|
||||
|
||||
o = newstr(strlen(t) + sizeof " (owner \"\")", 0);
|
||||
if (o)
|
||||
sprintf(o, " (owner \"%s\")", t);
|
||||
}
|
||||
/*
|
||||
* We use log_write directly here to avoid duplicating
|
||||
* the message formatting and arguments.
|
||||
*/
|
||||
log_write(log_ctx, ns_log_default,
|
||||
(transport != response_trans) ||
|
||||
(o == NULL) || (s == NULL) ||
|
||||
( (qry != NULL) &&
|
||||
(qry->q_flags & (Q_PRIMING|Q_ZSERIAL)) ) ?
|
||||
log_warning : log_info,
|
||||
"%s name \"%s\"%s %s (%s) is invalid - %s",
|
||||
context_strings[context],
|
||||
name, o != NULL ? o : "[memget failed]",
|
||||
p_class(class),
|
||||
s != NULL ? s : "[memget failed]",
|
||||
(severity == fail) ?
|
||||
"rejecting" : "proceeding anyway");
|
||||
if (severity == warn)
|
||||
ok = 1;
|
||||
if (s != NULL)
|
||||
(void)freestr(s);
|
||||
if (o != NULL)
|
||||
(void)freestr(o);
|
||||
}
|
||||
return (ok);
|
||||
}
|
||||
|
||||
int
|
||||
ns_wildcard(const char *name) {
|
||||
if (*name != '*')
|
||||
return (0);
|
||||
return (*++name == '\0');
|
||||
}
|
||||
|
||||
void
|
||||
ns_shutdown() {
|
||||
struct zoneinfo *zp;
|
||||
|
||||
#ifdef BIND_NOTIFY
|
||||
ns_unnotify();
|
||||
#endif
|
||||
/* Erase zones. */
|
||||
for (zp = &zones[0]; zp < &zones[nzones]; zp++) {
|
||||
if (zp->z_type) {
|
||||
if (zp->z_type != z_hint && zp->z_type != z_cache) {
|
||||
ns_stopxfrs(zp);
|
||||
purge_zone(zp, hashtab);
|
||||
} else if (zp->z_type == z_hint)
|
||||
purge_zone(zp, fcachetab);
|
||||
free_zone_contents(zp, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Erase the cache. */
|
||||
clean_cache(hashtab, 1);
|
||||
hashtab->h_cnt = 0; /* ??? */
|
||||
rm_hash(hashtab);
|
||||
hashtab = NULL;
|
||||
clean_cache(fcachetab, 1);
|
||||
fcachetab->h_cnt = 0; /* ??? */
|
||||
rm_hash(fcachetab);
|
||||
fcachetab = NULL;
|
||||
|
||||
if (zones != NULL)
|
||||
memput(zones, nzones * sizeof *zones);
|
||||
zones = NULL;
|
||||
|
||||
freeComplaints();
|
||||
shutdown_configuration();
|
||||
}
|
||||
@@ -1,584 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_ixfr.c,v 8.33 2003/02/24 23:36:01 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1999 by Check Point Software Technologies, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Check Point Software Technologies Incorporated not be used
|
||||
* in advertising or publicity pertaining to distribution of the document
|
||||
* or software without specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND CHECK POINT SOFTWARE TECHNOLOGIES
|
||||
* INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL CHECK POINT SOFTWARE TECHNOLOGIES INCORPRATED
|
||||
* BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <resolv.h>
|
||||
#include <res_update.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
#include <isc/misc.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
static void sx_new_ixfrmsg(struct qstream * qsp);
|
||||
void sx_send_ixfr(struct qstream * qsp);
|
||||
|
||||
static int sx_flush(struct qstream * qsp),
|
||||
sx_addrr(struct qstream * qsp,
|
||||
const char *dname,
|
||||
struct databuf * dp);
|
||||
|
||||
/*
|
||||
* u_char * sx_new_ixfrmsg(msg) init the header of a message, reset the
|
||||
* compression pointers, and reset the write pointer to the first byte
|
||||
* following the header.
|
||||
*/
|
||||
static void
|
||||
sx_new_ixfrmsg(struct qstream *qsp) {
|
||||
HEADER * hp = (HEADER *) qsp->xfr.msg;
|
||||
|
||||
memset(hp, 0, HFIXEDSZ);
|
||||
hp->id = htons(qsp->xfr.id);
|
||||
hp->opcode = qsp->xfr.opcode;
|
||||
hp->qr = 1;
|
||||
hp->aa = 1;
|
||||
hp->rcode = NOERROR;
|
||||
|
||||
qsp->xfr.ptrs[0] = qsp->xfr.msg;
|
||||
qsp->xfr.ptrs[1] = NULL;
|
||||
|
||||
qsp->xfr.cp = qsp->xfr.msg + HFIXEDSZ;
|
||||
if (qsp->xfr.ixfr_zone == 0) {
|
||||
int count, n;
|
||||
int buflen;
|
||||
struct namebuf *np;
|
||||
struct hashbuf *htp;
|
||||
struct zoneinfo *zp;
|
||||
const char * fname;
|
||||
|
||||
qsp->xfr.ixfr_zone = qsp->xfr.zone;
|
||||
zp = &zones[qsp->xfr.zone];
|
||||
n = dn_comp(zp->z_origin, qsp->xfr.cp,
|
||||
XFER_BUFSIZE - (qsp->xfr.cp - qsp->xfr.msg), NULL, NULL);
|
||||
qsp->xfr.cp += n;
|
||||
PUTSHORT((u_int16_t) T_IXFR, qsp->xfr.cp);
|
||||
PUTSHORT((u_int16_t) zp->z_class, qsp->xfr.cp);
|
||||
hp->qdcount = htons(ntohs(hp->qdcount) + 1);
|
||||
count = qsp->xfr.cp - qsp->xfr.msg;
|
||||
htp = hashtab;
|
||||
np = nlookup(zp->z_origin, &htp, &fname, 0);
|
||||
buflen = XFER_BUFSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_flush(qsp)
|
||||
* flush the intermediate buffer out to the stream IO system.
|
||||
* return:
|
||||
* passed through from sq_write().
|
||||
*/
|
||||
static int
|
||||
sx_flush(struct qstream *qsp) {
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug >= 10)
|
||||
fp_nquery(qsp->xfr.msg, qsp->xfr.cp - qsp->xfr.msg,
|
||||
log_get_stream(packet_channel));
|
||||
#endif
|
||||
if (qsp->xfr.tsig_state != NULL && qsp->xfr.tsig_skip == 0) {
|
||||
int msglen = qsp->xfr.cp - qsp->xfr.msg;
|
||||
|
||||
ns_sign_tcp(qsp->xfr.msg, &msglen, qsp->xfr.eom - qsp->xfr.msg,
|
||||
NOERROR, qsp->xfr.tsig_state,
|
||||
qsp->xfr.state == s_x_done);
|
||||
|
||||
if (qsp->xfr.state == s_x_done) {
|
||||
memput(qsp->xfr.tsig_state, sizeof(ns_tcp_tsig_state));
|
||||
qsp->xfr.tsig_state = NULL;
|
||||
}
|
||||
qsp->xfr.cp = qsp->xfr.msg + msglen;
|
||||
|
||||
}
|
||||
if (qsp->xfr.cp - qsp->xfr.msg > 0)
|
||||
ret = sq_write(qsp, qsp->xfr.msg, qsp->xfr.cp - qsp->xfr.msg);
|
||||
else {
|
||||
ns_debug(ns_log_default, 3, " Flush negative number *********");
|
||||
ret = -1;
|
||||
}
|
||||
if (ret >= 0) {
|
||||
qsp->xfr.cp = NULL;
|
||||
qsp->xfr.tsig_skip = 0;
|
||||
}
|
||||
else
|
||||
qsp->xfr.tsig_skip = 1;
|
||||
return (ret);
|
||||
}
|
||||
/*
|
||||
* int sx_addrr(qsp, name, dp) add name/dp's RR to the current assembly
|
||||
* message. if it won't fit, write current message out, renew the message,
|
||||
* and then RR should fit. return: -1 = the sq_write() failed so we could not
|
||||
* queue the full message. 0 = one way or another, everything is fine. side
|
||||
* effects: on success, the ANCOUNT is incremented and the pointers are
|
||||
* advanced.
|
||||
*/
|
||||
static int
|
||||
sx_addrr(struct qstream *qsp, const char *dname, struct databuf *dp) {
|
||||
HEADER *hp = (HEADER *) qsp->xfr.msg;
|
||||
u_char **edp = qsp->xfr.ptrs + sizeof qsp->xfr.ptrs / sizeof(u_char *);
|
||||
int n;
|
||||
|
||||
if (qsp->xfr.cp != NULL) {
|
||||
if (qsp->xfr.transfer_format == axfr_one_answer &&
|
||||
sx_flush(qsp) < 0)
|
||||
return (-1);
|
||||
}
|
||||
if (qsp->xfr.cp == NULL)
|
||||
sx_new_ixfrmsg(qsp);
|
||||
n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp,
|
||||
0, qsp->xfr.ptrs, edp, 0);
|
||||
if (n < 0) {
|
||||
if (sx_flush(qsp) < 0)
|
||||
return (-1);
|
||||
if (qsp->xfr.cp == NULL)
|
||||
sx_new_ixfrmsg(qsp);
|
||||
n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp,
|
||||
0, qsp->xfr.ptrs, edp, 0);
|
||||
INSIST(n >= 0);
|
||||
}
|
||||
hp->ancount = htons(ntohs(hp->ancount) + 1);
|
||||
qsp->xfr.cp += n;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
sx_send_ixfr(struct qstream *qsp) {
|
||||
char * cp;
|
||||
struct zoneinfo *zp = NULL;
|
||||
struct databuf *soa_dp;
|
||||
struct databuf *old_soadp;
|
||||
ns_delta *dp;
|
||||
ns_updrec *rp;
|
||||
int foundsoa;
|
||||
|
||||
zp = &zones[qsp->xfr.zone];
|
||||
soa_dp = (struct databuf *) findzonesoa(zp);
|
||||
if (soa_dp == NULL) {
|
||||
/* XXX should be more graceful */
|
||||
ns_panic(ns_log_update, 1,
|
||||
"sx_send_ixfr: unable to locate soa");
|
||||
}
|
||||
old_soadp = memget(BIND_DATASIZE(soa_dp->d_size));
|
||||
if (old_soadp == NULL)
|
||||
ns_panic(ns_log_update, 1, "sx_send_ixfr: out of memory");
|
||||
memcpy(old_soadp, soa_dp, BIND_DATASIZE(soa_dp->d_size));
|
||||
|
||||
again:
|
||||
switch (qsp->xfr.state) {
|
||||
case s_x_firstsoa:
|
||||
ns_debug(ns_log_default, 3,
|
||||
"IXFR: s_x_firstsoa (%s)", zp->z_origin);
|
||||
if (sx_addrr(qsp, zp->z_origin, soa_dp) < 0)
|
||||
goto cleanup;
|
||||
qsp->xfr.state = s_x_deletesoa;
|
||||
/* FALLTHROUGH */
|
||||
case s_x_deletesoa:
|
||||
ns_debug(ns_log_default, 3,
|
||||
"IXFR: s_x_deletesoa (%s)", zp->z_origin);
|
||||
dp = NULL;
|
||||
if (qsp->xfr.top.ixfr != NULL && !EMPTY(*qsp->xfr.top.ixfr))
|
||||
dp = HEAD(*qsp->xfr.top.ixfr);
|
||||
if (dp != NULL) {
|
||||
foundsoa = 0;
|
||||
|
||||
rp = HEAD(dp->d_changes);
|
||||
while (rp != NULL) {
|
||||
if (rp->r_opcode == DELETE &&
|
||||
rp->r_dp != NULL &&
|
||||
rp->r_dp->d_type == T_SOA) {
|
||||
if (sx_addrr(qsp, rp->r_dname,
|
||||
rp->r_dp) < 0)
|
||||
goto cleanup;
|
||||
db_detach(&rp->r_dp);
|
||||
foundsoa = 1;
|
||||
break;
|
||||
}
|
||||
rp = NEXT(rp, r_link);
|
||||
}
|
||||
|
||||
if (!foundsoa) {
|
||||
cp = (char *)findsoaserial(old_soadp->d_data);
|
||||
PUTLONG(HEAD(dp->d_changes)->r_zone, cp);
|
||||
|
||||
if (sx_addrr(qsp, zp->z_origin, old_soadp) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
qsp->xfr.state = s_x_deleting;
|
||||
/* FALLTHROUGH */
|
||||
case s_x_deleting:
|
||||
ns_debug(ns_log_default, 3,
|
||||
"IXFR: s_x_deleting (%s)", zp->z_origin);
|
||||
dp = NULL;
|
||||
if (qsp->xfr.top.ixfr != NULL && !EMPTY(*qsp->xfr.top.ixfr))
|
||||
dp = HEAD(*qsp->xfr.top.ixfr);
|
||||
if (dp != NULL) {
|
||||
rp = HEAD(dp->d_changes);
|
||||
while (rp != NULL) {
|
||||
if (rp->r_opcode == DELETE &&
|
||||
rp->r_dp != NULL) {
|
||||
/*
|
||||
* Drop any SOA deletes
|
||||
*/
|
||||
if (rp->r_dp->d_type != T_SOA &&
|
||||
sx_addrr(qsp, rp->r_dname,
|
||||
rp->r_dp) < 0)
|
||||
goto cleanup;
|
||||
db_detach(&rp->r_dp);
|
||||
}
|
||||
rp = NEXT(rp, r_link);
|
||||
}
|
||||
}
|
||||
qsp->xfr.state = s_x_addsoa;
|
||||
/* FALLTHROUGH */
|
||||
case s_x_addsoa:
|
||||
ns_debug(ns_log_default, 3,
|
||||
"IXFR: s_x_addsoa (%s)", zp->z_origin);
|
||||
dp = NULL;
|
||||
if (qsp->xfr.top.ixfr != NULL && !EMPTY(*qsp->xfr.top.ixfr))
|
||||
dp = HEAD(*qsp->xfr.top.ixfr);
|
||||
if (dp != NULL) {
|
||||
foundsoa = 0;
|
||||
rp = HEAD(dp->d_changes);
|
||||
while (rp != NULL) {
|
||||
if (rp->r_opcode == ADD &&
|
||||
rp->r_dp != NULL &&
|
||||
rp->r_dp->d_type == T_SOA) {
|
||||
if (sx_addrr(qsp, rp->r_dname,
|
||||
rp->r_dp) < 0)
|
||||
goto cleanup;
|
||||
db_detach(&rp->r_dp);
|
||||
foundsoa = 1;
|
||||
break;
|
||||
}
|
||||
rp = NEXT(rp, r_link);
|
||||
}
|
||||
|
||||
if (!foundsoa) {
|
||||
cp = (char *)findsoaserial(old_soadp->d_data);
|
||||
if (NEXT(dp, d_link) != NULL) {
|
||||
PUTLONG(HEAD(dp->d_changes)->r_zone, cp);
|
||||
if (sx_addrr(qsp, zp->z_origin,
|
||||
old_soadp) < 0)
|
||||
goto cleanup;
|
||||
} else {
|
||||
if (sx_addrr(qsp, zp->z_origin,
|
||||
soa_dp) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
qsp->xfr.state = s_x_adding;
|
||||
/* FALLTHROUGH */
|
||||
case s_x_adding:
|
||||
ns_debug(ns_log_default, 3,
|
||||
"IXFR: s_x_adding (%s)", zp->z_origin);
|
||||
dp = NULL;
|
||||
if (qsp->xfr.top.ixfr != NULL && !EMPTY(*qsp->xfr.top.ixfr)) {
|
||||
dp = HEAD(*qsp->xfr.top.ixfr);
|
||||
if (dp != NULL) {
|
||||
/* see s_x_deleting */
|
||||
rp = HEAD(dp->d_changes);
|
||||
while (rp != NULL) {
|
||||
if (rp->r_opcode == ADD &&
|
||||
rp->r_dp != NULL &&
|
||||
rp->r_dp->d_type != T_SOA) {
|
||||
if (sx_addrr(qsp, rp->r_dname,
|
||||
rp->r_dp) < 0)
|
||||
goto cleanup;
|
||||
db_detach(&rp->r_dp);
|
||||
}
|
||||
rp = NEXT(rp, r_link);
|
||||
}
|
||||
|
||||
/* move to next update */
|
||||
UNLINK(*qsp->xfr.top.ixfr, dp, d_link);
|
||||
|
||||
/* clean up old update */
|
||||
while ((rp = HEAD(dp->d_changes)) != NULL) {
|
||||
UNLINK(dp->d_changes, rp, r_link);
|
||||
if (rp->r_dp != NULL)
|
||||
db_detach(&rp->r_dp);
|
||||
res_freeupdrec(rp);
|
||||
}
|
||||
memput(dp, sizeof (*dp));
|
||||
if (HEAD(*qsp->xfr.top.ixfr) != NULL) {
|
||||
qsp->xfr.state = s_x_deletesoa;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
}
|
||||
qsp->xfr.state = s_x_lastsoa;
|
||||
/* FALLTHROUGH */
|
||||
case s_x_lastsoa:
|
||||
ns_debug(ns_log_default, 3,
|
||||
"IXFR: s_x_lastsoa (%s)", zp->z_origin);
|
||||
if (qsp->xfr.ixfr_zone != 0)
|
||||
sx_addrr(qsp, zp->z_origin, soa_dp);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ns_debug(ns_log_default, 3, "IXFR: flushing %s", zp->z_origin);
|
||||
qsp->xfr.state = s_x_done;
|
||||
sx_flush(qsp);
|
||||
sq_writeh(qsp, sq_flushw);
|
||||
if (qsp->xfr.top.ixfr != NULL) {
|
||||
if(!EMPTY(*qsp->xfr.top.ixfr)) {
|
||||
while ((dp = HEAD(*qsp->xfr.top.ixfr)) != NULL) {
|
||||
UNLINK(*qsp->xfr.top.ixfr, dp, d_link);
|
||||
while ((rp = HEAD(dp->d_changes)) != NULL) {
|
||||
UNLINK(dp->d_changes, rp, r_link);
|
||||
if (rp->r_dp != NULL)
|
||||
db_detach(&rp->r_dp);
|
||||
res_freeupdrec(rp);
|
||||
}
|
||||
memput(dp, sizeof *dp);
|
||||
}
|
||||
}
|
||||
memput(qsp->xfr.top.ixfr, sizeof *qsp->xfr.top.ixfr);
|
||||
qsp->xfr.top.ixfr = NULL;
|
||||
}
|
||||
cleanup:
|
||||
memput(old_soadp, BIND_DATASIZE(old_soadp->d_size));
|
||||
}
|
||||
|
||||
|
||||
#ifndef MAXBSIZE
|
||||
#define MAXBSIZE 8192
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* int ixfr_log_maint(struct zoneinfo *zp, int fast_trim)
|
||||
*
|
||||
* zp - pointer to the zone information
|
||||
*/
|
||||
int
|
||||
ixfr_log_maint(struct zoneinfo *zp) {
|
||||
int fd, rcount, wcount;
|
||||
int found = 0;
|
||||
int error = 0;
|
||||
long seek = 0;
|
||||
FILE *to_fp, *from_fp, *db_fp;
|
||||
char *tmpname;
|
||||
int len;
|
||||
struct stat db_sb;
|
||||
struct stat sb;
|
||||
size_t check_size;
|
||||
static char buf[MAXBSIZE];
|
||||
|
||||
ns_debug(ns_log_default, 3, "ixfr_log_maint(%s)", zp->z_origin);
|
||||
|
||||
/* find out how big the zone db file is */
|
||||
if ((db_fp = fopen(zp->z_source, "r")) == NULL) {
|
||||
ns_warning(ns_log_db, "%s: %s",
|
||||
zp->z_source, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
if (fstat(fileno(db_fp), &db_sb) < 0) {
|
||||
ns_warning(ns_log_db, "%s: %s",
|
||||
zp->z_source, strerror(errno));
|
||||
(void) my_fclose(db_fp);
|
||||
return (-1);
|
||||
}
|
||||
(void) my_fclose(db_fp);
|
||||
ns_debug(ns_log_default, 3, "%s, size %ld",
|
||||
zp->z_source, (long)db_sb.st_size);
|
||||
|
||||
/* open up the zone ixfr log */
|
||||
if ((from_fp = fopen(zp->z_ixfr_base, "r")) == NULL) {
|
||||
ns_warning(ns_log_db, "%s: %s",
|
||||
zp->z_ixfr_base, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (fstat(fileno(from_fp), &sb) < 0) {
|
||||
ns_warning(ns_log_db, "%s: %s",
|
||||
zp->z_ixfr_base, strerror(errno));
|
||||
(void) my_fclose(from_fp);
|
||||
return (-1);
|
||||
}
|
||||
ns_debug(ns_log_default, 3, "%s, size %ld max %ld\n", zp->z_ixfr_base,
|
||||
(long)sb.st_size, (long)zp->z_max_log_size_ixfr);
|
||||
check_size = zp->z_max_log_size_ixfr;
|
||||
if (!check_size)
|
||||
check_size = db_sb.st_size / 2;
|
||||
if (sb.st_size > check_size)
|
||||
seek = (sb.st_size - check_size) + (check_size / 10);
|
||||
else
|
||||
seek = 0;
|
||||
ns_debug(ns_log_default, 3, "seek: %ld", (long)seek);
|
||||
if (seek < 1) {
|
||||
ns_debug(ns_log_default, 3, "%s does not need to be reduced",
|
||||
zp->z_ixfr_base);
|
||||
(void) my_fclose(from_fp);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
len = strlen(zp->z_ixfr_base) + sizeof(".XXXXXX") + 1;
|
||||
tmpname = memget(len);
|
||||
if (!tmpname) {
|
||||
ns_warning(ns_log_default, "memget failed");
|
||||
return (-1);
|
||||
}
|
||||
#ifdef SHORT_FNAMES
|
||||
filenamecpy(tmpname, zp->z_ixfr_base);
|
||||
#else
|
||||
(void) strcpy(tmpname, zp->z_ixfr_base);
|
||||
#endif /* SHORT_FNAMES */
|
||||
|
||||
(void) strcat(tmpname, ".XXXXXX");
|
||||
if ((fd = mkstemp(tmpname)) == -1) {
|
||||
ns_warning(ns_log_db, "can't make tmpfile (%s): %s",
|
||||
tmpname, strerror(errno));
|
||||
memput(tmpname, len);
|
||||
(void) my_fclose(from_fp);
|
||||
return (-1);
|
||||
}
|
||||
if ((to_fp = fdopen(fd, "r+")) == NULL) {
|
||||
ns_warning(ns_log_db, "%s: %s",
|
||||
tmpname, strerror(errno));
|
||||
(void) unlink(tmpname);
|
||||
memput(tmpname, len);
|
||||
(void) my_fclose(from_fp);
|
||||
(void) close(fd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (fgets(buf, sizeof(buf), from_fp) == NULL) {
|
||||
ns_error(ns_log_update, "fgets() from %s failed: %s",
|
||||
zp->z_ixfr_base, strerror(errno));
|
||||
error++;
|
||||
goto clean_up;
|
||||
}
|
||||
if (strcmp(buf, LogSignature) != 0) {
|
||||
ns_error(ns_log_update, "invalid log file %s",
|
||||
zp->z_ixfr_base);
|
||||
error++;
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
if (fseek( from_fp, seek, 0) < 0) {
|
||||
error++;
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
found = 0;
|
||||
for (;;) {
|
||||
if (getword(buf, sizeof buf, from_fp, 0)) {
|
||||
if (strcasecmp(buf, "[END_DELTA]") == 0) {
|
||||
if (!(fgets(buf, 2, from_fp) == NULL)) /* eat <cr><lf> */
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (feof(from_fp))
|
||||
break;
|
||||
}
|
||||
if (found) {
|
||||
ns_debug(ns_log_default, 1,
|
||||
"ixfr_log_maint(): found [END_DELTA]");
|
||||
|
||||
fprintf(to_fp, "%s", LogSignature);
|
||||
|
||||
while ((rcount = fread(buf, sizeof(char), MAXBSIZE, from_fp)) > 0) {
|
||||
wcount = fwrite(buf, sizeof(char), rcount, to_fp);
|
||||
if (rcount != wcount || wcount == -1) {
|
||||
ns_warning(ns_log_default,
|
||||
"ixfr_log_maint: error in writting copy");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rcount < 0)
|
||||
ns_warning(ns_log_default,
|
||||
"ixfr_log_maint: error in reading copy");
|
||||
}
|
||||
clean_up:
|
||||
(void) my_fclose(to_fp);
|
||||
(void) my_fclose(from_fp);
|
||||
if (error == 0) {
|
||||
if (isc_movefile(tmpname, zp->z_ixfr_base) == -1) {
|
||||
ns_warning(ns_log_default,
|
||||
"can not rename %s to %s :%s",
|
||||
tmpname, zp->z_ixfr_base, strerror(errno));
|
||||
}
|
||||
if ((from_fp = fopen(zp->z_ixfr_base, "r")) == NULL) {
|
||||
ns_warning(ns_log_db, "%s: %s",
|
||||
zp->z_ixfr_base, strerror(errno));
|
||||
memput(tmpname, len);
|
||||
return (-1);
|
||||
}
|
||||
if (fstat(fileno(from_fp), &sb) < 0) {
|
||||
ns_warning(ns_log_db, "%s: %s",
|
||||
zp->z_ixfr_base, strerror(errno));
|
||||
memput(tmpname, len);
|
||||
(void) my_fclose(from_fp);
|
||||
return (-1);
|
||||
}
|
||||
if (sb.st_size <= 0)
|
||||
(void) unlink(zp->z_ixfr_base);
|
||||
else if (chmod(zp->z_ixfr_base, 0644) < 0)
|
||||
ns_error(ns_log_update,
|
||||
"chmod(%s,%o) failed, pressing on: %s",
|
||||
zp->z_source, sb.st_mode, strerror(errno));
|
||||
(void) my_fclose(from_fp);
|
||||
}
|
||||
(void) unlink(tmpname);
|
||||
memput(tmpname, len);
|
||||
|
||||
/* signal to read for lowest serial number */
|
||||
zp->z_serial_ixfr_start = 0;
|
||||
|
||||
ns_debug(ns_log_default, 3, "%s, size %ld max %ld\n", zp->z_ixfr_base,
|
||||
(long)sb.st_size, (long)zp->z_max_log_size_ixfr);
|
||||
|
||||
if (error)
|
||||
return(-1);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -1,826 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_lexer.c,v 8.31.10.1 2003/06/02 09:56:35 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
#include "ns_parser.h"
|
||||
#include "ns_parseutil.h"
|
||||
#include "ns_lexer.h"
|
||||
|
||||
typedef enum lexer_state {
|
||||
scan, number, identifier, ipv4, quoted_string
|
||||
} LexerState;
|
||||
|
||||
#define LEX_EOF 0x01
|
||||
#define LEXER_MAX_PUSHBACK 2
|
||||
|
||||
typedef struct lexer_file_context {
|
||||
char * name;
|
||||
FILE * stream;
|
||||
int line_number;
|
||||
LexerState state;
|
||||
u_int flags;
|
||||
int warnings;
|
||||
int errors;
|
||||
u_int pushback_count;
|
||||
char pushback[LEXER_MAX_PUSHBACK];
|
||||
struct lexer_file_context *
|
||||
next;
|
||||
} *LexerFileContext;
|
||||
|
||||
LexerFileContext current_file = NULL;
|
||||
|
||||
#define LEX_LAST_WAS_DOT 0x01
|
||||
#define LEX_CONSECUTIVE_DOTS 0x02
|
||||
|
||||
typedef struct lexer_identifier {
|
||||
char buffer[LEX_MAX_IDENT_SIZE+1];
|
||||
int index;
|
||||
int num_dots;
|
||||
unsigned int flags;
|
||||
} *LexerIdentifier;
|
||||
|
||||
static LexerIdentifier id;
|
||||
|
||||
static char special_chars[256];
|
||||
|
||||
#define whitespace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
|
||||
#define domain_char(c) (isalnum((c)) || (c) == '.' || (c) == '-')
|
||||
#define special_char(c) (special_chars[(c)] == 1)
|
||||
#define identifier_char(c) (!whitespace(c) && !special_char(c))
|
||||
|
||||
static int last_token;
|
||||
static YYSTYPE last_yylval;
|
||||
|
||||
static int lexer_initialized = 0;
|
||||
|
||||
/*
|
||||
* Problem Reporting
|
||||
*/
|
||||
|
||||
static char *
|
||||
token_to_text(int token, YYSTYPE lval) {
|
||||
static char buffer[LEX_MAX_IDENT_SIZE+50];
|
||||
|
||||
if (token < 128) {
|
||||
if (token == 0)
|
||||
strcpy(buffer, "<end of file>");
|
||||
else
|
||||
sprintf(buffer, "'%c'", token);
|
||||
} else {
|
||||
switch (token) {
|
||||
case L_EOS:
|
||||
strcpy(buffer, ";");
|
||||
break;
|
||||
case L_STRING:
|
||||
sprintf(buffer, "'%s'", lval.cp);
|
||||
break;
|
||||
case L_QSTRING:
|
||||
sprintf(buffer, "\"%s\"", lval.cp);
|
||||
break;
|
||||
case L_IPADDR:
|
||||
sprintf(buffer, "%s", inet_ntoa(lval.ip_addr));
|
||||
break;
|
||||
case L_NUMBER:
|
||||
sprintf(buffer, "%ld", lval.num);
|
||||
break;
|
||||
case L_END_INCLUDE:
|
||||
sprintf(buffer, "<end of include>");
|
||||
break;
|
||||
default:
|
||||
sprintf(buffer, "%s", lval.cp);
|
||||
}
|
||||
}
|
||||
|
||||
return (buffer);
|
||||
}
|
||||
|
||||
static char where[MAXPATHLEN + 100];
|
||||
static char message[20480];
|
||||
|
||||
static void
|
||||
parser_complain(int is_warning, int print_last_token, const char *format,
|
||||
va_list args) ISC_FORMAT_PRINTF(3, 0);
|
||||
|
||||
static void
|
||||
parser_complain(int is_warning, int print_last_token, const char *format,
|
||||
va_list args)
|
||||
{
|
||||
LexerFileContext lf;
|
||||
int severity;
|
||||
|
||||
if (is_warning) {
|
||||
severity = log_warning;
|
||||
} else {
|
||||
severity = log_error;
|
||||
}
|
||||
|
||||
INSIST(current_file != NULL);
|
||||
if (current_file->next != NULL) {
|
||||
for (lf = current_file; lf != NULL; lf = lf->next) {
|
||||
log_write(log_ctx, ns_log_parser, severity,
|
||||
"%s '%s' line %d",
|
||||
(lf == current_file) ?
|
||||
"In" : "included from",
|
||||
lf->name, lf->line_number);
|
||||
}
|
||||
}
|
||||
sprintf(where, "%s:%d: ", current_file->name,
|
||||
current_file->line_number);
|
||||
vsprintf(message, format, args);
|
||||
if (print_last_token)
|
||||
log_write(log_ctx, ns_log_parser, severity, "%s%s near %s",
|
||||
where, message,
|
||||
token_to_text(last_token, last_yylval));
|
||||
else
|
||||
log_write(log_ctx, ns_log_parser, severity,
|
||||
"%s%s", where, message);
|
||||
}
|
||||
|
||||
int
|
||||
parser_warning(int print_last_token, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
parser_complain(1, print_last_token, format, args);
|
||||
va_end(args);
|
||||
current_file->warnings++;
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
parser_error(int print_last_token, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
parser_complain(0, print_last_token, format, args);
|
||||
va_end(args);
|
||||
current_file->errors++;
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
yyerror(const char *message) {
|
||||
parser_error(1, "%s", message);
|
||||
}
|
||||
|
||||
/*
|
||||
* Keywords
|
||||
*/
|
||||
|
||||
struct keyword {
|
||||
const char *name;
|
||||
int token;
|
||||
};
|
||||
|
||||
/*
|
||||
* "keywords" is an array of the keywords which are the fixed syntactic
|
||||
* elements of the configuration file. Each keyword has a string version
|
||||
* of the keyword and a token id, which should be an identifier which
|
||||
* matches that in a %token statement inside the parser.y file.
|
||||
*/
|
||||
static struct keyword keywords[] = {
|
||||
{"acl", T_ACL},
|
||||
{"address", T_ADDRESS},
|
||||
{"algorithm", T_ALGID},
|
||||
{"allow", T_ALLOW},
|
||||
{"allow-query", T_ALLOW_QUERY},
|
||||
{"allow-recursion", T_ALLOW_RECURSION},
|
||||
{"allow-transfer", T_ALLOW_TRANSFER},
|
||||
{"allow-update", T_ALLOW_UPDATE},
|
||||
#ifdef BIND_NOTIFY
|
||||
{"also-notify", T_ALSO_NOTIFY},
|
||||
#endif
|
||||
{"auth-nxdomain", T_AUTH_NXDOMAIN},
|
||||
{"blackhole", T_BLACKHOLE},
|
||||
{"bogus", T_BOGUS},
|
||||
{"category", T_CATEGORY},
|
||||
{"class", T_CLASS},
|
||||
{"channel", T_CHANNEL},
|
||||
{"check-names", T_CHECK_NAMES},
|
||||
{"cleaning-interval", T_CLEAN_INTERVAL},
|
||||
{"controls", T_CONTROLS},
|
||||
{"coresize", T_CORESIZE},
|
||||
{"datasize", T_DATASIZE},
|
||||
{"deallocate-on-exit", T_DEALLOC_ON_EXIT},
|
||||
{"debug", T_DEBUG},
|
||||
{"default", T_DEFAULT},
|
||||
{"dialup", T_DIALUP},
|
||||
{"directory", T_DIRECTORY},
|
||||
{"dump-file", T_DUMP_FILE},
|
||||
{"dynamic", T_DYNAMIC},
|
||||
{"edns", T_EDNS},
|
||||
{"edns-udp-size", T_EDNS_UDP_SIZE},
|
||||
{"explicit", T_EXPLICIT},
|
||||
{"fail", T_FAIL},
|
||||
{"fake-iquery", T_FAKE_IQUERY},
|
||||
{"false", T_FALSE},
|
||||
{"fetch-glue", T_FETCH_GLUE},
|
||||
{"file", T_FILE},
|
||||
{"files", T_FILES},
|
||||
{"first", T_FIRST},
|
||||
{"forward", T_FORWARD},
|
||||
{"forwarders", T_FORWARDERS},
|
||||
{"group", T_GROUP},
|
||||
{"has-old-clients", T_HAS_OLD_CLIENTS},
|
||||
{"heartbeat-interval", T_HEARTBEAT},
|
||||
{"hint", T_HINT},
|
||||
#ifdef HITCOUNTS
|
||||
{"hit-count", T_HITCOUNT},
|
||||
#endif /* HITCOUNTS */
|
||||
{"host-statistics", T_HOSTSTATS},
|
||||
{"host-statistics-max", T_HOSTSTATSMAX},
|
||||
{"hostname", T_HOSTNAME},
|
||||
{"if-no-answer", T_IF_NO_ANSWER},
|
||||
{"if-no-domain", T_IF_NO_DOMAIN},
|
||||
{"ignore", T_IGNORE},
|
||||
{"include", T_INCLUDE},
|
||||
{"inet", T_INET},
|
||||
{"interface-interval", T_INTERFACE_INTERVAL},
|
||||
{"ixfr-base", T_FILE_IXFR},
|
||||
{"ixfr-tmp-file", T_IXFR_TMP},
|
||||
{"key", T_SEC_KEY},
|
||||
{"keys", T_KEYS},
|
||||
{"lame-ttl", T_LAME_TTL},
|
||||
{"listen-on", T_LISTEN_ON},
|
||||
{"logging", T_LOGGING},
|
||||
{"maintain-ixfr-base", T_MAINTAIN_IXFR_BASE},
|
||||
{"many-answers", T_MANY_ANSWERS},
|
||||
{"master", T_MASTER},
|
||||
{"masters", T_MASTERS},
|
||||
{"max-ixfr-log-size", T_MAX_LOG_SIZE_IXFR},
|
||||
{"max-ncache-ttl", T_MAX_NCACHE_TTL},
|
||||
{"max-transfer-time-in", T_MAX_TRANSFER_TIME_IN},
|
||||
{"memstatistics-file", T_MEMSTATS_FILE},
|
||||
{"min-roots", T_MIN_ROOTS},
|
||||
{"multiple-cnames", T_MULTIPLE_CNAMES},
|
||||
{"name", T_NAME},
|
||||
{"named-xfer", T_NAMED_XFER},
|
||||
{"no", T_NO},
|
||||
#ifdef BIND_NOTIFY
|
||||
{"notify", T_NOTIFY},
|
||||
#endif
|
||||
{"null", T_NULL_OUTPUT},
|
||||
{"one-answer", T_ONE_ANSWER},
|
||||
{"only", T_ONLY},
|
||||
{"order", T_ORDER},
|
||||
{"options", T_OPTIONS},
|
||||
{"owner", T_OWNER},
|
||||
{"perm", T_PERM},
|
||||
{"pid-file", T_PIDFILE},
|
||||
{"port", T_PORT},
|
||||
{"preferred-glue", T_PREFERRED_GLUE},
|
||||
{"print-category", T_PRINT_CATEGORY},
|
||||
{"print-severity", T_PRINT_SEVERITY},
|
||||
{"print-time", T_PRINT_TIME},
|
||||
{"pubkey", T_PUBKEY},
|
||||
{"query-source", T_QUERY_SOURCE},
|
||||
{"rfc2308-type1", T_RFC2308_TYPE1},
|
||||
{"rrset-order", T_RRSET_ORDER},
|
||||
{"recursion", T_RECURSION},
|
||||
{"response", T_RESPONSE},
|
||||
{"secret", T_SECRET},
|
||||
{"serial-queries", T_SERIAL_QUERIES},
|
||||
{"server", T_SERVER},
|
||||
{"severity", T_SEVERITY},
|
||||
{"size", T_SIZE},
|
||||
{"slave", T_SLAVE},
|
||||
{"sortlist", T_SORTLIST},
|
||||
{"stacksize", T_STACKSIZE},
|
||||
{"statistics-file", T_STATS_FILE},
|
||||
{"statistics-interval", T_STATS_INTERVAL},
|
||||
{"stub", T_STUB},
|
||||
{"support-ixfr", T_SUPPORT_IXFR},
|
||||
#ifdef BIND_NOTIFY
|
||||
{"suppress-initial-notify", T_NOTIFY_INITIAL},
|
||||
#endif
|
||||
{"syslog", T_SYSLOG},
|
||||
{"topology", T_TOPOLOGY},
|
||||
{"transfer-format", T_TRANSFER_FORMAT},
|
||||
{"transfer-source", T_TRANSFER_SOURCE},
|
||||
{"transfers", T_TRANSFERS},
|
||||
{"transfers-in", T_TRANSFERS_IN},
|
||||
{"transfers-out", T_TRANSFERS_OUT},
|
||||
{"transfers-per-ns", T_TRANSFERS_PER_NS},
|
||||
{"treat-cr-as-space", T_TREAT_CR_AS_SPACE},
|
||||
{"true", T_TRUE},
|
||||
{"trusted-keys", T_TRUSTED_KEYS},
|
||||
{"type", T_TYPE},
|
||||
{"unix", T_UNIX},
|
||||
{"unlimited", T_UNLIMITED},
|
||||
{"use-id-pool", T_USE_ID_POOL},
|
||||
{"use-ixfr", T_USE_IXFR},
|
||||
{"version", T_VERSION},
|
||||
{"versions", T_VERSIONS},
|
||||
{"warn", T_WARN},
|
||||
{"yes", T_YES},
|
||||
{"zone", T_ZONE},
|
||||
{(char *) NULL, 0},
|
||||
};
|
||||
|
||||
/*
|
||||
* The table size should be a prime chosen to minimize collisions.
|
||||
*/
|
||||
#define KEYWORD_TABLE_SIZE 461
|
||||
|
||||
static symbol_table keyword_table = NULL;
|
||||
|
||||
static void
|
||||
init_keywords() {
|
||||
struct keyword *k;
|
||||
symbol_value value;
|
||||
|
||||
if (keyword_table != NULL)
|
||||
free_symbol_table(keyword_table);
|
||||
keyword_table = new_symbol_table(KEYWORD_TABLE_SIZE, NULL);
|
||||
for (k = keywords; k->name != NULL; k++) {
|
||||
value.integer = k->token;
|
||||
define_symbol(keyword_table, k->name, 0, value, 0);
|
||||
}
|
||||
dprint_symbol_table(99, keyword_table);
|
||||
}
|
||||
|
||||
/*
|
||||
* File Contexts
|
||||
*/
|
||||
|
||||
void
|
||||
lexer_begin_file(const char *filename, FILE *stream) {
|
||||
LexerFileContext lf;
|
||||
|
||||
if (stream == NULL) {
|
||||
stream = fopen(filename, "r");
|
||||
if (stream == NULL) {
|
||||
parser_error(0, "couldn't open include file '%s'",
|
||||
filename);
|
||||
return;
|
||||
}
|
||||
}
|
||||
lf = (LexerFileContext)memget(sizeof (struct lexer_file_context));
|
||||
if (lf == NULL)
|
||||
panic("memget failed in lexer_begin_file", NULL);
|
||||
INSIST(stream != NULL);
|
||||
lf->stream = stream;
|
||||
lf->name = savestr(filename, 1);
|
||||
lf->line_number = 1;
|
||||
lf->state = scan;
|
||||
lf->flags = 0;
|
||||
lf->warnings = 0;
|
||||
lf->errors = 0;
|
||||
lf->pushback_count = 0;
|
||||
lf->next = current_file;
|
||||
current_file = lf;
|
||||
}
|
||||
|
||||
void
|
||||
lexer_end_file(void) {
|
||||
LexerFileContext lf;
|
||||
|
||||
INSIST(current_file != NULL);
|
||||
lf = current_file;
|
||||
current_file = lf->next;
|
||||
fclose(lf->stream);
|
||||
freestr(lf->name);
|
||||
memput(lf, sizeof *lf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Character Input
|
||||
*/
|
||||
|
||||
#define LEXER_GETC(c, cf) \
|
||||
do { \
|
||||
if ((cf)->pushback_count > 0) { \
|
||||
(cf)->pushback_count--; \
|
||||
(c) = (cf)->pushback[(cf)->pushback_count]; \
|
||||
} else \
|
||||
(c) = getc((cf)->stream); \
|
||||
} while (0);
|
||||
|
||||
#define LEXER_UNGETC(c, cf) \
|
||||
do { \
|
||||
INSIST((cf)->pushback_count < LEXER_MAX_PUSHBACK); \
|
||||
(cf)->pushback[(cf)->pushback_count++] = (c); \
|
||||
} while (0);
|
||||
|
||||
static void
|
||||
scan_to_comment_end(int c_plus_plus_style) {
|
||||
int c;
|
||||
int done = 0;
|
||||
int prev_was_star = 0;
|
||||
|
||||
while (!done) {
|
||||
LEXER_GETC(c, current_file);
|
||||
switch (c) {
|
||||
case EOF:
|
||||
if (!c_plus_plus_style)
|
||||
parser_error(0, "EOF in comment");
|
||||
current_file->flags |= LEX_EOF;
|
||||
done = 1;
|
||||
break;
|
||||
case '*':
|
||||
prev_was_star = 1;
|
||||
break;
|
||||
case '/':
|
||||
if (prev_was_star && !c_plus_plus_style)
|
||||
done = 1;
|
||||
prev_was_star = 0;
|
||||
break;
|
||||
case '\n':
|
||||
if (c_plus_plus_style) {
|
||||
/* don't consume the newline because
|
||||
we want it to be a delimiter for
|
||||
anything before the comment
|
||||
started */
|
||||
LEXER_UNGETC(c, current_file);
|
||||
done = 1;
|
||||
} else {
|
||||
current_file->line_number++;
|
||||
}
|
||||
prev_was_star = 0;
|
||||
break;
|
||||
default:
|
||||
prev_was_star = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
get_next_char(int comment_ok) {
|
||||
int c, nc;
|
||||
|
||||
if (current_file->flags & LEX_EOF)
|
||||
return (EOF);
|
||||
|
||||
LEXER_GETC(c, current_file);
|
||||
|
||||
if (comment_ok) {
|
||||
while (c == '/' || c == '#') {
|
||||
if (c == '#') {
|
||||
scan_to_comment_end(1);
|
||||
if (current_file->flags & LEX_EOF)
|
||||
return (EOF);
|
||||
LEXER_GETC(c, current_file);
|
||||
} else {
|
||||
LEXER_GETC(nc, current_file);
|
||||
switch (nc) {
|
||||
case EOF:
|
||||
current_file->flags |= LEX_EOF;
|
||||
return ('/');
|
||||
case '*':
|
||||
case '/':
|
||||
scan_to_comment_end((nc == '/'));
|
||||
if (current_file->flags & LEX_EOF)
|
||||
return (EOF);
|
||||
LEXER_GETC(c, current_file);
|
||||
break;
|
||||
default:
|
||||
LEXER_UNGETC(nc, current_file);
|
||||
return ('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (c == EOF)
|
||||
current_file->flags |= LEX_EOF;
|
||||
else if (c == '\n')
|
||||
current_file->line_number++;
|
||||
return (c);
|
||||
}
|
||||
|
||||
static void
|
||||
put_back_char(int c) {
|
||||
if (c == EOF)
|
||||
current_file->flags |= LEX_EOF;
|
||||
else {
|
||||
LEXER_UNGETC(c, current_file);
|
||||
if (c == '\n')
|
||||
current_file->line_number--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Identifiers
|
||||
*/
|
||||
|
||||
static void
|
||||
clear_identifier(LexerIdentifier id) {
|
||||
INSIST(id != NULL);
|
||||
id->index = 0;
|
||||
id->num_dots = 0;
|
||||
id->flags = 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
dup_identifier(LexerIdentifier id) {
|
||||
char *duplicate;
|
||||
|
||||
INSIST(id != NULL);
|
||||
duplicate = savestr(id->buffer, 1);
|
||||
return (duplicate);
|
||||
}
|
||||
|
||||
static void
|
||||
finish_identifier(LexerIdentifier id) {
|
||||
INSIST(id != NULL && id->index < LEX_MAX_IDENT_SIZE);
|
||||
id->buffer[id->index] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
add_to_identifier(LexerIdentifier id, int c) {
|
||||
INSIST(id != NULL);
|
||||
id->buffer[id->index] = c;
|
||||
id->index++;
|
||||
if (id->index >= LEX_MAX_IDENT_SIZE) {
|
||||
parser_error(0, "identifier too long");
|
||||
current_file->state = scan;
|
||||
/* discard chars until we hit a non-identifier char */
|
||||
while (c != EOF && identifier_char(c)) {
|
||||
c = get_next_char(1);
|
||||
}
|
||||
put_back_char(c);
|
||||
clear_identifier(id);
|
||||
} else {
|
||||
if (c == '.') {
|
||||
if (id->flags & LEX_LAST_WAS_DOT)
|
||||
id->flags |= LEX_CONSECUTIVE_DOTS;
|
||||
id->flags |= LEX_LAST_WAS_DOT;
|
||||
id->num_dots++;
|
||||
} else {
|
||||
id->flags &= ~LEX_LAST_WAS_DOT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* yylex() -- return the next token from the current input stream
|
||||
*/
|
||||
int
|
||||
yylex() {
|
||||
int c;
|
||||
int comment_ok = 1;
|
||||
int token = -1;
|
||||
symbol_value value;
|
||||
|
||||
while (token < 0) {
|
||||
c = get_next_char(comment_ok);
|
||||
switch(current_file->state) {
|
||||
case scan:
|
||||
if (c == EOF) {
|
||||
if (current_file->next == NULL)
|
||||
/*
|
||||
* We don't want to call
|
||||
* lexer_end_file() here because we
|
||||
* want to keep the toplevel file
|
||||
* context to log errors against.
|
||||
*/
|
||||
token = 0;
|
||||
else {
|
||||
lexer_end_file();
|
||||
token = L_END_INCLUDE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (whitespace(c))
|
||||
break;
|
||||
if (identifier_char(c)) {
|
||||
if (isdigit(c))
|
||||
current_file->state = number;
|
||||
else
|
||||
current_file->state = identifier;
|
||||
clear_identifier(id);
|
||||
add_to_identifier(id, c);
|
||||
} else
|
||||
if (special_char(c)) {
|
||||
if (c == ';') {
|
||||
token = L_EOS;
|
||||
break;
|
||||
}
|
||||
if (c == '"') {
|
||||
clear_identifier(id);
|
||||
current_file->state =
|
||||
quoted_string;
|
||||
comment_ok = 0;
|
||||
break;
|
||||
}
|
||||
token = c;
|
||||
} else {
|
||||
parser_error(0,
|
||||
"invalid character '%c'",
|
||||
c);
|
||||
}
|
||||
break;
|
||||
|
||||
case number:
|
||||
if (c != EOF && identifier_char(c)) {
|
||||
if (!isdigit(c))
|
||||
current_file->state =
|
||||
(c == '.') ? ipv4 : identifier;
|
||||
add_to_identifier(id, c);
|
||||
} else {
|
||||
put_back_char(c);
|
||||
current_file->state = scan;
|
||||
finish_identifier(id);
|
||||
yylval.num = strtol(id->buffer, (char**)0, 0);
|
||||
token = L_NUMBER;
|
||||
}
|
||||
break;
|
||||
|
||||
case identifier:
|
||||
if (c != EOF && identifier_char(c)) {
|
||||
add_to_identifier(id, c);
|
||||
} else {
|
||||
put_back_char(c);
|
||||
current_file->state = scan;
|
||||
finish_identifier(id);
|
||||
/* is it a keyword? */
|
||||
if (lookup_symbol(keyword_table, id->buffer,
|
||||
0, &value)) {
|
||||
yylval.cp = id->buffer;
|
||||
token = value.integer;
|
||||
} else {
|
||||
yylval.cp = dup_identifier(id);
|
||||
token = L_STRING;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ipv4:
|
||||
if (c != EOF && identifier_char(c)) {
|
||||
if (!isdigit(c)) {
|
||||
if (c != '.' ||
|
||||
(id->flags & LEX_CONSECUTIVE_DOTS))
|
||||
current_file->state =
|
||||
identifier;
|
||||
}
|
||||
add_to_identifier(id, c);
|
||||
} else {
|
||||
put_back_char(c);
|
||||
if (id->num_dots > 3 ||
|
||||
(id->flags & LEX_LAST_WAS_DOT))
|
||||
current_file->state = identifier;
|
||||
else {
|
||||
if (id->num_dots == 1) {
|
||||
add_to_identifier(id, '.');
|
||||
add_to_identifier(id, '0');
|
||||
add_to_identifier(id, '.');
|
||||
add_to_identifier(id, '0');
|
||||
} else if (id->num_dots == 2) {
|
||||
add_to_identifier(id, '.');
|
||||
add_to_identifier(id, '0');
|
||||
}
|
||||
current_file->state = scan;
|
||||
finish_identifier(id);
|
||||
token = L_IPADDR;
|
||||
if (inet_aton(id->buffer,
|
||||
&(yylval.ip_addr))==0) {
|
||||
yylval.cp = dup_identifier(id);
|
||||
token = L_STRING;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case quoted_string:
|
||||
if (c == EOF) {
|
||||
parser_error(0, "EOF in quoted string");
|
||||
return 0;
|
||||
} else {
|
||||
if (c == '"') {
|
||||
comment_ok = 1;
|
||||
current_file->state = scan;
|
||||
finish_identifier(id);
|
||||
yylval.cp = dup_identifier(id);
|
||||
token = L_QSTRING;
|
||||
} else {
|
||||
/* XXX add backslash escapes here */
|
||||
add_to_identifier(id, c);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("unhandled state in yylex", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
last_token = token;
|
||||
last_yylval = yylval;
|
||||
return (token);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialization
|
||||
*/
|
||||
|
||||
symbol_table constants;
|
||||
|
||||
static void
|
||||
import_constants(const struct ns_sym *s, int type) {
|
||||
symbol_value value;
|
||||
for ((void)NULL; s != NULL && s->name != NULL; s++) {
|
||||
value.integer = s->number;
|
||||
define_symbol(constants, s->name, type, value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
import_res_constants(const struct res_sym *r, int type) {
|
||||
symbol_value value;
|
||||
for ((void)NULL; r != NULL && r->name != NULL; r++) {
|
||||
value.integer = r->number;
|
||||
define_symbol(constants, r->name, type, value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#define CONSTANTS_TABLE_SIZE 397 /* should be prime */
|
||||
|
||||
static void
|
||||
import_all_constants() {
|
||||
constants = new_symbol_table(CONSTANTS_TABLE_SIZE, NULL);
|
||||
import_res_constants(__p_class_syms, SYM_CLASS);
|
||||
import_constants(category_constants, SYM_CATEGORY);
|
||||
import_constants(logging_constants, SYM_LOGGING);
|
||||
import_constants(syslog_constants, SYM_SYSLOG);
|
||||
}
|
||||
|
||||
void
|
||||
lexer_initialize() {
|
||||
memset(special_chars, 0, sizeof special_chars);
|
||||
special_chars[';'] = 1;
|
||||
special_chars['{'] = 1;
|
||||
special_chars['}'] = 1;
|
||||
special_chars['!'] = 1;
|
||||
special_chars['/'] = 1;
|
||||
special_chars['"'] = 1;
|
||||
special_chars['*'] = 1;
|
||||
id = (LexerIdentifier)memget(sizeof (struct lexer_identifier));
|
||||
if (id == NULL)
|
||||
panic("memget failed in lexer_initialize", NULL);
|
||||
init_keywords();
|
||||
import_all_constants();
|
||||
lexer_initialized = 1;
|
||||
}
|
||||
|
||||
void
|
||||
lexer_setup(void) {
|
||||
REQUIRE(lexer_initialized);
|
||||
|
||||
current_file = NULL; /* XXX should we INSIST(current_file==NULL)? */
|
||||
INSIST(id != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
lexer_shutdown(void) {
|
||||
REQUIRE(lexer_initialized);
|
||||
|
||||
free_symbol_table(keyword_table);
|
||||
free_symbol_table(constants);
|
||||
memput(id, sizeof (struct lexer_identifier));
|
||||
id = NULL;
|
||||
lexer_initialized = 0;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _NS_LEXER_H
|
||||
#define _NS_LEXER_H
|
||||
|
||||
/*
|
||||
* Note: <stdio.h> and "ns_parseutil.h" must be included
|
||||
* before this file is included.
|
||||
*/
|
||||
|
||||
#define LEX_MAX_IDENT_SIZE 1024
|
||||
|
||||
#define SYM_CLASS 0x01
|
||||
#define SYM_CATEGORY 0x02
|
||||
#define SYM_LOGGING 0x04
|
||||
#define SYM_SYSLOG 0x08
|
||||
|
||||
int parser_warning(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
int parser_error(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
void yyerror(const char *);
|
||||
void lexer_begin_file(const char *, FILE *);
|
||||
void lexer_end_file(void);
|
||||
int yylex(void);
|
||||
void lexer_initialize(void);
|
||||
void lexer_setup(void);
|
||||
void lexer_shutdown(void);
|
||||
|
||||
extern symbol_table constants;
|
||||
|
||||
#endif /* !_NS_LEXER_H */
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,269 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_ncache.c,v 8.30 2002/11/17 14:51:51 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
#define BOUNDS_CHECK(ptr, count) \
|
||||
do { \
|
||||
if ((ptr) + (count) > eom) { \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
cache_n_resp(u_char *msg, int msglen, struct sockaddr_in from,
|
||||
const char *qname, int qclass, int qtype)
|
||||
{
|
||||
struct databuf *dp;
|
||||
HEADER *hp;
|
||||
u_char *cp, *eom, *rdatap;
|
||||
char dname[MAXDNAME];
|
||||
int n, type, class, flags;
|
||||
u_int ancount, nscount, dlen;
|
||||
#ifdef RETURNSOA
|
||||
u_int32_t ttl;
|
||||
u_int16_t atype;
|
||||
u_char *sp, *cp1;
|
||||
u_char data[MAXDATA];
|
||||
u_char *eod = data + sizeof(data);
|
||||
#endif
|
||||
|
||||
nameserIncr(from.sin_addr, nssRcvdNXD);
|
||||
|
||||
hp = (HEADER *)msg;
|
||||
cp = msg + HFIXEDSZ;
|
||||
eom = msg + msglen;
|
||||
|
||||
switch (ntohs(hp->qdcount)) {
|
||||
case 0:
|
||||
dname[sizeof dname - 1] = '\0';
|
||||
strncpy(dname, qname, sizeof dname);
|
||||
if (dname[sizeof dname - 1] != '\0') {
|
||||
ns_debug(ns_log_ncache, 1,
|
||||
"qp->qname too long (%d)", strlen(qname));
|
||||
hp->rcode = FORMERR;
|
||||
return;
|
||||
}
|
||||
class = qclass;
|
||||
type = qtype;
|
||||
break;
|
||||
case 1:
|
||||
n = dn_expand(msg, eom, cp, dname, sizeof dname);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 1,
|
||||
"Query expand name failed: cache_n_resp");
|
||||
hp->rcode = FORMERR;
|
||||
return;
|
||||
}
|
||||
cp += n;
|
||||
BOUNDS_CHECK(cp, 2 * INT16SZ);
|
||||
GETSHORT(type, cp);
|
||||
GETSHORT(class, cp);
|
||||
if (class > CLASS_MAX) {
|
||||
ns_debug(ns_log_ncache, 1,
|
||||
"bad class in cache_n_resp");
|
||||
hp->rcode = FORMERR;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ns_debug(ns_log_ncache, 1,
|
||||
"QDCOUNT>1 (%d) in cache_n_resp", ntohs(hp->qdcount));
|
||||
hp->rcode = FORMERR;
|
||||
return;
|
||||
}
|
||||
ns_debug(ns_log_ncache, 1, "ncache: dname %s, type %d, class %d",
|
||||
dname, type, class);
|
||||
|
||||
ancount = ntohs(hp->ancount);
|
||||
nscount = ntohs(hp->nscount);
|
||||
|
||||
while (ancount--) {
|
||||
u_int32_t ttl;
|
||||
int atype, aclass;
|
||||
|
||||
n = dn_skipname(cp, eom);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error");
|
||||
return;
|
||||
}
|
||||
cp += n;
|
||||
BOUNDS_CHECK(cp, 3 * INT16SZ + INT32SZ);
|
||||
GETSHORT(atype, cp);
|
||||
GETSHORT(aclass, cp);
|
||||
if (atype != T_CNAME || aclass != class) {
|
||||
ns_debug(ns_log_ncache, 3,
|
||||
"ncache: not CNAME (%s) or wrong class (%s)",
|
||||
p_type(atype), p_class(aclass));
|
||||
return;
|
||||
}
|
||||
GETLONG(ttl, cp);
|
||||
GETSHORT(dlen, cp);
|
||||
BOUNDS_CHECK(cp, dlen);
|
||||
rdatap = cp;
|
||||
n = dn_expand(msg, msg + msglen, cp, dname, sizeof dname);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: bad cname target");
|
||||
return;
|
||||
}
|
||||
cp += n;
|
||||
if (cp != rdatap + dlen) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: bad cname rdata");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
dp = NULL;
|
||||
#ifdef RETURNSOA
|
||||
while (nscount--) {
|
||||
sp = cp;
|
||||
|
||||
/* we store NXDOMAIN as T_SOA regardless of the query type */
|
||||
if (hp->rcode == NXDOMAIN)
|
||||
type = T_SOA;
|
||||
|
||||
/* store ther SOA record */
|
||||
n = dn_skipname(cp, msg + msglen);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error");
|
||||
return;
|
||||
}
|
||||
cp += n;
|
||||
|
||||
BOUNDS_CHECK(cp, 3 * INT16SZ + INT32SZ);
|
||||
GETSHORT(atype, cp); /* type */
|
||||
cp += INT16SZ; /* class */
|
||||
GETLONG(ttl, cp); /* ttl */
|
||||
GETSHORT(dlen, cp); /* dlen */
|
||||
BOUNDS_CHECK(cp, dlen);
|
||||
if (atype != T_SOA) {
|
||||
ns_debug(ns_log_ncache, 3,
|
||||
"ncache: type (%d) != T_SOA", atype);
|
||||
cp += dlen;
|
||||
continue;
|
||||
}
|
||||
rdatap = cp;
|
||||
|
||||
/* origin */
|
||||
n = dn_expand(msg, msg + msglen, cp, (char*)data, eod - data);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3,
|
||||
"ncache: origin form error");
|
||||
return;
|
||||
}
|
||||
cp += n;
|
||||
n = strlen((char*)data) + 1;
|
||||
cp1 = data + n;
|
||||
/* mail */
|
||||
n = dn_expand(msg, msg + msglen, cp, (char*)cp1, eod - cp1);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: mail form error");
|
||||
return;
|
||||
}
|
||||
cp += n;
|
||||
n = strlen((char*)cp1) + 1;
|
||||
cp1 += n;
|
||||
n = 5 * INT32SZ;
|
||||
if (n > (eod - cp1)) /* Can't happen. See MAXDATA. */
|
||||
return;
|
||||
BOUNDS_CHECK(cp, n);
|
||||
memcpy(cp1, cp, n);
|
||||
/* serial, refresh, retry, expire, min */
|
||||
cp1 += n;
|
||||
cp += n;
|
||||
if (cp != rdatap + dlen) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error");
|
||||
return;
|
||||
}
|
||||
/* store the zone of the soa record */
|
||||
n = dn_expand(msg, msg + msglen, sp, (char*)cp1, eod - cp1);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error 2");
|
||||
return;
|
||||
}
|
||||
n = strlen((char*)cp1) + 1;
|
||||
cp1 += n;
|
||||
|
||||
/*
|
||||
* we only want to store these long enough so that
|
||||
* ns_resp can find it.
|
||||
*/
|
||||
if (qtype == T_SOA && hp->rcode == NXDOMAIN)
|
||||
ttl = 0;
|
||||
dp = savedata(class, type,
|
||||
MIN(ttl, server_options->max_ncache_ttl) +
|
||||
tt.tv_sec, data,
|
||||
cp1 - data);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if (dp == NULL)
|
||||
#ifdef STRICT_RFC2308
|
||||
dp = savedata(class, type, tt.tv_sec, NULL, 0);
|
||||
#else
|
||||
dp = savedata(class, type, NTTL + tt.tv_sec, NULL, 0);
|
||||
#endif
|
||||
dp->d_zone = DB_Z_CACHE;
|
||||
dp->d_cred = hp->aa ? DB_C_AUTH : DB_C_ANSWER;
|
||||
dp->d_secure = DB_S_INSECURE; /* BEW - should be UNCHECKED */
|
||||
dp->d_clev = 0;
|
||||
if(hp->rcode == NXDOMAIN) {
|
||||
dp->d_rcode = NXDOMAIN;
|
||||
flags = DB_NODATA|DB_NOTAUTH|DB_NOHINTS;
|
||||
} else {
|
||||
dp->d_rcode = NOERROR_NODATA;
|
||||
flags = DB_NOTAUTH|DB_NOHINTS;
|
||||
}
|
||||
|
||||
n = db_update(dname, dp, dp, NULL, flags, hashtab, from);
|
||||
if (n != OK)
|
||||
ns_debug(ns_log_ncache, 1,
|
||||
"db_update failed (%d), cache_n_resp()", n);
|
||||
else
|
||||
ns_debug(ns_log_ncache, 4,
|
||||
"ncache succeeded: [%s %s %s] rcode:%d ttl:%ld",
|
||||
dname, p_type(type), p_class(class),
|
||||
dp->d_rcode, (long)(dp->d_ttl - tt.tv_sec));
|
||||
db_detach(&dp);
|
||||
}
|
||||
@@ -1,462 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_notify.c,v 8.20 2002/04/25 05:27:12 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* Import. */
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include <isc/dst.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
#ifdef BIND_NOTIFY
|
||||
|
||||
/* Types. */
|
||||
|
||||
struct pnotify {
|
||||
char * name;
|
||||
ns_class class;
|
||||
ns_type type;
|
||||
evTimerID timer;
|
||||
LINK(struct pnotify) link;
|
||||
};
|
||||
|
||||
/* Forward. */
|
||||
|
||||
static void sysnotify(const char *, ns_class, ns_type);
|
||||
static void sysnotify_slaves(const char *, const char *,
|
||||
ns_class, ns_type, int, int *, int *);
|
||||
static void sysnotify_ns(const char *, const char *,
|
||||
ns_class, ns_type, int, int *, int *);
|
||||
static void free_notify(struct pnotify *);
|
||||
static void notify_timer(evContext, void *,
|
||||
struct timespec, struct timespec);
|
||||
|
||||
/* Local. */
|
||||
|
||||
static LIST(struct pnotify) pending_notifies;
|
||||
static LIST(struct pnotify) loading_notifies;
|
||||
|
||||
/* Public. */
|
||||
|
||||
/*
|
||||
* ns_notify(dname, class, type)
|
||||
* call this when a zone has changed and its slaves need to know.
|
||||
*/
|
||||
void
|
||||
ns_notify(const char *dname, ns_class class, ns_type type) {
|
||||
static const char no_room[] = "%s failed, cannot notify for zone %s";
|
||||
int delay, max_delay;
|
||||
struct zoneinfo *zp;
|
||||
struct pnotify *ni;
|
||||
|
||||
zp = find_auth_zone(dname, class);
|
||||
if (zp == NULL) {
|
||||
ns_warning(ns_log_notify,
|
||||
"no zone found for notify (\"%s\" %s %s)",
|
||||
(dname && *dname) ? dname : ".",
|
||||
p_class(class), p_type(type));
|
||||
return;
|
||||
}
|
||||
if (ns_samename(dname, zp->z_origin) != 1) {
|
||||
ns_warning(ns_log_notify,
|
||||
"notify not called with top of zone (\"%s\" %s %s)",
|
||||
(dname && *dname) ? dname : ".",
|
||||
p_class(class), p_type(type));
|
||||
return;
|
||||
}
|
||||
if ((zp->z_flags & Z_NOTIFY) != 0) {
|
||||
ns_info(ns_log_notify,
|
||||
"suppressing duplicate notify (\"%s\" %s %s)",
|
||||
(dname && *dname) ? dname : ".",
|
||||
p_class(class), p_type(type));
|
||||
return;
|
||||
}
|
||||
ni = memget(sizeof *ni);
|
||||
if (ni == NULL) {
|
||||
ns_info(ns_log_notify, no_room, "memget", dname);
|
||||
return;
|
||||
}
|
||||
ni->name = savestr(dname, 0);
|
||||
if (ni->name == NULL) {
|
||||
memput(ni, sizeof *ni);
|
||||
ni = NULL;
|
||||
ns_info(ns_log_notify, no_room, "memget", dname);
|
||||
return;
|
||||
}
|
||||
ni->class = class;
|
||||
ni->type = type;
|
||||
INIT_LINK(ni, link);
|
||||
evInitID(&ni->timer);
|
||||
|
||||
if (loading != 0) {
|
||||
APPEND(loading_notifies, ni, link);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Delay notification for from five seconds up to fifteen minutes. */
|
||||
max_delay = MIN(nzones, 895);
|
||||
max_delay = MAX(max_delay, 25);
|
||||
delay = 5 + (rand() % max_delay);
|
||||
if (evSetTimer(ev, notify_timer, ni,
|
||||
evAddTime(evNowTime(), evConsTime(delay, 0)),
|
||||
evConsTime(0, 0), &ni->timer) < 0) {
|
||||
ns_error(ns_log_notify, "evSetTimer() failed: %s",
|
||||
strerror(errno));
|
||||
ni->name = freestr(ni->name);
|
||||
memput(ni, sizeof *ni);
|
||||
return;
|
||||
}
|
||||
|
||||
zp->z_flags |= Z_NOTIFY;
|
||||
APPEND(pending_notifies, ni, link);
|
||||
ns_debug(ns_log_notify, 3,
|
||||
"ns_notify(%s, %s, %s): ni %p, zp %p, delay %d",
|
||||
(dname && *dname) ? dname : ".",
|
||||
p_class(class), p_type(type),
|
||||
ni, zp, delay);
|
||||
}
|
||||
|
||||
void
|
||||
notify_afterload() {
|
||||
struct pnotify *ni;
|
||||
|
||||
INSIST(loading == 0);
|
||||
while ((ni = HEAD(loading_notifies)) != NULL) {
|
||||
UNLINK(loading_notifies, ni, link);
|
||||
ns_notify(ni->name, ni->class, ni->type);
|
||||
ni->name = freestr(ni->name);
|
||||
memput(ni, sizeof *ni);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_unnotify()
|
||||
* call this when all pending notifies are now considered junque.
|
||||
*/
|
||||
void
|
||||
ns_unnotify(void) {
|
||||
while (!EMPTY(pending_notifies)) {
|
||||
struct pnotify *ni = HEAD(pending_notifies);
|
||||
|
||||
INSIST(LINKED(ni, link));
|
||||
UNLINK(pending_notifies, ni, link);
|
||||
free_notify(ni);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_stopnotify(const char *dname, ns_class class)
|
||||
* stop notifies for this particular zone.
|
||||
*/
|
||||
void
|
||||
ns_stopnotify(const char *dname, ns_class class) {
|
||||
struct pnotify *ni;
|
||||
|
||||
ni = HEAD(pending_notifies);
|
||||
while (ni != NULL &&
|
||||
(ni->class != class || ns_samename(ni->name, dname) != 1))
|
||||
ni = NEXT(ni, link);
|
||||
|
||||
if (ni != NULL) {
|
||||
UNLINK(pending_notifies, ni, link);
|
||||
free_notify(ni);
|
||||
}
|
||||
}
|
||||
|
||||
/* Private. */
|
||||
|
||||
/*
|
||||
* sysnotify(dname, class, type)
|
||||
* cause a NOTIFY request to be sysquery()'d to each slave server
|
||||
* of the zone that "dname" is within.
|
||||
*/
|
||||
static void
|
||||
sysnotify(const char *dname, ns_class class, ns_type type) {
|
||||
const char *zname;
|
||||
u_int32_t zserial;
|
||||
int nns, na, i;
|
||||
struct zoneinfo *zp;
|
||||
struct in_addr *also_addr;
|
||||
|
||||
ns_debug(ns_log_notify, 3, "sysnotify(%s, %s, %s)",
|
||||
dname, p_class(class), p_type(type));
|
||||
zp = find_auth_zone(dname, class);
|
||||
if (zp == NULL) {
|
||||
ns_warning(ns_log_notify, "sysnotify: can't find \"%s\" (%s)",
|
||||
dname, p_class(class));
|
||||
return;
|
||||
}
|
||||
if (ns_samename(dname, zp->z_origin) != 1) {
|
||||
ns_warning(ns_log_notify, "sysnotify: not auth for zone %s",
|
||||
dname);
|
||||
return;
|
||||
}
|
||||
if (zp->z_notify == notify_no ||
|
||||
(zp->z_notify == notify_use_default &&
|
||||
server_options->notify == notify_no))
|
||||
return;
|
||||
if (zp->z_type != z_master && zp->z_type != z_slave) {
|
||||
ns_warning(ns_log_notify, "sysnotify: %s not master or slave",
|
||||
dname);
|
||||
return;
|
||||
}
|
||||
zname = zp->z_origin;
|
||||
zserial = zp->z_serial;
|
||||
nns = na = 0;
|
||||
if (zp->z_notify == notify_yes ||
|
||||
(zp->z_notify == notify_use_default &&
|
||||
server_options->notify == notify_yes))
|
||||
sysnotify_slaves(dname, zname, class, type,
|
||||
zp - zones, &nns, &na);
|
||||
|
||||
/*
|
||||
* Handle any global or zone-specific also-notify clauses
|
||||
*/
|
||||
if (zp->z_notify_count != 0) {
|
||||
/* zone-specific also notify */
|
||||
|
||||
ns_debug(ns_log_notify, 3, "zone notify ns = %d",
|
||||
zp->z_notify_count);
|
||||
|
||||
also_addr = zp->z_also_notify;
|
||||
for (i = 0; i < zp->z_notify_count; i++) {
|
||||
ns_debug(ns_log_notify, 4, "notifying %s",
|
||||
inet_ntoa(*also_addr));
|
||||
sysquery(dname, class, type, also_addr, NULL, 1,
|
||||
ns_port, NS_NOTIFY_OP, 0);
|
||||
also_addr++;
|
||||
}
|
||||
nns += zp->z_notify_count;
|
||||
na += zp->z_notify_count;
|
||||
} else if (server_options->notify_count != 0) {
|
||||
ns_debug(ns_log_notify, 4, "global notify ns = %d",
|
||||
server_options->notify_count);
|
||||
also_addr = server_options->also_notify;
|
||||
for (i = 0; i < server_options->notify_count; i++) {
|
||||
ns_debug(ns_log_notify, 3, "notifying %s",
|
||||
inet_ntoa(*also_addr));
|
||||
sysquery(dname, class, type, also_addr, NULL, 1,
|
||||
ns_port, ns_o_notify, 0);
|
||||
also_addr++;
|
||||
}
|
||||
nns += server_options->notify_count;
|
||||
na += server_options->notify_count;
|
||||
}
|
||||
|
||||
if (nns != 0 || na != 0)
|
||||
ns_info(ns_log_notify,
|
||||
"Sent NOTIFY for \"%s %s %s %u\" (%s); %d NS, %d A",
|
||||
dname, p_class(class), p_type(type), zserial, zname, nns, na);
|
||||
}
|
||||
|
||||
static void
|
||||
sysnotify_slaves(const char *dname, const char *zname,
|
||||
ns_class class, ns_type type,
|
||||
int zn, int *nns, int *na)
|
||||
{
|
||||
const char *mname, *fname;
|
||||
struct hashbuf *htp;
|
||||
struct namebuf *np;
|
||||
struct databuf *dp;
|
||||
|
||||
/*
|
||||
* Master.
|
||||
*/
|
||||
htp = hashtab;
|
||||
np = nlookup(zname, &htp, &fname, 0);
|
||||
if (np == NULL) {
|
||||
ns_warning(ns_log_notify,
|
||||
"sysnotify: found name \"%s\" but not zone",
|
||||
dname);
|
||||
return;
|
||||
}
|
||||
mname = NULL;
|
||||
for (dp = np->n_data; dp != NULL; dp = dp->d_next) {
|
||||
if (dp->d_zone == DB_Z_CACHE || !match(dp, class, ns_t_soa))
|
||||
continue;
|
||||
if (dp->d_type == ns_t_sig)
|
||||
continue;
|
||||
if (mname) {
|
||||
ns_notice(ns_log_notify,
|
||||
"multiple SOA's for zone \"%s\"?",
|
||||
zname);
|
||||
return;
|
||||
}
|
||||
mname = (char *) dp->d_data;
|
||||
}
|
||||
if (mname == NULL) {
|
||||
ns_notice(ns_log_notify, "no SOA found for zone \"%s\"",
|
||||
zname);
|
||||
return;
|
||||
}
|
||||
for (dp = np->n_data; dp != NULL; dp = dp->d_next) {
|
||||
if (dp->d_zone == DB_Z_CACHE || !match(dp, class, ns_t_ns))
|
||||
continue;
|
||||
if (dp->d_type == ns_t_sig)
|
||||
continue;
|
||||
if (ns_samename((char*)dp->d_data, mname) == 1)
|
||||
continue;
|
||||
sysnotify_ns(dname, (char *)dp->d_data, class, type,
|
||||
zn, nns, na);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysnotify_ns(const char *dname, const char *aname,
|
||||
ns_class class, ns_type type,
|
||||
int zn, int *nns, int *na)
|
||||
{
|
||||
struct databuf *adp;
|
||||
struct namebuf *anp;
|
||||
const char *fname;
|
||||
struct in_addr nss[NSMAX];
|
||||
struct hashbuf *htp;
|
||||
int is_us, nsc, auth6, neg;
|
||||
int cname = 0;
|
||||
|
||||
htp = hashtab;
|
||||
anp = nlookup(aname, &htp, &fname, 0);
|
||||
nsc = 0;
|
||||
is_us = 0;
|
||||
auth6 = 0;
|
||||
neg = 0;
|
||||
if (anp != NULL)
|
||||
for (adp = anp->n_data; adp; adp = adp->d_next) {
|
||||
struct in_addr ina;
|
||||
|
||||
if (adp->d_class != class)
|
||||
continue;
|
||||
if (adp->d_rcode == NXDOMAIN) {
|
||||
neg = 1;
|
||||
break;
|
||||
}
|
||||
if (adp->d_type == T_CNAME && adp->d_rcode == 0) {
|
||||
cname = 1;
|
||||
ns_error(ns_log_notify,
|
||||
"NS '%s' for '%s/%s' is a CNAME",
|
||||
*aname ? aname : ".",
|
||||
*dname ? dname : ".",
|
||||
p_class(class));
|
||||
break;
|
||||
}
|
||||
if ((adp->d_type == T_AAAA || adp->d_type == ns_t_a6) &&
|
||||
(zones[adp->d_class].z_type == z_master ||
|
||||
zones[adp->d_class].z_type == z_slave)) {
|
||||
auth6 = 1;
|
||||
continue;
|
||||
}
|
||||
if (!match(adp, class, T_A))
|
||||
continue;
|
||||
if (adp->d_rcode) {
|
||||
neg = 1;
|
||||
continue;
|
||||
}
|
||||
if (adp->d_type == ns_t_sig)
|
||||
continue;
|
||||
ina = ina_get(adp->d_data);
|
||||
if (aIsUs(ina)) {
|
||||
is_us = 1;
|
||||
continue;
|
||||
}
|
||||
if (nsc < NSMAX)
|
||||
nss[nsc++] = ina;
|
||||
} /*next A*/
|
||||
if (nsc == 0) {
|
||||
if (!is_us && !cname && !auth6 && !neg &&
|
||||
!NS_OPTION_P(OPTION_NOFETCHGLUE)) {
|
||||
struct qinfo *qp;
|
||||
|
||||
qp = sysquery(aname, class, ns_t_a, NULL, NULL, 0,
|
||||
ns_port, ns_o_query, 0);
|
||||
if (qp != NULL)
|
||||
qp->q_notifyzone = zn;
|
||||
}
|
||||
return;
|
||||
}
|
||||
sysquery(dname, class, type, nss, NULL, nsc, ns_port, ns_o_notify, 0);
|
||||
(*nns)++;
|
||||
*na += nsc;
|
||||
}
|
||||
|
||||
static void
|
||||
free_notify(struct pnotify *ni) {
|
||||
struct zoneinfo *zp;
|
||||
|
||||
INSIST(!LINKED(ni, link));
|
||||
zp = find_auth_zone(ni->name, ni->class);
|
||||
if (zp != NULL && ns_samename(ni->name, zp->z_origin) == 1) {
|
||||
INSIST((zp->z_flags & Z_NOTIFY) != 0);
|
||||
zp->z_flags &= ~Z_NOTIFY;
|
||||
}
|
||||
if (evTestID(ni->timer)) {
|
||||
evClearTimer(ev, ni->timer);
|
||||
evInitID(&ni->timer);
|
||||
}
|
||||
ni->name = freestr(ni->name);
|
||||
memput(ni, sizeof *ni);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_timer(evContext ctx, void *uap,
|
||||
struct timespec due,
|
||||
struct timespec inter)
|
||||
{
|
||||
struct pnotify *ni = uap;
|
||||
|
||||
UNUSED(ctx);
|
||||
UNUSED(due);
|
||||
UNUSED(inter);
|
||||
|
||||
INSIST(evTestID(ni->timer));
|
||||
evInitID(&ni->timer);
|
||||
INSIST(LINKED(ni, link));
|
||||
UNLINK(pending_notifies, ni, link);
|
||||
sysnotify(ni->name, ni->class, ni->type);
|
||||
free_notify(ni);
|
||||
}
|
||||
|
||||
#endif /*BIND_NOTIFY*/
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* Global C stuff goes here. */
|
||||
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
#include "ns_parseutil.h"
|
||||
|
||||
|
||||
/*
|
||||
* Symbol Table
|
||||
*/
|
||||
|
||||
symbol_table
|
||||
new_symbol_table(int size_guess, free_function free_value) {
|
||||
symbol_table st;
|
||||
|
||||
st = (symbol_table)memget(sizeof (struct symbol_table));
|
||||
if (st == NULL)
|
||||
panic("memget failed in new_symbol_table()", NULL);
|
||||
st->table = (symbol_entry *)memget(size_guess * sizeof *st->table);
|
||||
if (st->table == NULL)
|
||||
panic("memget failed in new_symbol_table()", NULL);
|
||||
memset(st->table, 0, size_guess * sizeof (symbol_entry));
|
||||
st->size = size_guess; /* size_guess should be prime */
|
||||
st->free_value = free_value;
|
||||
return (st);
|
||||
}
|
||||
|
||||
void
|
||||
free_symbol(symbol_table st, symbol_entry ste) {
|
||||
ste->key = freestr(ste->key);
|
||||
if (ste->flags & SYMBOL_FREE_VALUE)
|
||||
(st->free_value)(ste->type, ste->value.pointer);
|
||||
}
|
||||
|
||||
void
|
||||
free_symbol_table(symbol_table st) {
|
||||
int i;
|
||||
symbol_entry ste, ste_next;
|
||||
|
||||
for (i = 0; i < st->size; i++) {
|
||||
for (ste = st->table[i]; ste != NULL; ste = ste_next) {
|
||||
ste_next = ste->next;
|
||||
free_symbol(st, ste);
|
||||
memput(ste, sizeof *ste);
|
||||
}
|
||||
}
|
||||
memput(st->table, st->size * sizeof (symbol_entry));
|
||||
memput(st, sizeof *st);
|
||||
}
|
||||
|
||||
void
|
||||
dprint_symbol_table(int level, symbol_table st) {
|
||||
int i;
|
||||
symbol_entry ste;
|
||||
|
||||
for (i = 0; i < st->size; i++) {
|
||||
for (ste = st->table[i]; ste != NULL; ste = ste->next)
|
||||
ns_debug(ns_log_parser, level,
|
||||
"%7d: (%s: %d %p/%d %04x) ",
|
||||
i, ste->key, ste->type, ste->value.pointer,
|
||||
ste->value.integer, ste->flags);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* P. J. Weinberger's hash function, adapted from p. 436 of
|
||||
* _Compilers: Principles, Techniques, and Tools_, Aho, Sethi
|
||||
* and Ullman, Addison-Wesley, 1986, ISBN 0-201-10088-6.
|
||||
*/
|
||||
static int
|
||||
symbol_hash(const char *key, int prime) {
|
||||
const char *s;
|
||||
unsigned int h = 0;
|
||||
unsigned int g;
|
||||
int c;
|
||||
|
||||
for (s = key; *s != '\0'; s++) {
|
||||
c = *s;
|
||||
if (isascii(c) && isupper(c))
|
||||
c = tolower(c);
|
||||
h = ( h << 4 ) + c;
|
||||
if ((g = ( h & 0xf0000000 )) != 0) {
|
||||
h = h ^ (g >> 24);
|
||||
h = h ^ g;
|
||||
}
|
||||
}
|
||||
return (h % prime);
|
||||
}
|
||||
|
||||
int
|
||||
lookup_symbol(symbol_table st, const char *key, int type,
|
||||
symbol_value *value) {
|
||||
int hash;
|
||||
symbol_entry ste;
|
||||
|
||||
hash = symbol_hash(key, st->size);
|
||||
for (ste = st->table[hash]; ste != NULL; ste = ste->next)
|
||||
if ((type == 0 || ste->type == type) &&
|
||||
strcasecmp(ste->key, key) == 0)
|
||||
break;
|
||||
if (ste != NULL) {
|
||||
if (value != NULL)
|
||||
*value = ste->value;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
define_symbol(symbol_table st, const char *key, int type, symbol_value value,
|
||||
unsigned int flags) {
|
||||
int hash;
|
||||
symbol_entry ste;
|
||||
|
||||
hash = symbol_hash(key, st->size);
|
||||
for (ste = st->table[hash]; ste != NULL; ste = ste->next)
|
||||
if ((type == 0 || ste->type == type) &&
|
||||
strcasecmp(ste->key, key) == 0)
|
||||
break;
|
||||
if (ste == NULL) {
|
||||
ste = (symbol_entry)memget(sizeof *ste);
|
||||
if (ste == NULL)
|
||||
panic("memget failed in define_symbol()", NULL);
|
||||
ste->key = savestr(key, 1);
|
||||
ste->type = type;
|
||||
ste->value = value;
|
||||
ste->flags = flags;
|
||||
ste->next = st->table[hash];
|
||||
st->table[hash] = ste;
|
||||
} else {
|
||||
ns_debug(ns_log_parser, 7, "redefined symbol %s type %d",
|
||||
key, type);
|
||||
free_symbol(st, ste);
|
||||
ste->key = savestr(key, 1);
|
||||
ste->value = value;
|
||||
ste->flags = flags;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
undefine_symbol(symbol_table st, char *key, int type) {
|
||||
int hash;
|
||||
symbol_entry prev_ste, ste;
|
||||
|
||||
hash = symbol_hash(key, st->size);
|
||||
for (prev_ste = NULL, ste = st->table[hash];
|
||||
ste != NULL;
|
||||
prev_ste = ste, ste = ste->next)
|
||||
if ((type == 0 || ste->type == type) &&
|
||||
strcasecmp(ste->key, key) == 0)
|
||||
break;
|
||||
if (ste != NULL) {
|
||||
free_symbol(st, ste);
|
||||
if (prev_ste != NULL)
|
||||
prev_ste->next = ste->next;
|
||||
else
|
||||
st->table[hash] = ste->next;
|
||||
memput(ste, sizeof *ste);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion Routines
|
||||
*/
|
||||
|
||||
int
|
||||
unit_to_ulong(char *in, u_long *out) {
|
||||
int c, units_done = 0;
|
||||
u_long result = 0L;
|
||||
|
||||
INSIST(in != NULL);
|
||||
|
||||
for (; (c = *in) != '\0'; in++) {
|
||||
if (units_done)
|
||||
return (0);
|
||||
if (isdigit(c)) {
|
||||
result *= 10;
|
||||
result += (c - '0');
|
||||
} else {
|
||||
switch (c) {
|
||||
case 'k':
|
||||
case 'K':
|
||||
result *= 1024;
|
||||
units_done = 1;
|
||||
break;
|
||||
case 'm':
|
||||
case 'M':
|
||||
result *= (1024*1024);
|
||||
units_done = 1;
|
||||
break;
|
||||
case 'g':
|
||||
case 'G':
|
||||
result *= (1024*1024*1024);
|
||||
units_done = 1;
|
||||
break;
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*out = result;
|
||||
return (1);
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _NS_PARSEUTIL_H
|
||||
#define _NS_PARSEUTIL_H
|
||||
|
||||
/*
|
||||
* Symbol Table
|
||||
*/
|
||||
|
||||
#define SYMBOL_FREE_VALUE 0x02
|
||||
|
||||
typedef union symbol_value {
|
||||
void *pointer;
|
||||
int integer;
|
||||
} symbol_value;
|
||||
|
||||
typedef void (*free_function)(int, void *);
|
||||
|
||||
typedef struct symbol_entry {
|
||||
char *key;
|
||||
int type;
|
||||
symbol_value value;
|
||||
unsigned int flags;
|
||||
struct symbol_entry *next;
|
||||
} *symbol_entry;
|
||||
|
||||
typedef struct symbol_table {
|
||||
int size;
|
||||
symbol_entry *table;
|
||||
free_function free_value;
|
||||
} *symbol_table;
|
||||
|
||||
symbol_table new_symbol_table(int, free_function);
|
||||
void free_symbol(symbol_table, symbol_entry);
|
||||
void free_symbol_table(symbol_table);
|
||||
void dprint_symbol_table(int, symbol_table);
|
||||
int lookup_symbol(symbol_table, const char *, int,
|
||||
symbol_value *);
|
||||
void define_symbol(symbol_table, const char *, int,
|
||||
symbol_value, unsigned int);
|
||||
void undefine_symbol(symbol_table, char *, int type);
|
||||
|
||||
/*
|
||||
* Conversion Routines
|
||||
*/
|
||||
|
||||
int unit_to_ulong(char *, u_long *);
|
||||
|
||||
#endif /* !_NS_PARSEUTIL_H */
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,297 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)ns_main.c 4.55 (Berkeley) 7/1/91";
|
||||
static const char rcsid[] = "$Id: ns_signal.c,v 8.15 2002/05/18 01:39:15 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986, 1989, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* Import. */
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#ifdef SVR4 /* XXX */
|
||||
# include <sys/sockio.h>
|
||||
#else
|
||||
#ifndef __hpux
|
||||
# include <sys/mbuf.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <net/route.h>
|
||||
#include <net/if.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <netdb.h>
|
||||
#include <pwd.h>
|
||||
#include <resolv.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
#include <isc/list.h>
|
||||
|
||||
#include "port_after.h"
|
||||
#include "named.h"
|
||||
|
||||
/* Forward. */
|
||||
|
||||
static SIG_FN onhup(int);
|
||||
static SIG_FN onintr(int);
|
||||
static SIG_FN setdumpflg(int);
|
||||
static SIG_FN setIncrDbgFlg(int);
|
||||
static SIG_FN setNoDbgFlg(int);
|
||||
static SIG_FN setQrylogFlg(int);
|
||||
static SIG_FN setstatsflg(int);
|
||||
static SIG_FN discard_pipe(int);
|
||||
static SIG_FN setreapflg(int);
|
||||
|
||||
/* Data. */
|
||||
|
||||
static struct {
|
||||
int sig;
|
||||
SIG_FN (*hand)(int);
|
||||
} sighandlers[] = {
|
||||
#ifdef DEBUG
|
||||
{ SIGUSR1, setIncrDbgFlg },
|
||||
{ SIGUSR2, setNoDbgFlg },
|
||||
#endif
|
||||
#if defined(SIGWINCH) && defined(QRYLOG)
|
||||
{ SIGWINCH, setQrylogFlg },
|
||||
#endif
|
||||
#if defined(SIGXFSZ)
|
||||
{ SIGXFSZ, onhup }, /* Wierd DEC Hesiodism, harmless. */
|
||||
#endif
|
||||
{ SIGINT, setdumpflg },
|
||||
{ SIGILL, setstatsflg },
|
||||
{ SIGHUP, onhup },
|
||||
{ SIGCHLD, setreapflg },
|
||||
{ SIGPIPE, discard_pipe },
|
||||
{ SIGTERM, onintr }
|
||||
};
|
||||
|
||||
static sigset_t mask;
|
||||
static int blocked = 0;
|
||||
|
||||
/* Private. */
|
||||
|
||||
static SIG_FN
|
||||
onhup(int sig) {
|
||||
|
||||
UNUSED(sig);
|
||||
|
||||
ns_need_unsafe(main_need_reload);
|
||||
}
|
||||
|
||||
static SIG_FN
|
||||
onintr(int sig) {
|
||||
|
||||
UNUSED(sig);
|
||||
|
||||
ns_need_unsafe(main_need_exit);
|
||||
}
|
||||
|
||||
static SIG_FN
|
||||
setdumpflg(int sig) {
|
||||
|
||||
UNUSED(sig);
|
||||
|
||||
ns_need_unsafe(main_need_dump);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static SIG_FN
|
||||
setIncrDbgFlg(int sig) {
|
||||
|
||||
UNUSED(sig);
|
||||
|
||||
desired_debug++;
|
||||
ns_need_unsafe(main_need_debug);
|
||||
}
|
||||
|
||||
static SIG_FN
|
||||
setNoDbgFlg(int sig) {
|
||||
|
||||
UNUSED(sig);
|
||||
|
||||
desired_debug = 0;
|
||||
ns_need_unsafe(main_need_debug);
|
||||
}
|
||||
#endif /*DEBUG*/
|
||||
|
||||
#if defined(QRYLOG) && defined(SIGWINCH)
|
||||
static SIG_FN
|
||||
setQrylogFlg(int sig) {
|
||||
|
||||
UNUSED(sig);
|
||||
|
||||
ns_need_unsafe(main_need_qrylog);
|
||||
}
|
||||
#endif /*QRYLOG && SIGWINCH*/
|
||||
|
||||
static SIG_FN
|
||||
setstatsflg(int sig) {
|
||||
|
||||
UNUSED(sig);
|
||||
|
||||
ns_need_unsafe(main_need_statsdump);
|
||||
}
|
||||
|
||||
static SIG_FN
|
||||
discard_pipe(int sig) {
|
||||
#ifdef SIGPIPE_ONE_SHOT
|
||||
int saved_errno = errno;
|
||||
struct sigaction sa;
|
||||
|
||||
UNUSED(sig);
|
||||
|
||||
memset(&sa, 0, sizeof sa);
|
||||
sa.sa_mask = mask;
|
||||
sa.sa_handler = discard_pipe;
|
||||
if (sigaction(SIGPIPE, &sa, NULL) < 0)
|
||||
ns_error(ns_log_os, "sigaction failed in discard_pipe: %s",
|
||||
strerror(errno));
|
||||
errno = saved_errno;
|
||||
#else
|
||||
UNUSED(sig);
|
||||
#endif
|
||||
}
|
||||
|
||||
static SIG_FN
|
||||
setreapflg(int sig) {
|
||||
|
||||
UNUSED(sig);
|
||||
|
||||
ns_need_unsafe(main_need_reap);
|
||||
}
|
||||
|
||||
/* Public. */
|
||||
|
||||
void
|
||||
init_signals(void) {
|
||||
size_t sh;
|
||||
|
||||
/* The mask of all our handlers will block all our other handlers. */
|
||||
(void)sigemptyset(&mask);
|
||||
for (sh = 0; sh < sizeof sighandlers / sizeof sighandlers[0]; sh++)
|
||||
sigaddset(&mask, sighandlers[sh].sig);
|
||||
|
||||
/* Install our signal handlers with that shared mask. */
|
||||
for (sh = 0; sh < sizeof sighandlers / sizeof sighandlers[0]; sh++) {
|
||||
struct sigaction sa;
|
||||
|
||||
memset(&sa, 0, sizeof sa);
|
||||
sa.sa_mask = mask;
|
||||
sa.sa_handler = sighandlers[sh].hand;
|
||||
if (sigaction(sighandlers[sh].sig, &sa, NULL) < 0)
|
||||
ns_error(ns_log_os,
|
||||
"sigaction failed in set_signal_handler(%d): %s",
|
||||
sighandlers[sh].sig, strerror(errno));
|
||||
}
|
||||
/* Unblock all signals that we expect to handle. */
|
||||
if (sigprocmask(SIG_UNBLOCK, &mask, NULL) < 0)
|
||||
ns_panic(ns_log_os, 1, "sigblock failed: %s", strerror(errno));
|
||||
}
|
||||
|
||||
void
|
||||
block_signals(void) {
|
||||
INSIST(!blocked);
|
||||
if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0)
|
||||
ns_panic(ns_log_os, 1, "sigblock failed: %s", strerror(errno));
|
||||
blocked = 1;
|
||||
}
|
||||
|
||||
void
|
||||
unblock_signals(void) {
|
||||
INSIST(blocked);
|
||||
if (sigprocmask(SIG_UNBLOCK, &mask, NULL) < 0)
|
||||
ns_panic(ns_log_os, 1, "sigblock failed: %s", strerror(errno));
|
||||
blocked = 0;
|
||||
}
|
||||
@@ -1,414 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)ns_sort.c 4.10 (Berkeley) 3/3/91";
|
||||
static const char rcsid[] = "$Id: ns_sort.c,v 8.8 2001/09/25 04:50:22 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Sorting should really be handled by the resolver, but:
|
||||
* 1) There are too many brain dead resolvers out there that can't be replaced.
|
||||
* 2) It would be a pain to individually configure all those resolvers anyway.
|
||||
*
|
||||
* Here's the scoop:
|
||||
*
|
||||
* To enable address sorting in responses, you need to supply the sortlist
|
||||
* statement in the config file. The sortlist statement takes an
|
||||
* address match list and interprets it even more specially than the
|
||||
* topology statement does.
|
||||
*
|
||||
* Each top level statement in the sortlist must itself be an explicit
|
||||
* address match list with one or two elements. The first element
|
||||
* (which may be an IP address, an IP prefix, an ACL name or nested
|
||||
* address match list) of each top level list is checked against the
|
||||
* source address of the query until a match is found.
|
||||
*
|
||||
* Once the source address of the query has been matched, if the top level
|
||||
* statement contains only one element, the actual primitive element that
|
||||
* matched the source address is used to select the address in the response
|
||||
* to move to the beginning of the response. If the statement is a list
|
||||
* of two elements, then the second element is treated like the address
|
||||
* match list in a topology statement. Each top level element is assigned
|
||||
* a distance and the address in the response with the minimum distance is
|
||||
* moved to the beginning of the response.
|
||||
*
|
||||
* In the following example, any queries received from any of the addresses
|
||||
* of the host itself will get responses preferring addresses on any of
|
||||
* the locally connected networks. Next most preferred are addresses on
|
||||
* the 192.168.1/24 network, and after that either the 192.168.2/24 or
|
||||
* 192.168.3/24 network with no preference shown between these two networks.
|
||||
* Queries received from a host on the 192.168.1/24 network will prefer
|
||||
* other addresses on that network to the 192.168.2/24 and 192.168.3/24
|
||||
* networks. Queries received from a host on the 192.168.4/24 or the
|
||||
* 192.168.5/24 network will only prefer other addresses on their
|
||||
* directly connected networks.
|
||||
*
|
||||
* sortlist {
|
||||
* {
|
||||
* localhost;
|
||||
* {
|
||||
* localnets;
|
||||
* 192.168.1/24;
|
||||
* { 192,168.2/24; 192.168.3/24; };
|
||||
* };
|
||||
* };
|
||||
* {
|
||||
* 192.168.1/24;
|
||||
* {
|
||||
* 192.168.1/24;
|
||||
* { 192.168.2/24; 192.168.3/24; };
|
||||
* };
|
||||
* };
|
||||
* {
|
||||
* 192.168.2/24;
|
||||
* {
|
||||
* 192.168.2/24;
|
||||
* { 192.168.1/24; 192.168.3/24; };
|
||||
* };
|
||||
* };
|
||||
* {
|
||||
* 192.168.3/24;
|
||||
* {
|
||||
* 192.168.3/24;
|
||||
* { 192.168.1/24; 192.168.2/24; };
|
||||
* };
|
||||
* };
|
||||
* {
|
||||
* { 192.168.4/24; 192.168.5/24; };
|
||||
* };
|
||||
* };
|
||||
*
|
||||
*
|
||||
* The following example will give reasonable behaviour for the local host
|
||||
* and hosts on directly connected networks. It is similar to the behavior
|
||||
* of the address sort in BIND 4.9.x. Responses sent to queries from the
|
||||
* local host will favor any of the directly connected networks. Responses
|
||||
* sent to queries from any other hosts on a directly connected network will
|
||||
* prefer addresses on that same network. Responses to other queries will
|
||||
* not be sorted.
|
||||
*
|
||||
* sortlist {
|
||||
* { localhost; localnets; };
|
||||
* { localnets; };
|
||||
* };
|
||||
*
|
||||
* XXX - it wouldb e nice to have an ACL called "source" that matched the
|
||||
* source address of a query so that a host could be configured to
|
||||
* automatically prefer itself, and an ACL called "sourcenet", that
|
||||
* would return the primitive IP match element that matched the source
|
||||
* address so that you could do:
|
||||
* { localnets; { sourcenet; { other stuff ...}; };
|
||||
* and automatically get similar behaviour to what you get with:
|
||||
* { localnets; };
|
||||
*
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/file.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <resolv.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
static int sort_rr(u_char *cp, u_char *eom, int ancount, ip_match_list iml);
|
||||
|
||||
static int ip_match_address_elt(ip_match_list, struct in_addr,
|
||||
ip_match_element *);
|
||||
|
||||
void
|
||||
sort_response(u_char *cp, u_char *eom, int ancount, struct sockaddr_in *from) {
|
||||
struct in_addr address;
|
||||
struct ip_match_element imelement;
|
||||
ip_match_element imetl, imematch, imeprimitive;
|
||||
struct ip_match_list imlist;
|
||||
ip_match_list iml;
|
||||
int indirect, matched;
|
||||
|
||||
if (server_options->sortlist == NULL)
|
||||
return;
|
||||
|
||||
if (from->sin_family != AF_INET)
|
||||
return;
|
||||
|
||||
address = from->sin_addr;
|
||||
|
||||
for (imetl = server_options->sortlist->first; imetl != NULL;
|
||||
imetl = imetl->next) {
|
||||
if (imetl->type == ip_match_indirect)
|
||||
imematch = imetl->u.indirect.list->first;
|
||||
else
|
||||
/*
|
||||
* allow a bare pattern as a top level statement
|
||||
* and treat it like {pattern;};
|
||||
*/
|
||||
imematch = imetl;
|
||||
|
||||
switch (imematch->type) {
|
||||
case ip_match_pattern:
|
||||
indirect = 0;
|
||||
break;
|
||||
case ip_match_indirect:
|
||||
indirect = 1;
|
||||
break;
|
||||
case ip_match_localhost:
|
||||
imematch->u.indirect.list = local_addresses;
|
||||
indirect = 1;
|
||||
break;
|
||||
case ip_match_localnets:
|
||||
imematch->u.indirect.list = local_networks;
|
||||
indirect = 1;
|
||||
break;
|
||||
default:
|
||||
indirect = 0;
|
||||
panic("unexpected ime type in ip_match_address()",
|
||||
NULL);
|
||||
}
|
||||
if (indirect) {
|
||||
imeprimitive = NULL;
|
||||
matched = ip_match_address_elt(imematch->u.indirect.list,
|
||||
address, &imeprimitive);
|
||||
if (matched >= 0) {
|
||||
if (imematch->flags & IP_MATCH_NEGATE)
|
||||
/* Don't sort */
|
||||
return;
|
||||
} else
|
||||
continue;
|
||||
} else {
|
||||
if (ina_onnet(address, imematch->u.direct.address,
|
||||
imematch->u.direct.mask)) {
|
||||
if (imematch->flags & IP_MATCH_NEGATE)
|
||||
/* Don't sort */
|
||||
return;
|
||||
else
|
||||
imeprimitive = imematch;
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
if (imetl != imematch && imematch->next != NULL) {
|
||||
/*
|
||||
* Not a bare pattern at the top level, but a two
|
||||
* element list
|
||||
*/
|
||||
switch (imematch->next->type) {
|
||||
case ip_match_pattern:
|
||||
case ip_match_localhost:
|
||||
case ip_match_localnets:
|
||||
imelement = *(imematch->next);
|
||||
imelement.next = NULL;
|
||||
iml = &imlist;
|
||||
iml->first = iml->last = &imelement;
|
||||
break;
|
||||
case ip_match_indirect:
|
||||
iml = imematch->next->u.indirect.list;
|
||||
break;
|
||||
default:
|
||||
iml = NULL;
|
||||
panic("unexpected ime type in ip_match_address()",
|
||||
NULL);
|
||||
}
|
||||
} else if (imeprimitive) {
|
||||
imelement = *imeprimitive;
|
||||
imelement.next = NULL;
|
||||
iml = &imlist;
|
||||
iml->first = iml->last = &imelement;
|
||||
} else {
|
||||
/* Don't sort because we'd just use "any" */
|
||||
return;
|
||||
}
|
||||
sort_rr(cp, eom, ancount, iml);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
sort_rr(u_char *cp, u_char *eom, int ancount, ip_match_list iml) {
|
||||
int type, class, dlen, n, c, distance, closest = 0;
|
||||
struct in_addr inaddr;
|
||||
u_char *rr1 = NULL, *rrbest = NULL, *cpstart;
|
||||
|
||||
rr1 = NULL;
|
||||
cpstart = cp;
|
||||
for (c = ancount; c > 0; --c) {
|
||||
n = dn_skipname(cp, eom);
|
||||
if (n < 0)
|
||||
return (1); /* bogus, stop processing */
|
||||
cp += n;
|
||||
if (cp + QFIXEDSZ > eom)
|
||||
return (1);
|
||||
GETSHORT(type, cp);
|
||||
GETSHORT(class, cp);
|
||||
cp += INT32SZ;
|
||||
GETSHORT(dlen, cp);
|
||||
if (dlen > eom - cp)
|
||||
return (1); /* bogus, stop processing */
|
||||
switch (type) {
|
||||
case T_A:
|
||||
switch (class) {
|
||||
case C_IN:
|
||||
case C_HS:
|
||||
memcpy((char *)&inaddr, cp, INADDRSZ);
|
||||
/* Find the address with the minimum distance */
|
||||
if (rr1 == NULL) {
|
||||
rr1 = cp;
|
||||
rrbest = cp;
|
||||
closest = distance_of_address(iml, inaddr);
|
||||
} else {
|
||||
distance = distance_of_address(iml, inaddr);
|
||||
if (distance < closest) {
|
||||
rrbest = cp;
|
||||
closest = distance;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
cp += dlen;
|
||||
}
|
||||
if (rr1 != rrbest && rr1 != NULL) {
|
||||
memcpy((char *)&inaddr, rrbest, INADDRSZ);
|
||||
memcpy(rrbest, rr1, INADDRSZ);
|
||||
memcpy(rr1, (char *)&inaddr, INADDRSZ);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Just like ip_match_address(), but also returns a pointer to the primitive
|
||||
* element that matched.
|
||||
*/
|
||||
|
||||
static int
|
||||
ip_match_address_elt(ip_match_list iml, struct in_addr address,
|
||||
ip_match_element *imep) {
|
||||
ip_match_element ime;
|
||||
int ret;
|
||||
int indirect;
|
||||
|
||||
INSIST(iml != NULL);
|
||||
for (ime = iml->first; ime != NULL; ime = ime->next) {
|
||||
switch (ime->type) {
|
||||
case ip_match_pattern:
|
||||
indirect = 0;
|
||||
break;
|
||||
case ip_match_indirect:
|
||||
indirect = 1;
|
||||
break;
|
||||
case ip_match_localhost:
|
||||
ime->u.indirect.list = local_addresses;
|
||||
indirect = 1;
|
||||
break;
|
||||
case ip_match_localnets:
|
||||
ime->u.indirect.list = local_networks;
|
||||
indirect = 1;
|
||||
break;
|
||||
default:
|
||||
indirect = 0;
|
||||
panic("unexpected ime type in ip_match_address()",
|
||||
NULL);
|
||||
}
|
||||
if (indirect) {
|
||||
ret = ip_match_address_elt(ime->u.indirect.list,
|
||||
address, imep);
|
||||
if (ret >= 0) {
|
||||
if (ime->flags & IP_MATCH_NEGATE)
|
||||
ret = (ret) ? 0 : 1;
|
||||
return (ret);
|
||||
}
|
||||
} else {
|
||||
if (ina_onnet(address, ime->u.direct.address,
|
||||
ime->u.direct.mask)) {
|
||||
*imep = ime;
|
||||
if (ime->flags & IP_MATCH_NEGATE)
|
||||
return (0);
|
||||
else
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
@@ -1,452 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)ns_stats.c 4.10 (Berkeley) 6/27/90";
|
||||
static const char rcsid[] = "$Id: ns_stats.c,v 8.34 2001/08/09 13:17:21 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
#include <isc/tree.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#ifdef HAVE_GETRUSAGE /* XXX */
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#include "named.h"
|
||||
|
||||
static u_long typestats[T_ANY+1];
|
||||
static void nameserStats(FILE *);
|
||||
static u_int32_t ns_stats_cnt = 0;
|
||||
static int ns_stats_disabled = 0;
|
||||
|
||||
void
|
||||
ns_stats_dumpandclear() {
|
||||
time_t timenow = time(NULL);
|
||||
FILE *f;
|
||||
|
||||
ns_stats();
|
||||
if (!(f = fopen(server_options->stats_filename, "a"))) {
|
||||
ns_notice(ns_log_statistics, "cannot open stat file, \"%s\"",
|
||||
server_options->stats_filename);
|
||||
}
|
||||
if (f != NULL) {
|
||||
(void) fchown(fileno(f), user_id, group_id);
|
||||
fprintf(f, "+++ Host Statistics Cleared +++ (%ld) %s",
|
||||
(long)timenow, checked_ctime(&timenow));
|
||||
(void) my_fclose(f);
|
||||
}
|
||||
ns_freestats();
|
||||
}
|
||||
|
||||
void
|
||||
ns_stats() {
|
||||
time_t timenow = time(NULL);
|
||||
FILE *f;
|
||||
int i;
|
||||
|
||||
ns_notice(ns_log_statistics, "dumping nameserver stats");
|
||||
|
||||
if (!(f = fopen(server_options->stats_filename, "a"))) {
|
||||
ns_notice(ns_log_statistics, "cannot open stat file, \"%s\"",
|
||||
server_options->stats_filename);
|
||||
return;
|
||||
}
|
||||
(void) fchown(fileno(f), user_id, group_id);
|
||||
|
||||
fprintf(f, "+++ Statistics Dump +++ (%ld) %s",
|
||||
(long)timenow, checked_ctime(&timenow));
|
||||
fprintf(f, "%ld\ttime since boot (secs)\n",
|
||||
(long)(timenow - boottime));
|
||||
fprintf(f, "%ld\ttime since reset (secs)\n",
|
||||
(long)(timenow - resettime));
|
||||
|
||||
/* query type statistics */
|
||||
fprintf(f, "%lu\tUnknown query types\n", (u_long)typestats[0]);
|
||||
for (i = 1; i < T_ANY+1; i++)
|
||||
fprintf(f, "%lu\t%s queries\n", typestats[i], p_type(i));
|
||||
|
||||
/* name server statistics */
|
||||
nameserStats(f);
|
||||
|
||||
fprintf(f, "--- Statistics Dump --- (%ld) %s",
|
||||
(long)timenow, checked_ctime(&timenow));
|
||||
(void) my_fclose(f);
|
||||
|
||||
/* Now do the memory statistics file */
|
||||
if (!(f = fopen(server_options->memstats_filename, "a"))) {
|
||||
ns_notice(ns_log_statistics, "cannot open memstat file, \"%s\"",
|
||||
server_options->memstats_filename);
|
||||
return;
|
||||
}
|
||||
(void) fchown(fileno(f), user_id, group_id);
|
||||
|
||||
fprintf(f, "+++ Memory Statistics Dump +++ (%ld) %s",
|
||||
(long)timenow, checked_ctime(&timenow));
|
||||
|
||||
fprintf(f, "%ld\ttime since boot (secs)\n",
|
||||
(long)(timenow - boottime));
|
||||
fprintf(f, "%ld\ttime since reset (secs)\n",
|
||||
(long)(timenow - resettime));
|
||||
|
||||
fprintf(f, "++ Memory Statistics ++\n");
|
||||
memstats(f);
|
||||
fprintf(f, "-- Memory Statistics --\n");
|
||||
|
||||
fprintf(f, "--- Memory Statistics Dump --- (%ld) %s",
|
||||
(long)timenow, checked_ctime(&timenow));
|
||||
(void) my_fclose(f);
|
||||
|
||||
ns_notice(ns_log_statistics, "done dumping nameserver stats");
|
||||
}
|
||||
|
||||
void
|
||||
qtypeIncr(qtype)
|
||||
int qtype;
|
||||
{
|
||||
if (qtype < T_A || qtype > T_ANY)
|
||||
qtype = 0; /* bad type */
|
||||
typestats[qtype]++;
|
||||
}
|
||||
|
||||
static tree *nameserTree;
|
||||
static int nameserInit;
|
||||
|
||||
static FILE *nameserStatsFile;
|
||||
static const char *statNames[nssLast] = {
|
||||
"RR", /* sent us an answer */
|
||||
"RNXD", /* sent us a negative response */
|
||||
"RFwdR", /* sent us a response we had to fwd */
|
||||
"RDupR", /* sent us an extra answer */
|
||||
"RFail", /* sent us a SERVFAIL */
|
||||
"RFErr", /* sent us a FORMERR */
|
||||
"RErr", /* sent us some other error */
|
||||
"RAXFR", /* sent us an AXFR */
|
||||
"RLame", /* sent us a lame delegation */
|
||||
"ROpts", /* sent us some IP options */
|
||||
"SSysQ", /* sent them a sysquery */
|
||||
"SAns", /* sent them an answer */
|
||||
"SFwdQ", /* fwdd a query to them */
|
||||
"SDupQ", /* sent them a retry */
|
||||
"SErr", /* sent failed (in sendto) */
|
||||
"RQ", /* sent us a query */
|
||||
"RIQ", /* sent us an inverse query */
|
||||
"RFwdQ", /* sent us a query we had to fwd */
|
||||
"RDupQ", /* sent us a retry */
|
||||
"RTCP", /* sent us a query using TCP */
|
||||
"SFwdR", /* fwdd a response to them */
|
||||
"SFail", /* sent them a SERVFAIL */
|
||||
"SFErr", /* sent them a FORMERR */
|
||||
"SNaAns", /* sent them a non autoritative answer */
|
||||
"SNXD", /* sent them a negative response */
|
||||
"RUQ", /* sent us an unapproved query */
|
||||
"RURQ", /* sent us an unapproved recursive query */
|
||||
"RUXFR", /* sent us an unapproved AXFR or IXFR */
|
||||
"RUUpd", /* sent us an unapproved update */
|
||||
};
|
||||
|
||||
/*
|
||||
* Note that addresses in network byte order always have the high byte first.
|
||||
* XXX - this is horribly IPv4 dependent, but it's performance critical.
|
||||
*/
|
||||
static int
|
||||
nameserCompar(const tree_t t1, const tree_t t2) {
|
||||
u_char *p1 = (u_char *)t1, *p2 = (u_char *)t2;
|
||||
int i;
|
||||
|
||||
for (i = INADDRSZ; i > 0; i--) {
|
||||
u_char c1 = *p1++, c2 = *p2++;
|
||||
|
||||
if (c1 < c2)
|
||||
return (-1);
|
||||
if (c1 > c2)
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct nameser *
|
||||
nameserFind(addr, flags)
|
||||
struct in_addr addr;
|
||||
int flags;
|
||||
{
|
||||
struct nameser dummy;
|
||||
struct nameser *ns;
|
||||
|
||||
if (!nameserInit) {
|
||||
tree_init(&nameserTree);
|
||||
nameserInit++;
|
||||
ns_stats_cnt = 0;
|
||||
ns_stats_disabled = 0;
|
||||
}
|
||||
|
||||
dummy.addr = addr;
|
||||
ns = (struct nameser *)tree_srch(&nameserTree, nameserCompar,
|
||||
(tree_t)&dummy);
|
||||
if (ns == NULL && (flags & NS_F_INSERT) != 0) {
|
||||
if (server_options->max_host_stats != 0 &&
|
||||
ns_stats_cnt > server_options->max_host_stats) {
|
||||
if (!ns_stats_disabled)
|
||||
ns_notice(ns_log_statistics,
|
||||
"ns_stats_disabled: %s reached",
|
||||
"host-statistics-max");
|
||||
ns_stats_disabled = 1;
|
||||
return (NULL);
|
||||
}
|
||||
ns = (struct nameser *)memget(sizeof(struct nameser));
|
||||
if (ns == NULL) {
|
||||
nomem: if (!haveComplained((u_long)nameserFind, 0))
|
||||
ns_notice(ns_log_statistics,
|
||||
"nameserFind: memget failed; %s",
|
||||
strerror(errno));
|
||||
return (NULL);
|
||||
}
|
||||
memset(ns, 0, sizeof *ns);
|
||||
ns->addr = addr;
|
||||
if (!tree_add(&nameserTree, nameserCompar, (tree_t)ns, NULL)) {
|
||||
int save = errno;
|
||||
memput(ns, sizeof *ns);
|
||||
errno = save;
|
||||
goto nomem;
|
||||
}
|
||||
ns_stats_cnt++;
|
||||
}
|
||||
return (ns);
|
||||
}
|
||||
|
||||
static void
|
||||
nameserStatsOut(f, stats)
|
||||
FILE *f;
|
||||
u_long stats[];
|
||||
{
|
||||
int i;
|
||||
const char *pre = "\t";
|
||||
|
||||
for (i = 0; i < (int)nssLast; i++) {
|
||||
fprintf(f, "%s%lu", pre, (u_long)stats[i]);
|
||||
pre = ((i+1) % 5) ? " " : " ";
|
||||
}
|
||||
fputc('\n', f);
|
||||
}
|
||||
|
||||
static void
|
||||
nameserStatsHdr(f)
|
||||
FILE *f;
|
||||
{
|
||||
int i;
|
||||
const char *pre = "\t";
|
||||
|
||||
fprintf(f, "(Legend)\n");
|
||||
for (i = 0; i < (int)nssLast; i++) {
|
||||
fprintf(f, "%s%s", pre,
|
||||
statNames[i] ? statNames[i] : "");
|
||||
pre = ((i+1) % 5) ? "\t" : "\n\t";
|
||||
}
|
||||
fputc('\n', f);
|
||||
}
|
||||
|
||||
static int
|
||||
nameserStatsTravUAR(t)
|
||||
tree_t t;
|
||||
{
|
||||
struct nameser *ns = (struct nameser *)t;
|
||||
|
||||
fprintf(nameserStatsFile, "[%s]\n", /* : rtt %u */
|
||||
inet_ntoa(ns->addr) /*, ns->rtt*/ );
|
||||
nameserStatsOut(nameserStatsFile, ns->stats);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
nameserStats(f)
|
||||
FILE *f;
|
||||
{
|
||||
nameserStatsFile = f;
|
||||
fprintf(f, "++ Name Server Statistics ++\n");
|
||||
nameserStatsHdr(f);
|
||||
fprintf(f, "(Global)\n");
|
||||
nameserStatsOut(f, globalStats);
|
||||
if (NS_OPTION_P(OPTION_HOSTSTATS)) {
|
||||
tree_trav(&nameserTree, nameserStatsTravUAR);
|
||||
if (ns_stats_disabled)
|
||||
fprintf(f, "++ Host Statistics Incomplete ++\n");
|
||||
}
|
||||
fprintf(f, "-- Name Server Statistics --\n");
|
||||
nameserStatsFile = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ns_logstats(evContext ctx, void *uap, struct timespec due,
|
||||
struct timespec inter)
|
||||
{
|
||||
char buffer[1024];
|
||||
char buffer2[32], header[128];
|
||||
time_t timenow = time(NULL);
|
||||
int i;
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
struct rusage usage, childu;
|
||||
#endif /*HAVE_GETRUSAGE*/
|
||||
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
# define tv_float(tv) ((tv).tv_sec + ((tv).tv_usec / 1000000.0))
|
||||
|
||||
UNUSED(ctx);
|
||||
UNUSED(uap);
|
||||
UNUSED(due);
|
||||
UNUSED(inter);
|
||||
|
||||
getrusage(RUSAGE_SELF, &usage);
|
||||
getrusage(RUSAGE_CHILDREN, &childu);
|
||||
|
||||
/*
|
||||
* Get around a stupid compiler bug in gcc on solaris.
|
||||
* There is a problem if three or more doubles are passed to
|
||||
* sprintf.
|
||||
* <http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=337&database=gcc>
|
||||
*/
|
||||
sprintf(buffer, "CPU=%gu/%gs CHILDCPU=", tv_float(usage.ru_utime),
|
||||
tv_float(usage.ru_stime));
|
||||
sprintf(header, "%gu/%gs", tv_float(childu.ru_utime),
|
||||
tv_float(childu.ru_stime));
|
||||
ns_info(ns_log_statistics, "USAGE %lu %lu %s%s", (u_long)timenow,
|
||||
(u_long)boottime, buffer, header);
|
||||
# undef tv_float
|
||||
#endif /*HAVE_GETRUSAGE*/
|
||||
|
||||
sprintf(header, "NSTATS %lu %lu", (u_long)timenow, (u_long)boottime);
|
||||
strcpy(buffer, header);
|
||||
|
||||
for (i = 0; i < T_ANY+1; i++) {
|
||||
if (typestats[i]) {
|
||||
sprintf(buffer2, " %s=%lu", p_type(i), typestats[i]);
|
||||
if (strlen(buffer) + strlen(buffer2) >
|
||||
sizeof(buffer) - 1) {
|
||||
ns_info(ns_log_statistics, "%s", buffer);
|
||||
strcpy(buffer, header);
|
||||
}
|
||||
strcat(buffer, buffer2);
|
||||
}
|
||||
}
|
||||
ns_info(ns_log_statistics, "%s", buffer);
|
||||
|
||||
sprintf(header, "XSTATS %lu %lu", (u_long)timenow, (u_long)boottime);
|
||||
strcpy(buffer, header);
|
||||
for (i = 0; i < (int)nssLast; i++) {
|
||||
sprintf(buffer2, " %s=%lu",
|
||||
statNames[i]?statNames[i]:"?", (u_long)globalStats[i]);
|
||||
if (strlen(buffer) + strlen(buffer2) > sizeof(buffer) - 1) {
|
||||
ns_info(ns_log_statistics, "%s", buffer);
|
||||
strcpy(buffer, header);
|
||||
}
|
||||
strcat(buffer, buffer2);
|
||||
}
|
||||
ns_info(ns_log_statistics, "%s", buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
nameserFree(void *uap) {
|
||||
struct nameser *ns = uap;
|
||||
|
||||
memput(ns, sizeof *ns);
|
||||
}
|
||||
|
||||
void
|
||||
ns_freestats(void) {
|
||||
if (nameserTree == NULL)
|
||||
return;
|
||||
tree_mung(&nameserTree, nameserFree);
|
||||
nameserInit = 0;
|
||||
ns_stats_cnt = 0;
|
||||
ns_stats_disabled = 0;
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_udp.c,v 8.9 2000/04/21 06:54:13 vixie Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <nlist.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
void
|
||||
ns_udp() {
|
||||
#if defined(CHECK_UDP_SUM) || defined(FIX_UDP_SUM)
|
||||
struct nlist nl[2];
|
||||
int fd;
|
||||
int sum;
|
||||
u_long res, offset;
|
||||
|
||||
nl[0].n_name = UDPSUM;
|
||||
nl[1].n_name = 0;
|
||||
|
||||
if (nlist(KSYMS, nl)) {
|
||||
ns_debug(ns_log_default, 1, "ns_udp: nlist (%s,%s) failed",
|
||||
KSYMS, UDPSUM);
|
||||
return;
|
||||
}
|
||||
|
||||
ns_debug(ns_log_default, 1, "ns_udp: %s %d %lu (%ld)",
|
||||
nl[0].n_name, nl[0].n_type, nl[0].n_value, nl[0].n_value);
|
||||
|
||||
if (!nl[0].n_type)
|
||||
return;
|
||||
|
||||
if ((fd = open(KMEM, O_RDWR, 0)) < 0) {
|
||||
ns_debug(ns_log_default, 1, "ns_udp: open %s failed: %s", KMEM,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
offset = nl[0].n_value;
|
||||
#ifdef KMAP
|
||||
offset &= ((~0UL)>>1);
|
||||
#endif
|
||||
|
||||
res = lseek(fd, offset, SEEK_SET);
|
||||
if (res != offset) {
|
||||
ns_debug(ns_log_default, 1, "ns_udp: lseek %lu failed %lu: %s",
|
||||
offset, res, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (read(fd, &sum, sizeof(sum)) != sizeof(sum)) {
|
||||
ns_debug(ns_log_default, 1, "ns_udp: read failed: %s",
|
||||
strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ns_debug(ns_log_default, 1, "ns_udp: %d", sum);
|
||||
if (sum == 0) {
|
||||
#ifdef FIX_UDP_SUM
|
||||
sum = 1;
|
||||
lseek(fd, offset, SEEK_SET);
|
||||
if (res != offset) {
|
||||
ns_debug(ns_log_default, 1,
|
||||
"ns_udp: lseek %lu failed %lu: %s",
|
||||
offset, res, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
if (write(fd, &sum, sizeof(sum)) != sizeof(sum)) {
|
||||
ns_debug(ns_log_default, 1, "ns_udp: write failed: %s",
|
||||
strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
ns_warning(ns_log_default, "ns_udp: check sums turned on");
|
||||
#else
|
||||
ns_panic(ns_log_default, 0,
|
||||
"ns_udp: checksums NOT turned on, exiting");
|
||||
#endif
|
||||
}
|
||||
cleanup:
|
||||
close(fd);
|
||||
#endif
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,871 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_xfr.c,v 8.69 2002/06/05 03:53:49 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <resolv.h>
|
||||
#include <res_update.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include <isc/dst.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
static struct qs_x_lev *sx_freelev(struct qs_x_lev *lev);
|
||||
|
||||
static int sx_flush(struct qstream *qsp),
|
||||
sx_addrr(struct qstream *qsp,
|
||||
const char *dname,
|
||||
struct databuf *dp),
|
||||
sx_nsrrs(struct qstream *qsp),
|
||||
sx_allrrs(struct qstream *qsp),
|
||||
sx_pushlev(struct qstream *qsp, struct namebuf *np);
|
||||
static struct databuf *db_next(struct databuf *dp);
|
||||
|
||||
/*
|
||||
* void
|
||||
* ns_xfr(qsp, znp, zone, class, type, opcode, id, serial_ixfr, in_tsig)
|
||||
* Initiate a concurrent (event driven) outgoing zone transfer.
|
||||
*/
|
||||
void
|
||||
ns_xfr(struct qstream *qsp, struct namebuf *znp,
|
||||
int zone, int class, int type,
|
||||
int opcode, int id, u_int32_t serial_ixfr, struct tsig_record *in_tsig)
|
||||
{
|
||||
server_info si;
|
||||
#ifdef SO_SNDBUF
|
||||
static const int sndbuf = XFER_BUFSIZE * 2;
|
||||
#endif
|
||||
#ifdef SO_SNDLOWAT
|
||||
static const int sndlowat = XFER_BUFSIZE;
|
||||
#endif
|
||||
ns_deltalist *changes;
|
||||
|
||||
switch (type) {
|
||||
case ns_t_ixfr:
|
||||
ns_info(ns_log_xfer_out,
|
||||
"zone transfer (%s) of \"%s\" (%s) to %s serial %u -> %u",
|
||||
p_type(type), zones[zone].z_origin, p_class(class),
|
||||
sin_ntoa(qsp->s_from), serial_ixfr,
|
||||
zones[zone].z_serial);
|
||||
break;
|
||||
case ns_t_axfr: /*FALLTHROUGH*/
|
||||
#ifdef BIND_ZXFR
|
||||
case ns_t_zxfr:
|
||||
#endif
|
||||
ns_info(ns_log_xfer_out,
|
||||
"zone transfer (%s) of \"%s\" (%s) to %s serial %u",
|
||||
p_type(type), zones[zone].z_origin, p_class(class),
|
||||
sin_ntoa(qsp->s_from), zones[zone].z_serial);
|
||||
break;
|
||||
default:
|
||||
ns_warning(ns_log_xfer_out,
|
||||
"unsupported XFR (type %s) of \"%s\" (%s) to %s",
|
||||
p_type(type), zones[zone].z_origin, p_class(class),
|
||||
sin_ntoa(qsp->s_from));
|
||||
goto abort;
|
||||
}
|
||||
|
||||
#ifdef SO_SNDBUF
|
||||
/*
|
||||
* The default seems to be 4K, and we'd like it to have enough room
|
||||
* to parallelize sending the pushed data with accumulating more
|
||||
* write() data from us.
|
||||
*/
|
||||
(void) setsockopt(qsp->s_rfd, SOL_SOCKET, SO_SNDBUF,
|
||||
(const char *)&sndbuf, sizeof sndbuf);
|
||||
#endif
|
||||
#ifdef SO_SNDLOWAT
|
||||
/*
|
||||
* We don't want select() to show writability 'til we can write
|
||||
* an XFER_BUFSIZE block of data.
|
||||
*/
|
||||
(void) setsockopt(qsp->s_rfd, SOL_SOCKET, SO_SNDLOWAT,
|
||||
(const char *)&sndlowat, sizeof sndlowat);
|
||||
#endif
|
||||
if (sq_openw(qsp, 64*1024) == -1) {
|
||||
ns_error(ns_log_xfer_out, "ns_xfr: out of memory");
|
||||
goto abort;
|
||||
}
|
||||
memset(&qsp->xfr, 0, sizeof qsp->xfr);
|
||||
qsp->xfr.top.axfr = znp;
|
||||
qsp->xfr.zone = zone;
|
||||
qsp->xfr.class = class;
|
||||
if (qsp->flags & STREAM_AXFRIXFR)
|
||||
type = ns_t_axfr;
|
||||
qsp->xfr.type = type;
|
||||
qsp->xfr.id = id;
|
||||
qsp->xfr.opcode = opcode;
|
||||
qsp->xfr.msg = memget(XFER_BUFSIZE);
|
||||
if (!qsp->xfr.msg) {
|
||||
ns_error(ns_log_xfer_out, "ns_xfr: out of memory");
|
||||
goto abort;
|
||||
}
|
||||
qsp->xfr.eom = qsp->xfr.msg + XFER_BUFSIZE;
|
||||
qsp->xfr.cp = NULL;
|
||||
qsp->xfr.state = s_x_firstsoa;
|
||||
zones[zone].z_numxfrs++;
|
||||
qsp->flags |= STREAM_AXFR;
|
||||
|
||||
#ifdef BIND_ZXFR
|
||||
if (type == ns_t_zxfr) {
|
||||
enum { rd = 0, wr = 1 };
|
||||
int z[2];
|
||||
pid_t p;
|
||||
|
||||
if (pipe(z) < 0) {
|
||||
ns_error(ns_log_xfer_out, "pipe: %s", strerror(errno));
|
||||
goto abort;
|
||||
}
|
||||
p = vfork();
|
||||
if (p < 0) {
|
||||
ns_error(ns_log_xfer_out, "vfork: %s", strerror(errno));
|
||||
goto abort;
|
||||
}
|
||||
if (p == 0) {
|
||||
/* Child. */
|
||||
dup2(z[rd], STDIN_FILENO);
|
||||
dup2(qsp->s_rfd, STDOUT_FILENO);
|
||||
execlp("gzip", "gzip", NULL);
|
||||
ns_error(ns_log_xfer_out, "execlp: %s", strerror(errno));
|
||||
_exit(1);
|
||||
}
|
||||
ns_info(ns_log_xfer_out, "zxfr gzip pid %lu", p);
|
||||
/* Parent. */
|
||||
dup2(z[wr], qsp->s_rfd);
|
||||
close(z[wr]);
|
||||
close(z[rd]);
|
||||
|
||||
/* When a ZXFR completes, there can be no more requests. */
|
||||
qsp->flags |= STREAM_DONE_CLOSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
si = find_server(qsp->s_from.sin_addr);
|
||||
if (si != NULL && si->transfer_format != axfr_use_default)
|
||||
qsp->xfr.transfer_format = si->transfer_format;
|
||||
else
|
||||
qsp->xfr.transfer_format = server_options->transfer_format;
|
||||
if (in_tsig == NULL) {
|
||||
qsp->xfr.tsig_state = NULL;
|
||||
qsp->xfr.tsig_size = 0;
|
||||
} else {
|
||||
qsp->xfr.tsig_state = memget(sizeof(ns_tcp_tsig_state));
|
||||
ns_sign_tcp_init(in_tsig->key, in_tsig->sig, in_tsig->siglen,
|
||||
qsp->xfr.tsig_state);
|
||||
qsp->xfr.tsig_skip = 0;
|
||||
qsp->xfr.tsig_size = in_tsig->tsig_size;
|
||||
}
|
||||
|
||||
if (type == ns_t_ixfr) {
|
||||
changes = ixfr_get_change_list(&zones[zone], serial_ixfr,
|
||||
zones[zone].z_serial);
|
||||
ixfr_log_maint(&zones[zone]);
|
||||
if (changes != NULL) {
|
||||
qsp->xfr.serial = serial_ixfr;
|
||||
qsp->xfr.top.ixfr = changes;
|
||||
}
|
||||
else {
|
||||
qsp->xfr.top.ixfr = NULL;
|
||||
goto abort;
|
||||
}
|
||||
} else {
|
||||
if (sx_pushlev(qsp, znp) < 0) {
|
||||
ns_error(ns_log_xfer_out, "ns_xfr: out of memory");
|
||||
abort:
|
||||
(void) shutdown(qsp->s_rfd, 2);
|
||||
sq_remove(qsp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (type != ns_t_ixfr) {
|
||||
ns_debug(ns_log_default, 3, "sq_writeh sx_sendsoa (%s)",
|
||||
zones[zone].z_origin);
|
||||
(void) sq_writeh(qsp, sx_sendsoa);
|
||||
} else {
|
||||
ns_debug(ns_log_default, 3, "sq_writeh sx_send_ixfr (%s)",
|
||||
zones[zone].z_origin);
|
||||
(void) sq_writeh(qsp, sx_send_ixfr);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* void
|
||||
* ns_stopxfrs(zp)
|
||||
* Stop (abort, reset) all transfers of the zone specified by 'zp'.
|
||||
*/
|
||||
void
|
||||
ns_stopxfrs(struct zoneinfo *zp) {
|
||||
struct qstream *this, *next;
|
||||
u_int zone = (u_int)(zp - zones);
|
||||
|
||||
ns_debug(ns_log_default, 3, "ns_stopxfrs (%s)", zp->z_origin);
|
||||
|
||||
for (this = streamq; this; this = next) {
|
||||
next = this->s_next;
|
||||
if (this->xfr.zone == zone) {
|
||||
(void) shutdown(this->s_rfd, 2);
|
||||
sq_remove(this);
|
||||
}
|
||||
}
|
||||
INSIST(zp->z_numxfrs == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* void
|
||||
* ns_freexfr(qsp)
|
||||
* Free all xfr-related dynamic data associated with qsp.
|
||||
*/
|
||||
void
|
||||
ns_freexfr(struct qstream *qsp) {
|
||||
ns_delta *dp;
|
||||
ns_updrec *rp;
|
||||
|
||||
if (qsp->xfr.msg != NULL) {
|
||||
memput(qsp->xfr.msg, XFER_BUFSIZE);
|
||||
qsp->xfr.msg = NULL;
|
||||
}
|
||||
if (qsp->xfr.type == ns_t_ixfr && qsp->xfr.top.ixfr != NULL) {
|
||||
while ((dp = HEAD(*qsp->xfr.top.ixfr)) != NULL) {
|
||||
UNLINK(*qsp->xfr.top.ixfr, dp, d_link);
|
||||
while ((rp = HEAD(dp->d_changes)) != NULL) {
|
||||
UNLINK(dp->d_changes, rp, r_link);
|
||||
if (rp->r_dp != NULL)
|
||||
db_detach(&rp->r_dp);
|
||||
res_freeupdrec(rp);
|
||||
}
|
||||
memput(dp, sizeof *dp);
|
||||
}
|
||||
memput(qsp->xfr.top.ixfr, sizeof *qsp->xfr.top.ixfr);
|
||||
qsp->xfr.top.ixfr = NULL;
|
||||
}
|
||||
while (qsp->xfr.lev)
|
||||
qsp->xfr.lev = sx_freelev(qsp->xfr.lev);
|
||||
if (qsp->xfr.tsig_state != NULL) {
|
||||
memput(qsp->xfr.tsig_state, sizeof(ns_tcp_tsig_state));
|
||||
qsp->xfr.tsig_state = NULL;
|
||||
}
|
||||
zones[qsp->xfr.zone].z_numxfrs--;
|
||||
qsp->flags &= ~(STREAM_AXFR | STREAM_AXFRIXFR);
|
||||
}
|
||||
|
||||
/*
|
||||
* u_char *
|
||||
* sx_newmsg(msg)
|
||||
* init the header of a message, reset the compression pointers, and
|
||||
* reset the write pointer to the first byte following the header.
|
||||
*/
|
||||
void
|
||||
sx_newmsg(struct qstream *qsp) {
|
||||
HEADER *hp = (HEADER *)qsp->xfr.msg;
|
||||
|
||||
memset(hp, 0, HFIXEDSZ);
|
||||
hp->id = htons(qsp->xfr.id);
|
||||
hp->opcode = qsp->xfr.opcode;
|
||||
hp->qr = 1;
|
||||
hp->rcode = NOERROR;
|
||||
|
||||
qsp->xfr.ptrs[0] = qsp->xfr.msg;
|
||||
qsp->xfr.ptrs[1] = NULL;
|
||||
|
||||
qsp->xfr.cp = qsp->xfr.msg + HFIXEDSZ;
|
||||
|
||||
qsp->xfr.eom = qsp->xfr.msg + XFER_BUFSIZE;
|
||||
|
||||
if (qsp->xfr.tsig_state != NULL)
|
||||
qsp->xfr.eom -= TSIG_BUF_SIZE;
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_flush(qsp)
|
||||
* flush the intermediate buffer out to the stream IO system.
|
||||
* return:
|
||||
* passed through from sq_write().
|
||||
*/
|
||||
static int
|
||||
sx_flush(struct qstream *qsp) {
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug >= 10)
|
||||
res_pquery(&res, qsp->xfr.msg, qsp->xfr.cp - qsp->xfr.msg,
|
||||
log_get_stream(packet_channel));
|
||||
#endif
|
||||
if (qsp->xfr.tsig_state != NULL && qsp->xfr.tsig_skip == 0) {
|
||||
int msglen = qsp->xfr.cp - qsp->xfr.msg;
|
||||
|
||||
ns_sign_tcp(qsp->xfr.msg, &msglen, qsp->xfr.eom - qsp->xfr.msg,
|
||||
NOERROR, qsp->xfr.tsig_state,
|
||||
qsp->xfr.state == s_x_done);
|
||||
|
||||
if (qsp->xfr.state == s_x_done) {
|
||||
memput(qsp->xfr.tsig_state, sizeof(ns_tcp_tsig_state));
|
||||
qsp->xfr.tsig_state = NULL;
|
||||
}
|
||||
qsp->xfr.cp = qsp->xfr.msg + msglen;
|
||||
|
||||
}
|
||||
ret = sq_write(qsp, qsp->xfr.msg, qsp->xfr.cp - qsp->xfr.msg);
|
||||
if (ret >= 0) {
|
||||
qsp->xfr.cp = NULL;
|
||||
qsp->xfr.tsig_skip = 0;
|
||||
}
|
||||
else
|
||||
qsp->xfr.tsig_skip = 1;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_addrr(qsp, name, dp)
|
||||
* add name/dp's RR to the current assembly message. if it won't fit,
|
||||
* write current message out, renew the message, and then RR *must* fit.
|
||||
* return:
|
||||
* -1 = the sx_flush() failed so we could not queue the full message.
|
||||
* 0 = one way or another, everything is fine.
|
||||
* side effects:
|
||||
* on success, the ANCOUNT is incremented and the pointers are advanced.
|
||||
*/
|
||||
static int
|
||||
sx_addrr(struct qstream *qsp, const char *dname, struct databuf *dp) {
|
||||
HEADER *hp = (HEADER *)qsp->xfr.msg;
|
||||
u_char **edp = qsp->xfr.ptrs + sizeof qsp->xfr.ptrs / sizeof(u_char*);
|
||||
int n, type;
|
||||
|
||||
if (qsp->xfr.cp != NULL) {
|
||||
if (qsp->xfr.transfer_format == axfr_one_answer &&
|
||||
sx_flush(qsp) < 0)
|
||||
return (-1);
|
||||
}
|
||||
if (qsp->xfr.cp == NULL)
|
||||
sx_newmsg(qsp);
|
||||
|
||||
/*
|
||||
* Add question to first answer.
|
||||
*/
|
||||
if (qsp->xfr.state == s_x_firstsoa && dp->d_type == T_SOA) {
|
||||
n = dn_comp(dname, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp,
|
||||
qsp->xfr.ptrs, edp);
|
||||
if (n > 0 && (qsp->xfr.cp + n + INT16SZ * 2) <= qsp->xfr.eom) {
|
||||
qsp->xfr.cp += n;
|
||||
if (qsp->xfr.type == ns_t_zxfr)
|
||||
type = ns_t_axfr;
|
||||
else if ((qsp->flags & STREAM_AXFRIXFR) != 0)
|
||||
type = ns_t_ixfr;
|
||||
else
|
||||
type = qsp->xfr.type;
|
||||
PUTSHORT((u_int16_t) type, qsp->xfr.cp);
|
||||
PUTSHORT((u_int16_t) qsp->xfr.class, qsp->xfr.cp);
|
||||
hp->qdcount = htons(ntohs(hp->qdcount) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp -
|
||||
qsp->xfr.tsig_size, 0, qsp->xfr.ptrs, edp, 0);
|
||||
if (n < 0) {
|
||||
if (sx_flush(qsp) < 0)
|
||||
return (-1);
|
||||
if (qsp->xfr.cp == NULL)
|
||||
sx_newmsg(qsp);
|
||||
n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom -
|
||||
qsp->xfr.cp - qsp->xfr.tsig_size,
|
||||
0, qsp->xfr.ptrs, edp, 0);
|
||||
INSIST(n >= 0);
|
||||
}
|
||||
hp->ancount = htons(ntohs(hp->ancount) + 1);
|
||||
qsp->xfr.cp += n;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_soarr(qsp)
|
||||
* add the SOA RR's at the current level's top np to the assembly message.
|
||||
* return:
|
||||
* 0 = success
|
||||
* -1 = write buffer full, cannot continue at this time
|
||||
* side effects:
|
||||
* if progress was made, header and pointers will be advanced.
|
||||
*/
|
||||
static int
|
||||
sx_soarr(struct qstream *qsp) {
|
||||
struct databuf *dp;
|
||||
int added_soa = 0;
|
||||
|
||||
foreach_rr(dp, qsp->xfr.top.axfr, T_SOA, qsp->xfr.class,
|
||||
qsp->xfr.zone) {
|
||||
if (sx_addrr(qsp, zones[qsp->xfr.zone].z_origin, dp) < 0) {
|
||||
/* RR wouldn't fit. Bail out. */
|
||||
return (-1);
|
||||
}
|
||||
added_soa = 1;
|
||||
break;
|
||||
}
|
||||
if (added_soa == 0)
|
||||
ns_panic(ns_log_xfer_out, 1, "no SOA at zone top");
|
||||
if (qsp->xfr.state == s_x_firstsoa) {
|
||||
foreach_rr(dp, qsp->xfr.top.axfr, T_SIG, qsp->xfr.class,
|
||||
qsp->xfr.zone)
|
||||
{
|
||||
if (SIG_COVERS(dp) != T_SOA)
|
||||
continue;
|
||||
if (sx_addrr(qsp, zones[qsp->xfr.zone].z_origin, dp) <
|
||||
0)
|
||||
{
|
||||
/* RR wouldn't fit. Bail out. */
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_nsrrs(qsp)
|
||||
* add the NS RR's at the current level's current np to the assembly msg.
|
||||
* This function also adds the SIG(NS), KEY, SIG(KEY), NXT, SIG(NXT),
|
||||
* since these records are also part of the delegation (see DNSSEC).
|
||||
* return:
|
||||
* >1 = number of NS RRs added, note that there may be more
|
||||
* 0 = success, there are no more NS RRs at this level
|
||||
* -1 = write buffer full, cannot continue at this time
|
||||
* side effects:
|
||||
* if progress was made, header and pointers will be advanced.
|
||||
* note:
|
||||
* this is meant for AXFR, which includes glue as part of the answer
|
||||
* sections. this is different from and incompatible with the additional
|
||||
* data of a referral response.
|
||||
*/
|
||||
static int
|
||||
sx_nsrrs(struct qstream *qsp) {
|
||||
struct databuf *dp, *tdp, *gdp;
|
||||
struct namebuf *gnp, *tnp, *top;
|
||||
struct hashbuf *htp;
|
||||
const char *fname;
|
||||
int class;
|
||||
|
||||
class = qsp->xfr.class;
|
||||
top = qsp->xfr.top.axfr;
|
||||
for ((void)NULL;
|
||||
(dp = qsp->xfr.lev->dp) != NULL;
|
||||
qsp->xfr.lev->dp = db_next(dp)) {
|
||||
if (dp->d_class != class && class != C_ANY)
|
||||
continue;
|
||||
if (dp->d_rcode)
|
||||
continue;
|
||||
/*
|
||||
* It might not be in the same zone, if we are authoritative
|
||||
* for both parent and child, but it does have to be a zone.
|
||||
*
|
||||
* XXX: this is sort of a bug, since it means we merge the
|
||||
* @ NS RRset into our parent's zone. But that is what
|
||||
* db_load() does, so for now we have no choice.
|
||||
*/
|
||||
if (dp->d_zone == DB_Z_CACHE)
|
||||
continue;
|
||||
|
||||
if (dp->d_type != T_NS && dp->d_type != T_KEY &&
|
||||
dp->d_type != T_NXT && dp->d_type != T_SIG)
|
||||
continue;
|
||||
if (dp->d_type == T_SIG && ((SIG_COVERS(dp) != T_NS) &&
|
||||
(SIG_COVERS(dp) != T_KEY) && (SIG_COVERS(dp) != T_NXT)))
|
||||
continue;
|
||||
if (!(qsp->xfr.lev->flags & SXL_GLUING)) {
|
||||
if (sx_addrr(qsp, qsp->xfr.lev->dname, dp) < 0) {
|
||||
/* RR wouldn't fit. Bail out. */
|
||||
return (-1);
|
||||
}
|
||||
if (dp->d_type != T_NS) /* no glue processing */
|
||||
continue;
|
||||
/* Remember we have found a zone cut */
|
||||
if (qsp->xfr.top.axfr != qsp->xfr.lev->np)
|
||||
qsp->xfr.lev->flags |= SXL_ZONECUT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Glue the sub domains together by sending the address
|
||||
* records for the sub domain name servers along if necessary.
|
||||
* Glue is necessary if the server is in any zone delegated
|
||||
* from the current (top) zone. Such a delegated zone might
|
||||
* or might not be that referred to by the NS record now
|
||||
* being handled.
|
||||
*/
|
||||
htp = hashtab;
|
||||
gnp = nlookup((char *)dp->d_data, &htp, &fname, 0);
|
||||
if (gnp == NULL || fname != (char *)dp->d_data)
|
||||
continue;
|
||||
for (tnp = gnp;
|
||||
tnp != NULL && tnp != top;
|
||||
tnp = tnp->n_parent)
|
||||
(void)NULL;
|
||||
if (tnp == NULL && NAME(*top)[0] != '\0')
|
||||
continue; /* name server is not below top domain */
|
||||
for (tnp = gnp;
|
||||
tnp != NULL && tnp != top;
|
||||
tnp = tnp->n_parent) {
|
||||
foreach_rr(tdp, tnp, T_NS, class, DB_Z_CACHE)
|
||||
break;
|
||||
/* If we found a zone cut, we're outta here. */
|
||||
if (tdp != NULL)
|
||||
break;
|
||||
}
|
||||
/* If name server is not in a delegated zone, skip it. */
|
||||
if (tnp == top || (tnp == NULL && NAME(*top)[0] == '\0'))
|
||||
continue;
|
||||
/* Now we know glue records are needed. Send them. */
|
||||
qsp->xfr.lev->flags |= SXL_GLUING;
|
||||
foreach_rr(gdp, gnp, T_A, class, DB_Z_CACHE)
|
||||
if (sx_addrr(qsp, fname, gdp) < 0) {
|
||||
/*
|
||||
* Rats. We already sent the NS RR, too.
|
||||
* Note that SXL_GLUING is being left on.
|
||||
*/
|
||||
return (-1);
|
||||
}
|
||||
/* for IPv6 glue AAAA record transfer */
|
||||
/* patched by [email protected], 1999/5/23 */
|
||||
foreach_rr(gdp, gnp, T_AAAA, class, DB_Z_CACHE)
|
||||
if (sx_addrr(qsp, fname, gdp) < 0) {
|
||||
/*
|
||||
* Rats. We already sent the NS RR, too.
|
||||
* Note that SXL_GLUING is being left on.
|
||||
*/
|
||||
return (-1);
|
||||
}
|
||||
foreach_rr(gdp, gnp, ns_t_a6, class, DB_Z_CACHE)
|
||||
if (sx_addrr(qsp, fname, gdp) < 0) {
|
||||
/*
|
||||
* Rats. We already sent the NS RR, too.
|
||||
* Note that SXL_GLUING is being left on.
|
||||
*/
|
||||
return (-1);
|
||||
}
|
||||
qsp->xfr.lev->flags &= ~SXL_GLUING;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_allrrs(qsp)
|
||||
* add the non-(SOA,NS) RR's at the current level's current np,
|
||||
* to the assembly message
|
||||
* do not add the DNSSEC types KEY and NXT as the delegation check
|
||||
* wrote these types out.
|
||||
* return:
|
||||
* >0 = number of RR's added, note that there may be more
|
||||
* 0 = success, there are no more RRs at this level
|
||||
* -1 = write buffer full, cannot continue at this time
|
||||
* side effects:
|
||||
* if progress was made, header and pointers will be advanced.
|
||||
* note:
|
||||
* this is meant for AXFR, which includes glue as part of the answer
|
||||
* sections. this is different from and incompatible with the additional
|
||||
* data of a referral response.
|
||||
*/
|
||||
static int
|
||||
sx_allrrs(struct qstream *qsp) {
|
||||
struct databuf *dp;
|
||||
struct namebuf *top;
|
||||
int rrcount, class;
|
||||
u_int zone;
|
||||
|
||||
class = qsp->xfr.class;
|
||||
top = qsp->xfr.top.axfr;
|
||||
zone = qsp->xfr.zone;
|
||||
rrcount = 0;
|
||||
for ((void)NULL;
|
||||
(dp = qsp->xfr.lev->dp) != NULL;
|
||||
qsp->xfr.lev->dp = db_next(dp)) {
|
||||
if (dp->d_class != class && class != C_ANY)
|
||||
continue;
|
||||
if (dp->d_rcode)
|
||||
continue;
|
||||
if (dp->d_zone != zone || stale(dp))
|
||||
continue;
|
||||
if (dp->d_type == T_SOA || dp->d_type == T_NS ||
|
||||
dp->d_type == T_NXT || dp->d_type == T_KEY)
|
||||
continue;
|
||||
if (dp->d_type == T_SIG &&
|
||||
(SIG_COVERS(dp) == T_SOA || SIG_COVERS(dp) == T_NS ||
|
||||
SIG_COVERS(dp) == T_KEY || SIG_COVERS(dp) == T_NXT))
|
||||
continue;
|
||||
INSIST(!(qsp->xfr.lev->flags & SXL_GLUING));
|
||||
|
||||
if (sx_addrr(qsp, qsp->xfr.lev->dname, dp) < 0) {
|
||||
/* RR wouldn't fit. Bail out. */
|
||||
return (-1);
|
||||
}
|
||||
rrcount++;
|
||||
}
|
||||
return (rrcount);
|
||||
}
|
||||
|
||||
/*
|
||||
* void
|
||||
* sx_sendlev(qsp)
|
||||
* send all the RRs at the current level (really a domain name), and
|
||||
* do a decomposed recursion to get all subdomains up to and including
|
||||
* but not exceeding bottom zone cuts.
|
||||
* side effects:
|
||||
* advances qsp->xfr pointers. changes qsp->xfr.lev quite often.
|
||||
* causes messages to be sent to a remote TCP client. changes the
|
||||
* qsp->xfr.state at the end of the topmost level. changes the
|
||||
* qsp->xfr.lev->state several times per domain name.
|
||||
*/
|
||||
void
|
||||
sx_sendlev(struct qstream *qsp) {
|
||||
struct qs_x_lev *lev;
|
||||
|
||||
again:
|
||||
lev = qsp->xfr.lev;
|
||||
switch (lev->state) {
|
||||
case sxl_ns: {
|
||||
while (lev->dp) {
|
||||
/* Was the child zone reloaded under us? */
|
||||
if ((lev->dp->d_flags & DB_F_ACTIVE) == 0) {
|
||||
(void) shutdown(qsp->s_rfd, 2);
|
||||
sq_remove(qsp);
|
||||
return;
|
||||
}
|
||||
/* If we can't pack this one in, come back later. */
|
||||
if (sx_nsrrs(qsp) < 0)
|
||||
return;
|
||||
}
|
||||
/* No more DP's for the NS RR pass on this NP. */
|
||||
if (lev->flags & SXL_ZONECUT) {
|
||||
/* Zone cut, so go directly to end of level. */
|
||||
break;
|
||||
}
|
||||
/* No NS RR's, so it's safe to send other types. */
|
||||
lev->state = sxl_all;
|
||||
lev->dp = lev->np->n_data;
|
||||
if (lev->dp)
|
||||
DRCNTINC(lev->dp);
|
||||
goto again;
|
||||
}
|
||||
case sxl_all: {
|
||||
while (lev->dp) {
|
||||
/* Was a record updated under us? */
|
||||
if ((lev->dp->d_flags & DB_F_ACTIVE) == 0) {
|
||||
(void) shutdown(qsp->s_rfd, 2);
|
||||
sq_remove(qsp);
|
||||
return;
|
||||
}
|
||||
/* If we can't pack this one in, come back later. */
|
||||
if (sx_allrrs(qsp) < 0)
|
||||
return;
|
||||
}
|
||||
/* No more non-NS DP's for this NP, do subdomains. */
|
||||
lev->state = sxl_sub;
|
||||
goto again;
|
||||
}
|
||||
case sxl_sub: {
|
||||
struct namebuf *np;
|
||||
|
||||
/* Get next in-use hash chain if we're not following one. */
|
||||
while (lev->nnp == NULL) {
|
||||
/* If no, or no more subdomains, end of level. */
|
||||
if (lev->npp == NULL || lev->npp == lev->npe)
|
||||
break;
|
||||
lev->nnp = *lev->npp++;
|
||||
}
|
||||
/* If we encountered the end of the level, we're outta here. */
|
||||
if ((np = lev->nnp) == NULL)
|
||||
break;
|
||||
/* Next time, we'll do the following NP, or the next chain. */
|
||||
lev->nnp = np->n_next;
|
||||
/* Skip our own NP if it appears as a subdom (as in root). */
|
||||
if (np != lev->np)
|
||||
sx_pushlev(qsp, np);
|
||||
goto again;
|
||||
}
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
/* End of level. Pop it off the stack. */
|
||||
|
||||
if ((qsp->xfr.lev = sx_freelev(lev)) == NULL) {
|
||||
/* End of topmost level. */
|
||||
qsp->xfr.state = s_x_lastsoa;
|
||||
sq_writeh(qsp, sx_sendsoa);
|
||||
return;
|
||||
}
|
||||
goto again;
|
||||
}
|
||||
|
||||
/*
|
||||
* void
|
||||
* sx_sendsoa(qsp)
|
||||
* send either the first or last SOA needed for an AXFR.
|
||||
* side effects:
|
||||
* changes qsp->xfr.state. adds RR to output buffer.
|
||||
*/
|
||||
void
|
||||
sx_sendsoa(struct qstream *qsp) {
|
||||
HEADER * hp = (HEADER *) qsp->xfr.msg;
|
||||
|
||||
if (sx_soarr(qsp) == -1)
|
||||
return; /* No state change, come back here later. */
|
||||
|
||||
hp->aa = 1;
|
||||
|
||||
switch (qsp->xfr.state) {
|
||||
case s_x_firstsoa: {
|
||||
/* Next thing to do is send the zone. */
|
||||
qsp->xfr.state = s_x_zone;
|
||||
sq_writeh(qsp, sx_sendlev);
|
||||
break;
|
||||
}
|
||||
case s_x_lastsoa: {
|
||||
/* Next thing to do is go back and wait for another query. */
|
||||
qsp->xfr.state = s_x_done;
|
||||
(void)sx_flush(qsp);
|
||||
sq_writeh(qsp, sq_flushw);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ns_panic(ns_log_xfer_out, 1,
|
||||
"unexpected state %d in sx_sendsoa", qsp->xfr.state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* int
|
||||
* sx_pushlev(qsp, np)
|
||||
* manage the decomposed recursion. set up for a new level (domain).
|
||||
* returns:
|
||||
* 0 = success
|
||||
* -1 = failure (check errno)
|
||||
*/
|
||||
static int
|
||||
sx_pushlev(struct qstream *qsp, struct namebuf *np) {
|
||||
struct qs_x_lev *new = memget(sizeof *new);
|
||||
struct hashbuf *htp;
|
||||
|
||||
if (!new) {
|
||||
errno = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
memset(new, 0, sizeof *new);
|
||||
new->state = sxl_ns;
|
||||
new->np = np;
|
||||
new->dp = np->n_data;
|
||||
if (new->dp)
|
||||
DRCNTINC(new->dp);
|
||||
getname(np, new->dname, sizeof new->dname);
|
||||
/*
|
||||
* We find the subdomains by looking in the hash table for this
|
||||
* domain, but the root domain needs special treatment, because
|
||||
* of the following wart in the database design:
|
||||
*
|
||||
* The top level hash table (pointed to by the global `hashtab'
|
||||
* variable) contains pointers to the namebuf's for the root as
|
||||
* well as for the top-level domains below the root, in contrast
|
||||
* to the usual situation where a hash table contains entries
|
||||
* for domains at the same level. The n_hash member of the
|
||||
* namebuf for the root domain is NULL instead of pointing to a
|
||||
* hashbuf for the top-level domains. The n_parent members of
|
||||
* the namebufs for the top-level domains are NULL instead of
|
||||
* pointing to the namebuf for the root.
|
||||
*
|
||||
* We work around the wart as follows:
|
||||
*
|
||||
* If we are not dealing with the root zone then we just set
|
||||
* htp = np->n_hash, pointing to the hash table for the current
|
||||
* domain, and we walk through the hash table as usual,
|
||||
* processing the namebufs for all the subdomains.
|
||||
*
|
||||
* If we are dealing with the root zone, then we set
|
||||
* htp = hashtab, pointing to the global hash table (because
|
||||
* there is no hash table associated with the root domain's
|
||||
* namebuf. While we walk this hash table, we take care not to
|
||||
* recursively process the entry for the root namebuf.
|
||||
*
|
||||
* (apb@und nov1990)
|
||||
*/
|
||||
htp = ((new->dname[0] == '\0') ? hashtab : np->n_hash);
|
||||
if (htp) {
|
||||
new->npp = htp->h_tab;
|
||||
new->npe = htp->h_tab + htp->h_size;
|
||||
} else {
|
||||
new->npp = NULL;
|
||||
new->npe = NULL;
|
||||
}
|
||||
new->nnp = NULL;
|
||||
new->next = qsp->xfr.lev;
|
||||
qsp->xfr.lev = new;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* qs_x_lev *
|
||||
* sx_freelev(lev)
|
||||
* free the memory occupied by a level descriptor
|
||||
* return:
|
||||
* pointer to "next" level descriptor
|
||||
*/
|
||||
static struct qs_x_lev *
|
||||
sx_freelev(struct qs_x_lev *lev) {
|
||||
struct qs_x_lev *next = lev->next;
|
||||
|
||||
if (lev->dp)
|
||||
db_detach(&lev->dp);
|
||||
memput(lev, sizeof *lev);
|
||||
return (next);
|
||||
}
|
||||
|
||||
static struct databuf *
|
||||
db_next(struct databuf *dp) {
|
||||
struct databuf *next = dp->d_next;
|
||||
|
||||
db_detach(&dp);
|
||||
if (next)
|
||||
DRCNTINC(next);
|
||||
|
||||
return (next);
|
||||
}
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* $Id: pathtemplate.h,v 8.6 2000/04/21 06:54:15 vixie Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-2000 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <paths.h>
|
||||
|
||||
#ifndef _PATH_CONF
|
||||
#define _PATH_CONF "%DESTETC%/named.conf"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DEBUG
|
||||
#define _PATH_DEBUG "named.run"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DUMPFILE
|
||||
#define _PATH_DUMPFILE "named_dump.db"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_NAMED
|
||||
#define _PATH_NAMED "%DESTSBIN%/named"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_PIDFILE
|
||||
#define _PATH_PIDFILE "%DESTRUN%/named.pid"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_NDCSOCK
|
||||
#ifdef NEED_SECURE_DIRECTORY
|
||||
#define _PATH_NDCSOCK "%DESTRUN%/ndc.d/ndc"
|
||||
#else
|
||||
#define _PATH_NDCSOCK "%DESTRUN%/ndc"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_STATS
|
||||
#define _PATH_STATS "named.stats"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_MEMSTATS
|
||||
#define _PATH_MEMSTATS "named.memstats"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_TMPXFER
|
||||
#define _PATH_TMPXFER "xfer.ddt.XXXXXX"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_XFER
|
||||
#define _PATH_XFER "%DESTEXEC%/named-xfer"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_XFERTRACE
|
||||
#define _PATH_XFERTRACE "xfer.trace"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_XFERDDT
|
||||
#define _PATH_XFERDDT "xfer.ddt"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DEVNULL
|
||||
#define _PATH_DEVNULL "/dev/null"
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
$ORIGIN 0.0.127.in-addr.arpa.
|
||||
|
||||
@ 1D IN SOA localhost. root.localhost. (
|
||||
42 ; serial (d. adams)
|
||||
3H ; refresh
|
||||
15M ; retry
|
||||
1W ; expiry
|
||||
1D ) ; minimum
|
||||
|
||||
1D IN NS localhost.
|
||||
1 1D IN PTR localhost.
|
||||
@@ -1,10 +0,0 @@
|
||||
$ORIGIN localhost.
|
||||
@ 1D IN SOA @ root (
|
||||
42 ; serial (d. adams)
|
||||
3H ; refresh
|
||||
15M ; retry
|
||||
1W ; expiry
|
||||
1D ) ; minimum
|
||||
|
||||
1D IN NS @
|
||||
1D IN A 127.0.0.1
|
||||
@@ -1,45 +0,0 @@
|
||||
// This is a configuration file for named (from BIND 8.1 or later).
|
||||
// It would normally be installed as /etc/named.conf.
|
||||
|
||||
options {
|
||||
// directory "/var/named";
|
||||
check-names master warn; /* default. */
|
||||
datasize 20M;
|
||||
deallocate-on-exit yes;
|
||||
listen-on { 10.0.0.53; };
|
||||
};
|
||||
|
||||
zone "localhost" IN {
|
||||
type master;
|
||||
file "localhost.zone";
|
||||
check-names fail;
|
||||
allow-update { none; };
|
||||
allow-transfer { any; };
|
||||
};
|
||||
|
||||
zone "0.0.127.in-addr.arpa" IN {
|
||||
type master;
|
||||
file "127.0.0.zone";
|
||||
check-names fail;
|
||||
allow-update { none; };
|
||||
allow-transfer { any; };
|
||||
};
|
||||
|
||||
zone "." IN {
|
||||
type hint;
|
||||
file "root.hint";
|
||||
};
|
||||
|
||||
logging {
|
||||
channel xfer-log {
|
||||
file "/var/tmp/bind-xfer.log" versions unlimited size 10m;
|
||||
print-category yes;
|
||||
print-severity yes;
|
||||
print-time yes;
|
||||
severity info;
|
||||
};
|
||||
category xfer-in { xfer-log; };
|
||||
category xfer-out { xfer-log; };
|
||||
category notify { xfer-log; };
|
||||
category load { xfer-log; };
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
; <<>> DiG 2.2 <<>> @192.5.5.241
|
||||
; (1 server found)
|
||||
;; res options: init recurs defnam dnsrch
|
||||
;; got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10
|
||||
;; flags: qr aa rd; QUERY: 1, ANSWER: 9, AUTHORITY: 0, ADDITIONAL: 9
|
||||
;; QUERY SECTION:
|
||||
;; ., type = NS, class = IN
|
||||
|
||||
;; ANSWER SECTION:
|
||||
. 6D IN NS C.ROOT-SERVERS.NET.
|
||||
. 6D IN NS D.ROOT-SERVERS.NET.
|
||||
. 6D IN NS E.ROOT-SERVERS.NET.
|
||||
. 6D IN NS I.ROOT-SERVERS.NET.
|
||||
. 6D IN NS F.ROOT-SERVERS.NET.
|
||||
. 6D IN NS G.ROOT-SERVERS.NET.
|
||||
. 6D IN NS A.ROOT-SERVERS.NET.
|
||||
. 6D IN NS H.ROOT-SERVERS.NET.
|
||||
. 6D IN NS B.ROOT-SERVERS.NET.
|
||||
|
||||
;; ADDITIONAL SECTION:
|
||||
C.ROOT-SERVERS.NET. 5w6d16h IN A 192.33.4.12
|
||||
D.ROOT-SERVERS.NET. 5w6d16h IN A 128.8.10.90
|
||||
E.ROOT-SERVERS.NET. 5w6d16h IN A 192.203.230.10
|
||||
I.ROOT-SERVERS.NET. 5w6d16h IN A 192.36.148.17
|
||||
F.ROOT-SERVERS.NET. 5w6d16h IN A 192.5.5.241
|
||||
G.ROOT-SERVERS.NET. 5w6d16h IN A 192.112.36.4
|
||||
A.ROOT-SERVERS.NET. 5w6d16h IN A 198.41.0.4
|
||||
H.ROOT-SERVERS.NET. 5w6d16h IN A 128.63.2.53
|
||||
B.ROOT-SERVERS.NET. 5w6d16h IN A 128.9.0.107
|
||||
|
||||
;; Total query time: 8 msec
|
||||
;; FROM: wisdom.home.vix.com to SERVER: 192.5.5.241
|
||||
;; WHEN: Fri Nov 22 00:08:05 1996
|
||||
;; MSG SIZE sent: 17 rcvd: 312
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* @(#)Version.c 4.9 (Berkeley) 7/21/90
|
||||
* $Id: version.c,v 8.3 1999/01/02 06:05:14 vixie Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char sccsid[] = "@(#)named %VERSION% %WHEN% %WHOANDWHERE%";
|
||||
char rcsid[] = "$Id: version.c,v 8.3 1999/01/02 06:05:14 vixie Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
char Version[] = "named %VERSION% %WHEN%\n\t%WHOANDWHERE%";
|
||||
char ShortVersion[] = "%VERSION%";
|
||||
|
||||
#ifdef COMMENT
|
||||
|
||||
SCCS/s.Version.c:
|
||||
|
||||
D 4.8.3 90/06/27 17:05:21 bloom 37 35 00031/00028/00079
|
||||
Version distributed with 4.3 Reno tape (June 1990)
|
||||
|
||||
D 4.8.2 89/09/18 13:57:11 bloom 35 34 00020/00014/00087
|
||||
Interim fixes release
|
||||
|
||||
D 4.8.1 89/02/08 17:12:15 karels 34 33 00026/00017/00075
|
||||
branch for 4.8.1
|
||||
|
||||
D 4.8 88/07/09 14:27:00 karels 33 28 00043/00031/00049
|
||||
4.8 is here!
|
||||
|
||||
D 4.7 87/11/20 13:15:52 karels 25 24 00000/00000/00062
|
||||
4.7.3 beta
|
||||
|
||||
D 4.6 87/07/21 12:15:52 karels 25 24 00000/00000/00062
|
||||
4.6 declared stillborn
|
||||
|
||||
D 4.5 87/02/10 12:33:25 kjd 24 18 00000/00000/00062
|
||||
February 1987, Network Release. Child (bind) grows up, parent (kevin) leaves home.
|
||||
|
||||
D 4.4 86/10/01 10:06:26 kjd 18 12 00020/00017/00042
|
||||
October 1, 1986 Network Distribution
|
||||
|
||||
D 4.3 86/06/04 12:12:18 kjd 12 7 00015/00028/00044
|
||||
Version distributed with 4.3BSD
|
||||
|
||||
D 4.2 86/04/30 20:57:16 kjd 7 1 00056/00000/00016
|
||||
Network distribution Freeze and one more version until 4.3BSD
|
||||
|
||||
D 1.1 86/04/30 19:30:00 kjd 1 0 00016/00000/00000
|
||||
date and time created 86/04/30 19:30:00 by kjd
|
||||
|
||||
code versions:
|
||||
|
||||
Makefile
|
||||
Makefile 4.14 (Berkeley) 2/28/88
|
||||
db.h
|
||||
db.h 4.13 (Berkeley) 2/17/88
|
||||
db_dump.c
|
||||
db_dump.c 4.20 (Berkeley) 2/17/88
|
||||
db_load.c
|
||||
db_load.c 4.26 (Berkeley) 2/28/88
|
||||
db_lookup.c
|
||||
db_lookup.c 4.14 (Berkeley) 2/17/88
|
||||
db_reload.c
|
||||
db_reload.c 4.15 (Berkeley) 2/28/88
|
||||
db_save.c
|
||||
db_save.c 4.13 (Berkeley) 2/17/88
|
||||
db_update.c
|
||||
db_update.c 4.16 (Berkeley) 2/28/88
|
||||
ns_forw.c
|
||||
ns_forw.c 4.26 (Berkeley) 3/28/88
|
||||
ns_init.c
|
||||
ns_init.c 4.23 (Berkeley) 2/28/88
|
||||
ns_main.c
|
||||
Copyright (c) 1986 Regents of the University of California.\n\
|
||||
ns_main.c 4.30 (Berkeley) 3/7/88
|
||||
ns_maint.c
|
||||
ns_maint.c 4.23 (Berkeley) 2/28/88
|
||||
ns_req.c
|
||||
ns_req.c 4.32 (Berkeley) 3/31/88
|
||||
ns_resp.c
|
||||
ns_resp.c 4.50 (Berkeley) 4/7/88
|
||||
ns_sort.c
|
||||
ns_sort.c 4.3 (Berkeley) 2/17/88
|
||||
ns_stats.c
|
||||
ns_stats.c 4.3 (Berkeley) 2/17/88
|
||||
newvers.sh
|
||||
newvers.sh 4.4 (Berkeley) 3/28/88
|
||||
|
||||
#endif /* COMMENT */
|
||||
@@ -1,96 +0,0 @@
|
||||
## Copyright (c) 1996,1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 1.17 2000/12/23 08:02:54 vixie Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
AR= ar cru
|
||||
INSTALL= install
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
PS=ps
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL} ${DEFS}
|
||||
|
||||
PROG= ndc
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
HDRS= pathnames.h
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: ${HDRS} ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} ${LIBBIND} ${SYSLIBS}
|
||||
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
pathnames.h: ${TOP}/.settings Makefile ../named/pathtemplate.h
|
||||
rm -f pathnames.h
|
||||
sed -e "s|%DESTSBIN%|${DESTSBIN}|" \
|
||||
-e "s|%DESTEXEC%|${DESTEXEC}|" \
|
||||
-e "s|%DESTETC%|${DESTETC}|" \
|
||||
-e "s|%DESTRUN%|${DESTRUN}|" \
|
||||
< ../named/pathtemplate.h > pathnames.h
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
rm -f pathnames.h
|
||||
|
||||
depend: ${SRCS} pathnames.h
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTSBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTSBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTSBIN} ${PROG}${EXE}
|
||||
${INSTALL} ${INSTALL_EXEC} ${STRIP} -c -m 755 ${PROG}${EXE} ${DESTDIR}${DESTSBIN}/${PROG}${EXE}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags ${SRCS} *.h
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
@@ -1,913 +0,0 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ndc.c,v 1.25 2003/04/03 05:42:10 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/ctl.h>
|
||||
|
||||
#include "port_after.h"
|
||||
#include "pathnames.h"
|
||||
#ifndef PATH_SEP
|
||||
#define PATH_SEP '/'
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
struct sockaddr_in in;
|
||||
#ifndef NO_SOCKADDR_UN
|
||||
struct sockaddr_un un;
|
||||
#endif
|
||||
} sockaddr_t;
|
||||
|
||||
typedef void (*closure)(void *, const char *, int);
|
||||
|
||||
static const char * program = "amnesia";
|
||||
static enum { e_channel, e_signals } mode = e_channel;
|
||||
static const char * channel = _PATH_NDCSOCK;
|
||||
static const char helpfmt[] = "\t%-16s\t%s\n";
|
||||
static const char * pidfile = _PATH_PIDFILE;
|
||||
static sockaddr_t client, server;
|
||||
static int quiet = 0, tracing = 0, silent = 0, client_set = 0;
|
||||
static int debug = 0, errors = 0, doneflag, exitflag;
|
||||
static int logger_show = 1;
|
||||
static evContext ev;
|
||||
static char cmd[1000];
|
||||
static const char * named_path = _PATH_NAMED;
|
||||
|
||||
static int slashcmd(void);
|
||||
static void slashhelp(void);
|
||||
static int builtincmd(void);
|
||||
static void command(void);
|
||||
static int running(int, pid_t *);
|
||||
static void command_channel(void);
|
||||
static void channel_loop(const char *, int, closure, void *);
|
||||
static void getpid_closure(void *, const char *, int);
|
||||
static void banner(struct ctl_cctx *, void *, const char *, u_int);
|
||||
static void done(struct ctl_cctx *, void *, const char *, u_int);
|
||||
static void logger(enum ctl_severity, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
static void command_signals(void);
|
||||
static void stop_named(pid_t);
|
||||
static void start_named(const char *, int);
|
||||
static int fgetpid(const char *, pid_t *);
|
||||
static int get_sockaddr(const char *, sockaddr_t *);
|
||||
static size_t impute_addrlen(const struct sockaddr *);
|
||||
static void vtrace(const char *, va_list) ISC_FORMAT_PRINTF(1, 0);
|
||||
static void trace(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||
static void result(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||
static void fatal(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||
static void verror(const char *, va_list) ISC_FORMAT_PRINTF(1, 0);
|
||||
static void error(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||
|
||||
static void
|
||||
usage(const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
fprintf(stderr, "%s: usage error: ", program);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fputc('\n', stderr);
|
||||
va_end(args);
|
||||
fatal("usage: %s \
|
||||
[-l localsock] [-c channel] [-p pidfile] [-n namedpath] \
|
||||
[-dqst] [command [args]]\n\
|
||||
",
|
||||
program);
|
||||
}
|
||||
|
||||
/* Public. */
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
char *p;
|
||||
int ch;
|
||||
|
||||
if ((program = strrchr(argv[0], PATH_SEP)) != NULL)
|
||||
program++;
|
||||
else
|
||||
program = argv[0];
|
||||
while ((ch = getopt(argc, argv, "c:p:l:n:dqst")) != -1) {
|
||||
switch (ch) {
|
||||
case 'c':
|
||||
channel = optarg;
|
||||
mode = e_channel;
|
||||
break;
|
||||
case 'p':
|
||||
pidfile = optarg;
|
||||
mode = e_signals;
|
||||
break;
|
||||
case 'l':
|
||||
if (!get_sockaddr(optarg, &client))
|
||||
usage("bad local socket (%s)", optarg);
|
||||
client_set++;
|
||||
break;
|
||||
case 'n':
|
||||
named_path = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
tracing++;
|
||||
debug++;
|
||||
break;
|
||||
case 'q':
|
||||
quiet++;
|
||||
break;
|
||||
case 's':
|
||||
silent++;
|
||||
break;
|
||||
case 't':
|
||||
tracing++;
|
||||
break;
|
||||
default:
|
||||
usage("unrecognized command option (%c)", ch);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
if (mode != e_channel && client_set)
|
||||
usage("the -l flag is only valid for control channels");
|
||||
if (mode == e_channel) {
|
||||
if (!get_sockaddr(channel, &server))
|
||||
usage("bad channel name (%s)", channel);
|
||||
if (evCreate(&ev) < 0)
|
||||
fatal("evCreate - %s", strerror(errno));
|
||||
}
|
||||
*(p = cmd) = '\0';
|
||||
for (argc -= optind, argv += optind;
|
||||
argc > 0;
|
||||
argc--, argv++) {
|
||||
size_t t = strlen(*argv);
|
||||
|
||||
if ((p - cmd) + t + 2 > sizeof cmd)
|
||||
usage("command too long");
|
||||
strcpy(p, *argv);
|
||||
p += t;
|
||||
if (argv[1] != NULL)
|
||||
*p++ = ' ';
|
||||
*p = '\0';
|
||||
}
|
||||
if (cmd[0] != '\0') {
|
||||
command();
|
||||
} else {
|
||||
if (!quiet)
|
||||
result("Type help -or- /h if you need help.");
|
||||
for (exitflag = 0; !exitflag; (void)NULL) {
|
||||
if (!quiet) {
|
||||
printf("%s> ", program);
|
||||
fflush(stdout);
|
||||
}
|
||||
if (!fgets(cmd, sizeof cmd, stdin)) {
|
||||
if (!quiet)
|
||||
result("EOF");
|
||||
exitflag++;
|
||||
continue;
|
||||
}
|
||||
if (cmd[strlen(cmd) - 1] == '\n')
|
||||
cmd[strlen(cmd) - 1] = '\0';
|
||||
if (cmd[0] == '\0')
|
||||
continue;
|
||||
if (slashcmd())
|
||||
continue;
|
||||
command();
|
||||
}
|
||||
}
|
||||
if (mode == e_channel)
|
||||
evDestroy(ev);
|
||||
exit(errors != 0);
|
||||
}
|
||||
|
||||
/* Private. */
|
||||
|
||||
static int
|
||||
slashcmd(void) {
|
||||
if (strncasecmp(cmd, "/help", strlen(cmd)) == 0)
|
||||
slashhelp();
|
||||
else if (strncasecmp(cmd, "/exit", strlen(cmd)) == 0)
|
||||
exitflag++;
|
||||
else if (strncasecmp(cmd, "/trace", strlen(cmd)) == 0)
|
||||
result("tracing now %s",
|
||||
(tracing = !tracing) ? "on" : "off");
|
||||
else if (strncasecmp(cmd, "/debug", strlen(cmd)) == 0)
|
||||
result("debugging now %s",
|
||||
(debug = !debug) ? "on" : "off");
|
||||
else if (strncasecmp(cmd, "/quiet", strlen(cmd)) == 0)
|
||||
result("%s is now %s", program,
|
||||
(quiet = !quiet) ? "quiet" : "noisy");
|
||||
else if (strncasecmp(cmd, "/silent", strlen(cmd)) == 0)
|
||||
result("%s is now %s", program,
|
||||
(silent = !silent)
|
||||
? "silent" : "gregarious");
|
||||
else
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
slashhelp(void) {
|
||||
printf(helpfmt, "/h(elp)", "this text");
|
||||
printf(helpfmt, "/e(xit)", "leave this program");
|
||||
printf(helpfmt, "/t(race)",
|
||||
"toggle tracing (protocol and system events)");
|
||||
printf(helpfmt, "/d(ebug)",
|
||||
"toggle debugging (internal program events)");
|
||||
printf(helpfmt, "/q(uiet)",
|
||||
"toggle quietude (prompts and results)");
|
||||
printf(helpfmt, "/s(ilent)",
|
||||
"toggle silence (suppresses nonfatal errors)");
|
||||
}
|
||||
|
||||
struct argv {
|
||||
int argc;
|
||||
char **argv;
|
||||
int error;
|
||||
};
|
||||
|
||||
static char hexdigits[] = "0123456789abcdef";
|
||||
|
||||
static void
|
||||
getargs_closure(void *arg, const char *msg, int flags) {
|
||||
struct argv *argv = arg;
|
||||
int len;
|
||||
int i;
|
||||
const char *cp, *cp2;
|
||||
char *tp, c;
|
||||
|
||||
UNUSED(flags);
|
||||
|
||||
if (argv->error)
|
||||
return;
|
||||
|
||||
if (argv->argc == -1) {
|
||||
i = atoi(msg + 4);
|
||||
if (i < 1) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
argv->argc = i;
|
||||
argv->argv = calloc((i+1), sizeof(char*));
|
||||
return;
|
||||
}
|
||||
len = 0;
|
||||
cp = msg + 4;
|
||||
while (*cp != '\0') {
|
||||
c = *cp;
|
||||
if (c == '%') {
|
||||
cp2 = strchr(hexdigits, cp[1]);
|
||||
if (cp2 == NULL) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
c = (cp2-hexdigits) << 4;
|
||||
cp2 = strchr(hexdigits, cp[2]);
|
||||
if (cp2 == NULL) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
c += (cp2-hexdigits);
|
||||
cp += 2;
|
||||
}
|
||||
if (!isalnum((unsigned)c)) {
|
||||
switch (c) {
|
||||
case '+': case '-': case '=': case '/': case '.':
|
||||
break;
|
||||
default:
|
||||
len++;
|
||||
}
|
||||
}
|
||||
len++;
|
||||
cp++;
|
||||
}
|
||||
i = 0;
|
||||
while (argv->argv[i] != NULL)
|
||||
i++;
|
||||
if (i >= argv->argc) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
argv->argv[i] = malloc(len + 1);
|
||||
if (argv->argv[i] == NULL) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
cp = msg + 4;
|
||||
tp = argv->argv[i];
|
||||
while (*cp != '\0') {
|
||||
c = *cp;
|
||||
if (c == '%') {
|
||||
cp2 = strchr(hexdigits, cp[1]);
|
||||
if (cp2 == NULL) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
c = (cp2-hexdigits) << 4;
|
||||
cp2 = strchr(hexdigits, cp[2]);
|
||||
if (cp2 == NULL) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
c += (cp2-hexdigits);
|
||||
cp += 2;
|
||||
}
|
||||
if (!isalnum((unsigned)c)) {
|
||||
switch (c) {
|
||||
case '+': case '-': case '=': case '/': case '.':
|
||||
break;
|
||||
default:
|
||||
*tp = '\\';
|
||||
}
|
||||
}
|
||||
*tp++ = c;
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
get_args(char **restp) {
|
||||
struct argv argv;
|
||||
int len, i;
|
||||
char *rest, *p;
|
||||
int result = 1;
|
||||
|
||||
argv.argc = -1;
|
||||
argv.argv = NULL;
|
||||
argv.error = 0;
|
||||
|
||||
channel_loop("args", 1, getargs_closure, &argv);
|
||||
if (argv.error) {
|
||||
result = 0;
|
||||
goto err;
|
||||
}
|
||||
len = 0;
|
||||
for (i = 1 ; i < argv.argc && argv.argv[i] != NULL; i++)
|
||||
len += strlen(argv.argv[i]) + 1;
|
||||
if (len == 0)
|
||||
len = 1;
|
||||
rest = malloc(len);
|
||||
if (rest == NULL) {
|
||||
result = 0;
|
||||
goto err;
|
||||
}
|
||||
p = rest;
|
||||
for (i = 1 ; i < argv.argc && argv.argv[i] != NULL; i++) {
|
||||
strcpy(p, argv.argv[i]);
|
||||
p += strlen(argv.argv[i]);
|
||||
*p++ = ' ';
|
||||
}
|
||||
if (p != rest)
|
||||
p--;
|
||||
p[0] = '\0';
|
||||
*restp = rest;
|
||||
|
||||
err:
|
||||
if (argv.argv) {
|
||||
for (i = 0 ; i < argv.argc && argv.argv[i] != NULL; i++)
|
||||
free(argv.argv[i]);
|
||||
free(argv.argv);
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
static void
|
||||
exec_closure(void *arg, const char *msg, int flags) {
|
||||
int *result = arg;
|
||||
UNUSED(flags);
|
||||
if (atoi(msg) == 250)
|
||||
*result = 1;
|
||||
}
|
||||
|
||||
static int
|
||||
try_exec(int local_quiet) {
|
||||
int good = 0;
|
||||
pid_t pid;
|
||||
|
||||
channel_loop("exec", 1, exec_closure, &good);
|
||||
|
||||
if (good) {
|
||||
sleep(3);
|
||||
if (!running(0, &pid))
|
||||
error("name server has not restarted (yet?)");
|
||||
else if (!local_quiet)
|
||||
result("new pid is %ld", (long)pid);
|
||||
}
|
||||
return (good);
|
||||
}
|
||||
|
||||
static int
|
||||
builtincmd(void) {
|
||||
static const char spaces[] = " \t";
|
||||
char *rest, *syscmd;
|
||||
pid_t pid;
|
||||
int save_quiet = quiet;
|
||||
int len;
|
||||
int freerest = 0;
|
||||
|
||||
quiet = 1;
|
||||
|
||||
len = strcspn(cmd, spaces);
|
||||
rest = cmd + len;
|
||||
if (*rest != '\0')
|
||||
rest += strspn(rest, spaces);
|
||||
if (*rest == '\0' && !strncasecmp(cmd, "restart", len)) {
|
||||
if (try_exec(save_quiet))
|
||||
return (1);
|
||||
freerest = get_args(&rest);
|
||||
}
|
||||
syscmd = malloc(strlen(named_path) + sizeof " " + strlen(rest));
|
||||
if (syscmd == NULL)
|
||||
fatal("malloc() failed - %s", strerror(errno));
|
||||
strcpy(syscmd, named_path);
|
||||
if (*rest != '\0') {
|
||||
strcat(syscmd, " ");
|
||||
strcat(syscmd, rest);
|
||||
}
|
||||
if (freerest)
|
||||
free(rest);
|
||||
if (strncasecmp(cmd, "start", len) == 0) {
|
||||
if (running(debug, &pid))
|
||||
error("name server already running? (pid %ld)",
|
||||
(long)pid);
|
||||
else
|
||||
start_named(syscmd, save_quiet);
|
||||
quiet = save_quiet;
|
||||
free(syscmd);
|
||||
return (1);
|
||||
} else if (strncasecmp(cmd, "restart", len) == 0) {
|
||||
if (!running(debug, &pid))
|
||||
error("name server was not running (warning only)");
|
||||
else
|
||||
stop_named(pid);
|
||||
start_named(syscmd, save_quiet);
|
||||
quiet = save_quiet;
|
||||
free(syscmd);
|
||||
return (1);
|
||||
}
|
||||
quiet = save_quiet;
|
||||
free(syscmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
builtinhelp(void) {
|
||||
const char *fmt;
|
||||
|
||||
switch (mode) {
|
||||
case e_channel:
|
||||
fmt = "(builtin) %s - %s\n";
|
||||
break;
|
||||
case e_signals:
|
||||
fmt = helpfmt;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
printf(fmt, "start", "start the server");
|
||||
printf(fmt, "restart", "stop server if any, start a new one");
|
||||
}
|
||||
|
||||
static void
|
||||
command(void) {
|
||||
if (builtincmd())
|
||||
return;
|
||||
switch (mode) {
|
||||
case e_channel:
|
||||
command_channel();
|
||||
break;
|
||||
case e_signals:
|
||||
command_signals();
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
running(int show, pid_t *pidp) {
|
||||
pid_t pid;
|
||||
|
||||
switch (mode) {
|
||||
case e_channel:
|
||||
pid = 0;
|
||||
channel_loop("getpid", show, getpid_closure, &pid);
|
||||
if (pid != 0) {
|
||||
if (tracing)
|
||||
result("pid %ld is running", (long)pid);
|
||||
*pidp = pid;
|
||||
return (1);
|
||||
}
|
||||
break;
|
||||
case e_signals:
|
||||
if (fgetpid(pidfile, pidp)) {
|
||||
if (tracing)
|
||||
result("pid %ld is running", (long)pid);
|
||||
return (1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
if (show)
|
||||
error("pid not valid or server not running");
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
getpid_closure(void *uap, const char *text, int flags) {
|
||||
pid_t *pidp = uap;
|
||||
const char *cp;
|
||||
|
||||
flags = flags;
|
||||
if ((cp = strchr(text, '<')) != NULL) {
|
||||
long l = 0;
|
||||
char ch;
|
||||
|
||||
while ((ch = *++cp) != '\0' && ch != '>' && isdigit(ch))
|
||||
l *= 10, l += (ch - '0');
|
||||
if (ch == '>') {
|
||||
*pidp = (pid_t)l;
|
||||
return;
|
||||
}
|
||||
}
|
||||
error("response does not contain pid (%s)", text);
|
||||
}
|
||||
|
||||
static void
|
||||
command_channel(void) {
|
||||
int helping = (strcasecmp(cmd, "help") == 0);
|
||||
int save_quiet = quiet;
|
||||
|
||||
if (helping) {
|
||||
quiet = 0;
|
||||
builtinhelp();
|
||||
}
|
||||
channel_loop(cmd, !quiet, NULL, NULL);
|
||||
quiet = save_quiet;
|
||||
}
|
||||
|
||||
struct args {
|
||||
const char *cmd;
|
||||
closure cl;
|
||||
void *ua;
|
||||
};
|
||||
|
||||
static void
|
||||
channel_loop(const char *cmdtext, int show, closure cl, void *ua) {
|
||||
struct ctl_cctx *ctl;
|
||||
struct sockaddr *client_addr;
|
||||
struct args a;
|
||||
evEvent e;
|
||||
int save_logger_show = logger_show;
|
||||
|
||||
if (!client_set)
|
||||
client_addr = NULL;
|
||||
else
|
||||
client_addr = (struct sockaddr *)&client;
|
||||
a.cmd = cmdtext;
|
||||
a.cl = cl;
|
||||
a.ua = ua;
|
||||
logger_show = show;
|
||||
trace("command '%s'", cmdtext);
|
||||
ctl = ctl_client(ev, client_addr, impute_addrlen(client_addr),
|
||||
(struct sockaddr *)&server,
|
||||
impute_addrlen((struct sockaddr *)&server),
|
||||
banner, &a, 15, logger);
|
||||
if (ctl == NULL) {
|
||||
if (show)
|
||||
error("cannot connect to command channel (%s)",
|
||||
channel);
|
||||
} else {
|
||||
doneflag = 0;
|
||||
while (evGetNext(ev, &e, EV_WAIT) == 0)
|
||||
if (evDispatch(ev, e) < 0 || doneflag)
|
||||
break;
|
||||
ctl_endclient(ctl);
|
||||
}
|
||||
logger_show = save_logger_show;
|
||||
}
|
||||
|
||||
static void
|
||||
banner(struct ctl_cctx *ctl, void *uap, const char *msg, u_int flags) {
|
||||
struct args *a = uap;
|
||||
|
||||
if (msg == NULL) {
|
||||
trace("EOF");
|
||||
doneflag = 1;
|
||||
return;
|
||||
}
|
||||
trace("%s", msg);
|
||||
if ((flags & CTL_MORE) != 0)
|
||||
return;
|
||||
if (ctl_command(ctl, a->cmd, strlen(a->cmd), done, a) < 0) {
|
||||
error("ctl_command failed - %s", strerror(errno));
|
||||
doneflag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
done(struct ctl_cctx *ctl, void *uap, const char *msg, u_int flags) {
|
||||
struct args *a = uap;
|
||||
|
||||
UNUSED(ctl);
|
||||
|
||||
if (msg == NULL) {
|
||||
trace("EOF");
|
||||
doneflag = 1;
|
||||
return;
|
||||
}
|
||||
if (!tracing && !quiet && strlen(msg) > 4)
|
||||
result("%s", msg + 4);
|
||||
trace("%s", msg);
|
||||
if (a->cl)
|
||||
(a->cl)(a->ua, msg, flags);
|
||||
if ((flags & CTL_MORE) == 0)
|
||||
doneflag = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
logger(enum ctl_severity ctlsev, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
switch (ctlsev) {
|
||||
case ctl_debug:
|
||||
/* FALLTHROUGH */
|
||||
case ctl_warning:
|
||||
if (debug)
|
||||
vtrace(format, args);
|
||||
break;
|
||||
case ctl_error:
|
||||
if (logger_show)
|
||||
verror(format, args);
|
||||
break;
|
||||
default:
|
||||
va_end(args);
|
||||
abort();
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static struct cmdsig {
|
||||
const char * cmd;
|
||||
int sig;
|
||||
const char * help;
|
||||
} cmdsigs[] = {
|
||||
{ "dumpdb", SIGINT, "dump cache database to a file" },
|
||||
{ "reload", SIGHUP, "reload configuration file" },
|
||||
{ "stats", SIGILL, "dump statistics to a file" },
|
||||
{ "trace", SIGUSR1, "increment trace level" },
|
||||
{ "notrace", SIGUSR2, "turn off tracing" },
|
||||
#ifdef SIGWINCH
|
||||
{ "querylog", SIGWINCH, "toggle query logging" },
|
||||
{ "qrylog", SIGWINCH, "alias for querylog" },
|
||||
#endif
|
||||
{ NULL, 0, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
command_signals(void) {
|
||||
struct cmdsig *cmdsig;
|
||||
pid_t pid;
|
||||
|
||||
if (strcasecmp(cmd, "help") == 0) {
|
||||
printf(helpfmt, "help", "this output");
|
||||
printf(helpfmt, "status", "check for running server");
|
||||
printf(helpfmt, "stop", "stop the server");
|
||||
builtinhelp();
|
||||
for (cmdsig = cmdsigs; cmdsig->cmd != NULL; cmdsig++)
|
||||
printf(helpfmt, cmdsig->cmd, cmdsig->help);
|
||||
} else if (strcasecmp(cmd, "status") == 0) {
|
||||
if (!fgetpid(pidfile, &pid))
|
||||
error("pid not valid or server not running");
|
||||
else
|
||||
result("pid %ld is running", (long)pid);
|
||||
} else if (strcasecmp(cmd, "stop") == 0) {
|
||||
if (!fgetpid(pidfile, &pid))
|
||||
error("name server not running");
|
||||
else
|
||||
stop_named(pid);
|
||||
} else {
|
||||
for (cmdsig = cmdsigs; cmdsig->cmd != NULL; cmdsig++)
|
||||
if (strcasecmp(cmd, cmdsig->cmd) == 0)
|
||||
break;
|
||||
if (cmdsig->cmd == NULL)
|
||||
error("unrecognized command (%s)", cmd);
|
||||
else if (!fgetpid(pidfile, &pid))
|
||||
error("can't get pid (%s)", pidfile);
|
||||
else if (kill(pid, cmdsig->sig) < 0)
|
||||
error("kill() failed - %s", strerror(errno));
|
||||
else
|
||||
trace("pid %ld sig %d OK", (long)pid, cmdsig->sig);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
stop_named(pid_t pid) {
|
||||
int n;
|
||||
|
||||
trace("stopping named (pid %ld)", (long)pid);
|
||||
switch (mode) {
|
||||
case e_signals:
|
||||
if (kill(pid, SIGTERM) < 0) {
|
||||
error("kill(%ld, SIGTERM) failed - %s",
|
||||
(long)pid, strerror(errno));
|
||||
return;
|
||||
}
|
||||
trace("SIGTERM ok, waiting for death");
|
||||
break;
|
||||
case e_channel:
|
||||
channel_loop("stop", tracing, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
for (n = 0; n < 10; n++) {
|
||||
if (kill(pid, 0) != 0) {
|
||||
trace("named (pid %ld) is dead", (long)pid);
|
||||
return;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
error("named (pid %ld) didn't die", (long)pid);
|
||||
}
|
||||
|
||||
static void
|
||||
start_named(const char *syscmd, int local_quiet) {
|
||||
pid_t pid;
|
||||
|
||||
if (system(syscmd) != 0)
|
||||
error("could not start new name server (%s)", syscmd);
|
||||
else {
|
||||
sleep(3);
|
||||
if (!running(0, &pid))
|
||||
error("name server has not started (yet?)");
|
||||
else if (!local_quiet)
|
||||
result("new pid is %ld", (long)pid);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
fgetpid(const char *f, pid_t *pid) {
|
||||
FILE *fp;
|
||||
int try;
|
||||
long t;
|
||||
|
||||
for (try = 0; try < 5; try++) {
|
||||
trace("pidfile is \"%s\" (try #%d)", f, try + 1);
|
||||
if ((fp = fopen(f, "r")) == NULL)
|
||||
trace("pid file (%s) unavailable - %s",
|
||||
f, strerror(errno));
|
||||
else if (fscanf(fp, "%ld\n", &t) != 1)
|
||||
trace("pid file (%s) format is bad", f);
|
||||
else if (*pid = (pid_t)t, fclose(fp), kill(*pid, 0) < 0)
|
||||
trace("pid file (%s) contains unusable pid (%d) - %s",
|
||||
f, *pid, strerror(errno));
|
||||
else {
|
||||
trace("pid is %ld", (long)*pid);
|
||||
return (1);
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
trace("pid not found");
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
get_sockaddr(const char *name, sockaddr_t *addr) {
|
||||
char *slash;
|
||||
|
||||
#ifndef NO_SOCKADDR_UN
|
||||
if (name[0] == '/') {
|
||||
memset(&addr->un, '\0', sizeof addr->un);
|
||||
addr->un.sun_family = AF_UNIX;
|
||||
strncpy(addr->un.sun_path, name, sizeof addr->un.sun_path - 1);
|
||||
addr->un.sun_path[sizeof addr->un.sun_path - 1] = '\0';
|
||||
} else
|
||||
#endif
|
||||
if ((slash = strrchr(name, '/')) != NULL) {
|
||||
char *ibuf = malloc(slash - name + 1);
|
||||
if (!ibuf)
|
||||
usage("no memory for IP address (%s)", name);
|
||||
memcpy(ibuf, name, slash - name);
|
||||
ibuf[slash - name] = '\0';
|
||||
memset(&addr->in, '\0', sizeof addr->in);
|
||||
if (!inet_pton(AF_INET, ibuf, &addr->in.sin_addr))
|
||||
usage("bad ip address (%s)", name);
|
||||
if ((addr->in.sin_port = htons(atoi(slash+1))) == 0)
|
||||
usage("bad ip port (%s)", slash+1);
|
||||
addr->in.sin_family = AF_INET;
|
||||
free (ibuf);
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
static size_t
|
||||
impute_addrlen(const struct sockaddr *sa) {
|
||||
if (sa == NULL)
|
||||
return (0);
|
||||
switch (sa->sa_family) {
|
||||
case AF_INET:
|
||||
return (sizeof(struct sockaddr_in));
|
||||
#ifndef NO_SOCKADDR_UN
|
||||
case AF_UNIX:
|
||||
return (sizeof(struct sockaddr_un));
|
||||
#endif
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
static void
|
||||
vtrace(const char *fmt, va_list ap) {
|
||||
if (tracing) {
|
||||
fprintf(stdout, "%s: [", program);
|
||||
vfprintf(stdout, fmt, ap);
|
||||
fputs("]\n", stdout);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
trace(const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vtrace(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void
|
||||
result(const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vfprintf(stdout, fmt, args);
|
||||
fputc('\n', stdout);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void
|
||||
fatal(const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
fprintf(stderr, "%s: fatal error: ", program);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fputc('\n', stderr);
|
||||
va_end(args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
verror(const char *fmt, va_list ap) {
|
||||
fprintf(stderr, "%s: error: ", program);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fputc('\n', stderr);
|
||||
errors++;
|
||||
}
|
||||
|
||||
static void
|
||||
error(const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
if (silent)
|
||||
vtrace(fmt, args);
|
||||
else
|
||||
verror(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
## Copyright (c) 1996,1999 by Internet Software Consortium
|
||||
##
|
||||
## Permission to use, copy, modify, and distribute this software for any
|
||||
## purpose with or without fee is hereby granted, provided that the above
|
||||
## copyright notice and this permission notice appear in all copies.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.28 2002/05/21 00:44:59 marka Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g -Wall
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = freebsd
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
EXE=
|
||||
LEX = lex -I
|
||||
SYSLIBS =-lutil
|
||||
LIBL=-ll
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
INSTALL_EXEC=
|
||||
INSTALL_LIB=-o bin -g bin
|
||||
|
||||
LDFLAGS=
|
||||
DEFS= -D_PATH_HELPFILE=\"${DESTHELP}/nslookup.help\"
|
||||
CFLAGS= ${CDEBUG}
|
||||
CPPFLAGS= -I${PORTINCL} -I${INCL} ${DEFS}
|
||||
|
||||
PROG= nslookup
|
||||
CSRCS= main.c getinfo.c debug.c send.c skip.c list.c subr.c
|
||||
SRCS= ${CSRCS} commands.l
|
||||
OBJS= main.${O} getinfo.${O} debug.${O} send.${O} skip.${O} list.${O} \
|
||||
subr.${O} commands.${O}
|
||||
|
||||
all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
|
||||
${LIBBIND} ${LIBL} ${SYSLIBS}
|
||||
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
distclean: clean
|
||||
rm -f commands.c
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG}${EXE} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
rm -f lex.yy.c lex.yy.o
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${DEFS} ${CSRCS}
|
||||
|
||||
${DESTDIR}${DESTHELP}:
|
||||
mkdir -p ${DESTDIR}${DESTHELP}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${DESTDIR}${DESTHELP} ${PROG}${EXE}
|
||||
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
|
||||
${INSTALL} -c ${INSTALL_LIB} -m 444 nslookup.help ${DESTDIR}${DESTHELP}/
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[chl] SRC/nslookup.help .
|
||||
|
||||
tags: FRC
|
||||
ctags ${CSRCS} *.h
|
||||
|
||||
commands.c: commands.l
|
||||
${LEX} -t $< > $@ || rm $@
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
@@ -1,273 +0,0 @@
|
||||
%{
|
||||
/* $FreeBSD$ */
|
||||
/*
|
||||
* Copyright (c) 1985
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)commands.l 5.13 (Berkeley) 7/24/90";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* commands.l
|
||||
*
|
||||
* Andrew Cherenson CS298-26 Fall 1985
|
||||
*
|
||||
* Lex input file for the nslookup program command interpreter.
|
||||
* When a sequence is recognized, the associated action
|
||||
* routine is called. The action routine may need to
|
||||
* parse the string for additional information.
|
||||
*
|
||||
* Recognized commands: (identifiers are shown in uppercase)
|
||||
*
|
||||
* server NAME - set default server to NAME, using default server
|
||||
* lserver NAME - set default server to NAME, using initial server
|
||||
* finger [NAME] - finger the optional NAME
|
||||
* exit - exit the program
|
||||
* root - set default server to the root
|
||||
* ls NAME - list the domain NAME
|
||||
* set OPTION - set an option
|
||||
* help - print help information
|
||||
* ? - print help information
|
||||
* NAME - print info about the host/domain NAME
|
||||
* using default server.
|
||||
* NAME1 NAME2 - as above, but use NAME2 as server
|
||||
*
|
||||
*
|
||||
* yylex Results:
|
||||
* 0 upon end-of-file.
|
||||
* 1 after each command.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <histedit.h>
|
||||
#include "port_after.h"
|
||||
#include <resolv.h>
|
||||
#include "res.h"
|
||||
|
||||
extern char rootServerName[];
|
||||
extern void PrintHelp();
|
||||
|
||||
#define YY_INPUT(buf, result, max_size) \
|
||||
{ \
|
||||
nslookup_yy_input((char *)buf, &result, \
|
||||
max_size, yy_current_buffer->yy_is_interactive); \
|
||||
}
|
||||
|
||||
const char *
|
||||
nslookup_prompt()
|
||||
{
|
||||
return ("> ");
|
||||
}
|
||||
|
||||
int
|
||||
nslookup_yy_input(buf, result, max_size, intr)
|
||||
char * buf;
|
||||
int * result;
|
||||
int max_size;
|
||||
int intr;
|
||||
{
|
||||
static EditLine *el = NULL;
|
||||
static History *hist = NULL;
|
||||
HistEvent he;
|
||||
int num = 0;
|
||||
const char *bp = NULL;
|
||||
|
||||
if (intr) {
|
||||
if (!el) {
|
||||
el = el_init("nslookup", yyin, yyout, stderr);
|
||||
hist = history_init();
|
||||
history(hist, &he, H_EVENT, 100);
|
||||
el_set(el, EL_HIST, history, hist);
|
||||
el_set(el, EL_EDITOR, "emacs");
|
||||
el_set(el, EL_PROMPT, nslookup_prompt);
|
||||
el_set(el, EL_SIGNAL, 1);
|
||||
el_source(el, NULL);
|
||||
}
|
||||
|
||||
if ((bp = el_gets(el, &num)) == NULL || num == 0) {
|
||||
*result = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
*result = (num > max_size) ? max_size : num;
|
||||
strncpy(buf, bp, *result);
|
||||
history(hist, &he, H_ENTER, bp);
|
||||
} else {
|
||||
if ( ((*result = fread( buf, 1, max_size, yyin )) == 0)
|
||||
&& ferror( yyin ) )
|
||||
yy_fatal_error( "input in flex scanner failed" );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
%}
|
||||
WS [ \t]
|
||||
FLET [:A-Za-z0-9.*\\_]
|
||||
LET [:A-Za-z0-9.*_]
|
||||
NAME [:A-Za-z0-9.*=_/-]
|
||||
%%
|
||||
^{WS}*server{WS}+{LET}{NAME}*{WS}*$ {
|
||||
/*
|
||||
* 0 == use current server to find
|
||||
* the new one.
|
||||
* 1 == use original server to find
|
||||
* the new one.
|
||||
*/
|
||||
SetDefaultServer((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*lserver{WS}+{LET}{NAME}*{WS}*$ {
|
||||
SetDefaultServer((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*exit{WS}*$ {
|
||||
return(0);
|
||||
}
|
||||
^{WS}*root{WS}*$ {
|
||||
SetDefaultServer(rootServerName, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*finger({WS}+{LET}{NAME}*)?{WS}+>>?{WS}*{NAME}+{WS}*$ {
|
||||
/*
|
||||
* 2nd arg.
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
Finger((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*finger({WS}+{LET}{NAME}*)?{WS}*$ {
|
||||
Finger((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ {
|
||||
/*
|
||||
* 2nd arg.
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
ListHosts((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}*$ {
|
||||
ListHosts((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+-t{WS}+({LET}{NAME}*{WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ {
|
||||
/*
|
||||
* 2nd arg.
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
ListHostsByType((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+-t{WS}+({LET}{NAME}*{WS}+)?{LET}{NAME}*{WS}*$ {
|
||||
ListHostsByType((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*set{WS}+{NAME}+{WS}*$ {
|
||||
SetOption((char*)yytext);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*help{WS}*$ {
|
||||
PrintHelp();
|
||||
return(1);
|
||||
}
|
||||
^{WS}*"?"{WS}*$ {
|
||||
extern void PrintHelp();
|
||||
|
||||
PrintHelp();
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}+>>?{WS}*{NAME}+{WS}*$ {
|
||||
/*
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
LookupHost((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}*$ {
|
||||
LookupHost((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}+{LET}{NAME}*{WS}+>>?{WS}*{NAME}+{WS}*$ {
|
||||
/*
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
LookupHostWithServer((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}+{LET}{NAME}*{WS}*$ {
|
||||
LookupHostWithServer((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*\n {
|
||||
return(1);
|
||||
}
|
||||
^.*\n {
|
||||
printf("Unrecognized command: %s",
|
||||
(char*)yytext);
|
||||
return(1);
|
||||
}
|
||||
\n { ; }
|
||||
%%
|
||||
@@ -1,657 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/*
|
||||
* Copyright (c) 1985, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char sccsid[] = "@(#)debug.c 5.26 (Berkeley) 3/21/91";
|
||||
static const char rcsid[] = "$Id: debug.c,v 8.19 2001/09/25 04:50:26 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* debug.c --
|
||||
*
|
||||
* Routines to print out packets received from a name server query.
|
||||
*
|
||||
* Modified version of 4.3BSD BIND res_debug.c 5.30 6/27/90
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "res.h"
|
||||
|
||||
/*
|
||||
* Imported from res_debug.c
|
||||
*/
|
||||
#ifndef HAVE_DECL_RES_OPCODES
|
||||
extern char *_res_opcodes[];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Used to highlight the start of a record when printing it.
|
||||
*/
|
||||
#define INDENT " -> "
|
||||
|
||||
/*
|
||||
* Print the contents of a query.
|
||||
* This is intended to be primarily a debugging routine.
|
||||
*/
|
||||
|
||||
void
|
||||
Print_query(const u_char *msg, const u_char *eom, int printHeader) {
|
||||
Fprint_query(msg, eom, printHeader, stdout);
|
||||
}
|
||||
|
||||
void
|
||||
Fprint_query(const u_char *msg, const u_char *eom, int printHeader, FILE *file)
|
||||
{
|
||||
const u_char *cp;
|
||||
const HEADER *hp;
|
||||
int n;
|
||||
u_int class, type = 0;
|
||||
|
||||
/*
|
||||
* Print header fields.
|
||||
*/
|
||||
hp = (const HEADER *)msg;
|
||||
cp = msg + HFIXEDSZ;
|
||||
if (printHeader || (res.options & RES_DEBUG2)) {
|
||||
fprintf(file," HEADER:\n");
|
||||
fprintf(file,"\topcode = %s", _res_opcodes[hp->opcode]);
|
||||
fprintf(file,", id = %d", ntohs(hp->id));
|
||||
fprintf(file,", rcode = %s\n", p_rcode(hp->rcode));
|
||||
fprintf(file,"\theader flags: ");
|
||||
if (hp->qr) {
|
||||
fprintf(file," response");
|
||||
} else {
|
||||
fprintf(file," query");
|
||||
}
|
||||
if (hp->aa)
|
||||
fprintf(file,", auth. answer");
|
||||
if (hp->tc)
|
||||
fprintf(file,", truncation");
|
||||
if (hp->rd)
|
||||
fprintf(file,", want recursion");
|
||||
if (hp->ra)
|
||||
fprintf(file,", recursion avail.");
|
||||
if (hp->unused)
|
||||
fprintf(file,", UNUSED-QUERY_BIT");
|
||||
if (hp->ad)
|
||||
fprintf(file,", authentic data");
|
||||
if (hp->cd)
|
||||
fprintf(file,", checking disabled");
|
||||
fprintf(file,"\n\tquestions = %d", ntohs(hp->qdcount));
|
||||
fprintf(file,", answers = %d", ntohs(hp->ancount));
|
||||
fprintf(file,", authority records = %d", ntohs(hp->nscount));
|
||||
fprintf(file,", additional = %d\n\n", ntohs(hp->arcount));
|
||||
}
|
||||
|
||||
/*
|
||||
* Print question records.
|
||||
*/
|
||||
n = ntohs(hp->qdcount);
|
||||
if (n > 0) {
|
||||
fprintf(file," QUESTIONS:\n");
|
||||
while (--n >= 0) {
|
||||
fprintf(file,"\t");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
type = ns_get16((const u_char*)cp);
|
||||
cp += INT16SZ;
|
||||
class = ns_get16((const u_char*)cp);
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", type = %s", p_type(type));
|
||||
fprintf(file,", class = %s\n", p_class(class));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Print authoritative answer records
|
||||
*/
|
||||
n = ntohs(hp->ancount);
|
||||
if (n > 0) {
|
||||
fprintf(file," ANSWERS:\n");
|
||||
if (type == ns_t_a && n > MAXADDRS) {
|
||||
printf("Limiting response to MAX Addrs = %d \n",
|
||||
MAXADDRS);
|
||||
n = MAXADDRS;
|
||||
}
|
||||
while (--n >= 0) {
|
||||
fprintf(file, INDENT);
|
||||
cp = Print_rr(cp, msg, eom, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* print name server records
|
||||
*/
|
||||
n = ntohs(hp->nscount);
|
||||
if (n > 0) {
|
||||
fprintf(file," AUTHORITY RECORDS:\n");
|
||||
while (--n >= 0) {
|
||||
fprintf(file, INDENT);
|
||||
cp = Print_rr(cp, msg, eom, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* print additional records
|
||||
*/
|
||||
n = ntohs(hp->arcount);
|
||||
if (n > 0) {
|
||||
fprintf(file," ADDITIONAL RECORDS:\n");
|
||||
while (--n >= 0) {
|
||||
fprintf(file, INDENT);
|
||||
cp = Print_rr(cp, msg, eom, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
}
|
||||
}
|
||||
fprintf(file,"\n------------\n");
|
||||
}
|
||||
|
||||
static const u_char *
|
||||
Print_cdname_sub(const u_char *cp, const u_char *msg, const u_char *eom,
|
||||
FILE *file, int format)
|
||||
{
|
||||
char name[MAXDNAME];
|
||||
int n;
|
||||
|
||||
n = dn_expand(msg, eom, cp, name, sizeof name);
|
||||
if (n < 0)
|
||||
return (NULL);
|
||||
if (name[0] == '\0')
|
||||
strcpy(name, "(root)");
|
||||
if (format)
|
||||
fprintf(file, "%-30s", name);
|
||||
else
|
||||
fputs(name, file);
|
||||
return (cp + n);
|
||||
}
|
||||
|
||||
const u_char *
|
||||
Print_cdname(const u_char *cp, const u_char *msg, const u_char *eom,
|
||||
FILE *file)
|
||||
{
|
||||
return (Print_cdname_sub(cp, msg, eom, file, 0));
|
||||
}
|
||||
|
||||
const u_char *
|
||||
Print_cdname2(const u_char *cp, const u_char *msg, const u_char *eom,
|
||||
FILE *file)
|
||||
{
|
||||
return (Print_cdname_sub(cp, msg, eom, file, 1));
|
||||
}
|
||||
|
||||
#define BOUNDS_CHECK(ptr, count) \
|
||||
do { \
|
||||
if ((ptr) + (count) > eom) { \
|
||||
fprintf(file, "(form error.)\n"); \
|
||||
return (NULL); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Print resource record fields in human readable form (not master file form).
|
||||
*/
|
||||
const u_char *
|
||||
Print_rr(const u_char *ocp, const u_char *msg, const u_char *eom, FILE *file) {
|
||||
u_int type, class;
|
||||
int dlen, n, c, debug;
|
||||
u_long rrttl, ttl;
|
||||
struct in_addr inaddr;
|
||||
const u_char *cp, *cp1, *cp2;
|
||||
|
||||
if ((cp = Print_cdname(ocp, msg, eom, file)) == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
|
||||
BOUNDS_CHECK(cp, 3 * INT16SZ + INT32SZ);
|
||||
NS_GET16(type, cp);
|
||||
NS_GET16(class, cp);
|
||||
NS_GET32(rrttl, cp);
|
||||
NS_GET16(dlen, cp);
|
||||
BOUNDS_CHECK(cp, dlen);
|
||||
|
||||
debug = res.options & (RES_DEBUG|RES_DEBUG2);
|
||||
if (debug) {
|
||||
if (res.options & RES_DEBUG2)
|
||||
fprintf(file,"\n\ttype = %s, class = %s, dlen = %d",
|
||||
p_type(type), p_class(class), dlen);
|
||||
if (type == T_SOA)
|
||||
fprintf(file,"\n\tttl = %lu (%s)",
|
||||
rrttl, p_time(rrttl));
|
||||
putc('\n', file);
|
||||
}
|
||||
|
||||
cp1 = cp;
|
||||
|
||||
/*
|
||||
* Print type specific data, if appropriate
|
||||
*/
|
||||
switch (type) {
|
||||
case T_A:
|
||||
BOUNDS_CHECK(cp, INADDRSZ);
|
||||
memcpy(&inaddr, cp, INADDRSZ);
|
||||
fprintf(file,"\tinternet address = %s\n", inet_ntoa(inaddr));
|
||||
cp += dlen;
|
||||
break;
|
||||
|
||||
case T_CNAME:
|
||||
fprintf(file,"\tcanonical name = ");
|
||||
goto doname;
|
||||
|
||||
case T_MG:
|
||||
fprintf(file,"\tmail group member = ");
|
||||
goto doname;
|
||||
|
||||
case T_MB:
|
||||
fprintf(file,"\tmail box = ");
|
||||
goto doname;
|
||||
|
||||
case T_MR:
|
||||
fprintf(file,"\tmailbox rename = ");
|
||||
goto doname;
|
||||
|
||||
case T_MX:
|
||||
BOUNDS_CHECK(cp, INT16SZ);
|
||||
fprintf(file,"\tpreference = %u",ns_get16((const u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", mail exchanger = ");
|
||||
goto doname;
|
||||
|
||||
case T_NAPTR:
|
||||
BOUNDS_CHECK(cp, 2 * INT16SZ);
|
||||
fprintf(file, "\torder = %u",ns_get16((const u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", preference = %u\n", ns_get16((const u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
/* Flags */
|
||||
BOUNDS_CHECK(cp, 1);
|
||||
n = *cp++;
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\tflags = \"%.*s\"\n", (int)n, cp);
|
||||
cp += n;
|
||||
/* Service */
|
||||
BOUNDS_CHECK(cp, 1);
|
||||
n = *cp++;
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\tservices = \"%.*s\"\n", (int)n, cp);
|
||||
cp += n;
|
||||
/* Regexp */
|
||||
BOUNDS_CHECK(cp, 1);
|
||||
n = *cp++;
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\trule = \"%.*s\"\n", (int)n, cp);
|
||||
cp += n;
|
||||
/* Replacement */
|
||||
fprintf(file,"\treplacement = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(replacement truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_SRV:
|
||||
BOUNDS_CHECK(cp, 3 * INT16SZ);
|
||||
fprintf(file, "\tpriority = %u",ns_get16((const u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", weight = %u", ns_get16((const u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", port= %u\n", ns_get16((const u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
|
||||
fprintf(file,"\thost = ");
|
||||
goto doname;
|
||||
|
||||
case T_PX:
|
||||
BOUNDS_CHECK(cp, INT16SZ);
|
||||
fprintf(file,"\tpreference = %u",ns_get16((const u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", RFC 822 = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
fprintf(file,"\nX.400 = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_RT:
|
||||
BOUNDS_CHECK(cp, INT16SZ);
|
||||
fprintf(file,"\tpreference = %u",ns_get16((const u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", router = ");
|
||||
goto doname;
|
||||
|
||||
case T_AFSDB:
|
||||
BOUNDS_CHECK(cp, INT16SZ);
|
||||
fprintf(file,"\tsubtype = %d",ns_get16((const u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", DCE/AFS server = ");
|
||||
goto doname;
|
||||
|
||||
case T_NS:
|
||||
fprintf(file,"\tnameserver = ");
|
||||
goto doname;
|
||||
|
||||
case T_PTR:
|
||||
fprintf(file,"\tname = ");
|
||||
doname:
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_HINFO:
|
||||
cp2 = cp + dlen;
|
||||
BOUNDS_CHECK(cp, 1);
|
||||
if ((n = *cp++) != 0) {
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\tCPU = %.*s", n, cp);
|
||||
cp += n;
|
||||
}
|
||||
if ((cp < cp2) && ((n = *cp++) != 0)) {
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\tOS = %.*s\n", n, cp);
|
||||
cp += n;
|
||||
} else fprintf(file, "\n*** Warning *** OS-type missing\n");
|
||||
break;
|
||||
|
||||
case T_ISDN:
|
||||
cp2 = cp + dlen;
|
||||
BOUNDS_CHECK(cp, 1);
|
||||
n = *cp++;
|
||||
if (n != 0) {
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\tISDN = \"%.*s", n, cp);
|
||||
cp += n;
|
||||
}
|
||||
if ((cp < cp2) && (n = *cp++)) {
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"-%.*s\"\n", n, cp);
|
||||
cp += n;
|
||||
} else fprintf(file,"\"\n");
|
||||
break;
|
||||
|
||||
case T_SOA:
|
||||
if (!debug)
|
||||
putc('\n', file);
|
||||
fprintf(file,"\torigin = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
fprintf(file,"\n\tmail addr = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
BOUNDS_CHECK(cp, 5 * INT32SZ);
|
||||
fprintf(file,"\n\tserial = %lu", ns_get32((const u_char*)cp));
|
||||
cp += INT32SZ;
|
||||
ttl = ns_get32((const u_char*)cp);
|
||||
fprintf(file,"\n\trefresh = %lu (%s)", ttl, p_time(ttl));
|
||||
cp += INT32SZ;
|
||||
ttl = ns_get32((const u_char*)cp);
|
||||
fprintf(file,"\n\tretry = %lu (%s)", ttl, p_time(ttl));
|
||||
cp += INT32SZ;
|
||||
ttl = ns_get32((const u_char*)cp);
|
||||
fprintf(file,"\n\texpire = %lu (%s)", ttl, p_time(ttl));
|
||||
cp += INT32SZ;
|
||||
ttl = ns_get32((const u_char*)cp);
|
||||
fprintf(file,
|
||||
"\n\tminimum ttl = %lu (%s)\n", ttl, p_time(ttl));
|
||||
cp += INT32SZ;
|
||||
break;
|
||||
|
||||
case T_MINFO:
|
||||
if (!debug)
|
||||
putc('\n', file);
|
||||
fprintf(file,"\trequests = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
fprintf(file,"\n\terrors = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_RP:
|
||||
if (!debug)
|
||||
putc('\n', file);
|
||||
fprintf(file,"\tmailbox = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
fprintf(file,"\n\ttext = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_TXT:
|
||||
(void) fputs("\ttext = ", file);
|
||||
cp2 = cp1 + dlen;
|
||||
while (cp < cp2) {
|
||||
(void) putc('"', file);
|
||||
n = (unsigned char) *cp++;
|
||||
if (n != 0) {
|
||||
for (c = n; c > 0 && cp < cp2; c--) {
|
||||
if ((*cp == '\n') || (*cp == '"') || (*cp == '\\'))
|
||||
(void) putc('\\', file);
|
||||
(void) putc(*cp++, file);
|
||||
}
|
||||
}
|
||||
(void) putc('"', file);
|
||||
if (cp < cp2)
|
||||
(void) putc(' ', file);
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_X25:
|
||||
(void) fputs("\tX25 = \"", file);
|
||||
cp2 = cp1 + dlen;
|
||||
while (cp < cp2) {
|
||||
n = (unsigned char) *cp++;
|
||||
if (n != 0) {
|
||||
for (c = n; c > 0 && cp < cp2; c--)
|
||||
if (*cp == '\n') {
|
||||
(void) putc('\\', file);
|
||||
(void) putc(*cp++, file);
|
||||
} else
|
||||
(void) putc(*cp++, file);
|
||||
}
|
||||
}
|
||||
(void) fputs("\"\n", file);
|
||||
break;
|
||||
|
||||
case T_NSAP:
|
||||
fprintf(file, "\tnsap = %s\n", inet_nsap_ntoa(dlen, cp, NULL));
|
||||
cp += dlen;
|
||||
break;
|
||||
|
||||
case T_AAAA: {
|
||||
char t[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
|
||||
|
||||
BOUNDS_CHECK(cp, IN6ADDRSZ);
|
||||
fprintf(file, "\tIPv6 address = %s\n",
|
||||
inet_ntop(AF_INET6, cp, t, sizeof t));
|
||||
cp += IN6ADDRSZ;
|
||||
break;
|
||||
}
|
||||
|
||||
case T_WKS: {
|
||||
struct protoent *protoPtr;
|
||||
|
||||
BOUNDS_CHECK(cp, INADDRSZ + 1);
|
||||
if (!debug)
|
||||
(void) putc('\n', file);
|
||||
memcpy(&inaddr, cp, INADDRSZ);
|
||||
cp += INADDRSZ;
|
||||
if ((protoPtr = getprotobynumber(*cp)) != NULL) {
|
||||
fprintf(file,"\tinet address = %s, protocol = %s\n\t",
|
||||
inet_ntoa(inaddr), protoPtr->p_name);
|
||||
} else {
|
||||
fprintf(file,"\tinet address = %s, protocol = %d\n\t",
|
||||
inet_ntoa(inaddr), *cp);
|
||||
}
|
||||
cp++;
|
||||
n = 0;
|
||||
while (cp < cp1 + dlen) {
|
||||
c = *cp++;
|
||||
do {
|
||||
struct servent *s;
|
||||
|
||||
if (c & 0200) {
|
||||
s = getservbyport((int)htons(n),
|
||||
protoPtr ? protoPtr->p_name : NULL);
|
||||
if (s != NULL) {
|
||||
fprintf(file," %s", s->s_name);
|
||||
} else {
|
||||
fprintf(file," #%d", n);
|
||||
}
|
||||
}
|
||||
c <<= 1;
|
||||
} while (++n & 07);
|
||||
}
|
||||
putc('\n',file);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_NULL:
|
||||
fprintf(file, "\tNULL (dlen %d)\n", dlen);
|
||||
cp += dlen;
|
||||
break;
|
||||
|
||||
case T_NXT:
|
||||
case T_SIG:
|
||||
case T_KEY:
|
||||
default: {
|
||||
char buf[2048]; /* XXX need to malloc/realloc. */
|
||||
char rrname[NS_MAXDNAME];
|
||||
|
||||
cp2 = p_fqnname(ocp, msg, NS_MAXCDNAME, rrname, sizeof rrname);
|
||||
if (cp2 == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
|
||||
if (ns_sprintrrf(msg, eom - msg, rrname, (ns_class)class,
|
||||
(ns_type)type, rrttl, cp1, dlen, NULL, NULL,
|
||||
buf, sizeof buf) < 0) {
|
||||
perror("ns_sprintrrf");
|
||||
} else {
|
||||
fprintf(file,
|
||||
"\trecord type %s, interpreted as:\n%s\n",
|
||||
p_type(type), buf);
|
||||
}
|
||||
cp += dlen;
|
||||
}
|
||||
}
|
||||
if (res.options & RES_DEBUG && type != T_SOA) {
|
||||
fprintf(file,"\tttl = %lu (%s)\n", rrttl, p_time(rrttl));
|
||||
}
|
||||
if (cp != cp1 + dlen) {
|
||||
fprintf(file,
|
||||
"\n*** Error: record size incorrect (%d != %d)\n\n",
|
||||
cp - cp1, dlen);
|
||||
cp = NULL;
|
||||
}
|
||||
return (cp);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,705 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1985, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char sccsid[] = "@(#)list.c 5.23 (Berkeley) 3/21/91";
|
||||
static const char rcsid[] = "$Id: list.c,v 8.27 2002/04/09 05:55:17 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* list.c --
|
||||
*
|
||||
* Routines to obtain info from name and finger servers.
|
||||
*
|
||||
* Adapted from 4.3BSD BIND ns_init.c and from finger.c.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "res.h"
|
||||
|
||||
extern char *pager;
|
||||
|
||||
typedef union {
|
||||
HEADER qb1;
|
||||
u_char qb2[PACKETSZ];
|
||||
} querybuf;
|
||||
|
||||
extern HostInfo *defaultPtr;
|
||||
extern HostInfo curHostInfo;
|
||||
extern int curHostValid;
|
||||
extern int queryType;
|
||||
extern int queryClass;
|
||||
|
||||
static int sockFD = -1;
|
||||
int ListSubr();
|
||||
|
||||
/*
|
||||
* During a listing to a file, hash marks are printed
|
||||
* every HASH_SIZE records.
|
||||
*/
|
||||
|
||||
#define HASH_SIZE 50
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* ListHosts --
|
||||
* ListHostsByType --
|
||||
*
|
||||
* Requests the name server to do a zone transfer so we
|
||||
* find out what hosts it knows about.
|
||||
*
|
||||
* For ListHosts, there are five types of output:
|
||||
* - Internet addresses (default)
|
||||
* - cpu type and operating system (-h option)
|
||||
* - canonical and alias names (-a option)
|
||||
* - well-known service names (-s option)
|
||||
* - ALL records (-d option)
|
||||
* ListHostsByType prints records of the default type or of a speicific
|
||||
* type.
|
||||
*
|
||||
* To see all types of information sorted by name, do the following:
|
||||
* ls -d domain.edu > file
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS the listing was successful.
|
||||
* ERROR the server could not be contacted because
|
||||
* a socket could not be obtained or an error
|
||||
* occured while receiving, or the output file
|
||||
* could not be opened.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void
|
||||
ListHostsByType(char *string, int putToFile) {
|
||||
char *namePtr, name[NAME_LEN], option[NAME_LEN];
|
||||
int i, j, qtype, result;
|
||||
|
||||
/*
|
||||
* Parse the command line. It maybe of the form "ls -t domain"
|
||||
* or "ls -t type domain".
|
||||
*/
|
||||
|
||||
/* simulate sscanf(string, " ls -t %s %s", option, name) */
|
||||
i = matchString(" ls -t ", string);
|
||||
if (i > 0) {
|
||||
j = pickString(string + i, option, sizeof option);
|
||||
if (j > 0) {
|
||||
j = pickString(string + i + j, name, sizeof name);
|
||||
if (j > 0)
|
||||
i = 2;
|
||||
else
|
||||
i = 1;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (putToFile && i == 2 && name[0] == '>')
|
||||
i--;
|
||||
if (i == 2) {
|
||||
qtype = StringToType(option, -1, stderr);
|
||||
if (qtype == -1)
|
||||
return;
|
||||
namePtr = name;
|
||||
} else if (i == 1) {
|
||||
namePtr = option;
|
||||
qtype = queryType;
|
||||
} else {
|
||||
fprintf(stderr, "*** ls: invalid request %s\n", string);
|
||||
return;
|
||||
}
|
||||
result = ListSubr(qtype, namePtr, putToFile ? string : NULL);
|
||||
if (result != SUCCESS)
|
||||
fprintf(stderr, "*** Can't list domain %s: %s\n",
|
||||
namePtr, DecodeError(result));
|
||||
}
|
||||
|
||||
void
|
||||
ListHosts(char *string, int putToFile) {
|
||||
char *namePtr, name[NAME_LEN], option[NAME_LEN];
|
||||
int i, j, qtype, result;
|
||||
|
||||
/*
|
||||
* Parse the command line. It maybe of the form "ls domain",
|
||||
* "ls -X domain".
|
||||
*/
|
||||
|
||||
/* simulate i = sscanf(string, " ls %s %s", option, name) */
|
||||
i = matchString(" ls ", string);
|
||||
if (i > 0) {
|
||||
j = pickString(string + i, option, sizeof option);
|
||||
if (j > 0) {
|
||||
j = pickString(string + i + j, name, sizeof name);
|
||||
if (j > 0)
|
||||
i = 2;
|
||||
else
|
||||
i = 1;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (putToFile && i == 2 && name[0] == '>')
|
||||
i--;
|
||||
if (i == 2) {
|
||||
if (strcmp("-a", option) == 0)
|
||||
qtype = T_CNAME;
|
||||
else if (strcmp("-h", option) == 0)
|
||||
qtype = T_HINFO;
|
||||
else if (strcmp("-m", option) == 0)
|
||||
qtype = T_MX;
|
||||
else if (strcmp("-p", option) == 0)
|
||||
qtype = T_PX;
|
||||
else if (strcmp("-s", option) == 0)
|
||||
qtype = T_WKS;
|
||||
else if (strcmp("-d", option) == 0)
|
||||
qtype = T_ANY;
|
||||
else if (strcmp("-n", option) == 0)
|
||||
qtype = T_NAPTR;
|
||||
else
|
||||
qtype = T_A;
|
||||
namePtr = name;
|
||||
} else if (i == 1) {
|
||||
namePtr = option;
|
||||
qtype = T_A;
|
||||
} else {
|
||||
fprintf(stderr, "*** ls: invalid request %s\n",string);
|
||||
return;
|
||||
}
|
||||
result = ListSubr(qtype, namePtr, putToFile ? string : NULL);
|
||||
if (result != SUCCESS)
|
||||
fprintf(stderr, "*** Can't list domain %s: %s\n",
|
||||
namePtr, DecodeError(result));
|
||||
}
|
||||
|
||||
int
|
||||
ListSubr(int qtype, char *domain, char *cmd) {
|
||||
static u_char *answer = NULL;
|
||||
static int answerLen = 0;
|
||||
|
||||
ns_msg handle;
|
||||
querybuf buf;
|
||||
struct sockaddr_storage sa;
|
||||
struct sockaddr_in *sin;
|
||||
struct sockaddr_in6 *sin6;
|
||||
HEADER *headerPtr;
|
||||
int msglen, amtToRead, numRead, soacnt;
|
||||
u_int len;
|
||||
int numAnswers = 0;
|
||||
int numRecords = 0;
|
||||
u_char tmp[INT16SZ], *cp;
|
||||
char soaname[2][NAME_LEN], file[PATH_MAX];
|
||||
enum { NO_ERRORS, ERR_READING_LEN, ERR_READING_MSG, ERR_PRINTING }
|
||||
error = NO_ERRORS;
|
||||
struct iovec iov[2];
|
||||
AddrInfo *AddrPtr;
|
||||
int salen = 0;
|
||||
|
||||
/*
|
||||
* Create a query packet for the requested domain name.
|
||||
*/
|
||||
msglen = res_nmkquery(&res, QUERY, domain, queryClass, T_AXFR,
|
||||
NULL, 0, 0, buf.qb2, sizeof buf);
|
||||
if (msglen < 0) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
fprintf(stderr, "*** ls: res_nmkquery failed\n");
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if we have the address of the server or the
|
||||
* address of a server who knows about this domain.
|
||||
*
|
||||
* For now, just use the first address in the list. XXX.
|
||||
*/
|
||||
|
||||
if (defaultPtr->addrList != NULL)
|
||||
AddrPtr = defaultPtr->addrList[0];
|
||||
else
|
||||
AddrPtr = defaultPtr->servers[0]->addrList[0];
|
||||
|
||||
memset(&sa, 0, sizeof sa);
|
||||
switch (AddrPtr->addrType) {
|
||||
case AF_INET:
|
||||
sin = (struct sockaddr_in *)&sa;
|
||||
sin->sin_family = AddrPtr->addrType;
|
||||
sin->sin_port = htons(nsport);
|
||||
memcpy(&sin->sin_addr, AddrPtr->addr, AddrPtr->addrLen);
|
||||
#ifdef HAVE_SA_LEN
|
||||
sin->sin_len = sizeof(*sin);
|
||||
#endif
|
||||
salen = sizeof(struct sockaddr_in);
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
sin6 = (struct sockaddr_in6 *)&sa;
|
||||
sin6->sin6_family = AddrPtr->addrType;
|
||||
sin6->sin6_port = htons(nsport);
|
||||
memcpy(&sin6->sin6_addr, AddrPtr->addr, AddrPtr->addrLen);
|
||||
#ifdef HAVE_SA_LEN
|
||||
sin6->sin6_len = sizeof(*sin6);
|
||||
#endif
|
||||
salen = sizeof(struct sockaddr_in6);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up a virtual circuit to the server.
|
||||
*/
|
||||
sockFD = socket(AddrPtr->addrType, SOCK_STREAM, 0);
|
||||
if (sockFD < 0) {
|
||||
perror("ls: socket");
|
||||
return (ERROR);
|
||||
}
|
||||
if (connect(sockFD, (struct sockaddr *)&sa, salen) < 0) {
|
||||
int e;
|
||||
|
||||
if (errno == ECONNREFUSED)
|
||||
e = NO_RESPONSE;
|
||||
else {
|
||||
perror("ls: connect");
|
||||
e = ERROR;
|
||||
}
|
||||
(void) close(sockFD);
|
||||
sockFD = -1;
|
||||
return (e);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send length & message for zone transfer
|
||||
*/
|
||||
ns_put16(msglen, tmp);
|
||||
iov[0].iov_base = (char *)tmp;
|
||||
iov[0].iov_len = INT16SZ;
|
||||
iov[1].iov_base = (char *)buf.qb2;
|
||||
iov[1].iov_len = msglen;
|
||||
if (writev(sockFD, iov, 2) != INT16SZ + msglen) {
|
||||
perror("ls: write");
|
||||
(void) close(sockFD);
|
||||
sockFD = -1;
|
||||
return(ERROR);
|
||||
}
|
||||
|
||||
fprintf(stdout,"[%s]\n", (defaultPtr->addrList != NULL)
|
||||
? defaultPtr->name : defaultPtr->servers[0]->name);
|
||||
|
||||
if (cmd == NULL) {
|
||||
filePtr = stdout;
|
||||
} else {
|
||||
filePtr = OpenFile(cmd, file, sizeof file);
|
||||
if (filePtr == NULL) {
|
||||
fprintf(stderr, "*** Can't open %s for writing\n",
|
||||
file);
|
||||
(void) close(sockFD);
|
||||
sockFD = -1;
|
||||
return (ERROR);
|
||||
}
|
||||
fprintf(filePtr, "> %s\n", cmd);
|
||||
fprintf(filePtr, "[%s]\n", (defaultPtr->addrList != NULL)
|
||||
? defaultPtr->name : defaultPtr->servers[0]->name);
|
||||
}
|
||||
|
||||
soacnt = 0;
|
||||
while (soacnt < 2) {
|
||||
/*
|
||||
* Read the length of the response.
|
||||
*/
|
||||
|
||||
cp = tmp; amtToRead = INT16SZ;
|
||||
while (amtToRead > 0 &&
|
||||
(numRead = read(sockFD, cp, amtToRead)) > 0) {
|
||||
cp += numRead;
|
||||
amtToRead -= numRead;
|
||||
}
|
||||
if (numRead <= 0) {
|
||||
error = ERR_READING_LEN;
|
||||
break;
|
||||
}
|
||||
|
||||
len = ns_get16(tmp);
|
||||
if (len == 0)
|
||||
break; /* nothing left to read */
|
||||
|
||||
/*
|
||||
* If the server sent too much data to fit the existing
|
||||
* buffer, allocate a new one.
|
||||
*/
|
||||
if (len > (u_int)answerLen) {
|
||||
if (answerLen != 0)
|
||||
free(answer);
|
||||
answerLen = len;
|
||||
answer = (u_char *)Malloc(answerLen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the response.
|
||||
*/
|
||||
amtToRead = len; cp = answer;
|
||||
while (amtToRead > 0 &&
|
||||
(numRead = read(sockFD, cp, amtToRead)) > 0) {
|
||||
cp += numRead;
|
||||
amtToRead -= numRead;
|
||||
}
|
||||
if (numRead <= 0) {
|
||||
error = ERR_READING_MSG;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ns_initparse(answer, cp - answer, &handle) < 0) {
|
||||
perror("ns_initparse");
|
||||
error = ERR_PRINTING;
|
||||
break;
|
||||
}
|
||||
if (ns_msg_getflag(handle, ns_f_rcode) != ns_r_noerror ||
|
||||
ns_msg_count(handle, ns_s_an) == 0) {
|
||||
/* Signalled protocol error, or empty message. */
|
||||
error = ERR_PRINTING;
|
||||
break;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
static char origin[NS_MAXDNAME], name_ctx[NS_MAXDNAME];
|
||||
const char *name;
|
||||
char buf[2048]; /* XXX need to malloc/realloc. */
|
||||
ns_rr rr;
|
||||
|
||||
if (ns_parserr(&handle, ns_s_an, -1, &rr)) {
|
||||
if (errno != ENODEV) {
|
||||
perror("ns_parserr");
|
||||
error = ERR_PRINTING;
|
||||
}
|
||||
break;
|
||||
}
|
||||
name = ns_rr_name(rr);
|
||||
if (origin[0] == '\0' && name[0] != '\0') {
|
||||
if (strcmp(name, ".") != 0)
|
||||
strcpy(origin, name);
|
||||
fprintf(filePtr, "$ORIGIN %s.\n", origin);
|
||||
if (strcmp(name, ".") == 0)
|
||||
strcpy(origin, name);
|
||||
strcpy(name_ctx, "@");
|
||||
}
|
||||
if (qtype == T_ANY || (int)ns_rr_type(rr) == qtype) {
|
||||
if (ns_sprintrr(&handle, &rr, name_ctx, origin,
|
||||
buf, sizeof buf) < 0) {
|
||||
perror("ns_sprintrr");
|
||||
error = ERR_PRINTING;
|
||||
break;
|
||||
}
|
||||
strcpy(name_ctx, name);
|
||||
numRecords++;
|
||||
fputs(buf, filePtr);
|
||||
fputc('\n', filePtr);
|
||||
}
|
||||
if (ns_rr_type(rr) == T_SOA) {
|
||||
strcpy(soaname[soacnt], name);
|
||||
if (soacnt == 0)
|
||||
soacnt = 1;
|
||||
else if (ns_samename(soaname[0],
|
||||
soaname[1]) == 1) {
|
||||
soacnt = 2;
|
||||
/* This means we're finished.
|
||||
* But we've to reset origin and
|
||||
* name_ctx now ! */
|
||||
origin[0] = name_ctx[0] ='\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error != NO_ERRORS)
|
||||
break;
|
||||
numAnswers++;
|
||||
if (cmd != NULL && ((numAnswers % HASH_SIZE) == 0)) {
|
||||
fprintf(stdout, "#");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd != NULL)
|
||||
fprintf(stdout, "%sReceived %d answer%s (%d record%s).\n",
|
||||
(numAnswers >= HASH_SIZE) ? "\n" : "",
|
||||
numAnswers, (numAnswers != 1) ? "s" : "",
|
||||
numRecords, (numRecords != 1) ? "s" : "");
|
||||
|
||||
(void) close(sockFD);
|
||||
sockFD = -1;
|
||||
if (cmd != NULL && filePtr != NULL) {
|
||||
fclose(filePtr);
|
||||
filePtr = NULL;
|
||||
}
|
||||
|
||||
switch (error) {
|
||||
case NO_ERRORS:
|
||||
return (SUCCESS);
|
||||
|
||||
case ERR_READING_LEN:
|
||||
return (ERROR);
|
||||
|
||||
case ERR_PRINTING:
|
||||
return (ERROR);
|
||||
|
||||
case ERR_READING_MSG:
|
||||
headerPtr = (HEADER *) answer;
|
||||
fprintf(stderr,"*** ls: error receiving zone transfer:\n");
|
||||
fprintf(stderr,
|
||||
" result: %s, answers = %d, authority = %d, additional = %d\n",
|
||||
p_rcode(headerPtr->rcode),
|
||||
ntohs(headerPtr->ancount), ntohs(headerPtr->nscount),
|
||||
ntohs(headerPtr->arcount));
|
||||
return (ERROR);
|
||||
default:
|
||||
return (ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Finger --
|
||||
*
|
||||
* Connects with the finger server for the current host
|
||||
* to request info on the specified person (long form)
|
||||
* who is on the system (short form).
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS the finger server was contacted.
|
||||
* ERROR the server could not be contacted because
|
||||
* a socket could not be obtained or connected
|
||||
* to or the service could not be found.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
int
|
||||
Finger(string, putToFile)
|
||||
char *string;
|
||||
int putToFile;
|
||||
{
|
||||
struct servent *sp;
|
||||
struct sockaddr_storage sa;
|
||||
struct sockaddr_in *sin;
|
||||
struct sockaddr_in6 *sin6;
|
||||
FILE *f;
|
||||
int c;
|
||||
int lastc;
|
||||
char name[NAME_LEN];
|
||||
char file[PATH_MAX];
|
||||
int i;
|
||||
int salen = 0;
|
||||
|
||||
/*
|
||||
* We need a valid current host info to get an inet address.
|
||||
*/
|
||||
if (!curHostValid) {
|
||||
fprintf(stderr, "Finger: no current host defined.\n");
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* simulate: sscanf("finger %s") ; */
|
||||
|
||||
i = matchString(" finger ", string);
|
||||
if (i > 0) {
|
||||
i = pickString(string + i, name, sizeof name);
|
||||
if (i > 0) {
|
||||
i = 1 ;
|
||||
}
|
||||
/* note that if the argument to the finger command is
|
||||
bigger than sizeof name it will be treated as if there
|
||||
was no argument. */
|
||||
}
|
||||
|
||||
if (i == 1) {
|
||||
if (putToFile && (name[0] == '>')) {
|
||||
name[0] = '\0';
|
||||
}
|
||||
} else {
|
||||
name[0] = '\0';
|
||||
}
|
||||
|
||||
sp = getservbyname("finger", "tcp");
|
||||
if (sp == 0) {
|
||||
fprintf(stderr, "Finger: unknown service\n");
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
memset(&sa, 0, sizeof sa);
|
||||
switch (curHostInfo.addrList[0]->addrType) {
|
||||
case AF_INET:
|
||||
sin = (struct sockaddr_in *)&sa;
|
||||
sin->sin_family = curHostInfo.addrList[0]->addrType;
|
||||
sin->sin_port = sp->s_port;
|
||||
memcpy(&sin->sin_addr, curHostInfo.addrList[0]->addr,
|
||||
curHostInfo.addrList[0]->addrLen);
|
||||
#ifdef HAVE_SA_LEN
|
||||
sin->sin_len = sizeof(*sin);
|
||||
#endif
|
||||
salen = sizeof(struct sockaddr_in);
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
sin6 = (struct sockaddr_in6 *)&sa;
|
||||
sin6->sin6_family = curHostInfo.addrList[0]->addrType;
|
||||
sin6->sin6_port = sp->s_port;
|
||||
memcpy(&sin6->sin6_addr, curHostInfo.addrList[0]->addr,
|
||||
curHostInfo.addrList[0]->addrLen);
|
||||
#ifdef HAVE_SA_LEN
|
||||
sin6->sin6_len = sizeof(*sin6);
|
||||
#endif
|
||||
salen = sizeof(struct sockaddr_in6);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up a virtual circuit to the host.
|
||||
*/
|
||||
|
||||
sockFD = socket(curHostInfo.addrList[0]->addrType, SOCK_STREAM, 0);
|
||||
if (sockFD < 0) {
|
||||
fflush(stdout);
|
||||
perror("finger: socket");
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
if (connect(sockFD, (struct sockaddr *)&sa, salen) < 0) {
|
||||
fflush(stdout);
|
||||
perror("finger: connect");
|
||||
close(sockFD);
|
||||
sockFD = -1;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
if (!putToFile) {
|
||||
filePtr = stdout;
|
||||
} else {
|
||||
filePtr = OpenFile(string, file, sizeof file);
|
||||
if (filePtr == NULL) {
|
||||
fprintf(stderr, "*** Can't open %s for writing\n", file);
|
||||
close(sockFD);
|
||||
sockFD = -1;
|
||||
return(ERROR);
|
||||
}
|
||||
fprintf(filePtr,"> %s\n", string);
|
||||
}
|
||||
fprintf(filePtr, "[%s]\n", curHostInfo.name);
|
||||
|
||||
if (name[0] != '\0') {
|
||||
write(sockFD, "/W ", 3);
|
||||
}
|
||||
write(sockFD, name, strlen(name));
|
||||
write(sockFD, "\r\n", 2);
|
||||
f = fdopen(sockFD, "r");
|
||||
lastc = '\n';
|
||||
while ((c = getc(f)) != EOF) {
|
||||
switch (c) {
|
||||
case 0210:
|
||||
case 0211:
|
||||
case 0212:
|
||||
case 0214:
|
||||
c -= 0200;
|
||||
break;
|
||||
case 0215:
|
||||
c = '\n';
|
||||
break;
|
||||
}
|
||||
putc(lastc = c, filePtr);
|
||||
}
|
||||
if (lastc != '\n') {
|
||||
putc('\n', filePtr);
|
||||
}
|
||||
putc('\n', filePtr);
|
||||
|
||||
close(sockFD);
|
||||
sockFD = -1;
|
||||
|
||||
if (putToFile) {
|
||||
fclose(filePtr);
|
||||
filePtr = NULL;
|
||||
}
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
ListHost_close(void) {
|
||||
if (sockFD != -1) {
|
||||
(void) close(sockFD);
|
||||
sockFD = -1;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,33 +0,0 @@
|
||||
$Id: nslookup.help,v 8.5 2000/03/30 23:25:35 vixie Exp $
|
||||
|
||||
Commands: (identifiers are shown in uppercase, [] means optional)
|
||||
NAME - print info about the host/domain NAME using default server
|
||||
NAME1 NAME2 - as above, but use NAME2 as server
|
||||
help or ? - print info on common commands; see nslookup(1) for details
|
||||
set OPTION - set an option
|
||||
all - print options, current server and host
|
||||
[no]debug - print debugging information
|
||||
[no]d2 - print exhaustive debugging information
|
||||
[no]defname - append domain name to each query
|
||||
[no]recurse - ask for recursive answer to query
|
||||
[no]vc - always use a virtual circuit
|
||||
domain=NAME - set default domain name to NAME
|
||||
srchlist=N1[/N2/.../N6] - set domain to N1 and search list to N1,N2, etc.
|
||||
root=NAME - set root server to NAME
|
||||
retry=X - set number of retries to X
|
||||
timeout=X - set initial time-out interval to X seconds
|
||||
querytype=X - set query type, e.g., A,ANY,CNAME,HINFO,MX,PX,NS,PTR,SOA,TXT,WKS,SRV,NAPTR
|
||||
port=X - set port number to send query on
|
||||
type=X - synonym for querytype
|
||||
class=X - set query class to one of IN (Internet), CHAOS, HESIOD or ANY
|
||||
server NAME - set default server to NAME, using current default server
|
||||
lserver NAME - set default server to NAME, using initial server
|
||||
finger [USER] - finger the optional USER at the current default host
|
||||
root - set current default server to the root
|
||||
ls [opt] DOMAIN [> FILE] - list addresses in DOMAIN (optional: output to FILE)
|
||||
-a - list canonical names and aliases
|
||||
-h - list HINFO (CPU type and operating system)
|
||||
-s - list well-known services
|
||||
-d - list all records
|
||||
-t TYPE - list records of the given type (e.g., A,CNAME,MX, etc.)
|
||||
exit - exit the program, ^D also exits
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* ++Copyright++ 1990
|
||||
* -
|
||||
* Copyright (c) 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* -
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
* -
|
||||
* --Copyright--
|
||||
*/
|
||||
|
||||
/*
|
||||
* @(#)pathnames.h 5.1 (Berkeley) 5/28/90
|
||||
* $Id: pathnames.h,v 8.2 2000/11/08 06:47:32 marka Exp $
|
||||
*/
|
||||
|
||||
#define _PATH_NSLOOKUPRC "/.nslookuprc"
|
||||
#ifndef _PATH_PAGERCMD
|
||||
#define _PATH_PAGERCMD "more"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_HELPFILE
|
||||
#if defined(BSD) && BSD >= 198810
|
||||
#define _PATH_HELPFILE "/usr/share/misc/nslookup.help"
|
||||
#else
|
||||
#define _PATH_HELPFILE "/usr/lib/nslookup.help"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
/*
|
||||
* ++Copyright++ 1985, 1989
|
||||
* -
|
||||
* Copyright (c) 1985, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* -
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
* -
|
||||
* --Copyright--
|
||||
*/
|
||||
|
||||
/*
|
||||
* @(#)res.h 5.10 (Berkeley) 6/1/90
|
||||
* $Id: res.h,v 8.10 2002/04/09 05:55:22 marka Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* res.h --
|
||||
*
|
||||
* Definitions used by modules of the name server lookup program.
|
||||
*
|
||||
* Copyright (c) 1985
|
||||
* Andrew Cherenson
|
||||
* U.C. Berkeley
|
||||
* CS298-26 Fall 1985
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
typedef int Boolean;
|
||||
|
||||
#define MAXALIASES 35
|
||||
#define MAXADDRS 35
|
||||
#define MAXDOMAINS 35
|
||||
#define MAXSERVERS 10
|
||||
|
||||
/*
|
||||
* Define return statuses in addtion to the ones defined in namserv.h
|
||||
* let SUCCESS be a synonym for NOERROR
|
||||
*
|
||||
* TIME_OUT - a socket connection timed out.
|
||||
* NO_INFO - the server didn't find any info about the host.
|
||||
* ERROR - one of the following types of errors:
|
||||
* dn_expand, res_mkquery failed
|
||||
* bad command line, socket operation failed, etc.
|
||||
* NONAUTH - the server didn't have the desired info but
|
||||
* returned the name(s) of some servers who should.
|
||||
* NO_RESPONSE - the server didn't respond.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ERROR
|
||||
#undef ERROR
|
||||
#endif
|
||||
|
||||
#define SUCCESS 0
|
||||
#define TIME_OUT -1
|
||||
#define NO_INFO -2
|
||||
#define ERROR -3
|
||||
#define NONAUTH -4
|
||||
#define NO_RESPONSE -5
|
||||
|
||||
/*
|
||||
* Define additional options for the resolver state structure.
|
||||
*
|
||||
* RES_DEBUG2 more verbose debug level
|
||||
*/
|
||||
|
||||
#define RES_DEBUG2 0x80000000
|
||||
|
||||
/*
|
||||
* Maximum length of server, host and file names.
|
||||
*/
|
||||
|
||||
#define NAME_LEN 256
|
||||
|
||||
|
||||
/*
|
||||
* Modified struct hostent from <netdb.h>
|
||||
*
|
||||
* "Structures returned by network data base library. All addresses
|
||||
* are supplied in host order, and returned in network order (suitable
|
||||
* for use in system calls)."
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int addrType;
|
||||
int addrLen;
|
||||
char *addr;
|
||||
} AddrInfo;
|
||||
|
||||
typedef struct {
|
||||
char *name; /* official name of host */
|
||||
char **domains; /* domains it serves */
|
||||
AddrInfo **addrList; /* list of addresses from name server */
|
||||
} ServerInfo;
|
||||
|
||||
typedef struct {
|
||||
char *name; /* official name of host */
|
||||
char **aliases; /* alias list */
|
||||
AddrInfo **addrList; /* list of addresses from name server */
|
||||
ServerInfo **servers;
|
||||
} HostInfo;
|
||||
|
||||
|
||||
/*
|
||||
* FilePtr is used for directing listings to a file.
|
||||
* It is global so the Control-C handler can close it.
|
||||
*/
|
||||
|
||||
extern FILE *filePtr;
|
||||
|
||||
/*
|
||||
* TCP/UDP port of server.
|
||||
*/
|
||||
extern unsigned short nsport;
|
||||
|
||||
/*
|
||||
* Our resolver context.
|
||||
*/
|
||||
extern struct __res_state res;
|
||||
|
||||
/*
|
||||
* External routines:
|
||||
*/
|
||||
|
||||
/* XXX need prototypes */
|
||||
void Print_query(const u_char *msg, const u_char *eom, int printHeader);
|
||||
void Fprint_query(const u_char *msg, const u_char *eom, int printHeader,
|
||||
FILE *file);
|
||||
const u_char *Print_cdname(const u_char *cp, const u_char *msg,
|
||||
const u_char *eom, FILE *file);
|
||||
const u_char *Print_cdname2(const u_char *cp, const u_char *msg,
|
||||
const u_char *eom, FILE *file);
|
||||
const u_char *Print_rr(const u_char *ocp, const u_char *msg,
|
||||
const u_char *eom, FILE *file);
|
||||
extern const char *DecodeType(); /* descriptive version of p_type */
|
||||
extern const char *DecodeError();
|
||||
extern char *Calloc();
|
||||
extern char *Malloc();
|
||||
extern void NsError();
|
||||
extern void PrintServer();
|
||||
extern void PrintHostInfo();
|
||||
extern void FreeHostInfoPtr();
|
||||
extern FILE *OpenFile();
|
||||
extern int pickString(const char *, char *, size_t);
|
||||
extern int GetHostInfoByName(union res_sockaddr_union *, int, int,
|
||||
const char *, HostInfo *, Boolean, Boolean);
|
||||
extern int GetHostDomain(union res_sockaddr_union *, int, int,
|
||||
const char *, char *, HostInfo *, Boolean, Boolean);
|
||||
extern int matchString(const char *, const char *);
|
||||
extern int StringToType(char *, int, FILE *);
|
||||
extern int StringToClass(char *, int, FILE *);
|
||||
extern int SendRequest(union res_sockaddr_union *, const u_char *, int,
|
||||
u_char *, u_int, int *);
|
||||
extern void SendRequest_close(void);
|
||||
extern int SetDefaultServer(char *, Boolean);
|
||||
extern int Finger(char *, int);
|
||||
void ListHostsByType(char *, int);
|
||||
void ListHosts(char *, int);
|
||||
void ListHost_close(void);
|
||||
int SetOption(char *);
|
||||
int LookupHost(char *, Boolean);
|
||||
int LookupHostWithServer(char *, Boolean);
|
||||
const char * DecodeType(int);
|
||||
const char * DecodeError(int);
|
||||
FILE * OpenFile(char *, char *, size_t);
|
||||
void PrintHostInfo(FILE *, const char *, HostInfo *);
|
||||
char * Calloc(int, int);
|
||||
char * Malloc(int);
|
||||
SIG_FN IntrHandler(int);
|
||||
int ListSubr(int, char *, char *);
|
||||
void FreeHostInfoPtr(HostInfo *);
|
||||
unsigned char * res_skip(unsigned char *, int, unsigned char *);
|
||||
extern Boolean IsAddr(const char *, union res_sockaddr_union *);
|
||||
void PrintHelp(void);
|
||||
int GetHostInfoByAddr(union res_sockaddr_union *, union res_sockaddr_union *,
|
||||
HostInfo *);
|
||||
|
||||
Loaded 100 of 3535 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user