mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 18:45:07 -05:00
Compare commits
2392 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d869d8709 | ||
|
|
4f94e22b4b | ||
|
|
d9b720471d | ||
|
|
039b388c82 | ||
|
|
3f6528da77 | ||
|
|
4f43c060a3 | ||
|
|
3e55fe6919 | ||
|
|
754097944b | ||
|
|
dd6a25edf2 | ||
|
|
e697833976 | ||
|
|
40d80624f6 | ||
|
|
9a716cc284 | ||
|
|
13a78ecd2f | ||
|
|
a9f0c681cb | ||
|
|
862aa285a2 | ||
|
|
84d2811800 | ||
|
|
635a9d3f5a | ||
|
|
81f7f6ddf0 | ||
|
|
aa22c515ce | ||
|
|
2ca2c85365 | ||
|
|
966e6fd939 | ||
|
|
4f0dd72cf0 | ||
|
|
69aa2eff99 | ||
|
|
3e1ec36ca5 | ||
|
|
224ab8ddb1 | ||
|
|
307c2ec70f | ||
|
|
5381fb4ee9 | ||
|
|
3812ec2aa2 | ||
|
|
4e7690ebec | ||
|
|
cf3d976a68 | ||
|
|
26fc28c056 | ||
|
|
d2117ab697 | ||
|
|
52b29f673f | ||
|
|
e86b60a9d7 | ||
|
|
53501b743f | ||
|
|
c61ddb70da | ||
|
|
9339766bfe | ||
|
|
f60410016a | ||
|
|
7a02371698 | ||
|
|
579d8c9907 | ||
|
|
10c760a80c | ||
|
|
2d39a12f51 | ||
|
|
517b1ae29a | ||
|
|
b7347d931b | ||
|
|
4f878ba144 | ||
|
|
8acdb5d1e2 | ||
|
|
62f2d5736d | ||
|
|
dc22df93f5 | ||
|
|
d898bd246b | ||
|
|
ebf0ff2c0d | ||
|
|
cc77b0e9fd | ||
|
|
a8bc25e543 | ||
|
|
6615bb1b78 | ||
|
|
f650b8c515 | ||
|
|
ae2e0318d1 | ||
|
|
26ce610155 | ||
|
|
316d47e3b4 | ||
|
|
90557cf1ba | ||
|
|
80e627c86b | ||
|
|
0e4995e10b | ||
|
|
a598983f9b | ||
|
|
27641876c5 | ||
|
|
4d139eeca6 | ||
|
|
3f2806c19c | ||
|
|
e297df78e4 | ||
|
|
c1d56ede3f | ||
|
|
2e52aca3bf | ||
|
|
b0fc5832f4 | ||
|
|
cf6af112e1 | ||
|
|
fa3052e776 | ||
|
|
f8610d69f0 | ||
|
|
1a8dcce84f | ||
|
|
f74eb67567 | ||
|
|
144fcdde34 | ||
|
|
3cef7f975c | ||
|
|
a2372b0c3a | ||
|
|
362d7c517d | ||
|
|
62389b7e50 | ||
|
|
eb9e6701fd | ||
|
|
b585954b21 | ||
|
|
82ddc6a883 | ||
|
|
624b76e86e | ||
|
|
4dd0aece02 | ||
|
|
e85fb0c25e | ||
|
|
fc8783a933 | ||
|
|
e7897eb9cc | ||
|
|
59e8b79034 | ||
|
|
fb7475bf59 | ||
|
|
cd98516cae | ||
|
|
e399d8dd1f | ||
|
|
d327cfea5a | ||
|
|
c94e7c72e7 | ||
|
|
f3aea33ad4 | ||
|
|
48709d9c4a | ||
|
|
4779adcb50 | ||
|
|
01e29ec685 | ||
|
|
e4cccc115d | ||
|
|
8e9716d5d4 | ||
|
|
a96d288027 | ||
|
|
545d2563ef | ||
|
|
1494ef1df3 | ||
|
|
698f270b5b | ||
|
|
f15f6a86b0 | ||
|
|
5d60d611ae | ||
|
|
6e71e902c8 | ||
|
|
473cb3c968 | ||
|
|
df43ebe9e0 | ||
|
|
642173e864 | ||
|
|
944cf6e318 | ||
|
|
a655eab34f | ||
|
|
f020d479e0 | ||
|
|
de752b28de | ||
|
|
f41d370e6a | ||
|
|
a97830d9d6 | ||
|
|
ea4fc47cda | ||
|
|
0e08ca7c89 | ||
|
|
068cd3c311 | ||
|
|
455b8e4b44 | ||
|
|
d9a363606b | ||
|
|
59ad433b6b | ||
|
|
35b3a42ed9 | ||
|
|
0639205617 | ||
|
|
3916c3366b | ||
|
|
f0a33e7b28 | ||
|
|
c9b8f8bc70 | ||
|
|
983b0723f6 | ||
|
|
02c38934ea | ||
|
|
c28c2cde43 | ||
|
|
349323dec7 | ||
|
|
ddfaf2e542 | ||
|
|
3177474ae8 | ||
|
|
cc535632d1 | ||
|
|
cb8ee57b9e | ||
|
|
c0b19b3fea | ||
|
|
8235da6885 | ||
|
|
f6625717cd | ||
|
|
fdfcabd79b | ||
|
|
2bb88b45c6 | ||
|
|
9820c22c1d | ||
|
|
bcd7bad467 | ||
|
|
83ea9fe284 | ||
|
|
c74d6e458d | ||
|
|
ff466439fc | ||
|
|
0fcdf4389b | ||
|
|
9cb9021c87 | ||
|
|
9c36236742 | ||
|
|
adebb027be | ||
|
|
7d3798d7cd | ||
|
|
b7c7c293e5 | ||
|
|
9ca250755f | ||
|
|
bd3b36865e | ||
|
|
538e1c5eb1 | ||
|
|
009f1a5ae8 | ||
|
|
4f1418abf9 | ||
|
|
79b348f075 | ||
|
|
9d88c028e2 | ||
|
|
51172b3510 | ||
|
|
892636036a | ||
|
|
4cf6b29397 | ||
|
|
571359b366 | ||
|
|
0f009e7718 | ||
|
|
24effd7340 | ||
|
|
5289fc5f80 | ||
|
|
ca49304bd6 | ||
|
|
b7fbac617d | ||
|
|
839e9aa4af | ||
|
|
c5ac15ad33 | ||
|
|
598cd10c34 | ||
|
|
1885729024 | ||
|
|
2127f63961 | ||
|
|
97a8b1e43b | ||
|
|
aeee1feda6 | ||
|
|
18d9243eb9 | ||
|
|
1aa4827b3b | ||
|
|
ed1077a788 | ||
|
|
356c475a6a | ||
|
|
9ac582fa35 | ||
|
|
8c75f44603 | ||
|
|
0a63ad95ce | ||
|
|
d274fe44da | ||
|
|
6d1cb58d8f | ||
|
|
784122d44f | ||
|
|
32fb8d41ca | ||
|
|
4993c35e11 | ||
|
|
6a5665ca58 | ||
|
|
e5cf006378 | ||
|
|
0e51552d2d | ||
|
|
cc007ad93b | ||
|
|
3096926547 | ||
|
|
d48f012809 | ||
|
|
def137bc80 | ||
|
|
3e0272e55f | ||
|
|
be503bbcf6 | ||
|
|
72bf3d26eb | ||
|
|
cc20ead3dc | ||
|
|
fd8fbcd090 | ||
|
|
77bd0f83fe | ||
|
|
32a82a38fd | ||
|
|
66e097e3e6 | ||
|
|
51d77d6cfc | ||
|
|
2bb0769516 | ||
|
|
58da0c0ad2 | ||
|
|
c10b66b579 | ||
|
|
55a90c3735 | ||
|
|
962afb9e7d | ||
|
|
7abd982f87 | ||
|
|
c099aac79c | ||
|
|
828e6ce30f | ||
|
|
dc08cbfe59 | ||
|
|
3bdcce6903 | ||
|
|
d93aa10bac | ||
|
|
de4ecc72d1 | ||
|
|
db54bfc0c1 | ||
|
|
72ee80debe | ||
|
|
a3436c26f0 | ||
|
|
b0f5024d56 | ||
|
|
eae4b2abe5 | ||
|
|
ff03b813b0 | ||
|
|
4e747da4b4 | ||
|
|
99e3c67a81 | ||
|
|
c4a2550518 | ||
|
|
4ef944b734 | ||
|
|
0f04baeb97 | ||
|
|
bf7f63eaed | ||
|
|
59cf4e0b96 | ||
|
|
3fc72c0cfa | ||
|
|
ad69f4f32b | ||
|
|
81c2b2e886 | ||
|
|
c9f03fb222 | ||
|
|
b0fe443632 | ||
|
|
8882fb21e0 | ||
|
|
7d551d34a0 | ||
|
|
feef0dd983 | ||
|
|
d29f7b7c70 | ||
|
|
e3cd248f0d | ||
|
|
27e20a568b | ||
|
|
80316de3b8 | ||
|
|
f9e2a5852d | ||
|
|
500c9cbf3b | ||
|
|
46714fec2d | ||
|
|
e1d9a57bd0 | ||
|
|
1b82604f61 | ||
|
|
d69ac07183 | ||
|
|
519796de37 | ||
|
|
ea4811b3b3 | ||
|
|
951f14ae06 | ||
|
|
428f9e4228 | ||
|
|
ea425bf01e | ||
|
|
8567a0e466 | ||
|
|
f6bf12bdcd | ||
|
|
e8968ea429 | ||
|
|
cf10ce1b68 | ||
|
|
15dc83420d | ||
|
|
37dbc211cd | ||
|
|
ed78cda6ad | ||
|
|
faff931a76 | ||
|
|
1e68671690 | ||
|
|
8eb167fd21 | ||
|
|
bc46174e98 | ||
|
|
b86c89460a | ||
|
|
03541f3626 | ||
|
|
39a462496a | ||
|
|
7ba8994838 | ||
|
|
8da025da99 | ||
|
|
5dc7242703 | ||
|
|
11bffa0d55 | ||
|
|
5f6f265f80 | ||
|
|
bf92314dc4 | ||
|
|
a3fda9f992 | ||
|
|
cd34b377aa | ||
|
|
145423068b | ||
|
|
fb4c3f31c0 | ||
|
|
60049f1551 | ||
|
|
e555548dda | ||
|
|
eedf61b3a2 | ||
|
|
ab54f76a38 | ||
|
|
f8df4789b1 | ||
|
|
6366ebc17e | ||
|
|
3a2d33d5a3 | ||
|
|
1afd5b23d7 | ||
|
|
17fb9e3709 | ||
|
|
7a7295992f | ||
|
|
526974366f | ||
|
|
51fe589aeb | ||
|
|
28cf4acf13 | ||
|
|
ee2220f2e7 | ||
|
|
a6ec6ec3ac | ||
|
|
4f5343f086 | ||
|
|
79c7384e5e | ||
|
|
75beeaf2b0 | ||
|
|
f4ed2abdca | ||
|
|
11a5c7337a | ||
|
|
972c476c5a | ||
|
|
a8c8f2f309 | ||
|
|
a0d2513be6 | ||
|
|
43dc0b3295 | ||
|
|
195ff5c51b | ||
|
|
e49aececce | ||
|
|
814b07c3a2 | ||
|
|
3470ab66f0 | ||
|
|
6901df5c18 | ||
|
|
bddb3b3228 | ||
|
|
dfe877144a | ||
|
|
59a9b7a9f6 | ||
|
|
ad8fb64276 | ||
|
|
436c1d3ea2 | ||
|
|
7fc5da5f80 | ||
|
|
105b3faa46 | ||
|
|
709223826f | ||
|
|
eace93f2af | ||
|
|
2775846db7 | ||
|
|
4aff08e95d | ||
|
|
958d66f8a7 | ||
|
|
85fa29c43d | ||
|
|
0344b9a9c9 | ||
|
|
04f6329773 | ||
|
|
d690faeb19 | ||
|
|
0b2e77ae64 | ||
|
|
2a4fd0a5c6 | ||
|
|
e569e1c9d9 | ||
|
|
7be360041c | ||
|
|
2fa83b541c | ||
|
|
8db9d59dac | ||
|
|
adcf073484 | ||
|
|
5296858411 | ||
|
|
d603426389 | ||
|
|
d3f4292968 | ||
|
|
4dde7198c8 | ||
|
|
b145d3ff51 | ||
|
|
9b98247d9c | ||
|
|
eedabb3d27 | ||
|
|
66dc2b6d6b | ||
|
|
bcdbbbd694 | ||
|
|
7b07e47c08 | ||
|
|
a608496faf | ||
|
|
c687224a11 | ||
|
|
a6f2a613f3 | ||
|
|
cfa39af345 | ||
|
|
8bab35c122 | ||
|
|
b20ef4cd7f | ||
|
|
b8b751a932 | ||
|
|
4a390841eb | ||
|
|
f506f44033 | ||
|
|
1f8355f154 | ||
|
|
ddc2761498 | ||
|
|
8b50a8298a | ||
|
|
3eab329042 | ||
|
|
552d3b53b1 | ||
|
|
8afd62d954 | ||
|
|
4883086fc1 | ||
|
|
2582be8754 | ||
|
|
ff9301567e | ||
|
|
e7a254265f | ||
|
|
d5311adafb | ||
|
|
18d7ea62b3 | ||
|
|
fb2849b230 | ||
|
|
fd59877692 | ||
|
|
bb0553e4c4 | ||
|
|
46f954490d | ||
|
|
31e6a50386 | ||
|
|
9a9c0d7b99 | ||
|
|
0c80f00d0b | ||
|
|
27b3bf48ea | ||
|
|
c3e34b8145 | ||
|
|
7bf3ec4aeb | ||
|
|
50204a125b | ||
|
|
111d170542 | ||
|
|
d6dd6f0bc9 | ||
|
|
44aac84feb | ||
|
|
c41508723f | ||
|
|
6043632f80 | ||
|
|
a420ed57a1 | ||
|
|
72f99033fe | ||
|
|
2d798bc4cf | ||
|
|
881d07fa0a | ||
|
|
c5306bed39 | ||
|
|
934b8712a5 | ||
|
|
1d4690eb64 | ||
|
|
e6848b1e3f | ||
|
|
3e537416a9 | ||
|
|
26a1ed8bc3 | ||
|
|
24538fe3e9 | ||
|
|
e43d699973 | ||
|
|
1e727c4497 | ||
|
|
83010590af | ||
|
|
fa402a173a | ||
|
|
ca83d2a804 | ||
|
|
725beb360a | ||
|
|
86d29221f3 | ||
|
|
e8062b7ff1 | ||
|
|
9468fd4aa6 | ||
|
|
5ed9b888ff | ||
|
|
7661a6e95b | ||
|
|
aca1daf7c9 | ||
|
|
46cac4e22f | ||
|
|
56a102ed4d | ||
|
|
ca28dbd2c3 | ||
|
|
588785e160 | ||
|
|
cabcccd6c3 | ||
|
|
567e66a0bb | ||
|
|
b8ee6d6e56 | ||
|
|
9ea1e4e40f | ||
|
|
2d492eacb5 | ||
|
|
cb8660e79a | ||
|
|
d29bef93e9 | ||
|
|
5a09adebfd | ||
|
|
8c0ee9c175 | ||
|
|
f20fabdbf4 | ||
|
|
57cea56e6e | ||
|
|
db7d9639b4 | ||
|
|
beb40d63ed | ||
|
|
672b98dd3f | ||
|
|
a24d2713cd | ||
|
|
a5110d3ed9 | ||
|
|
9d1c1505b9 | ||
|
|
8c25632321 | ||
|
|
2507b66640 | ||
|
|
d7e3ad17ff | ||
|
|
84902d0e00 | ||
|
|
f7f3667bcb | ||
|
|
794cbfbbb5 | ||
|
|
1858104b5c | ||
|
|
994409a036 | ||
|
|
2d9eb5b6fa | ||
|
|
3477cbe28f | ||
|
|
8634158de0 | ||
|
|
3eaf0765b0 | ||
|
|
dd0679ad45 | ||
|
|
bfcd8ecc56 | ||
|
|
50e5865c73 | ||
|
|
93f6358916 | ||
|
|
9300854439 | ||
|
|
02914ac637 | ||
|
|
00fff161cf | ||
|
|
3763befd62 | ||
|
|
2ae008bcee | ||
|
|
ea41f7ab09 | ||
|
|
c673b1e8b7 | ||
|
|
2bf1ba22f2 | ||
|
|
dfc2f70876 | ||
|
|
0dba2b9689 | ||
|
|
e7fc2d31cc | ||
|
|
f231efb811 | ||
|
|
c4d6f98bed | ||
|
|
bff3f51d13 | ||
|
|
f5eb7daf20 | ||
|
|
d66b2f2b24 | ||
|
|
a57e1eb542 | ||
|
|
25bdee7a0e | ||
|
|
f6001202ec | ||
|
|
0cf506c929 | ||
|
|
d05e9fb2ec | ||
|
|
54d7e3e94a | ||
|
|
c7223f4c8f | ||
|
|
07badbede7 | ||
|
|
468cfeeb71 | ||
|
|
b3fc549622 | ||
|
|
077dbd5692 | ||
|
|
e18903a6b5 | ||
|
|
7dfd4ae556 | ||
|
|
429c4468b0 | ||
|
|
7a4c396bba | ||
|
|
88f846f656 | ||
|
|
27c8a64977 | ||
|
|
2fc8edacb8 | ||
|
|
903fa247f8 | ||
|
|
96771d6857 | ||
|
|
f4c6a00b2a | ||
|
|
990f8cd89b | ||
|
|
813ea71b50 | ||
|
|
e8be384cdf | ||
|
|
61773a2c07 | ||
|
|
510aa8b050 | ||
|
|
57957ab6cf | ||
|
|
e8069a0179 | ||
|
|
f3f840551a | ||
|
|
10a42c1e04 | ||
|
|
4a219ecbf1 | ||
|
|
0d298bfc4c | ||
|
|
792c241e3a | ||
|
|
6336a87855 | ||
|
|
f5721b1212 | ||
|
|
7d3e9180c6 | ||
|
|
03b8ca186a | ||
|
|
435cbef31a | ||
|
|
4adcf58368 | ||
|
|
004986310d | ||
|
|
7a88e0a87b | ||
|
|
64e21d6281 | ||
|
|
9ef7ea2bcb | ||
|
|
6d1796d6be | ||
|
|
fcaba98101 | ||
|
|
9bbda5c964 | ||
|
|
2c81d38861 | ||
|
|
78fec3f05a | ||
|
|
392a1a5ff6 | ||
|
|
219a414cb7 | ||
|
|
58fc81441b | ||
|
|
02ada36838 | ||
|
|
81978f0ba0 | ||
|
|
622769cdfd | ||
|
|
3038047f9b | ||
|
|
3e3f045ab7 | ||
|
|
a6d9f41eda | ||
|
|
bf6a4e1a81 | ||
|
|
5982d96b75 | ||
|
|
28e3e4cdca | ||
|
|
24134c78e8 | ||
|
|
5e8ed72b89 | ||
|
|
45e41b7ac1 | ||
|
|
27fd751915 | ||
|
|
4d26cfc92b | ||
|
|
d78680912e | ||
|
|
47e4cb31b2 | ||
|
|
91da65a782 | ||
|
|
bb1c02e9f5 | ||
|
|
c651ea9b6b | ||
|
|
207f9fb128 | ||
|
|
f06c1cfa97 | ||
|
|
6cd47bff8f | ||
|
|
2de24cfd82 | ||
|
|
86a3ef9ed1 | ||
|
|
3f8c57c8f2 | ||
|
|
ca96946416 | ||
|
|
e5b9b6d701 | ||
|
|
8cb689a5e6 | ||
|
|
2270234115 | ||
|
|
a073f383e6 | ||
|
|
8e74655b03 | ||
|
|
70fa3a6905 | ||
|
|
1227873b88 | ||
|
|
d30e73d0d9 | ||
|
|
9e7a7008de | ||
|
|
62d6aed6a6 | ||
|
|
ffb9887cce | ||
|
|
9220c9b8a2 | ||
|
|
2e28b19112 | ||
|
|
636a4e2794 | ||
|
|
5c9e1e0b69 | ||
|
|
64fd1b8ba5 | ||
|
|
69d3913f3e | ||
|
|
08fd011b6a | ||
|
|
c172268cfe | ||
|
|
94b014865c | ||
|
|
099aaf2cb1 | ||
|
|
4481a8b24f | ||
|
|
b626fe661e | ||
|
|
ba8fcd145d | ||
|
|
981d09de40 | ||
|
|
86a99bb257 | ||
|
|
3093a11cd0 | ||
|
|
058b788d38 | ||
|
|
66a42fa493 | ||
|
|
a85f63cc15 | ||
|
|
bbe1e69dcc | ||
|
|
1b52bba7b9 | ||
|
|
c5c80ef400 | ||
|
|
a78031ce0d | ||
|
|
34e9dd13ce | ||
|
|
6e52a9be7a | ||
|
|
69c6dffd63 | ||
|
|
2ddd0ae231 | ||
|
|
79db0b7eca | ||
|
|
2ebba7fbaa | ||
|
|
e392d1fde9 | ||
|
|
d7c93ec950 | ||
|
|
6af39d63aa | ||
|
|
cc8414b1b3 | ||
|
|
6b44055e3d | ||
|
|
9f9c6cc6ab | ||
|
|
f176193d35 | ||
|
|
e8bc41e862 | ||
|
|
91dbe3c6c2 | ||
|
|
3e876d4218 | ||
|
|
31b1f2e8a1 | ||
|
|
4169e94b1d | ||
|
|
948ecf8431 | ||
|
|
91f3f97ea7 | ||
|
|
65bb65b440 | ||
|
|
ea6e8d85a3 | ||
|
|
add932501f | ||
|
|
89390a738f | ||
|
|
ac4f6ab93b | ||
|
|
dbcb1b9b0b | ||
|
|
6375307798 | ||
|
|
fb78e60d26 | ||
|
|
b822c7164f | ||
|
|
aa295730a0 | ||
|
|
69d70703b2 | ||
|
|
b2b6ef00dc | ||
|
|
5dc86c236b | ||
|
|
2563dd9d29 | ||
|
|
a899e3df33 | ||
|
|
692cea49f8 | ||
|
|
bcedacaa3d | ||
|
|
be3c1b5243 | ||
|
|
e626ec6c37 | ||
|
|
49d52b547f | ||
|
|
74a546a9e7 | ||
|
|
d1777087c1 | ||
|
|
cf7b5363cd | ||
|
|
7f3183cc72 | ||
|
|
f1b8da085b | ||
|
|
09dfca49ec | ||
|
|
88e0ec07aa | ||
|
|
0adc8e8f92 | ||
|
|
5fc7674e36 | ||
|
|
018977044a | ||
|
|
cc49d8e6e6 | ||
|
|
933bd017b4 | ||
|
|
d558b33d85 | ||
|
|
9268bf2cff | ||
|
|
dbf2c22467 | ||
|
|
af4fe92095 | ||
|
|
e034a07be8 | ||
|
|
eb8c9ad601 | ||
|
|
6847536669 | ||
|
|
f5206db9b0 | ||
|
|
6ab2ed0da6 | ||
|
|
7352e470e1 | ||
|
|
5bc9c0d07a | ||
|
|
a2146e82ef | ||
|
|
6e10e6740c | ||
|
|
bfaa10f2b0 | ||
|
|
9f167a7997 | ||
|
|
6908163464 | ||
|
|
671daf06b8 | ||
|
|
b189a5386b | ||
|
|
7889d108c2 | ||
|
|
3cfa8ce9d3 | ||
|
|
570573fe28 | ||
|
|
62b1a11736 | ||
|
|
c00d517e12 | ||
|
|
001f3d5e27 | ||
|
|
6045023a49 | ||
|
|
bba29a0ee7 | ||
|
|
cffc856b50 | ||
|
|
419077e04b | ||
|
|
7db9d4acea | ||
|
|
8d5b86efe7 | ||
|
|
6cf16aea7b | ||
|
|
870545d3cb | ||
|
|
2a030c0d0c | ||
|
|
0b709ab1bc | ||
|
|
a1f2f17385 | ||
|
|
2240eefbd0 | ||
|
|
706d0c281a | ||
|
|
ca73e34f30 | ||
|
|
cca2ef4649 | ||
|
|
05d9edbf8f | ||
|
|
c5bdc52a59 | ||
|
|
74f0c0924a | ||
|
|
05492d1d23 | ||
|
|
eea343b93f | ||
|
|
afff06c88c | ||
|
|
c0717a27f6 | ||
|
|
159bd73f76 | ||
|
|
9931a9166b | ||
|
|
8aa4ae027b | ||
|
|
dcce79fdbe | ||
|
|
189aafde9d | ||
|
|
99e3045df4 | ||
|
|
c498c21fad | ||
|
|
6bef8aa0e9 | ||
|
|
108d112272 | ||
|
|
05078e4252 | ||
|
|
4ceb9e4cd0 | ||
|
|
a9f237a395 | ||
|
|
e7ca560c3d | ||
|
|
d9f86f6f70 | ||
|
|
879d936277 | ||
|
|
5bb2bf9361 | ||
|
|
a8167b7959 | ||
|
|
b33b682356 | ||
|
|
2c47602c33 | ||
|
|
59d1b41716 | ||
|
|
5b75d4afef | ||
|
|
e15c7cd236 | ||
|
|
9bc774d6af | ||
|
|
9b34556952 | ||
|
|
9a6369d8f1 | ||
|
|
49cdd6bf09 | ||
|
|
63fe34e890 | ||
|
|
85465afb62 | ||
|
|
339cb06a49 | ||
|
|
10150bfcab | ||
|
|
e50dc739d8 | ||
|
|
26e08abe71 | ||
|
|
7637faa0d0 | ||
|
|
8a57a28177 | ||
|
|
34db671b57 | ||
|
|
8b9021bf34 | ||
|
|
ce6b896948 | ||
|
|
2962fc6286 | ||
|
|
76bed76289 | ||
|
|
113f2ebec0 | ||
|
|
7c5bd948bb | ||
|
|
8cbc68f28f | ||
|
|
bf7aa52394 | ||
|
|
366345790d | ||
|
|
f881c153bf | ||
|
|
19f3ab2225 | ||
|
|
fd1e80802f | ||
|
|
4b7cb161a8 | ||
|
|
7848794222 | ||
|
|
94822d5156 | ||
|
|
e3f840aae9 | ||
|
|
5aae563277 | ||
|
|
02de782fa3 | ||
|
|
3f6df33feb | ||
|
|
a94f5fe007 | ||
|
|
63f0234748 | ||
|
|
47921c7c0c | ||
|
|
42a85f685e | ||
|
|
feca2399e4 | ||
|
|
d34e611ec8 | ||
|
|
02098ed830 | ||
|
|
aa4228bf1b | ||
|
|
b296441708 | ||
|
|
b827475378 | ||
|
|
78a6698ae1 | ||
|
|
e7b6feb34b | ||
|
|
84be834385 | ||
|
|
e83d808dfd | ||
|
|
35a68d5b59 | ||
|
|
3c593137b0 | ||
|
|
deaf0ffed3 | ||
|
|
af145e871e | ||
|
|
fbca570d0b | ||
|
|
448ef779c2 | ||
|
|
499a69e611 | ||
|
|
58c2915878 | ||
|
|
eda4b111d3 | ||
|
|
c6dd749687 | ||
|
|
d2a96f5fbc | ||
|
|
499f513d40 | ||
|
|
8b1f68b1b4 | ||
|
|
8e4c776900 | ||
|
|
d0eb9427c2 | ||
|
|
7d100b89fc | ||
|
|
a4bd7f1800 | ||
|
|
5308e0a25f | ||
|
|
da862158bf | ||
|
|
7b98443a13 | ||
|
|
4da9f74d24 | ||
|
|
e41042e258 | ||
|
|
5581466c63 | ||
|
|
e79a6c2116 | ||
|
|
666ece122e | ||
|
|
2c7ab98370 | ||
|
|
f0f18a02a7 | ||
|
|
c5d8af0285 | ||
|
|
0ce15a8472 | ||
|
|
da60629201 | ||
|
|
2343e7a89c | ||
|
|
45f27f4f5e | ||
|
|
0bc112f8b4 | ||
|
|
bfc2fa645c | ||
|
|
11111804fd | ||
|
|
87ec67247e | ||
|
|
0df8328ceb | ||
|
|
b563048ee2 | ||
|
|
e8096330be | ||
|
|
b1647dbcb7 | ||
|
|
4ddadd5622 | ||
|
|
3e854006c7 | ||
|
|
2c4c235147 | ||
|
|
6863e43269 | ||
|
|
de8708f331 | ||
|
|
d0b2486036 | ||
|
|
5384a93645 | ||
|
|
4bbc768652 | ||
|
|
fead915b45 | ||
|
|
5422e49026 | ||
|
|
77a1f27a1d | ||
|
|
b45d864f73 | ||
|
|
f35c81c871 | ||
|
|
a349b2803c | ||
|
|
f5d1b8fb74 | ||
|
|
a0fe71eef1 | ||
|
|
154b39cf7a | ||
|
|
6f54210db2 | ||
|
|
f6539449c5 | ||
|
|
b8d546a0d1 | ||
|
|
04e6474b75 | ||
|
|
eb51c500e8 | ||
|
|
6f8fba9a3f | ||
|
|
750afc30f2 | ||
|
|
e0e6ec0d84 | ||
|
|
c9f50fc686 | ||
|
|
83c26b458b | ||
|
|
b711873f45 | ||
|
|
c68ca40ce4 | ||
|
|
51fe80ad95 | ||
|
|
7ffee73524 | ||
|
|
f40b0024bd | ||
|
|
a06c9909a6 | ||
|
|
aee42fada8 | ||
|
|
3e93068c43 | ||
|
|
36291b707b | ||
|
|
6dad2c24bf | ||
|
|
27cbf20d23 | ||
|
|
5c571bbbe7 | ||
|
|
33d65c8614 | ||
|
|
d87db7cdb8 | ||
|
|
45fa4750da | ||
|
|
8472fd8133 | ||
|
|
5ab645e310 | ||
|
|
8ccda538d3 | ||
|
|
b06d74ab73 | ||
|
|
d0964ffa83 | ||
|
|
3d08815efb | ||
|
|
a83f0d3cdc | ||
|
|
702db726d3 | ||
|
|
ed5c43204b | ||
|
|
f91bdd604d | ||
|
|
3a1dbb1354 | ||
|
|
4b511143b8 | ||
|
|
93076e7e1c | ||
|
|
1c51feb3c5 | ||
|
|
c2773dbc2f | ||
|
|
4534db84c4 | ||
|
|
be8215e181 | ||
|
|
ae82bbbace | ||
|
|
2b6ea41062 | ||
|
|
d9f745fe70 | ||
|
|
9aac179367 | ||
|
|
b896bb5a78 | ||
|
|
64c2fd9888 | ||
|
|
2668a12e4e | ||
|
|
e1645966ec | ||
|
|
4f1fc1ee78 | ||
|
|
d70df3daab | ||
|
|
554b9b06de | ||
|
|
f734bd1a7c | ||
|
|
77fc5c42b9 | ||
|
|
ea85bc43e0 | ||
|
|
e8fb11c433 | ||
|
|
01a29c7a11 | ||
|
|
6ec3dc1650 | ||
|
|
0c54cf316d | ||
|
|
bd3fb49a1e | ||
|
|
f6e72a80e1 | ||
|
|
c2ab1426e5 | ||
|
|
fa2c59d78d | ||
|
|
16afa8eb50 | ||
|
|
992590e99c | ||
|
|
0baa35eade | ||
|
|
2e0870ee0c | ||
|
|
43cd119d6d | ||
|
|
62cd319a51 | ||
|
|
d0f789425b | ||
|
|
30e6549692 | ||
|
|
043c7d7c9f | ||
|
|
1c277a8850 | ||
|
|
ccb94ac5fb | ||
|
|
778fce4039 | ||
|
|
9983185d6d | ||
|
|
7bd1c02781 | ||
|
|
760285218f | ||
|
|
4fe0e6b7fd | ||
|
|
0773a1e630 | ||
|
|
4a24368763 | ||
|
|
577290c5bc | ||
|
|
854ff69f78 | ||
|
|
29b0ad894c | ||
|
|
cde0a20307 | ||
|
|
a768578a26 | ||
|
|
5d838729ef | ||
|
|
d6b763dc24 | ||
|
|
95adb52a45 | ||
|
|
707d9a3484 | ||
|
|
1872d4d195 | ||
|
|
17f32c266e | ||
|
|
6207655ab2 | ||
|
|
5e1e31ad5f | ||
|
|
13111c1dd8 | ||
|
|
85c84073c1 | ||
|
|
c2944d8727 | ||
|
|
e118b9b1e8 | ||
|
|
7fb7f95979 | ||
|
|
cc507bffae | ||
|
|
0dbfe020ad | ||
|
|
018a1c42b0 | ||
|
|
c5735ebfe9 | ||
|
|
db93180ce1 | ||
|
|
39da10d939 | ||
|
|
f2da253bc3 | ||
|
|
934d4047f1 | ||
|
|
b799cfd1c4 | ||
|
|
b712c100d7 | ||
|
|
c049bce007 | ||
|
|
46fad717e5 | ||
|
|
ae0c3bbbe8 | ||
|
|
f95d57e0d9 | ||
|
|
a1cbd4eb82 | ||
|
|
6cbeb107db | ||
|
|
3a5566c6c3 | ||
|
|
73c548ad01 | ||
|
|
82203e12c8 | ||
|
|
1ca099473f | ||
|
|
eceb8d9937 | ||
|
|
4ba92bb6d6 | ||
|
|
f31f68ae8e | ||
|
|
cff15f91d4 | ||
|
|
6b74917954 | ||
|
|
1bf2384a1f | ||
|
|
54a12779e2 | ||
|
|
e8b06fef9f | ||
|
|
653d70ec4e | ||
|
|
abb09418b1 | ||
|
|
c103bebd9f | ||
|
|
935d855b47 | ||
|
|
f8f9100a0d | ||
|
|
6de7b98e76 | ||
|
|
c390351c65 | ||
|
|
768bce799b | ||
|
|
d3a30142e5 | ||
|
|
3a635fc51f | ||
|
|
10078566da | ||
|
|
c44346096c | ||
|
|
0ff449e6a6 | ||
|
|
f3a16383b9 | ||
|
|
539ef3f770 | ||
|
|
f282856c72 | ||
|
|
6db8ec1ba2 | ||
|
|
5187c08c90 | ||
|
|
c8076ac10d | ||
|
|
362d155558 | ||
|
|
7b7eb0a6e5 | ||
|
|
d96f49f67d | ||
|
|
43ba5d2126 | ||
|
|
48f7598fed | ||
|
|
510b22e96b | ||
|
|
0a0aff14d8 | ||
|
|
e225ac68bc | ||
|
|
58060c40a5 | ||
|
|
2ac1b3d5c4 | ||
|
|
c174566982 | ||
|
|
60fca19d40 | ||
|
|
8bcb15b02f | ||
|
|
65c2cebcd5 | ||
|
|
2a51b45a43 | ||
|
|
5ac791665e | ||
|
|
a4e3f83611 | ||
|
|
8a837f9c2b | ||
|
|
da2d33e9a8 | ||
|
|
4b98dadae9 | ||
|
|
86acea5c46 | ||
|
|
a60fc73e7b | ||
|
|
50f99ec5f4 | ||
|
|
31b6a14444 | ||
|
|
9df4d36157 | ||
|
|
b70f0b674f | ||
|
|
510784077f | ||
|
|
9800e397fb | ||
|
|
1436d9961f | ||
|
|
98f5d05925 | ||
|
|
7a937c7652 | ||
|
|
b198d76676 | ||
|
|
97d4203354 | ||
|
|
beaaaad162 | ||
|
|
4e78975909 | ||
|
|
99147ed8f2 | ||
|
|
dec0d3bfc2 | ||
|
|
cd84c99e70 | ||
|
|
d5c507975c | ||
|
|
b4235abd36 | ||
|
|
1966085a97 | ||
|
|
e31e7af48f | ||
|
|
adb9123fc3 | ||
|
|
b0f7efd59e | ||
|
|
e28dfada8c | ||
|
|
ac0b28cce6 | ||
|
|
48b16ae66c | ||
|
|
061579ec28 | ||
|
|
f2f834e7e7 | ||
|
|
a7802e9a76 | ||
|
|
8f7ab95ff0 | ||
|
|
042c670747 | ||
|
|
cacbe9976f | ||
|
|
8efec1d640 | ||
|
|
c44d282f0b | ||
|
|
4432f29bd2 | ||
|
|
5fee3ed5e9 | ||
|
|
b76ea64263 | ||
|
|
ed904f08a4 | ||
|
|
96cc80ffc8 | ||
|
|
ab99373cfc | ||
|
|
dbfb49384b | ||
|
|
14bb9f29a3 | ||
|
|
16519ee2cc | ||
|
|
50022e9286 | ||
|
|
5059019535 | ||
|
|
c6a38f5069 | ||
|
|
11ed197663 | ||
|
|
5634e6b963 | ||
|
|
db312a5ff6 | ||
|
|
88c31b3785 | ||
|
|
967f3e4f77 | ||
|
|
2e311d1766 | ||
|
|
11f7cc0507 | ||
|
|
a4f28892a5 | ||
|
|
5bc53741be | ||
|
|
95a4f33265 | ||
|
|
fac1093ebf | ||
|
|
1b1384ccaa | ||
|
|
0c9a19ded5 | ||
|
|
b7bd7469b7 | ||
|
|
9568ff3f06 | ||
|
|
742ddcce11 | ||
|
|
e72cc9e3da | ||
|
|
3156e5a293 | ||
|
|
9a901e1cb0 | ||
|
|
8c11044ee2 | ||
|
|
a75d2db75b | ||
|
|
6aac72fd80 | ||
|
|
b692cb720c | ||
|
|
25102489f5 | ||
|
|
a2d2cad384 | ||
|
|
859e0c2323 | ||
|
|
e62a39cafe | ||
|
|
8bbb8fa062 | ||
|
|
68039e0d14 | ||
|
|
65fd30a547 | ||
|
|
23a4e8b38d | ||
|
|
979b53866d | ||
|
|
46061d8eec | ||
|
|
946ee8f611 | ||
|
|
7f757f09ce | ||
|
|
9ba8a33966 | ||
|
|
492940568d | ||
|
|
b95c2a3f78 | ||
|
|
53b661b59d | ||
|
|
a049c9e0f8 | ||
|
|
3513484852 | ||
|
|
2d67871bbf | ||
|
|
e6e9a472db | ||
|
|
1d5d768545 | ||
|
|
6c8588c13c | ||
|
|
89b127bf6c | ||
|
|
38c4a7ff97 | ||
|
|
2f5b4aea91 | ||
|
|
4fc6a1b424 | ||
|
|
6b3800cc94 | ||
|
|
633a007b7b | ||
|
|
756c2e9afb | ||
|
|
27ea58d5fd | ||
|
|
64f9205189 | ||
|
|
535ca64bba | ||
|
|
7255f9ef74 | ||
|
|
cdb0b6124f | ||
|
|
5fb1107cc7 | ||
|
|
1045adaa88 | ||
|
|
ed286f3617 | ||
|
|
9f9dd7948b | ||
|
|
9c760de676 | ||
|
|
90229984cf | ||
|
|
2b3d64c31d | ||
|
|
d23c647e34 | ||
|
|
2408bbcd77 | ||
|
|
d75f6830f1 | ||
|
|
4d7eb2f7a6 | ||
|
|
3a67dedad6 | ||
|
|
518837e17a | ||
|
|
c7e778757a | ||
|
|
c45be946ce | ||
|
|
258bcc21b8 | ||
|
|
db286ca6ea | ||
|
|
85fbfd9b15 | ||
|
|
b819c7fe55 | ||
|
|
2b5c86b9a3 | ||
|
|
0a848e2528 | ||
|
|
b443ec5ea5 | ||
|
|
37d1467368 | ||
|
|
1d9d19d76b | ||
|
|
9603f0552a | ||
|
|
12befc2afd | ||
|
|
78f20f7b3e | ||
|
|
875b0e262c | ||
|
|
8823e2b064 | ||
|
|
5b2caf48dc | ||
|
|
7ec048ce7f | ||
|
|
cfb3c3ba44 | ||
|
|
4b0ef09221 | ||
|
|
74f581e7ab | ||
|
|
07aa54b183 | ||
|
|
00da177e51 | ||
|
|
6e9bfac07d | ||
|
|
06f93e7bf0 | ||
|
|
d84a706c08 | ||
|
|
ea58a1e72c | ||
|
|
5c691a5460 | ||
|
|
2c877fa149 | ||
|
|
33053a5e14 | ||
|
|
8662652192 | ||
|
|
227c7e60a4 | ||
|
|
6e9c04896b | ||
|
|
0e273939d2 | ||
|
|
14647032b2 | ||
|
|
14a1059e43 | ||
|
|
4449259d88 | ||
|
|
01e5ea7d31 | ||
|
|
94522bfed1 | ||
|
|
9bdd35c9fa | ||
|
|
d366530699 | ||
|
|
96d652e5bd | ||
|
|
bd736f9234 | ||
|
|
90b25f5b83 | ||
|
|
997406fe47 | ||
|
|
14c8f07629 | ||
|
|
8f6a1b5318 | ||
|
|
a8c6bea2d5 | ||
|
|
19fde8f49c | ||
|
|
8f85291d23 | ||
|
|
9c48166e90 | ||
|
|
b536296c05 | ||
|
|
d36c522453 | ||
|
|
2577e20f09 | ||
|
|
c169ad3f58 | ||
|
|
411f4697ca | ||
|
|
6c5de8dcb0 | ||
|
|
c8373f1649 | ||
|
|
45f86122fa | ||
|
|
c0a8afdb68 | ||
|
|
1afb285aad | ||
|
|
c08e7e716d | ||
|
|
a06a5f1baa | ||
|
|
fb5d4f1da4 | ||
|
|
d2e5b41369 | ||
|
|
4b6b6e5cba | ||
|
|
27b4c396d0 | ||
|
|
41eb5b79cb | ||
|
|
23cf74d5c7 | ||
|
|
1a038bfd50 | ||
|
|
dd02d67224 | ||
|
|
648bf8bd3e | ||
|
|
82c4bfe5d2 | ||
|
|
98ba4ce4d5 | ||
|
|
f63e414024 | ||
|
|
a8886603c2 | ||
|
|
4f10144b09 | ||
|
|
af664e6cec | ||
|
|
c30816eb65 | ||
|
|
b1accfd0ff | ||
|
|
5c45e4ccb5 | ||
|
|
41cf867738 | ||
|
|
02844e9b01 | ||
|
|
7a1ebc3467 | ||
|
|
8d89610ff6 | ||
|
|
cfe706f032 | ||
|
|
99cc94529d | ||
|
|
d0dfa1de9e | ||
|
|
0899ab52dd | ||
|
|
71e0ebcb6b | ||
|
|
e488371b01 | ||
|
|
39f34eb674 | ||
|
|
9d9d6c30cf | ||
|
|
27d59e54cc | ||
|
|
507a01ab17 | ||
|
|
f7b8cd1a09 | ||
|
|
8bc48af630 | ||
|
|
b0838280a9 | ||
|
|
cea21adbbb | ||
|
|
c619d555f0 | ||
|
|
e306199588 | ||
|
|
895c15d677 | ||
|
|
d18f9ca75a | ||
|
|
82e76c39d9 | ||
|
|
577aed4842 | ||
|
|
2a8ce63fc7 | ||
|
|
61dd4e0ccb | ||
|
|
8220e51ae4 | ||
|
|
d322c8e6e5 | ||
|
|
3dec266dd5 | ||
|
|
862938cc79 | ||
|
|
ee396702f2 | ||
|
|
316d50d6f1 | ||
|
|
5e92aaf8a5 | ||
|
|
7ffe59a734 | ||
|
|
6cd558398a | ||
|
|
632cd1a177 | ||
|
|
223ad0e8aa | ||
|
|
f8bd9ab378 | ||
|
|
d78e8f096c | ||
|
|
57fc2ff1be | ||
|
|
d8d096aa54 | ||
|
|
0a10545314 | ||
|
|
aeb57a36b2 | ||
|
|
b703bc32c9 | ||
|
|
09afdd4b36 | ||
|
|
5cadaf8d55 | ||
|
|
89ac745184 | ||
|
|
e2422023c4 | ||
|
|
1ec0813663 | ||
|
|
6ba7fad2a7 | ||
|
|
962ca91574 | ||
|
|
91cbebb629 | ||
|
|
722f038f1f | ||
|
|
5e61c002a6 | ||
|
|
46e1e79921 | ||
|
|
546e5e236c | ||
|
|
16a1a89bf4 | ||
|
|
8a996572d2 | ||
|
|
5f082b9a4d | ||
|
|
4622173135 | ||
|
|
99e1c44c25 | ||
|
|
b48e4421de | ||
|
|
d1f4e5876b | ||
|
|
71b7e689c0 | ||
|
|
26b87b844d | ||
|
|
1834ee05e5 | ||
|
|
7d7bf915ac | ||
|
|
d86e9f4aa3 | ||
|
|
942b52a3ca | ||
|
|
b252c57a22 | ||
|
|
2aab6a85a4 | ||
|
|
10719d6d35 | ||
|
|
59938efd23 | ||
|
|
53b15bd5c7 | ||
|
|
5084a8b342 | ||
|
|
4d1c795804 | ||
|
|
a9049569af | ||
|
|
dec1d2bfb2 | ||
|
|
62e66bda60 | ||
|
|
3abaa92926 | ||
|
|
37e6357c02 | ||
|
|
6accd19eb3 | ||
|
|
da96d334ab | ||
|
|
5a92dbe784 | ||
|
|
8fe5e9cf1e | ||
|
|
81f440a882 | ||
|
|
981f897c96 | ||
|
|
eb75ce7d07 | ||
|
|
5645e57ce0 | ||
|
|
a12c7c422b | ||
|
|
d70e815e9f | ||
|
|
eb329e9f52 | ||
|
|
5833be6ccf | ||
|
|
ea3950d57e | ||
|
|
3f51805e62 | ||
|
|
b45f53dd20 | ||
|
|
9749a1c6fc | ||
|
|
5ca5d279d7 | ||
|
|
7b52c1578f | ||
|
|
72975ce1f0 | ||
|
|
9a4c22db03 | ||
|
|
e7af875b68 | ||
|
|
4acca9b727 | ||
|
|
b2d93b2e38 | ||
|
|
74afffed0c | ||
|
|
5828426977 | ||
|
|
d04fb4b7fa | ||
|
|
f5fe3ab4a1 | ||
|
|
6b6b097fe8 | ||
|
|
4998afc9bb | ||
|
|
80f4d75968 | ||
|
|
910663c37b | ||
|
|
34a4695e81 | ||
|
|
fe00319f45 | ||
|
|
4c77d18416 | ||
|
|
a63e18edb8 | ||
|
|
8b676502de | ||
|
|
cf5b344ea8 | ||
|
|
4ab98f62e9 | ||
|
|
e6cc682f86 | ||
|
|
ff541e24fb | ||
|
|
008615370a | ||
|
|
beaf275222 | ||
|
|
400820d3f3 | ||
|
|
4eabc84a0c | ||
|
|
cf636a969e | ||
|
|
e3191e372b | ||
|
|
705e32acdc | ||
|
|
6e4dd9302d | ||
|
|
ea002130d7 | ||
|
|
7ba5ffa706 | ||
|
|
861ac013bc | ||
|
|
a6da963f45 | ||
|
|
55ba7ee2a1 | ||
|
|
3121f31ced | ||
|
|
da296db91d | ||
|
|
d36ca9288a | ||
|
|
8549043a3f | ||
|
|
e0ae2b4bb5 | ||
|
|
aad42ceaec | ||
|
|
f225469e6e | ||
|
|
7cc432ff7e | ||
|
|
0a9d75bfb8 | ||
|
|
070f2706b7 | ||
|
|
9b019a03e7 | ||
|
|
f52a738660 | ||
|
|
b80df5152a | ||
|
|
beb275a769 | ||
|
|
86c21a3a85 | ||
|
|
05236a4f23 | ||
|
|
a78bf9725a | ||
|
|
82fbb5c2f5 | ||
|
|
a592d82ad9 | ||
|
|
7fcf69ce5f | ||
|
|
32ac6ffa26 | ||
|
|
0d12410eaa | ||
|
|
54c8732c46 | ||
|
|
9b9d6ab150 | ||
|
|
c6554bfd30 | ||
|
|
83cd8ae39b | ||
|
|
23b9d80897 | ||
|
|
e98f76e084 | ||
|
|
936f5cb0f1 | ||
|
|
fa15fb3d53 | ||
|
|
62d61de93d | ||
|
|
ba81d68b07 | ||
|
|
ba25fb1bcc | ||
|
|
69642dd440 | ||
|
|
e5a593f013 | ||
|
|
acec7d0e28 | ||
|
|
a4c89e5bbe | ||
|
|
c5265f6070 | ||
|
|
0a10df1cf5 | ||
|
|
30f2a2003c | ||
|
|
67b108d1ce | ||
|
|
8a95631e39 | ||
|
|
82510e6b1f | ||
|
|
12ee4bf6ac | ||
|
|
3cb0351aff | ||
|
|
d5bc4e92e6 | ||
|
|
8e327bb0a3 | ||
|
|
fbf170a6c2 | ||
|
|
cd472e6aaf | ||
|
|
e9487b1a1a | ||
|
|
3cf6acdf24 | ||
|
|
334ac06102 | ||
|
|
2d9486ec7c | ||
|
|
fe502128b8 | ||
|
|
46f0ad6b53 | ||
|
|
fedc605956 | ||
|
|
d44e26ba22 | ||
|
|
610f234043 | ||
|
|
aa9a4c697c | ||
|
|
1b8ee3259e | ||
|
|
c7ae4940c3 | ||
|
|
aa4bf41400 | ||
|
|
4e32de09a2 | ||
|
|
86e0399ea9 | ||
|
|
302abf8480 | ||
|
|
f50b520557 | ||
|
|
d4074c7993 | ||
|
|
d3096c3b5e | ||
|
|
98947a4e52 | ||
|
|
bafb434f06 | ||
|
|
8e71a46173 | ||
|
|
934df19c52 | ||
|
|
024842a38b | ||
|
|
657929f8ec | ||
|
|
b506594c2d | ||
|
|
830135edea | ||
|
|
464cdbbb6e | ||
|
|
086e886d1e | ||
|
|
f2b82c1e1d | ||
|
|
801830df57 | ||
|
|
8b235297a5 | ||
|
|
59a3140621 | ||
|
|
16bd56ae7e | ||
|
|
750d82f1d1 | ||
|
|
139fc667aa | ||
|
|
f21e5f6cc5 | ||
|
|
f660aa9d7a | ||
|
|
d28d644b04 | ||
|
|
a634fd3a2d | ||
|
|
045794df4c | ||
|
|
dfc96e4702 | ||
|
|
8225bf01f7 | ||
|
|
116c697282 | ||
|
|
6199a89170 | ||
|
|
cbd77c9752 | ||
|
|
df9b5d8c22 | ||
|
|
66d534417b | ||
|
|
8803ab27c6 | ||
|
|
38910424f2 | ||
|
|
0076458e9d | ||
|
|
bdb1650ed8 | ||
|
|
a030ed4f39 | ||
|
|
9fc15394de | ||
|
|
34ea8770d0 | ||
|
|
a5897840a0 | ||
|
|
59087dd0ff | ||
|
|
1924481077 | ||
|
|
da1f7563e9 | ||
|
|
7496a14d2d | ||
|
|
6e6dead680 | ||
|
|
55dbbab5eb | ||
|
|
d6b6461658 | ||
|
|
85f7a4054d | ||
|
|
01965d147a | ||
|
|
6a84126c28 | ||
|
|
32f8bec92d | ||
|
|
00a6394b48 | ||
|
|
ca5a791d09 | ||
|
|
6a9c756cf0 | ||
|
|
1714d3e8ae | ||
|
|
25b7d47b34 | ||
|
|
9e8b4bae11 | ||
|
|
a466395a19 | ||
|
|
a3cb3fc490 | ||
|
|
3396778061 | ||
|
|
01cef64070 | ||
|
|
a9bfaf9e54 | ||
|
|
cec7c44f61 | ||
|
|
38ac2b39ce | ||
|
|
967e358dbc | ||
|
|
60721d2cc1 | ||
|
|
b698184939 | ||
|
|
c6c833fb9c | ||
|
|
3eb43f4619 | ||
|
|
440c159217 | ||
|
|
b49dcfbef7 | ||
|
|
a4d9cfaaeb | ||
|
|
7b2430fc3c | ||
|
|
bd8be7133d | ||
|
|
692ef0549b | ||
|
|
d6fdae5f1d | ||
|
|
8feb37df2b | ||
|
|
1d2b481069 | ||
|
|
c062fa2fa9 | ||
|
|
f444561a10 | ||
|
|
046f219a0e | ||
|
|
3cd32ed660 | ||
|
|
4f172f6f9f | ||
|
|
22fc0a6846 | ||
|
|
71e596b443 | ||
|
|
98c245ed7b | ||
|
|
bf57222e96 | ||
|
|
c075c070f0 | ||
|
|
4bc6950632 | ||
|
|
bde279c093 | ||
|
|
4f6ab8ac93 | ||
|
|
d2d82e2e5f | ||
|
|
1b2510e4b2 | ||
|
|
e735be59a7 | ||
|
|
5190539ce1 | ||
|
|
5776eb35b6 | ||
|
|
f102acd423 | ||
|
|
06486f3162 | ||
|
|
1619453b2b | ||
|
|
5a40950ffd | ||
|
|
16eb18e797 | ||
|
|
7bf0684557 | ||
|
|
961c490436 | ||
|
|
d8b0a4a288 | ||
|
|
76d12ac136 | ||
|
|
434faeecb8 | ||
|
|
ea2858b323 | ||
|
|
3391d5f846 | ||
|
|
7d6de7afe6 | ||
|
|
67ce6bd279 | ||
|
|
770db1fe02 | ||
|
|
d73394dde1 | ||
|
|
eb0c7e33d2 | ||
|
|
b9cfdaf666 | ||
|
|
5039f959e0 | ||
|
|
b7a54f8cd8 | ||
|
|
7b6435b2b8 | ||
|
|
8854c00d48 | ||
|
|
c0867b58f5 | ||
|
|
05183748a8 | ||
|
|
e56154a687 | ||
|
|
e5784c1ca8 | ||
|
|
282a9c7d7c | ||
|
|
b11ca92ca6 | ||
|
|
49846b3e68 | ||
|
|
0887824324 | ||
|
|
fbe65f2c71 | ||
|
|
eb5a412bed | ||
|
|
0cc8f68754 | ||
|
|
7079ca2718 | ||
|
|
70ad0bc573 | ||
|
|
22345c5ddf | ||
|
|
28b0a23949 | ||
|
|
1b57a796b1 | ||
|
|
0abb470022 | ||
|
|
b7a4b84f0a | ||
|
|
794a1e6cfe | ||
|
|
7c4db99d44 | ||
|
|
30b6213910 | ||
|
|
b6a27df5b9 | ||
|
|
18d514d552 | ||
|
|
f1ed08abf0 | ||
|
|
6d42dd8603 | ||
|
|
e7100e106d | ||
|
|
6402350c83 | ||
|
|
236576c124 | ||
|
|
9a83cab2f8 | ||
|
|
92706b158e | ||
|
|
ad34b26955 | ||
|
|
12c434fdc0 | ||
|
|
9ceaef6479 | ||
|
|
abb56bded2 | ||
|
|
0bcd10560a | ||
|
|
46b7148f3b | ||
|
|
37732130e1 | ||
|
|
7a3b1414cd | ||
|
|
a4a21c1dca | ||
|
|
206e597b04 | ||
|
|
ceef8ad2d8 | ||
|
|
2d581a6a86 | ||
|
|
82f7fa3887 | ||
|
|
f88a01e8c7 | ||
|
|
ca8e03b785 | ||
|
|
15932c9d7b | ||
|
|
0fc0f906e1 | ||
|
|
7f58852ec0 | ||
|
|
85a9a53e69 | ||
|
|
aa0c0fc401 | ||
|
|
0e694e08fc | ||
|
|
c2ddcc9f36 | ||
|
|
7a7cf6a5ce | ||
|
|
c2f83bd8a4 | ||
|
|
1f0e6296c6 | ||
|
|
ab1f01bacd | ||
|
|
b9b896d8e7 | ||
|
|
6be54f366c | ||
|
|
802cdb3230 | ||
|
|
7e27880cb6 | ||
|
|
d3ad85aa43 | ||
|
|
59192fc695 | ||
|
|
9095b80c5b | ||
|
|
ed5b78bf09 | ||
|
|
d6aafa3f64 | ||
|
|
8de04a808d | ||
|
|
2a299233b3 | ||
|
|
64f83c8861 | ||
|
|
1009fe3d9c | ||
|
|
ba341fe81a | ||
|
|
36e8cb6530 | ||
|
|
273da62aec | ||
|
|
41788184a7 | ||
|
|
fb9c2c7dc8 | ||
|
|
43116be122 | ||
|
|
ee038d5de5 | ||
|
|
ea7fae5277 | ||
|
|
70b108ab69 | ||
|
|
08b152d6a2 | ||
|
|
83c6213c67 | ||
|
|
4253075a97 | ||
|
|
0abdc2a350 | ||
|
|
31669f343a | ||
|
|
438b881ab4 | ||
|
|
27863146a3 | ||
|
|
cd4b73612b | ||
|
|
3c217a9e37 | ||
|
|
cde3a003ea | ||
|
|
2c35f56612 | ||
|
|
4295db25d7 | ||
|
|
3c06e57f24 | ||
|
|
e949cf5967 | ||
|
|
4eeaf34295 | ||
|
|
2212a90698 | ||
|
|
dc52b61dad | ||
|
|
bbf4c3186b | ||
|
|
f72016a78e | ||
|
|
29b587a9c5 | ||
|
|
cec4f2b140 | ||
|
|
05278c3b4c | ||
|
|
1769b8ea0f | ||
|
|
5686bd87d7 | ||
|
|
1cda2db45d | ||
|
|
fdf9640349 | ||
|
|
8f2d5d99f1 | ||
|
|
61272e7ce8 | ||
|
|
88b76f49cc | ||
|
|
ad942e352d | ||
|
|
39c2bcd462 | ||
|
|
ae10664b24 | ||
|
|
074dac4195 | ||
|
|
a8239b865a | ||
|
|
f6a9c5c1b7 | ||
|
|
42774ee851 | ||
|
|
4e26f48781 | ||
|
|
aec97397e8 | ||
|
|
183a648d01 | ||
|
|
27f8ad7fd1 | ||
|
|
a79fbef21e | ||
|
|
565976acbe | ||
|
|
54bbd2b1c0 | ||
|
|
10b2b53aa7 | ||
|
|
e18ee0bb46 | ||
|
|
857d51ea8e | ||
|
|
ba85544611 | ||
|
|
293806d52d | ||
|
|
7f45eb7957 | ||
|
|
f0c48680fe | ||
|
|
78283dd822 | ||
|
|
bbdf708d1a | ||
|
|
08195d7e41 | ||
|
|
9ff0dbb7a4 | ||
|
|
6ba97f9161 | ||
|
|
4eca60e7dc | ||
|
|
2af6f8cf78 | ||
|
|
d9a84d24cf | ||
|
|
09ce631e21 | ||
|
|
f93f2a15af | ||
|
|
47839b7701 | ||
|
|
41e99afe54 | ||
|
|
80af04040a | ||
|
|
3caa1e2f71 | ||
|
|
ddbbe30b9e | ||
|
|
802a98e7fc | ||
|
|
bb21841659 | ||
|
|
3f9691baff | ||
|
|
f8db832491 | ||
|
|
c68a92ba80 | ||
|
|
e5cf4645fe | ||
|
|
fad97e12da | ||
|
|
2f6152a580 | ||
|
|
7446da8c9b | ||
|
|
00eecd3a1d | ||
|
|
46a178cf48 | ||
|
|
ddcc28f726 | ||
|
|
04f86aa2ff | ||
|
|
72f0f99ac3 | ||
|
|
c8fe0fe992 | ||
|
|
be5c3b0b90 | ||
|
|
5194101c8b | ||
|
|
0ee27c6ef6 | ||
|
|
46a0aab6b9 | ||
|
|
55fb7abc39 | ||
|
|
407e47b306 | ||
|
|
4e54770f18 | ||
|
|
f9a31f36a0 | ||
|
|
547272e66c | ||
|
|
35e11ffe60 | ||
|
|
52e12e42e5 | ||
|
|
5214d42c07 | ||
|
|
40bbe2539b | ||
|
|
6d1dda0fad | ||
|
|
7a90dab8ff | ||
|
|
395c89cff2 | ||
|
|
aad242d54b | ||
|
|
220ef264fb | ||
|
|
f64dcc0ac2 | ||
|
|
e57abae138 | ||
|
|
fc73accfe5 | ||
|
|
c4d57f0e3d | ||
|
|
eadabfe890 | ||
|
|
02cbe5e1ad | ||
|
|
2645e632a8 | ||
|
|
e14a03a172 | ||
|
|
513e65900c | ||
|
|
4b81cda521 | ||
|
|
6688f40325 | ||
|
|
42dd5caa1b | ||
|
|
308bcae257 | ||
|
|
f2c80cae44 | ||
|
|
aaf744dfab | ||
|
|
7534ffee64 | ||
|
|
ed862c8d08 | ||
|
|
1d977e021d | ||
|
|
dccd61966a | ||
|
|
93aeecefeb | ||
|
|
df63790bb3 | ||
|
|
c743ecbf50 | ||
|
|
29c1df4610 | ||
|
|
40f8591257 | ||
|
|
4d1a754ec6 | ||
|
|
699680807d | ||
|
|
ccaf0874e1 | ||
|
|
1afcb4f29a | ||
|
|
1bb2732056 | ||
|
|
6744ad392d | ||
|
|
1aecc51c70 | ||
|
|
c9571e55f5 | ||
|
|
aba4596ba9 | ||
|
|
bd3cfeae92 | ||
|
|
9ef723eb97 | ||
|
|
7958b1764e | ||
|
|
44f612acbc | ||
|
|
5d7df69116 | ||
|
|
8f06245428 | ||
|
|
0f8368bcf1 | ||
|
|
5d0356a75e | ||
|
|
5f68941241 | ||
|
|
63af4889f6 | ||
|
|
6f84d2fac1 | ||
|
|
049eae661a | ||
|
|
e930d94728 | ||
|
|
819b8eb73d | ||
|
|
a78bf0c34e | ||
|
|
e0059bcc6b | ||
|
|
af0b83a2c3 | ||
|
|
2c033989b6 | ||
|
|
8fbfe55e92 | ||
|
|
740e8130dd | ||
|
|
5bddaf6820 | ||
|
|
c36230e21b | ||
|
|
15d8c08eaa | ||
|
|
2f738d5805 | ||
|
|
e05b687009 | ||
|
|
55a22656b8 | ||
|
|
2db20adc3e | ||
|
|
c7eeb57a32 | ||
|
|
361726b3ae | ||
|
|
c404786b92 | ||
|
|
2ff4eca7bf | ||
|
|
1eca83ff22 | ||
|
|
2575fa8f83 | ||
|
|
b7e86192ee | ||
|
|
078f0f511e | ||
|
|
4963b931d0 | ||
|
|
75fd327222 | ||
|
|
9e71932c2e | ||
|
|
d92583ed33 | ||
|
|
cd27860e55 | ||
|
|
ba875fc04a | ||
|
|
b5a85bd2fe | ||
|
|
4e0df8c2a6 | ||
|
|
37bc30c8d9 | ||
|
|
f6ed7844e1 | ||
|
|
d466390233 | ||
|
|
336473398a | ||
|
|
bb16c81e7b | ||
|
|
f955b46c13 | ||
|
|
b54711252b | ||
|
|
f2710d5b55 | ||
|
|
285fae856d | ||
|
|
111b63bb16 | ||
|
|
767a8b19a9 | ||
|
|
cb28d6cdb7 | ||
|
|
a0d5abef88 | ||
|
|
ebab36e859 | ||
|
|
3988a1e9a8 | ||
|
|
949ef3e1dc | ||
|
|
dd12303276 | ||
|
|
f1379a6574 | ||
|
|
ad58384760 | ||
|
|
0e786f5907 | ||
|
|
e1accce498 | ||
|
|
28db0fdde9 | ||
|
|
584bf9382b | ||
|
|
0168b405a3 | ||
|
|
b5e0d76337 | ||
|
|
c924fba4fa | ||
|
|
8ec43a39af | ||
|
|
9f16445464 | ||
|
|
1a795b04ee | ||
|
|
b862f3e64d | ||
|
|
4e66b5ce8a | ||
|
|
d446950c6a | ||
|
|
e3c77f9b4b | ||
|
|
090ec985f3 | ||
|
|
e63bd490b0 | ||
|
|
badf97d4ba | ||
|
|
ba283e6b6e | ||
|
|
0bdac2c7b3 | ||
|
|
58b211d707 | ||
|
|
068ce237af | ||
|
|
a5e9e5d0df | ||
|
|
e0af8069c1 | ||
|
|
696b05d6e6 | ||
|
|
7e1a699616 | ||
|
|
716d73d982 | ||
|
|
38ac081114 | ||
|
|
5fce101f85 | ||
|
|
c6e064200d | ||
|
|
c52e9085d1 | ||
|
|
d0fb17d70c | ||
|
|
713153b610 | ||
|
|
09d039fba6 | ||
|
|
07f7f28058 | ||
|
|
a2b40f527d | ||
|
|
6d8ffeefd6 | ||
|
|
9ce25bab04 | ||
|
|
cd5105b1db | ||
|
|
ff4abc69c3 | ||
|
|
192f74f0a1 | ||
|
|
be203d9af0 | ||
|
|
f8af299321 | ||
|
|
474b2af1a6 | ||
|
|
cb88cea3c4 | ||
|
|
fc2892fbb0 | ||
|
|
36b25cbd2b | ||
|
|
d18c071849 | ||
|
|
61b629fdad | ||
|
|
29647c8280 | ||
|
|
97b15cb3ae | ||
|
|
f725921dfb | ||
|
|
a4b4d0c0d8 | ||
|
|
f59ade7f80 | ||
|
|
a9b9e7befe | ||
|
|
ead9394a31 | ||
|
|
80129fa9ab | ||
|
|
18796a3c18 | ||
|
|
f632b6d4cb | ||
|
|
7799e14770 | ||
|
|
20aab86e12 | ||
|
|
b7766478a6 | ||
|
|
3d57b7a44d | ||
|
|
51a2b436f4 | ||
|
|
88015081f2 | ||
|
|
20cc1f6550 | ||
|
|
43cca04c33 | ||
|
|
17d944c333 | ||
|
|
6789b5165c | ||
|
|
d631d7e81f | ||
|
|
c6245dc616 | ||
|
|
4b36799ce1 | ||
|
|
d26bb9b4eb | ||
|
|
698404b02f | ||
|
|
d46d7ad947 | ||
|
|
7c6630905d | ||
|
|
129aa587c6 | ||
|
|
cc1c6c94e3 | ||
|
|
41266cbaa0 | ||
|
|
fbfd261da6 | ||
|
|
71602b8ee6 | ||
|
|
14cae239f6 | ||
|
|
2e9e309a0d | ||
|
|
3fba33d5f5 | ||
|
|
77a7162361 | ||
|
|
75efa5174c | ||
|
|
c62afbe77b | ||
|
|
a6f0688f46 | ||
|
|
5762d33e38 | ||
|
|
9c6d1c214f | ||
|
|
a5c865937f | ||
|
|
f48fd84d76 | ||
|
|
a8693a21f8 | ||
|
|
9b630a0664 | ||
|
|
79ac20c161 | ||
|
|
cb74f3e7ad | ||
|
|
c4865e2cb6 | ||
|
|
20d2363fb7 | ||
|
|
64ba5a5b65 | ||
|
|
9913851413 | ||
|
|
e9a8503c6b | ||
|
|
a02d7555c2 | ||
|
|
779b341b61 | ||
|
|
a646cf7923 | ||
|
|
0dea8d97f4 | ||
|
|
97ba9e4d47 | ||
|
|
3f3ebd3b3b | ||
|
|
571669ad6c | ||
|
|
855eb09d58 | ||
|
|
ead3ca14a0 | ||
|
|
34f12c0864 | ||
|
|
28876d6afa | ||
|
|
cea68ebc6f | ||
|
|
a33a955163 | ||
|
|
a3e60c93da | ||
|
|
44c9744d69 | ||
|
|
b69b648d18 | ||
|
|
3ebebac695 | ||
|
|
13d734c8d2 | ||
|
|
c903c5f72b | ||
|
|
b03c7581f2 | ||
|
|
2ed9853bcc | ||
|
|
26e00ffbeb | ||
|
|
b745b6d546 | ||
|
|
e147f2f11e | ||
|
|
14687d003d | ||
|
|
e8bb95ba55 | ||
|
|
a43810533f | ||
|
|
98bbfdf73c | ||
|
|
ee53d816ce | ||
|
|
e176587e96 | ||
|
|
8210be0f17 | ||
|
|
f88a712d01 | ||
|
|
9cf78b974a | ||
|
|
3e1dc801b0 | ||
|
|
cf3c7b3bd6 | ||
|
|
0b7f64cb33 | ||
|
|
ec4542bbe4 | ||
|
|
fc235a3f16 | ||
|
|
4cf8395470 | ||
|
|
fd03d823f2 | ||
|
|
e65fa1aa7b | ||
|
|
3de72917c3 | ||
|
|
b3b2f67d2f | ||
|
|
c2dc25e062 | ||
|
|
ad9c360845 | ||
|
|
a65686e83f | ||
|
|
fe35de6931 | ||
|
|
3f1aea2f53 | ||
|
|
0c542dcd3d | ||
|
|
5483567190 | ||
|
|
d243f1f8fe | ||
|
|
9b137b2e37 | ||
|
|
6ee357d230 | ||
|
|
779e40ed66 | ||
|
|
be3439fef1 | ||
|
|
ed96b4d49d | ||
|
|
5ca8aa7840 | ||
|
|
1eede1bc08 | ||
|
|
cc86461d9b | ||
|
|
29c5ca9091 | ||
|
|
86fbcdc62b | ||
|
|
e82220974e | ||
|
|
46951b8598 | ||
|
|
08faca03b7 | ||
|
|
3217421797 | ||
|
|
7fa22d4c25 | ||
|
|
8671002bd7 | ||
|
|
bc6b40568d | ||
|
|
3888b9dcec | ||
|
|
ae104b5c28 | ||
|
|
5cb7e6c9c3 | ||
|
|
ff31702f74 | ||
|
|
3edd3fe5a4 | ||
|
|
4f3fb95981 | ||
|
|
7c7ab95e2e | ||
|
|
70feea48f8 | ||
|
|
c546c48d0d | ||
|
|
0baf00e1c0 | ||
|
|
788e7fcd89 | ||
|
|
7c45b1d2a3 | ||
|
|
93b66ac141 | ||
|
|
610284dcc3 | ||
|
|
60d8586b6d | ||
|
|
70928dba52 | ||
|
|
7fda9c6723 | ||
|
|
4932f9d077 | ||
|
|
0094128ca6 | ||
|
|
de5178575f | ||
|
|
9eac078c18 | ||
|
|
05c5445fe2 | ||
|
|
f9d8b6f99e | ||
|
|
597a37d66e | ||
|
|
73e4986866 | ||
|
|
91e74c704b | ||
|
|
727bf195d1 | ||
|
|
b13836e9cc | ||
|
|
cf12d72f21 | ||
|
|
5c2bbaca3b | ||
|
|
b717904f9e | ||
|
|
f2c4ab09a8 | ||
|
|
9a657cd4a3 | ||
|
|
308de81221 | ||
|
|
6823109cfb | ||
|
|
a02149cf65 | ||
|
|
7aa4bbf621 | ||
|
|
5afddad0d2 | ||
|
|
0380cf0c76 | ||
|
|
6c2a1e62e0 | ||
|
|
6560628209 | ||
|
|
3cc81376a6 | ||
|
|
8d02e5f680 | ||
|
|
f9e2213afd | ||
|
|
8b362ba3e7 | ||
|
|
eecec8fffa | ||
|
|
a26058d425 | ||
|
|
c14b81f3a9 | ||
|
|
0059a43254 | ||
|
|
7dd3cc354d | ||
|
|
ce34aa0763 | ||
|
|
7a512ad9c3 | ||
|
|
0a56c0e8c1 | ||
|
|
0b71504ee9 | ||
|
|
9479c6451e | ||
|
|
115e83f3aa | ||
|
|
ea526b96dd | ||
|
|
726cf84e19 | ||
|
|
dc8a46363f | ||
|
|
916ca7ab86 | ||
|
|
be036ed58a | ||
|
|
2afdd4544d | ||
|
|
c4e61835d3 | ||
|
|
e15ce69d08 | ||
|
|
d537ed11fd | ||
|
|
dba458d50c | ||
|
|
3e23430926 | ||
|
|
3f507b782c | ||
|
|
2fc3525fdf | ||
|
|
0f3e464202 | ||
|
|
925d7119ec | ||
|
|
f456cd57b9 | ||
|
|
ea58500cef | ||
|
|
4048b200ed | ||
|
|
54211f0f6e | ||
|
|
4b5f465026 | ||
|
|
7efd1151cb | ||
|
|
19dbe52930 | ||
|
|
2a981b7d39 | ||
|
|
d34ebdb431 | ||
|
|
60d0fa2993 | ||
|
|
8545ba733a | ||
|
|
04c8a8c75d | ||
|
|
b7ed44f113 | ||
|
|
46a39716b6 | ||
|
|
e77b0070af | ||
|
|
3c5cf81e32 | ||
|
|
be14dbffef | ||
|
|
b4f6a0f94a | ||
|
|
c15acff39a | ||
|
|
ed0ac6e3f6 | ||
|
|
6cc9c4940c | ||
|
|
0e8b27556d | ||
|
|
162c6a49b5 | ||
|
|
61dbdd80b9 | ||
|
|
8df1bedb1b | ||
|
|
b55e914273 | ||
|
|
1c3aff37de | ||
|
|
4bbc5520b8 | ||
|
|
0731cd6950 | ||
|
|
f88e96599c | ||
|
|
cd7bfa2510 | ||
|
|
ea418b2e18 | ||
|
|
c00d93a897 | ||
|
|
bc361c48a0 | ||
|
|
1f39169be3 | ||
|
|
030833087d | ||
|
|
c38dbcc6b5 | ||
|
|
ba1d548cc8 | ||
|
|
7261d11bb0 | ||
|
|
f38872eab3 | ||
|
|
1939aae70e | ||
|
|
3f85d1dcc1 | ||
|
|
922e2fe23b | ||
|
|
d5a9c1535e | ||
|
|
169eee6792 | ||
|
|
9c398051bb | ||
|
|
1d289787b6 | ||
|
|
b5658f4d9c | ||
|
|
ad58baa13b | ||
|
|
c6fdeeb6bb | ||
|
|
7712455d9a | ||
|
|
a9a5f98406 | ||
|
|
9ac8f64d89 | ||
|
|
0da5cf9163 | ||
|
|
f6a39d75a7 | ||
|
|
25aa9f5b42 | ||
|
|
829b3adac3 | ||
|
|
4847a3a259 | ||
|
|
551541d9c8 | ||
|
|
f996f4c9fb | ||
|
|
ac78ad60f3 | ||
|
|
42d7cf8922 | ||
|
|
e811ba7b4c | ||
|
|
cb464cac4d | ||
|
|
fa409ddc8f | ||
|
|
821226e473 | ||
|
|
0e298bedf6 | ||
|
|
aa76760268 | ||
|
|
8bf87bbfde | ||
|
|
38e889c85c | ||
|
|
d5b737cce8 | ||
|
|
6ba764b5be | ||
|
|
707b857b68 | ||
|
|
f8d609fee5 | ||
|
|
01f797ac05 | ||
|
|
6fa11a853a | ||
|
|
9c78ad708b | ||
|
|
57f8160d6c | ||
|
|
8d80ce444f | ||
|
|
95c3acf67e | ||
|
|
561f7a66dd | ||
|
|
0193688671 | ||
|
|
6d7605a3d0 | ||
|
|
e0171f6e96 | ||
|
|
4ef1c6f2c8 | ||
|
|
f7e2d7c2ec | ||
|
|
3d1be1cd75 | ||
|
|
2d509eb8bd | ||
|
|
6ca73bf670 | ||
|
|
f7802f0111 | ||
|
|
2f3ef235a1 | ||
|
|
1ad22e9a02 | ||
|
|
6d2fb9f782 | ||
|
|
22e5ed44c2 | ||
|
|
9666831818 | ||
|
|
ff8e04f9ba | ||
|
|
52272f4dc5 | ||
|
|
18a66a2ba8 | ||
|
|
8aa9eb19c8 | ||
|
|
62027f1b47 | ||
|
|
41805d572f | ||
|
|
58f768928a | ||
|
|
0074135097 | ||
|
|
8eb7ce8581 | ||
|
|
2ceb3c89ca | ||
|
|
d46e2a69a1 | ||
|
|
20f9454be3 | ||
|
|
8092366897 | ||
|
|
066254b6c8 | ||
|
|
79811bf3e2 | ||
|
|
32bf32e7d5 | ||
|
|
df968ca47c | ||
|
|
cce7a5f15e | ||
|
|
288043c13b | ||
|
|
78ae4ebfaa | ||
|
|
cf700a0084 | ||
|
|
60a25f6e71 | ||
|
|
3eff836b2e | ||
|
|
2b9fe764d5 | ||
|
|
030e3b2dab | ||
|
|
5079f6bbff | ||
|
|
afceb9d24e | ||
|
|
a2656a20bc | ||
|
|
359d444343 | ||
|
|
d510154ba2 | ||
|
|
1c901b82dc | ||
|
|
ea3672df4e | ||
|
|
72d0b3c913 | ||
|
|
51a2d8dfd8 | ||
|
|
bc25380950 | ||
|
|
ae1e3bf73c | ||
|
|
9673a2726c | ||
|
|
02524397c1 | ||
|
|
5e5dde1a67 | ||
|
|
0f8def4ca4 | ||
|
|
182ec04e24 | ||
|
|
ebae435398 | ||
|
|
52657945d8 | ||
|
|
12166f8a47 | ||
|
|
c5f1dd8615 | ||
|
|
10e67e3c1d | ||
|
|
4e8ceaae86 | ||
|
|
73d4eaafbb | ||
|
|
cf00179964 | ||
|
|
edda0c60b3 | ||
|
|
f2eb6b165a | ||
|
|
4933c216b2 | ||
|
|
0655def57f | ||
|
|
6eafff2450 | ||
|
|
0bb772c575 | ||
|
|
b261693095 | ||
|
|
129db63e30 | ||
|
|
1759d89d8a | ||
|
|
0540b17fb9 | ||
|
|
8893dda350 | ||
|
|
b14689d59b | ||
|
|
1ca844af98 | ||
|
|
3059747c35 | ||
|
|
bbbb3633a7 | ||
|
|
df6c2a432f | ||
|
|
d0acfc2652 | ||
|
|
711cda6aed | ||
|
|
0c738d84af | ||
|
|
be1e1dc441 | ||
|
|
2a305d8e16 | ||
|
|
15b6ab77ea | ||
|
|
6199822783 | ||
|
|
0b72b2940a | ||
|
|
d4ce3f19c3 | ||
|
|
824e86a82f | ||
|
|
2a5c045c3d | ||
|
|
f7c65a4b88 | ||
|
|
a8956f2f56 | ||
|
|
91c9f84a01 | ||
|
|
2be89bc6f2 | ||
|
|
d6c447a445 | ||
|
|
a60586eaad | ||
|
|
d77356837a | ||
|
|
d6842301dd | ||
|
|
19b3c5be26 | ||
|
|
5fb5a89f02 | ||
|
|
9367e7b9af | ||
|
|
6673cadfa2 | ||
|
|
b485051b65 | ||
|
|
9a01ccc07f | ||
|
|
1b8deaf354 | ||
|
|
c7d0232bb1 | ||
|
|
79e5f2be13 | ||
|
|
9ab181eb9c | ||
|
|
3cc6021e03 | ||
|
|
375389fa1e | ||
|
|
777303f130 | ||
|
|
6015f99d98 | ||
|
|
78fc17c661 | ||
|
|
d42addf746 | ||
|
|
f570eb76b3 | ||
|
|
cc3f5962b8 | ||
|
|
6ab3d1daa3 | ||
|
|
b088b70f82 | ||
|
|
fbbb6bbc00 | ||
|
|
5c36342958 | ||
|
|
f1a0cacc5a | ||
|
|
1d2a0856b4 | ||
|
|
7fb50d9a3e | ||
|
|
919b5b5a7d | ||
|
|
1e35b26826 | ||
|
|
27b0b5824a | ||
|
|
1d72d22bc5 | ||
|
|
e0c9ed44f9 | ||
|
|
411f4da340 | ||
|
|
4fac84098e | ||
|
|
21b2063a6f | ||
|
|
917c191650 | ||
|
|
2bfce03d29 | ||
|
|
1cb8167be0 | ||
|
|
40d33cc64d | ||
|
|
95433e9639 | ||
|
|
bbe1a09e7e | ||
|
|
dce2366b3a | ||
|
|
bab7ba22cf | ||
|
|
d6a91057ae | ||
|
|
c6e9065498 | ||
|
|
22fda21eae | ||
|
|
103a520aa6 | ||
|
|
86531a51a7 | ||
|
|
2b7e4d645f | ||
|
|
a5f63180fc | ||
|
|
934d4e04b5 | ||
|
|
1b8547059a | ||
|
|
91279a0f28 | ||
|
|
31ba3144c8 | ||
|
|
0bf34725e3 | ||
|
|
91749ebb2b | ||
|
|
4ba3dd66ad | ||
|
|
d40696f7f3 | ||
|
|
4a401a9e83 | ||
|
|
6a2a837ede | ||
|
|
eca08a281c | ||
|
|
9fd8f76fa0 | ||
|
|
50de930730 | ||
|
|
da1097095c | ||
|
|
ec7d302a6c | ||
|
|
8cc7ebffa9 | ||
|
|
de4d14843f | ||
|
|
18605795a7 | ||
|
|
da2c8d9076 | ||
|
|
3120f8adb6 | ||
|
|
2dcc16169b | ||
|
|
a8efd8c398 | ||
|
|
bb40f4aff4 | ||
|
|
66c7ac4d24 | ||
|
|
7f12919fea | ||
|
|
55e0c6a0a1 | ||
|
|
20f306602b | ||
|
|
70735d8d79 | ||
|
|
165e6805ab | ||
|
|
2a0c35646c | ||
|
|
28710e0449 | ||
|
|
c5587b60b2 | ||
|
|
bb95c39356 | ||
|
|
20a43409c6 | ||
|
|
4699f7ca0b | ||
|
|
bc7586b3f4 | ||
|
|
8d3d45ea1a | ||
|
|
21ba1d3761 | ||
|
|
e79584bb9e | ||
|
|
bca7819247 | ||
|
|
0ecabae2c3 | ||
|
|
598c04eea2 | ||
|
|
faec23f6bd | ||
|
|
896dad9224 | ||
|
|
680612cf09 | ||
|
|
3fbd4bb15f | ||
|
|
cb9055072d | ||
|
|
0fc9b555f1 | ||
|
|
6ed58628f5 | ||
|
|
efff149988 | ||
|
|
b02d4092f1 | ||
|
|
9dc7ea7c62 | ||
|
|
546a3cdd50 | ||
|
|
e8c5d15690 | ||
|
|
e63cba05b2 | ||
|
|
e8fe1dc415 | ||
|
|
9cf08fc780 | ||
|
|
b712b3a979 | ||
|
|
a931b2eece | ||
|
|
2e74beebbf | ||
|
|
db510a9558 | ||
|
|
222198acf3 | ||
|
|
bc4d5df94e | ||
|
|
9d35b5deac | ||
|
|
59c68d240c | ||
|
|
930a41b845 | ||
|
|
323f0d187e | ||
|
|
0078705bbe | ||
|
|
3b3ca4afdc | ||
|
|
1d6b94b458 | ||
|
|
30c038c3c3 | ||
|
|
05e002cd42 | ||
|
|
7f6ed73145 | ||
|
|
0c4968ec51 | ||
|
|
ff69e86559 | ||
|
|
98f79404d6 | ||
|
|
eec438a614 | ||
|
|
c88801065f | ||
|
|
833022b745 | ||
|
|
d1b820e7e3 | ||
|
|
4373918a2f | ||
|
|
6e96b4ba33 | ||
|
|
2d326bfc48 | ||
|
|
a6988b2a79 | ||
|
|
8b93e1a780 | ||
|
|
4e318c1abc | ||
|
|
3cb6840d2d | ||
|
|
6ed5a65064 | ||
|
|
b977c95be4 | ||
|
|
feb8811f37 | ||
|
|
0de82a70a6 | ||
|
|
cc3a8918f0 | ||
|
|
63ef2badd6 | ||
|
|
e98080b8bb | ||
|
|
bed5b72cbe | ||
|
|
7ab2c0e4a5 | ||
|
|
7a6ee1d729 | ||
|
|
d9596334c3 | ||
|
|
16676ae726 | ||
|
|
fd3702f973 | ||
|
|
d674d23b45 | ||
|
|
5b8835f46b | ||
|
|
ddb2cf3b8b | ||
|
|
f924862e89 | ||
|
|
061d497df0 | ||
|
|
3a222336d7 | ||
|
|
78300d018a | ||
|
|
e95676f65f | ||
|
|
c8fe69c956 | ||
|
|
fe4b661fe7 | ||
|
|
5344028c40 | ||
|
|
e591e3622b | ||
|
|
d8fc5fee0a | ||
|
|
eeb73b3670 | ||
|
|
2f2e524bc6 | ||
|
|
6b0198c2d7 | ||
|
|
2a64b75893 | ||
|
|
034e172033 | ||
|
|
1faeb45063 | ||
|
|
fa84496423 | ||
|
|
a3d47ffc81 | ||
|
|
d841c86a6e | ||
|
|
3b4e4b785d | ||
|
|
7ba6b617a1 | ||
|
|
100f732e20 | ||
|
|
cb28aeeacc | ||
|
|
7994b31de4 | ||
|
|
6dcf3238f6 | ||
|
|
f6320e7050 | ||
|
|
597bb80d18 | ||
|
|
9775f3a030 | ||
|
|
a080d00352 | ||
|
|
5fb0a9d53b | ||
|
|
40d82675bd | ||
|
|
f851e1f90e | ||
|
|
73d775c8b4 | ||
|
|
97f3e9404a | ||
|
|
83da131e99 | ||
|
|
7973aef7b7 | ||
|
|
9a3bdcc20b | ||
|
|
aa91c608f4 | ||
|
|
3d260d41b3 | ||
|
|
2458325c09 | ||
|
|
ab68a9d1d3 | ||
|
|
93b5b08bed | ||
|
|
be4369936b | ||
|
|
1a7415a6ab | ||
|
|
c15db71f9e | ||
|
|
74cb1c877c | ||
|
|
a949ab6935 | ||
|
|
f0fd7099c0 | ||
|
|
e0009f9f40 | ||
|
|
14d2576924 | ||
|
|
c386d11765 | ||
|
|
f12bc10917 | ||
|
|
99d18abf59 | ||
|
|
bc29c84610 | ||
|
|
e78e65ef22 | ||
|
|
f9103531c4 | ||
|
|
2ea87490f4 | ||
|
|
5fb5551c36 | ||
|
|
b9b0326d15 | ||
|
|
97f2f16fd6 | ||
|
|
fc1514db04 | ||
|
|
7fb0598b50 | ||
|
|
fd375ca55b | ||
|
|
0f70959d8e | ||
|
|
8cb6fcad7e | ||
|
|
20d898d182 | ||
|
|
10c9a7d4b7 | ||
|
|
441e42c276 | ||
|
|
fe2dbfb6cb | ||
|
|
032ac800aa | ||
|
|
5e86eeacfb | ||
|
|
75b7d33fb7 | ||
|
|
a6e532442b | ||
|
|
a123a12f59 | ||
|
|
f261251a9b | ||
|
|
a0e1154bfb | ||
|
|
e261278a5c | ||
|
|
dbb550e6db | ||
|
|
27a9b0e7b1 | ||
|
|
8a00758cf5 | ||
|
|
15e154c09d | ||
|
|
52d0c9a057 | ||
|
|
4593471ad5 | ||
|
|
a3288d4284 | ||
|
|
22f0da4da6 | ||
|
|
baa977a3ed | ||
|
|
b4b2491015 | ||
|
|
902ed3c694 | ||
|
|
4a9205b341 |
32
.gitignore
vendored
32
.gitignore
vendored
@@ -1,6 +1,28 @@
|
|||||||
*.swp
|
.deps
|
||||||
|
.vimrc
|
||||||
|
*.gcda
|
||||||
|
*.gcno
|
||||||
*.o
|
*.o
|
||||||
Makefile
|
*.swp
|
||||||
chronyc
|
*.dSYM
|
||||||
chronyd
|
*.DS_Store
|
||||||
version.h
|
core.*
|
||||||
|
tags
|
||||||
|
/RELEASES
|
||||||
|
/Makefile
|
||||||
|
/chronyc
|
||||||
|
/chronyd
|
||||||
|
/config.h
|
||||||
|
/config.log
|
||||||
|
/doc/Makefile
|
||||||
|
/doc/*.html
|
||||||
|
/doc/*.man
|
||||||
|
/doc/*.man.in
|
||||||
|
/doc/*.txt
|
||||||
|
/getdate.c
|
||||||
|
/version.h
|
||||||
|
/test/simulation/clknetsim
|
||||||
|
/test/simulation/tmp
|
||||||
|
/test/unit/Makefile
|
||||||
|
/test/unit/*.test
|
||||||
|
/test/unit/*.o
|
||||||
|
|||||||
93
INSTALL
93
INSTALL
@@ -1,93 +0,0 @@
|
|||||||
The software is distributed as source code which has to be compiled.
|
|
||||||
|
|
||||||
PARTS OF THE SOFTWARE ARE HIGHLY SYSTEM-SPECIFIC AND NON-PORTABLE.
|
|
||||||
UNLESS YOU ARE RUNNING A SUPPORTED SYSTEM, BE PREPARED FOR SOME
|
|
||||||
PROGRAMMING!
|
|
||||||
|
|
||||||
After unpacking the source code, change directory into it, and type
|
|
||||||
|
|
||||||
./configure
|
|
||||||
|
|
||||||
This is a shell script that automatically determines the system type.
|
|
||||||
There is a single optional parameter, --prefix which indicates the
|
|
||||||
directory tree where the software should be installed. For example,
|
|
||||||
|
|
||||||
./configure --prefix=/opt/free
|
|
||||||
|
|
||||||
will install the chronyd daemon into /opt/free/sbin and the chronyc
|
|
||||||
control program into /opt/free/bin. The default value for the prefix
|
|
||||||
is /usr/local.
|
|
||||||
|
|
||||||
The configure script assumes you want to use gcc as your compiler.
|
|
||||||
If you want to use a different compiler, you can configure this way:
|
|
||||||
|
|
||||||
CC=cc CFLAGS=-O ./configure --prefix=/opt/free
|
|
||||||
|
|
||||||
for Bourne-family shells, or
|
|
||||||
|
|
||||||
setenv CC cc
|
|
||||||
setenv CFLAGS -O
|
|
||||||
./configure --prefix=/opt/free
|
|
||||||
|
|
||||||
for C-family shells.
|
|
||||||
|
|
||||||
If the software cannot (yet) be built on your system, an error message
|
|
||||||
will be shown. Otherwise, `Makefile' will be generated.
|
|
||||||
|
|
||||||
If editline or readline library is available, chronyc will be built
|
|
||||||
with line editing support. If you don't want this, specify the
|
|
||||||
--disable-readline flag to configure. Please refer to the chrony.txt
|
|
||||||
file for more information.
|
|
||||||
|
|
||||||
If a `timepps.h' header is available, chronyd will be built with PPS
|
|
||||||
API reference clock driver. If the header is installed in a location
|
|
||||||
that isn't normally searched by the compiler, you can add it to the
|
|
||||||
searched locations by setting CPPFLAGS variable to -I/path/to/timepps.
|
|
||||||
|
|
||||||
Now type
|
|
||||||
|
|
||||||
make
|
|
||||||
|
|
||||||
to build the programs.
|
|
||||||
|
|
||||||
If you want to build the manual in plain text, HTML and info versions, type
|
|
||||||
|
|
||||||
make docs
|
|
||||||
|
|
||||||
Once the programs have been successfully compiled, they need to be
|
|
||||||
installed in their target locations. This step normally needs to be
|
|
||||||
performed by the superuser, and requires the following command to be
|
|
||||||
entered.
|
|
||||||
|
|
||||||
make install
|
|
||||||
|
|
||||||
This will install the binaries, plain text manual and manpages.
|
|
||||||
|
|
||||||
To install the HTML and info versions of the manual as well, enter the command
|
|
||||||
|
|
||||||
make install-docs
|
|
||||||
|
|
||||||
If you want chrony to appear in the top level info directory listing, you need
|
|
||||||
to run the install-info command manually after this step. install-info takes 2
|
|
||||||
arguments. The first is the path to the chrony.info file you have just
|
|
||||||
installed. This will be the argument you gave to --prefix when you configured
|
|
||||||
(/usr/local by default), with /share/info/chrony.info on the end. The second
|
|
||||||
argument is the location of the file called 'dir'. This will typically be
|
|
||||||
/usr/share/info/dir. So the typical command line would be
|
|
||||||
|
|
||||||
install-info /usr/local/share/info/chrony.info /usr/share/info/dir
|
|
||||||
|
|
||||||
Now that the software is successfully installed, the next step is to
|
|
||||||
set up a configuration file. The contents of this depend on the
|
|
||||||
network environment in which the computer operates. Typical scenarios
|
|
||||||
are described in the manual. The simplest case is for a computer with
|
|
||||||
a permanent Internet connection - suppose you want to use the NTP
|
|
||||||
server ntp1.foobar.com as your time reference. You would create an
|
|
||||||
/etc/chrony.conf file containing
|
|
||||||
|
|
||||||
server ntp1.foobar.com
|
|
||||||
driftfile /etc/chrony.drift
|
|
||||||
|
|
||||||
and then run /usr/local/sbin/chronyd.
|
|
||||||
|
|
||||||
|
|
||||||
172
Makefile.in
172
Makefile.in
@@ -1,9 +1,5 @@
|
|||||||
##################################################
|
##################################################
|
||||||
#
|
#
|
||||||
# $Header: /cvs/src/chrony/Makefile.in,v 1.48 2003/09/19 22:48:26 richard Exp $
|
|
||||||
#
|
|
||||||
# =======================================================================
|
|
||||||
#
|
|
||||||
# chronyd/chronyc - Programs for keeping computer clocks accurate.
|
# chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
#
|
#
|
||||||
# Copyright (C) Richard P. Curnow 1997-2003
|
# Copyright (C) Richard P. Curnow 1997-2003
|
||||||
@@ -25,77 +21,63 @@
|
|||||||
#
|
#
|
||||||
# Makefile template
|
# Makefile template
|
||||||
|
|
||||||
SYSCONFDIR=@SYSCONFDIR@
|
SYSCONFDIR = @SYSCONFDIR@
|
||||||
BINDIR=@BINDIR@
|
BINDIR = @BINDIR@
|
||||||
SBINDIR=@SBINDIR@
|
SBINDIR = @SBINDIR@
|
||||||
MANDIR=@MANDIR@
|
LOCALSTATEDIR = @LOCALSTATEDIR@
|
||||||
INFODIR=@INFODIR@
|
CHRONYVARDIR = @CHRONYVARDIR@
|
||||||
DOCDIR=@DOCDIR@
|
DESTDIR =
|
||||||
|
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CCWARNFLAGS = @CCWARNFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
OPTFLAGS = @CFLAGS@
|
CPPFLAGS = @CPPFLAGS@
|
||||||
CPPFLAGS = @CPPFLAGS@ @SYSDEFS@ @EXTRA_DEFS@
|
|
||||||
|
|
||||||
DESTDIR=
|
|
||||||
|
|
||||||
OBJS = util.o sched.o regress.o local.o \
|
|
||||||
sys.o main.o ntp_io.o ntp_core.o ntp_sources.o \
|
|
||||||
sources.o sourcestats.o reference.o \
|
|
||||||
logging.o conf.o cmdmon.o md5.o keys.o \
|
|
||||||
nameserv.o acquire.o manual.o addrfilt.o \
|
|
||||||
cmdparse.o mkdirpp.o rtc.o pktlength.o clientlog.o \
|
|
||||||
broadcast.o refclock.o refclock_shm.o refclock_sock.o \
|
|
||||||
refclock_pps.o
|
|
||||||
|
|
||||||
EXTRA_OBJS=@EXTRA_OBJECTS@
|
|
||||||
|
|
||||||
CLI_OBJS = client.o md5.o nameserv.o getdate.o cmdparse.o \
|
|
||||||
pktlength.o util.o
|
|
||||||
|
|
||||||
SRCS = $(patsubst %.o,%.c,$(OBJS))
|
|
||||||
EXTRA_SRCS = $(patsubst %.o,%.c,$(EXTRA_OBJS))
|
|
||||||
|
|
||||||
CLI_SRCS = $(patsubst %.o,%.c,$(CLI_OBJS))
|
|
||||||
|
|
||||||
LDFLAGS = @LDFLAGS@
|
LDFLAGS = @LDFLAGS@
|
||||||
|
|
||||||
|
EXTRA_OBJS = @EXTRA_OBJS@
|
||||||
|
|
||||||
|
OBJS = array.o cmdparse.o conf.o local.o logging.o main.o memory.o \
|
||||||
|
reference.o regress.o rtc.o samplefilt.o sched.o socket.o sources.o sourcestats.o \
|
||||||
|
stubs.o smooth.o sys.o sys_null.o tempcomp.o util.o $(EXTRA_OBJS)
|
||||||
|
|
||||||
|
EXTRA_CLI_OBJS = @EXTRA_CLI_OBJS@
|
||||||
|
|
||||||
|
CLI_OBJS = array.o client.o cmdparse.o getdate.o memory.o nameserv.o \
|
||||||
|
pktlength.o socket.o util.o $(EXTRA_CLI_OBJS)
|
||||||
|
|
||||||
|
ALL_OBJS = $(OBJS) $(CLI_OBJS)
|
||||||
|
|
||||||
LIBS = @LIBS@
|
LIBS = @LIBS@
|
||||||
|
EXTRA_LIBS = @EXTRA_LIBS@
|
||||||
EXTRA_LIBS=@EXTRA_LIBS@
|
EXTRA_CLI_LIBS = @EXTRA_CLI_LIBS@
|
||||||
EXTRA_CLI_LIBS=@EXTRA_CLI_LIBS@
|
|
||||||
|
|
||||||
CFLAGS = $(CCWARNFLAGS) $(OPTFLAGS)
|
|
||||||
|
|
||||||
# Until we have a main procedure we can link, just build object files
|
# Until we have a main procedure we can link, just build object files
|
||||||
# to test compilation
|
# to test compilation
|
||||||
|
|
||||||
all : chronyd chronyc
|
all : chronyd chronyc
|
||||||
|
|
||||||
chronyd : $(OBJS) $(EXTRA_OBJS)
|
chronyd : $(OBJS)
|
||||||
$(CC) $(OPTFLAGS) -o chronyd $(OBJS) $(EXTRA_OBJS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS)
|
$(CC) $(CFLAGS) -o chronyd $(OBJS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS)
|
||||||
|
|
||||||
chronyc : $(CLI_OBJS)
|
chronyc : $(CLI_OBJS)
|
||||||
$(CC) $(OPTFLAGS) -o chronyc $(CLI_OBJS) $(LDFLAGS) @READLINE_LINK@ $(LIBS) $(EXTRA_CLI_LIBS)
|
$(CC) $(CFLAGS) -o chronyc $(CLI_OBJS) $(LDFLAGS) $(LIBS) $(EXTRA_CLI_LIBS)
|
||||||
|
|
||||||
conf.o : conf.c
|
distclean : clean
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -DDEFAULT_CONF_DIR=\"$(SYSCONFDIR)\" -c $<
|
$(MAKE) -C doc distclean
|
||||||
|
$(MAKE) -C test/unit distclean
|
||||||
client.o : client.c
|
-rm -f .DS_Store
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) @READLINE_COMPILE@ -c $<
|
-rm -f Makefile config.h config.log
|
||||||
|
|
||||||
.depend :
|
|
||||||
gcc -MM $(SRCS) $(EXTRA_SRCS) > .depend
|
|
||||||
|
|
||||||
distclean :
|
|
||||||
-rm -f *.o *.s chronyc chronyd core options.h Makefile *~
|
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
-rm -f *.o *.s chronyc chronyd core *~
|
$(MAKE) -C test/unit clean
|
||||||
|
-rm -f *.o *.s chronyc chronyd core.* *~
|
||||||
|
-rm -f *.gcda *.gcno
|
||||||
|
-rm -rf .deps
|
||||||
|
-rm -rf *.dSYM
|
||||||
|
|
||||||
version.h : version.txt
|
getdate.c : getdate.y
|
||||||
./mkversion
|
bison -o getdate.c getdate.y
|
||||||
|
|
||||||
getdate.c : ;
|
# This can be used to force regeneration of getdate.c
|
||||||
getdate :
|
getdate :
|
||||||
bison -o getdate.c getdate.y
|
bison -o getdate.c getdate.y
|
||||||
|
|
||||||
@@ -103,33 +85,23 @@ getdate :
|
|||||||
# seem to vary between systems.
|
# seem to vary between systems.
|
||||||
|
|
||||||
install: chronyd chronyc
|
install: chronyd chronyc
|
||||||
|
[ -d $(DESTDIR)$(SYSCONFDIR) ] || mkdir -p $(DESTDIR)$(SYSCONFDIR)
|
||||||
[ -d $(DESTDIR)$(SBINDIR) ] || mkdir -p $(DESTDIR)$(SBINDIR)
|
[ -d $(DESTDIR)$(SBINDIR) ] || mkdir -p $(DESTDIR)$(SBINDIR)
|
||||||
[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
|
[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
|
||||||
[ -d $(DESTDIR)$(DOCDIR) ] || mkdir -p $(DESTDIR)$(DOCDIR)
|
[ -d $(DESTDIR)$(CHRONYVARDIR) ] || mkdir -p $(DESTDIR)$(CHRONYVARDIR)
|
||||||
[ -d $(DESTDIR)$(MANDIR)/man1 ] || mkdir -p $(DESTDIR)$(MANDIR)/man1
|
|
||||||
[ -d $(DESTDIR)$(MANDIR)/man5 ] || mkdir -p $(DESTDIR)$(MANDIR)/man5
|
|
||||||
[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
|
|
||||||
[ -d $(DESTDIR)$(DOCDIR) ] || mkdir -p $(DESTDIR)$(DOCDIR)
|
|
||||||
if [ -f $(DESTDIR)$(SBINDIR)/chronyd ]; then rm -f $(DESTDIR)$(SBINDIR)/chronyd ; fi
|
if [ -f $(DESTDIR)$(SBINDIR)/chronyd ]; then rm -f $(DESTDIR)$(SBINDIR)/chronyd ; fi
|
||||||
if [ -f $(DESTDIR)$(BINDIR)/chronyc ]; then rm -f $(DESTDIR)$(BINDIR)/chronyc ; fi
|
if [ -f $(DESTDIR)$(BINDIR)/chronyc ]; then rm -f $(DESTDIR)$(BINDIR)/chronyc ; fi
|
||||||
cp chronyd $(DESTDIR)$(SBINDIR)/chronyd
|
cp chronyd $(DESTDIR)$(SBINDIR)/chronyd
|
||||||
chmod 755 $(DESTDIR)$(SBINDIR)/chronyd
|
chmod 755 $(DESTDIR)$(SBINDIR)/chronyd
|
||||||
cp chronyc $(DESTDIR)$(BINDIR)/chronyc
|
cp chronyc $(DESTDIR)$(BINDIR)/chronyc
|
||||||
chmod 755 $(DESTDIR)$(BINDIR)/chronyc
|
chmod 755 $(DESTDIR)$(BINDIR)/chronyc
|
||||||
cp chrony.txt $(DESTDIR)$(DOCDIR)/chrony.txt
|
$(MAKE) -C doc install
|
||||||
chmod 644 $(DESTDIR)$(DOCDIR)/chrony.txt
|
|
||||||
cp COPYING $(DESTDIR)$(DOCDIR)/COPYING
|
docs :
|
||||||
chmod 644 $(DESTDIR)$(DOCDIR)/COPYING
|
$(MAKE) -C doc docs
|
||||||
cp README $(DESTDIR)$(DOCDIR)/README
|
|
||||||
chmod 644 $(DESTDIR)$(DOCDIR)/README
|
install-docs :
|
||||||
cp chrony.1 $(DESTDIR)$(MANDIR)/man1
|
$(MAKE) -C doc install-docs
|
||||||
chmod 644 $(DESTDIR)$(MANDIR)/man1/chrony.1
|
|
||||||
cp chronyc.1 $(DESTDIR)$(MANDIR)/man1
|
|
||||||
chmod 644 $(DESTDIR)$(MANDIR)/man1/chronyc.1
|
|
||||||
cp chronyd.8 $(DESTDIR)$(MANDIR)/man8
|
|
||||||
chmod 644 $(DESTDIR)$(MANDIR)/man8/chronyd.8
|
|
||||||
cp chrony.conf.5 $(DESTDIR)$(MANDIR)/man5
|
|
||||||
chmod 644 $(DESTDIR)$(MANDIR)/man5/chrony.conf.5
|
|
||||||
|
|
||||||
%.o : %.c
|
%.o : %.c
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
|
||||||
@@ -137,33 +109,31 @@ install: chronyd chronyc
|
|||||||
%.s : %.c
|
%.s : %.c
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -S $<
|
$(CC) $(CFLAGS) $(CPPFLAGS) -S $<
|
||||||
|
|
||||||
main.o logging.o client.o : version.h
|
quickcheck : chronyd chronyc
|
||||||
|
$(MAKE) -C test/unit check
|
||||||
|
cd test/simulation && ./run
|
||||||
|
cd test/system && ./run
|
||||||
|
|
||||||
# makeinfo v4 required to generate plain text and html
|
check : chronyd chronyc
|
||||||
MAKEINFO:=makeinfo
|
$(MAKE) -C test/unit check
|
||||||
|
cd test/simulation && ./run -i 20 -m 2
|
||||||
|
cd test/system && ./run
|
||||||
|
|
||||||
install-docs : docs
|
print-chronyd-objects :
|
||||||
[ -d $(DESTDIR)$(DOCDIR) ] || mkdir -p $(DESTDIR)$(DOCDIR)
|
@echo $(OBJS)
|
||||||
cp chrony.txt $(DESTDIR)$(DOCDIR)/chrony.txt
|
|
||||||
chmod 644 $(DESTDIR)$(DOCDIR)/chrony.txt
|
|
||||||
cp chrony.html $(DESTDIR)$(DOCDIR)/chrony.html
|
|
||||||
chmod 644 $(DESTDIR)$(DOCDIR)/chrony.html
|
|
||||||
[ -d $(DESTDIR)$(INFODIR) ] || mkdir -p $(DESTDIR)$(INFODIR)
|
|
||||||
cp chrony.info* $(DESTDIR)$(INFODIR)
|
|
||||||
chmod 644 $(DESTDIR)$(INFODIR)/chrony.info*
|
|
||||||
|
|
||||||
docs : chrony.txt chrony.html chrony.info
|
Makefile : Makefile.in configure
|
||||||
|
@echo
|
||||||
|
@echo Makefile needs to be regenerated, run ./configure
|
||||||
|
@echo
|
||||||
|
@exit 1
|
||||||
|
|
||||||
chrony.txt : chrony.texi
|
.deps:
|
||||||
$(MAKEINFO) --no-headers --number-sections -o chrony.txt chrony.texi
|
@mkdir .deps
|
||||||
|
|
||||||
chrony.html : chrony.texi
|
.deps/%.d: %.c | .deps
|
||||||
$(MAKEINFO) --no-split --html --number-sections -o chrony.html chrony.texi
|
@$(CC) -MM $(CPPFLAGS) -MT '$(<:%.c=%.o) $@' $< -o $@
|
||||||
|
|
||||||
chrony.info : chrony.texi
|
|
||||||
$(MAKEINFO) chrony.texi
|
|
||||||
|
|
||||||
# This is only relevant if you're maintaining the website!
|
|
||||||
faq.php : faq.txt faqgen.pl
|
|
||||||
perl faqgen.pl < faq.txt > faq.php
|
|
||||||
|
|
||||||
|
ifndef NODEPS
|
||||||
|
-include $(ALL_OBJS:%.o=.deps/%.d)
|
||||||
|
endif
|
||||||
|
|||||||
606
NEWS
606
NEWS
@@ -1,6 +1,608 @@
|
|||||||
|
New in version 4.1
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add support for NTS servers specified by IP address (matching
|
||||||
|
Subject Alternative Name in server certificate)
|
||||||
|
* Add source-specific configuration of trusted certificates
|
||||||
|
* Allow multiple files and directories with trusted certificates
|
||||||
|
* Allow multiple pairs of server keys and certificates
|
||||||
|
* Add copy option to server/pool directive
|
||||||
|
* Increase PPS lock limit to 40% of pulse interval
|
||||||
|
* Perform source selection immediately after loading dump files
|
||||||
|
* Reload dump files for addresses negotiated by NTS-KE server
|
||||||
|
* Update seccomp filter
|
||||||
|
* Restart ongoing name resolution on online command
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix responding to IPv4 command requests on FreeBSD
|
||||||
|
* Fix dump files to not include uncorrected offset
|
||||||
|
* Fix initstepslew to accept time from own NTP clients
|
||||||
|
* Reset NTP address and port when no longer negotiated by NTS-KE server
|
||||||
|
|
||||||
|
New in version 4.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add support for Network Time Security (NTS) authentication
|
||||||
|
* Add support for AES-CMAC keys (AES128, AES256) with Nettle
|
||||||
|
* Add authselectmode directive to control selection of unauthenticated sources
|
||||||
|
* Add binddevice, bindacqdevice, bindcmddevice directives
|
||||||
|
* Add confdir directive to better support fragmented configuration
|
||||||
|
* Add sourcedir directive and "reload sources" command to support dynamic
|
||||||
|
NTP sources specified in files
|
||||||
|
* Add clockprecision directive
|
||||||
|
* Add dscp directive to set Differentiated Services Code Point (DSCP)
|
||||||
|
* Add -L option to limit log messages by severity
|
||||||
|
* Add -p option to print whole configuration with included files
|
||||||
|
* Add -U option to allow start under non-root user
|
||||||
|
* Allow maxsamples to be set to 1 for faster update with -q/-Q option
|
||||||
|
* Avoid replacing NTP sources with sources that have unreachable address
|
||||||
|
* Improve pools to repeat name resolution to get "maxsources" sources
|
||||||
|
* Improve source selection with trusted sources
|
||||||
|
* Improve NTP loop test to prevent synchronisation to itself
|
||||||
|
* Repeat iburst when NTP source is switched from offline state to online
|
||||||
|
* Update clock synchronisation status and leap status more frequently
|
||||||
|
* Update seccomp filter
|
||||||
|
* Add "add pool" command
|
||||||
|
* Add "reset sources" command to drop all measurements
|
||||||
|
* Add authdata command to print details about NTP authentication
|
||||||
|
* Add selectdata command to print details about source selection
|
||||||
|
* Add -N option and sourcename command to print original names of sources
|
||||||
|
* Add -a option to some commands to print also unresolved sources
|
||||||
|
* Add -k, -p, -r options to clients command to select, limit, reset data
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Don't set interface for NTP responses to allow asymmetric routing
|
||||||
|
* Handle RTCs that don't support interrupts
|
||||||
|
* Respond to command requests with correct address on multihomed hosts
|
||||||
|
|
||||||
|
Removed features
|
||||||
|
----------------
|
||||||
|
* Drop support for RIPEMD keys (RMD128, RMD160, RMD256, RMD320)
|
||||||
|
* Drop support for long (non-standard) MACs in NTPv4 packets (chrony 2.x
|
||||||
|
clients using non-MD5/SHA1 keys need to use option "version 3")
|
||||||
|
* Drop support for line editing with GNU Readline
|
||||||
|
|
||||||
|
New in version 3.5.1
|
||||||
|
====================
|
||||||
|
|
||||||
|
Security fixes
|
||||||
|
--------------
|
||||||
|
* Create new file when writing pidfile (CVE-2020-14367)
|
||||||
|
|
||||||
|
New in version 3.5
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add support for more accurate reading of PHC on Linux 5.0
|
||||||
|
* Add support for hardware timestamping on interfaces with read-only
|
||||||
|
timestamping configuration
|
||||||
|
* Add support for memory locking and real-time priority on FreeBSD,
|
||||||
|
NetBSD, Solaris
|
||||||
|
* Update seccomp filter to work on more architectures
|
||||||
|
* Validate refclock driver options
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix bindaddress directive on FreeBSD
|
||||||
|
* Fix transposition of hardware RX timestamp on Linux 4.13 and later
|
||||||
|
* Fix building on non-glibc systems
|
||||||
|
|
||||||
|
New in version 3.4
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add filter option to server/pool/peer directive
|
||||||
|
* Add minsamples and maxsamples options to hwtimestamp directive
|
||||||
|
* Add support for faster frequency adjustments in Linux 4.19
|
||||||
|
* Change default pidfile to /var/run/chrony/chronyd.pid to allow
|
||||||
|
chronyd without root privileges to remove it on exit
|
||||||
|
* Disable sub-second polling intervals for distant NTP sources
|
||||||
|
* Extend range of supported sub-second polling intervals
|
||||||
|
* Get/set IPv4 destination/source address of NTP packets on FreeBSD
|
||||||
|
* Make burst options and command useful with short polling intervals
|
||||||
|
* Modify auto_offline option to activate when sending request failed
|
||||||
|
* Respond from interface that received NTP request if possible
|
||||||
|
* Add onoffline command to switch between online and offline state
|
||||||
|
according to current system network configuration
|
||||||
|
* Improve example NetworkManager dispatcher script
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Avoid waiting in Linux getrandom system call
|
||||||
|
* Fix PPS support on FreeBSD and NetBSD
|
||||||
|
|
||||||
|
New in version 3.3
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add burst option to server/pool directive
|
||||||
|
* Add stratum and tai options to refclock directive
|
||||||
|
* Add support for Nettle crypto library
|
||||||
|
* Add workaround for missing kernel receive timestamps on Linux
|
||||||
|
* Wait for late hardware transmit timestamps
|
||||||
|
* Improve source selection with unreachable sources
|
||||||
|
* Improve protection against replay attacks on symmetric mode
|
||||||
|
* Allow PHC refclock to use socket in /var/run/chrony
|
||||||
|
* Add shutdown command to stop chronyd
|
||||||
|
* Simplify format of response to manual list command
|
||||||
|
* Improve handling of unknown responses in chronyc
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Respond to NTPv1 client requests with zero mode
|
||||||
|
* Fix -x option to not require CAP_SYS_TIME under non-root user
|
||||||
|
* Fix acquisitionport directive to work with privilege separation
|
||||||
|
* Fix handling of socket errors on Linux to avoid high CPU usage
|
||||||
|
* Fix chronyc to not get stuck in infinite loop after clock step
|
||||||
|
|
||||||
|
New in version 3.2
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Improve stability with NTP sources and reference clocks
|
||||||
|
* Improve stability with hardware timestamping
|
||||||
|
* Improve support for NTP interleaved modes
|
||||||
|
* Control frequency of system clock on macOS 10.13 and later
|
||||||
|
* Set TAI-UTC offset of system clock with leapsectz directive
|
||||||
|
* Minimise data in client requests to improve privacy
|
||||||
|
* Allow transmit-only hardware timestamping
|
||||||
|
* Add support for new timestamping options introduced in Linux 4.13
|
||||||
|
* Add root delay, root dispersion and maximum error to tracking log
|
||||||
|
* Add mindelay and asymmetry options to server/peer/pool directive
|
||||||
|
* Add extpps option to PHC refclock to timestamp external PPS signal
|
||||||
|
* Add pps option to refclock directive to treat any refclock as PPS
|
||||||
|
* Add width option to refclock directive to filter wrong pulse edges
|
||||||
|
* Add rxfilter option to hwtimestamp directive
|
||||||
|
* Add -x option to disable control of system clock
|
||||||
|
* Add -l option to log to specified file instead of syslog
|
||||||
|
* Allow multiple command-line options to be specified together
|
||||||
|
* Allow starting without root privileges with -Q option
|
||||||
|
* Update seccomp filter for new glibc versions
|
||||||
|
* Dump history on exit by default with dumpdir directive
|
||||||
|
* Use hardening compiler options by default
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Don't drop PHC samples with low-resolution system clock
|
||||||
|
* Ignore outliers in PHC tracking, RTC tracking, manual input
|
||||||
|
* Increase polling interval when peer is not responding
|
||||||
|
* Exit with error message when include directive fails
|
||||||
|
* Don't allow slash after hostname in allow/deny directive/command
|
||||||
|
* Try to connect to all addresses in chronyc before giving up
|
||||||
|
|
||||||
|
New in version 3.1
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add support for precise cross timestamping of PHC on Linux
|
||||||
|
* Add minpoll, precision, nocrossts options to hwtimestamp directive
|
||||||
|
* Add rawmeasurements option to log directive and modify measurements
|
||||||
|
option to log only valid measurements from synchronised sources
|
||||||
|
* Allow sub-second polling interval with NTP sources
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix time smoothing in interleaved mode
|
||||||
|
|
||||||
|
New in version 3.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add support for software and hardware timestamping on Linux
|
||||||
|
* Add support for client/server and symmetric interleaved modes
|
||||||
|
* Add support for MS-SNTP authentication in Samba
|
||||||
|
* Add support for truncated MACs in NTPv4 packets
|
||||||
|
* Estimate and correct for asymmetric network jitter
|
||||||
|
* Increase default minsamples and polltarget to improve stability
|
||||||
|
with very low jitter
|
||||||
|
* Add maxjitter directive to limit source selection by jitter
|
||||||
|
* Add offset option to server/pool/peer directive
|
||||||
|
* Add maxlockage option to refclock directive
|
||||||
|
* Add -t option to chronyd to exit after specified time
|
||||||
|
* Add partial protection against replay attacks on symmetric mode
|
||||||
|
* Don't reset polling interval when switching sources to online state
|
||||||
|
* Allow rate limiting with very short intervals
|
||||||
|
* Improve maximum server throughput on Linux and NetBSD
|
||||||
|
* Remove dump files after start
|
||||||
|
* Add tab-completion to chronyc with libedit/readline
|
||||||
|
* Add ntpdata command to print details about NTP measurements
|
||||||
|
* Allow all source options to be set in add server/peer command
|
||||||
|
* Indicate truncated addresses/hostnames in chronyc output
|
||||||
|
* Print reference IDs as hexadecimal numbers to avoid confusion with
|
||||||
|
IPv4 addresses
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix crash with disabled asynchronous name resolving
|
||||||
|
|
||||||
|
New in version 2.4.1
|
||||||
|
====================
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix processing of kernel timestamps on non-Linux systems
|
||||||
|
* Fix crash with smoothtime directive
|
||||||
|
* Fix validation of refclock sample times
|
||||||
|
* Fix parsing of refclock directive
|
||||||
|
|
||||||
|
New in version 2.4
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add orphan option to local directive for orphan mode compatible with ntpd
|
||||||
|
* Add distance option to local directive to set activation threshold
|
||||||
|
(1 second by default)
|
||||||
|
* Add maxdrift directive to set maximum allowed drift of system clock
|
||||||
|
* Try to replace NTP sources exceeding maximum distance
|
||||||
|
* Randomise source replacement to avoid getting stuck with bad sources
|
||||||
|
* Randomise selection of sources from pools on start
|
||||||
|
* Ignore reference timestamp as ntpd doesn't always set it correctly
|
||||||
|
* Modify tracking report to use same values as seen by NTP clients
|
||||||
|
* Add -c option to chronyc to write reports in CSV format
|
||||||
|
* Provide detailed manual pages
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix SOCK refclock to work correctly when not specified as last refclock
|
||||||
|
* Fix initstepslew and -q/-Q options to accept time from own NTP clients
|
||||||
|
* Fix authentication with keys using 512-bit hash functions
|
||||||
|
* Fix crash on exit when multiple signals are received
|
||||||
|
* Fix conversion of very small floating-point numbers in command packets
|
||||||
|
|
||||||
|
Removed features
|
||||||
|
----------------
|
||||||
|
* Drop documentation in Texinfo format
|
||||||
|
|
||||||
|
New in version 2.3
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add support for NTP and command response rate limiting
|
||||||
|
* Add support for dropping root privileges on Mac OS X, FreeBSD, Solaris
|
||||||
|
* Add require and trust options for source selection
|
||||||
|
* Enable logchange by default (1 second threshold)
|
||||||
|
* Set RTC on Mac OS X with rtcsync directive
|
||||||
|
* Allow binding to NTP port after dropping root privileges on NetBSD
|
||||||
|
* Drop CAP_NET_BIND_SERVICE capability on Linux when NTP port is disabled
|
||||||
|
* Resolve names in separate process when seccomp filter is enabled
|
||||||
|
* Replace old records in client log when memory limit is reached
|
||||||
|
* Don't reveal local time and synchronisation state in client packets
|
||||||
|
* Don't keep client sockets open for longer than necessary
|
||||||
|
* Ignore poll in KoD RATE packets as ntpd doesn't always set it correctly
|
||||||
|
* Warn when using keys shorter than 80 bits
|
||||||
|
* Add keygen command to generate random keys easily
|
||||||
|
* Add serverstats command to report NTP and command packet statistics
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix clock correction after making step on Mac OS X
|
||||||
|
* Fix building on Solaris
|
||||||
|
|
||||||
|
New in version 2.2.1
|
||||||
|
====================
|
||||||
|
|
||||||
|
Security fixes
|
||||||
|
--------------
|
||||||
|
* Restrict authentication of NTP server/peer to specified key (CVE-2016-1567)
|
||||||
|
|
||||||
|
New in version 2.2
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add support for configuration and monitoring over Unix domain socket
|
||||||
|
(accessible by root or chrony user when root privileges are dropped)
|
||||||
|
* Add support for system call filtering with seccomp on Linux (experimental)
|
||||||
|
* Add support for dropping root privileges on NetBSD
|
||||||
|
* Control frequency of system clock on FreeBSD, NetBSD, Solaris
|
||||||
|
* Add system leap second handling mode on FreeBSD, NetBSD, Solaris
|
||||||
|
* Add dynamic drift removal on Mac OS X
|
||||||
|
* Add support for setting real-time priority on Mac OS X
|
||||||
|
* Add maxdistance directive to limit source selection by root distance
|
||||||
|
(3 seconds by default)
|
||||||
|
* Add refresh command to get new addresses of NTP sources
|
||||||
|
* Allow wildcard patterns in include directive
|
||||||
|
* Restore time from driftfile with -s option if later than RTC time
|
||||||
|
* Add configure option to set default hwclockfile
|
||||||
|
* Add -d option to chronyc to enable debug messages
|
||||||
|
* Allow multiple addresses to be specified for chronyc with -h option
|
||||||
|
and reconnect when no valid reply is received
|
||||||
|
* Make check interval in waitsync command configurable
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix building on NetBSD, Solaris
|
||||||
|
* Restore time from driftfile with -s option if reading RTC failed
|
||||||
|
|
||||||
|
Removed features
|
||||||
|
----------------
|
||||||
|
* Drop support for authentication with command key (run-time configuration
|
||||||
|
is now allowed only for local users that can access the Unix domain socket)
|
||||||
|
|
||||||
|
New in version 2.1.1
|
||||||
|
====================
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix clock stepping by integer number of seconds on Linux
|
||||||
|
|
||||||
|
New in version 2.1
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add support for Mac OS X
|
||||||
|
* Try to replace unreachable and falseticker servers/peers specified
|
||||||
|
by name like pool sources
|
||||||
|
* Add leaponly option to smoothtime directive to allow synchronised
|
||||||
|
leap smear between multiple servers
|
||||||
|
* Use specific reference ID when smoothing served time
|
||||||
|
* Add smoothing command to report time smoothing status
|
||||||
|
* Add smoothtime command to activate or reset time smoothing
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix crash in source selection with preferred sources
|
||||||
|
* Fix resetting of time smoothing
|
||||||
|
* Include packet precision in peer dispersion
|
||||||
|
* Fix crash in chronyc on invalid command syntax
|
||||||
|
|
||||||
|
New in version 2.0
|
||||||
|
==================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Update to NTP version 4 (RFC 5905)
|
||||||
|
* Add pool directive to specify pool of NTP servers
|
||||||
|
* Add leapsecmode directive to select how to correct clock for leap second
|
||||||
|
* Add smoothtime directive to smooth served time and enable leap smear
|
||||||
|
* Add minsources directive to set required number of selectable sources
|
||||||
|
* Add minsamples and maxsamples options for all sources
|
||||||
|
* Add tempcomp configuration with list of points
|
||||||
|
* Allow unlimited number of NTP sources, refclocks and keys
|
||||||
|
* Allow unreachable sources to remain selected
|
||||||
|
* Improve source selection
|
||||||
|
* Handle offline sources as unreachable
|
||||||
|
* Open NTP server port only when necessary (client access is allowed by
|
||||||
|
allow directive/command or peer/broadcast is configured)
|
||||||
|
* Change default bindcmdaddress to loopback address
|
||||||
|
* Change default maxdelay to 3 seconds
|
||||||
|
* Change default stratumweight to 0.001
|
||||||
|
* Update adjtimex synchronisation status
|
||||||
|
* Use system headers for adjtimex
|
||||||
|
* Check for memory allocation errors
|
||||||
|
* Reduce memory usage
|
||||||
|
* Add configure options to compile without NTP, cmdmon, refclock support
|
||||||
|
* Extend makestep command to set automatic clock stepping
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Add sanity checks for time and frequency offset
|
||||||
|
* Don't report synchronised status during leap second
|
||||||
|
* Don't combine reference clocks with close NTP sources
|
||||||
|
* Fix accepting requests from configured sources
|
||||||
|
* Fix initial fallback drift setting
|
||||||
|
|
||||||
|
New in version 1.31.1
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Security fixes
|
||||||
|
--------------
|
||||||
|
* Protect authenticated symmetric NTP associations against DoS attacks
|
||||||
|
(CVE-2015-1853)
|
||||||
|
* Fix access configuration with subnet size indivisible by 4 (CVE-2015-1821)
|
||||||
|
* Fix initialization of reply slots for authenticated commands (CVE-2015-1822)
|
||||||
|
|
||||||
|
New in version 1.31
|
||||||
|
===================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Support operation in other NTP eras (next era begins in 2036),
|
||||||
|
NTP time is mapped to [-50, +86] years around build date by default
|
||||||
|
* Restore time from driftfile with -s when RTC is missing/unsupported
|
||||||
|
* Close connected client sockets when not waiting for reply
|
||||||
|
* Use one client socket with random port when acquisitionport is 0
|
||||||
|
* Use NTP packets instead of UDP echo for presend
|
||||||
|
* Don't adjust polling interval when sending fails
|
||||||
|
* Allow binding to addresses that don't exist yet
|
||||||
|
* Ignore measurements around leap second
|
||||||
|
* Improve detection of unexpected time jumps
|
||||||
|
* Include example of logrotate configuration, systemd services and
|
||||||
|
NetworkManager dispatcher script
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Reconnect client sockets for each request to follow changes
|
||||||
|
in network configuration automatically
|
||||||
|
* Restart timer when polling interval is changed on reset
|
||||||
|
|
||||||
|
New in version 1.30
|
||||||
|
===================
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
* Add asynchronous name resolving with POSIX threads
|
||||||
|
* Add PTP hardware clock (PHC) refclock driver
|
||||||
|
* Add new generic clock driver to slew by adjusting frequency only
|
||||||
|
(without kernel PLL or adjtime) and use it on Linux
|
||||||
|
* Add rtcautotrim directive to trim RTC automatically
|
||||||
|
* Add hwclockfile directive to share RTC LOCAL/UTC setting with hwclock
|
||||||
|
* Add maxslewrate directive to set maximum allowed slew rate
|
||||||
|
* Add maxdispersion option for refclocks
|
||||||
|
* Add -q/-Q options to set clock/print offset once and exit
|
||||||
|
* Allow directives to be specified on chronyd command line
|
||||||
|
* Replace frequency scaling in Linux driver with retaining of tick
|
||||||
|
* Try to detect unexpected forward time jumps and reset state
|
||||||
|
* Exit with non-zero code when maxchange limit is reached
|
||||||
|
* Improve makestep to not start and stop slew unnecessarily
|
||||||
|
* Change default corrtimeratio to 3.0 to improve frequency accuracy
|
||||||
|
* Announce leap second only on last day of June and December
|
||||||
|
* Use separate connected client sockets for each NTP server
|
||||||
|
* Remove separate NTP implementation used for initstepslew
|
||||||
|
* Limit maximum minpoll set by KoD RATE to default maxpoll
|
||||||
|
* Don't send NTP requests with unknown key
|
||||||
|
* Print warning when source is added with unknown key
|
||||||
|
* Take leap second in PPS refclock from locked source
|
||||||
|
* Make reading of RTC for initial trim more reliable
|
||||||
|
* Don't create cmdmon sockets when cmdport is 0
|
||||||
|
* Add configure option to set default user to drop root privileges
|
||||||
|
* Add configure option to compile with debug messages
|
||||||
|
* Print debug messages when -d is used more than once
|
||||||
|
* Change format of messages written to terminal with -d
|
||||||
|
* Write fatal messages also to stderr with -n
|
||||||
|
* Use IP_RECVERR socket option in chronyc to not wait unnecessarily
|
||||||
|
* Shorten default chronyc timeout for localhost
|
||||||
|
* Change default hostname in chronyc from localhost to 127.0.0.1
|
||||||
|
* Print error message on invalid syntax with all chronyc commands
|
||||||
|
* Include simulation test suite using clknetsim
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
* Fix crash when selecting with multiple preferred sources
|
||||||
|
* Fix frequency calculation with large frequency offsets
|
||||||
|
* Fix code writing drift and RTC files to compile correctly
|
||||||
|
* Fix -4/-6 options in chronyc to not reset hostname set by -h
|
||||||
|
* Fix refclock sample validation with sub-second polling interval
|
||||||
|
* Set stratum correctly with non-PPS SOCK refclock and local stratum
|
||||||
|
* Modify dispersion accounting in refclocks to prevent PPS getting
|
||||||
|
stuck with large dispersion and not accepting new samples
|
||||||
|
|
||||||
|
New in version 1.29.1
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Security fixes
|
||||||
|
--------------
|
||||||
|
* Modify chronyc protocol to prevent amplification attacks (CVE-2014-0021)
|
||||||
|
(incompatible with previous protocol version, chronyc supports both)
|
||||||
|
|
||||||
|
New in version 1.29
|
||||||
|
===================
|
||||||
|
|
||||||
|
Security fixes
|
||||||
|
--------------
|
||||||
|
* Fix crash when processing crafted commands (CVE-2012-4502)
|
||||||
|
(possible with IP addresses allowed by cmdallow and localhost)
|
||||||
|
* Don't send uninitialized data in SUBNETS_ACCESSED and CLIENT_ACCESSES
|
||||||
|
replies (CVE-2012-4503) (not used by chronyc)
|
||||||
|
|
||||||
|
Other changes
|
||||||
|
-------------
|
||||||
|
* Drop support for SUBNETS_ACCESSED and CLIENT_ACCESSES commands
|
||||||
|
|
||||||
|
New in version 1.28
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Combine sources to improve accuracy
|
||||||
|
* Make config and command parser strict
|
||||||
|
* Add -a option to chronyc to authenticate automatically
|
||||||
|
* Add -R option to ignore initstepslew and makestep directives
|
||||||
|
* Add generatecommandkey, minsamples, maxsamples and user directives
|
||||||
|
* Improve compatibility with NTPv1 and NTPv2 clients
|
||||||
|
* Create sockets only in selected family with -4/-6 option
|
||||||
|
* Treat address bind errors as non-fatal
|
||||||
|
* Extend tracking log
|
||||||
|
* Accept float values as initstepslew threshold
|
||||||
|
* Allow hostnames in offline, online and burst commands
|
||||||
|
* Fix and improve peer polling
|
||||||
|
* Fix crash in config parsing with too many servers
|
||||||
|
* Fix crash with duplicated initstepslew address
|
||||||
|
* Fix delta calculation with extreme frequency offsets
|
||||||
|
* Set local stratum correctly
|
||||||
|
* Remove unnecessary adjtimex calls
|
||||||
|
* Set paths in documentation by configure
|
||||||
|
* Update chrony.spec
|
||||||
|
|
||||||
|
New in version 1.27
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Support for stronger keys via NSS or libtomcrypt library
|
||||||
|
* Support reading leap second data from tz database
|
||||||
|
* Support for precise clock stepping on Linux
|
||||||
|
* Support for nanoseconds in SHM refclock
|
||||||
|
* Make offset corrections smoother on Linux
|
||||||
|
* Make transmit timestamps random below clock precision
|
||||||
|
* Add corrtimeratio and maxchange directives
|
||||||
|
* Extend tracking, sources and activity reports
|
||||||
|
* Wait in foreground process until daemon is fully initialized
|
||||||
|
* Fix crash with slow name resolving
|
||||||
|
* Fix iburst with jittery sources
|
||||||
|
* Fix offset stored in rtc data right after trimrtc
|
||||||
|
* Fix crash and hang with RTC or manual samples
|
||||||
|
* Don't use readonly adjtime on Linux kernels before 2.6.28
|
||||||
|
* Changed chronyc protocol, incompatible with older versions
|
||||||
|
|
||||||
|
New in version 1.26
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Add compatibility with Linux 3.0 and later
|
||||||
|
* Use proper source address in NTP replies on multihomed IPv6 hosts
|
||||||
|
* Accept NTP packets with versions 4, 3 and 2
|
||||||
|
* Cope with unexpected backward time jumps
|
||||||
|
* Don't reset kernel frequency on start without drift file
|
||||||
|
* Retry on permanent DNS error by default
|
||||||
|
* Add waitsync command
|
||||||
|
|
||||||
|
New in version 1.25
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Improve accuracy with NTP sources
|
||||||
|
* Improve accuracy with reference clocks
|
||||||
|
* Improve polling interval adjustment
|
||||||
|
* Improve stability with temporary asymmetric delays
|
||||||
|
* Improve source selection
|
||||||
|
* Improve initial synchronisation
|
||||||
|
* Add delayed server name resolving
|
||||||
|
* Add temperature compensation
|
||||||
|
* Add nanosecond slewing to Linux driver
|
||||||
|
* Add fallback drifts
|
||||||
|
* Add iburst, minstratum, maxdelaydevratio, polltarget,
|
||||||
|
prefer, noselect options
|
||||||
|
* Add rtcsync directive to enable Linux 11-minute mode
|
||||||
|
* Add reselectdist, stratumweight, logbanner, maxclockerror,
|
||||||
|
include directives
|
||||||
|
* Add -n option to not detach daemon from terminal
|
||||||
|
* Fix pidfile directive
|
||||||
|
* Fix name resolving with disabled IPv6 support
|
||||||
|
* Fix reloading sample histories with reference clocks
|
||||||
|
* Fix crash with auto_offline option
|
||||||
|
* Fix online command on auto_offline sources
|
||||||
|
* Fix file descriptor leaks
|
||||||
|
* Increase burst polling interval and stop on KoD RATE
|
||||||
|
* Set maxupdateskew to 1000 ppm by default
|
||||||
|
* Require password for clients command
|
||||||
|
* Update drift file at most once per hour
|
||||||
|
* Use system headers for Linux RTC support
|
||||||
|
* Reduce default chronyc timeout and make it configurable
|
||||||
|
* Avoid large values in chronyc sources and sourcestats output
|
||||||
|
* Add reselect command to force reselecting best source
|
||||||
|
* Add -m option to allow multiple commands on command line
|
||||||
|
|
||||||
New in version 1.24
|
New in version 1.24
|
||||||
===================
|
===================
|
||||||
|
|
||||||
|
Security fixes
|
||||||
|
--------------
|
||||||
|
* Don't reply to invalid cmdmon packets (CVE-2010-0292)
|
||||||
|
* Limit client log memory size (CVE-2010-0293)
|
||||||
|
* Limit rate of syslog messages (CVE-2010-0294)
|
||||||
|
|
||||||
|
Bug fixes/Enhancements
|
||||||
|
----------------------
|
||||||
* Support for reference clocks (SHM, SOCK, PPS drivers)
|
* Support for reference clocks (SHM, SOCK, PPS drivers)
|
||||||
* IPv6 support
|
* IPv6 support
|
||||||
* Linux capabilities support (to drop root privileges)
|
* Linux capabilities support (to drop root privileges)
|
||||||
@@ -12,8 +614,10 @@ New in version 1.24
|
|||||||
* NTP client support for KoD RATE
|
* NTP client support for KoD RATE
|
||||||
* Read kernel timestamps for received NTP packets
|
* Read kernel timestamps for received NTP packets
|
||||||
* Reply to NTP requests with correct address on multihomed hosts
|
* Reply to NTP requests with correct address on multihomed hosts
|
||||||
* Add option to limit client log memory size
|
|
||||||
* Retry name resolving after temporary failure
|
* Retry name resolving after temporary failure
|
||||||
|
* Fix makestep command, make it available on all systems
|
||||||
|
* Add makestep directive for automatic clock stepping
|
||||||
|
* Don't require _bigadj kernel symbol on NetBSD
|
||||||
* Avoid blocking read in Linux RTC driver
|
* Avoid blocking read in Linux RTC driver
|
||||||
* Support for Linux on S/390 and PowerPC
|
* Support for Linux on S/390 and PowerPC
|
||||||
* Fix various bugs on 64-bit systems
|
* Fix various bugs on 64-bit systems
|
||||||
|
|||||||
255
README
255
README
@@ -2,121 +2,71 @@ This is the README for chrony.
|
|||||||
|
|
||||||
What is chrony?
|
What is chrony?
|
||||||
===============
|
===============
|
||||||
Chrony is a pair of programs for maintaining the accuracy of computer
|
|
||||||
clocks.
|
|
||||||
|
|
||||||
chronyd is a (background) daemon program that can be started at boot
|
chrony is a versatile implementation of the Network Time Protocol (NTP).
|
||||||
time. This does most of the work.
|
It can synchronise the system clock with NTP servers, reference clocks
|
||||||
|
(e.g. GPS receiver), and manual input using wristwatch and keyboard.
|
||||||
|
It can also operate as an NTPv4 (RFC 5905) server and peer to provide
|
||||||
|
a time service to other computers in the network.
|
||||||
|
|
||||||
chronyc is a command-line interface program which can be used to
|
It is designed to perform well in a wide range of conditions, including
|
||||||
monitor chronyd's performance and to change various operating
|
intermittent network connections, heavily congested networks, changing
|
||||||
parateters whilst it is running.
|
temperatures (ordinary computer clocks are sensitive to temperature),
|
||||||
|
and systems that do not run continuosly, or run on a virtual machine.
|
||||||
|
|
||||||
chronyd's main function is to obtain measurements of the true (UTC)
|
Typical accuracy between two machines synchronised over the Internet is
|
||||||
time from one of several sources, and correct the system clock
|
within a few milliseconds; on a LAN, accuracy is typically in tens of
|
||||||
accordingly. It also works out the rate at which the system clock
|
microseconds. With hardware timestamping, or a hardware reference clock,
|
||||||
gains or loses time and uses this information to keep it accurate
|
sub-microsecond accuracy may be possible.
|
||||||
between measurements from the reference.
|
|
||||||
|
|
||||||
The reference time can be derived from Network Time Protocol (NTP)
|
|
||||||
servers, reference clocks, or wristwatch-and-keyboard (via chronyc).
|
|
||||||
The main source of information about the Network Time Protocol is
|
|
||||||
http://www.eecis.udel.edu/~ntp.
|
|
||||||
|
|
||||||
It is designed so that it can work on computers which only have
|
|
||||||
intermittent access to reference sources, for example computers which
|
|
||||||
use a dial-up account to access the Internet. Of course, it will work
|
|
||||||
on computers with permanent connections too.
|
|
||||||
|
|
||||||
In addition, on Linux it can monitor the system's real time clock
|
|
||||||
performance, so the system can maintain accurate time even across
|
|
||||||
reboots.
|
|
||||||
|
|
||||||
Typical accuracies available between 2 machines are
|
|
||||||
|
|
||||||
On an ethernet LAN : 100-200 microseconds, often much better
|
|
||||||
On a V32bis dial-up modem connection : 10's of milliseconds (from one
|
|
||||||
session to the next)
|
|
||||||
|
|
||||||
With a good reference clock the accuracy can reach one microsecond.
|
|
||||||
|
|
||||||
chronyd can also operate as an RFC1305-compatible NTP server and peer.
|
|
||||||
|
|
||||||
|
Two programs are included in chrony, chronyd is a daemon that can be
|
||||||
|
started at boot time and chronyc is a command-line interface program
|
||||||
|
which can be used to monitor chronyd's performance and to change various
|
||||||
|
operating parameters whilst it is running.
|
||||||
|
|
||||||
What will chrony run on?
|
What will chrony run on?
|
||||||
========================
|
========================
|
||||||
|
|
||||||
Chrony can be successfully built and run on
|
The software is known to work on Linux, FreeBSD, NetBSD, macOS and
|
||||||
|
Solaris. Closely related systems may work too. Any other system will
|
||||||
1. Linux v1.2.13, v2.0.x, 2.1.x (partially), 2.2.x, 2.3.x, 2.4.x, 2.6.x.
|
likely require a porting exercise.
|
||||||
Real time clock support is limited to 2.0.32 onwards and to 2.2, 2.3,
|
|
||||||
2.4 and 2.6 series only. i386, x86_64, PowerPC are known to be
|
|
||||||
supported.
|
|
||||||
|
|
||||||
2. Solaris 2.5/2.5.1/2.6/2.7/2.8 (various platforms)
|
|
||||||
|
|
||||||
3. SunOS 4.1.4 (Sparc 2 and Sparc 20)
|
|
||||||
|
|
||||||
4. BSD/386 v1.1 has been reported to work using the SunOS 4.1 driver.
|
|
||||||
|
|
||||||
5. NetBSD.
|
|
||||||
|
|
||||||
Any other system will require a porting exercise. You would need to
|
|
||||||
start from one of the existing system-specific drivers and look into
|
|
||||||
the quirks of certain system calls and the kernel on your target
|
|
||||||
system. (This is described in the manual).
|
|
||||||
|
|
||||||
How do I set it up?
|
How do I set it up?
|
||||||
===================
|
===================
|
||||||
|
|
||||||
The file INSTALL gives instructions. On supported systems the
|
The file INSTALL gives instructions. On supported systems the
|
||||||
compilation process should be automatic.
|
compilation process should be automatic. You will need a C compiler,
|
||||||
|
e.g. gcc or clang.
|
||||||
You will need an ANSI C compiler -- gcc is recommended.
|
|
||||||
|
|
||||||
The manual (in texinfo and text formats) describes how to set the
|
|
||||||
software up for the less straightforward cases.
|
|
||||||
|
|
||||||
What documentation is there?
|
What documentation is there?
|
||||||
============================
|
============================
|
||||||
|
|
||||||
A manual is supplied in Texinfo format (chrony.texi) and
|
The distribution includes manual pages and a document containing
|
||||||
ready-formatted plain text (chrony.txt) in the distribution.
|
Frequently Asked Questions (FAQ).
|
||||||
|
|
||||||
There is also information available on the chrony web pages, accessible
|
The documentation is also available on the chrony web pages, accessible
|
||||||
through the URL
|
through the URL
|
||||||
|
|
||||||
http://chrony.tuxfamily.org/
|
https://chrony.tuxfamily.org/
|
||||||
|
|
||||||
What can chrony not do?
|
|
||||||
=======================
|
|
||||||
|
|
||||||
Compared to the `reference' RFC1305 implementation xntpd, chronyd does
|
|
||||||
not support broadcast modes.
|
|
||||||
|
|
||||||
Where are new versions announced?
|
Where are new versions announced?
|
||||||
=================================
|
=================================
|
||||||
|
|
||||||
There is a low volume mailing list where new versions and other
|
There is a low volume mailing list where new versions and other
|
||||||
important news relating to chrony is announced. You can join this list
|
important news relating to chrony are announced. You can join this list
|
||||||
by sending mail with the subject "subscribe" to
|
by sending mail with the subject "subscribe" to
|
||||||
|
|
||||||
chrony-announce-request@chrony.tuxfamily.org
|
chrony-announce-request@chrony.tuxfamily.org
|
||||||
|
|
||||||
These messages will be copied to chrony-users (see below). New versions
|
|
||||||
are announced also on Freshmeat (http://freshmeat.net/).
|
|
||||||
|
|
||||||
How can I get support for chrony?
|
How can I get support for chrony?
|
||||||
and where can I discuss new features, possible bugs etc?
|
=================================
|
||||||
========================================================
|
|
||||||
|
|
||||||
There are 3 mailing lists relating to chrony. chrony-announce was
|
There are two other mailing lists relating to chrony. chrony-users is a
|
||||||
mentioned above. chrony-users is a users' discussion list, e.g. for
|
discussion list for users, e.g. for questions about chrony configuration
|
||||||
general questions and answers about using chrony. chrony-dev is a more
|
and bug reports. chrony-dev is a more technical list for developers,
|
||||||
technical list, e.g. for discussing how new features should be
|
e.g. for submitting patches and discussing how new features should be
|
||||||
implemented, exchange of information between developers etc. To
|
implemented. To subscribe to either of these lists, send a message with
|
||||||
subscribe to either of these lists, send a message with the subject
|
the subject "subscribe" to
|
||||||
"subscribe" to
|
|
||||||
|
|
||||||
chrony-users-request@chrony.tuxfamily.org
|
chrony-users-request@chrony.tuxfamily.org
|
||||||
or
|
or
|
||||||
@@ -124,122 +74,87 @@ chrony-dev-request@chrony.tuxfamily.org
|
|||||||
|
|
||||||
as applicable.
|
as applicable.
|
||||||
|
|
||||||
|
License
|
||||||
|
=======
|
||||||
|
|
||||||
Author
|
chrony is distributed under the GNU General Public License version 2.
|
||||||
======
|
|
||||||
|
Authors
|
||||||
|
=======
|
||||||
|
|
||||||
Richard P. Curnow <rc@rc0.org.uk>
|
Richard P. Curnow <rc@rc0.org.uk>
|
||||||
|
|
||||||
|
|
||||||
Maintainers
|
|
||||||
===========
|
|
||||||
|
|
||||||
John Hasler <john@dhh.gt.org>
|
|
||||||
Miroslav Lichvar <mlichvar@redhat.com>
|
Miroslav Lichvar <mlichvar@redhat.com>
|
||||||
|
|
||||||
|
|
||||||
Acknowledgements
|
Acknowledgements
|
||||||
================
|
================
|
||||||
|
|
||||||
|
In writing the chronyd program, extensive use has been made of the NTPv3 (RFC
|
||||||
|
1305) and NTPv4 (RFC 5905) specification. The source code of the xntpd/ntpd
|
||||||
|
implementation written by Dennis Fergusson, Lars Mathiesen, David Mills, and
|
||||||
|
others has been used to check the details of the protocol.
|
||||||
|
|
||||||
The following people have provided patches and other major contributions
|
The following people have provided patches and other major contributions
|
||||||
to the program :
|
to chrony:
|
||||||
|
|
||||||
|
Lonnie Abelbeck <lonnie@abelbeck.com>
|
||||||
|
Benny Lyne Amorsen <benny@amorsen.dk>
|
||||||
Andrew Bishop <amb@gedanken.demon.co.uk>
|
Andrew Bishop <amb@gedanken.demon.co.uk>
|
||||||
Fixes for bugs in logging when in daemon mode
|
Vincent Blut <vincent.debian@free.fr>
|
||||||
Fixes for compiler warnings
|
|
||||||
Robustness improvements for drift file
|
|
||||||
Improve installation (directory checking etc)
|
|
||||||
Entries in contrib directory
|
|
||||||
Improvements to 'sources' and 'sourcestats' output from chronyc
|
|
||||||
Improvements to documentation
|
|
||||||
Investigation of required dosynctodr behaviour for various Solaris
|
|
||||||
versions.
|
|
||||||
|
|
||||||
Stephan I. Boettcher <stephan@nevis1.columbia.edu>
|
Stephan I. Boettcher <stephan@nevis1.columbia.edu>
|
||||||
Entries in contrib directory
|
David Bohman <debohman@gmail.com>
|
||||||
|
Goswin Brederlow <brederlo@informatik.uni-tuebingen.de>
|
||||||
|
Leigh Brown <leigh@solinno.co.uk>
|
||||||
Erik Bryer <ebryer@spots.ab.ca>
|
Erik Bryer <ebryer@spots.ab.ca>
|
||||||
Entries in contrib directory
|
Jonathan Cameron <jic23@cam.ac.uk>
|
||||||
|
Bryan Christianson <bryan@whatroute.net>
|
||||||
Juliusz Chroboczek <jch@pps.jussieu.fr>
|
Juliusz Chroboczek <jch@pps.jussieu.fr>
|
||||||
Fix install rule in Makefile if chronyd file is in use.
|
Kamil Dudka <kdudka@redhat.com>
|
||||||
|
Christian Ehrhardt <christian.ehrhardt@canonical.com>
|
||||||
Paul Elliott <pelliott@io.com>
|
Paul Elliott <pelliott@io.com>
|
||||||
DNSchrony (in contrib directory), a tool for handling NTP servers
|
Robert Fairley <rfairley@redhat.com>
|
||||||
with variable IP addresses.
|
Stefan R. Filipek <srfilipek@gmail.com>
|
||||||
|
|
||||||
Mike Fleetwood <mike@rockover.demon.co.uk>
|
Mike Fleetwood <mike@rockover.demon.co.uk>
|
||||||
Fixes for compiler warnings
|
|
||||||
|
|
||||||
Alexander Gretencord <arutha@gmx.de>
|
Alexander Gretencord <arutha@gmx.de>
|
||||||
Changes to installation directory system to make it easier for
|
Andrew Griffiths <agriffit@redhat.com>
|
||||||
package builders.
|
|
||||||
|
|
||||||
Walter Haidinger <walter.haidinger@gmx.at>
|
Walter Haidinger <walter.haidinger@gmx.at>
|
||||||
Providing me with login access to a Linux installation where v1.12
|
|
||||||
wouldn't compile, so I could develop the fixes for v1.13. Also, for
|
|
||||||
providing the disc space so I can keep an independent backup of the
|
|
||||||
sources.
|
|
||||||
|
|
||||||
Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
|
Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
|
||||||
Port to NetBSD
|
|
||||||
|
|
||||||
John Hasler <john@dhh.gt.org>
|
John Hasler <john@dhh.gt.org>
|
||||||
Changes to support 64 bit machines (i.e. those where
|
Tjalling Hattink <t.hattink@fugro.nl>
|
||||||
sizeof(unsigned long) > 4)
|
|
||||||
Bug fix to initstepslew directive
|
|
||||||
Fix to remove potential buffer overrun errors.
|
|
||||||
Memory locking and real-time scheduler support
|
|
||||||
Fix fault where chronyd enters an endless loop
|
|
||||||
|
|
||||||
Liam Hatton <me@liamhatton.com>
|
Liam Hatton <me@liamhatton.com>
|
||||||
Advice on configuring for Linux on PPC
|
|
||||||
|
|
||||||
Jachym Holecek <jakym@volny.cz>
|
Jachym Holecek <jakym@volny.cz>
|
||||||
Patch to make Linux real time clock work with devfs
|
Håkan Johansson <f96hajo@chalmers.se>
|
||||||
|
|
||||||
Jim Knoble <jmknoble@pobox.com>
|
Jim Knoble <jmknoble@pobox.com>
|
||||||
Fixes for compiler warnings
|
|
||||||
|
|
||||||
Antti Jrvinen <costello@iki.fi>
|
Antti Jrvinen <costello@iki.fi>
|
||||||
Advice on configuring for BSD/386
|
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
|
||||||
|
Eric Lammerts <eric@lammerts.org>
|
||||||
Miroslav Lichvar <mlichvar@redhat.com>
|
Stefan Lucke <stefan@lucke.in-berlin.de>
|
||||||
Reference clock support
|
Victor Lum <viclum@vanu.com>
|
||||||
IPv6 support
|
Kevin Lyda <kevin@ie.suberic.net>
|
||||||
Linux capabilities support
|
Paul Menzel <paulepanter@users.sourceforge.net>
|
||||||
Leap second support
|
Vladimir Michl <vladimir.michl@seznam.cz>
|
||||||
Various bug fixes and improvements
|
|
||||||
|
|
||||||
Victor Moroz <vim@prv.adlum.ru>
|
Victor Moroz <vim@prv.adlum.ru>
|
||||||
Patch to support Linux with HZ!=100
|
|
||||||
|
|
||||||
Kalle Olavi Niemitalo <tosi@stekt.oulu.fi>
|
Kalle Olavi Niemitalo <tosi@stekt.oulu.fi>
|
||||||
acquisitionport support
|
|
||||||
|
|
||||||
Frank Otto <sandwichmacher@web.de>
|
Frank Otto <sandwichmacher@web.de>
|
||||||
Handling arbitrary HZ values
|
Denny Page <dennypage@me.com>
|
||||||
|
Chris Perl <cperl@janestreet.com>
|
||||||
|
Gautier PHILIPPON <gautier.philippon@ensimag.grenoble-inp.fr>
|
||||||
Andreas Piesk <apiesk@virbus.de>
|
Andreas Piesk <apiesk@virbus.de>
|
||||||
Patch to make chronyc use the readline library if available
|
Baruch Siach <baruch@tkos.co.il>
|
||||||
|
Foster Snowhill <forst@forstwoof.ru>
|
||||||
|
Andreas Steinmetz <ast@domdv.de>
|
||||||
|
NAKAMURA Takumi <takumi@ps.sakura.ne.jp>
|
||||||
Timo Teras <timo.teras@iki.fi>
|
Timo Teras <timo.teras@iki.fi>
|
||||||
Patch to reply correctly on multihomed hosts
|
Bill Unruh <unruh@physics.ubc.ca>
|
||||||
|
Stephen Wadeley <swadeley@redhat.com>
|
||||||
|
Bernhard Weiss <lisnablagh@web.de>
|
||||||
Wolfgang Weisselberg <weissel@netcologne.de>
|
Wolfgang Weisselberg <weissel@netcologne.de>
|
||||||
Entries in contrib directory
|
Bernhard M. Wiedemann <bwiedemann@suse.de>
|
||||||
|
Joachim Wiedorn <ad_debian@joonet.de>
|
||||||
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
||||||
Many robustness and security improvements
|
Ulrich Windl <ulrich.windl@rz.uni-regensburg.de>
|
||||||
|
Michael Witten <mfwitten@gmail.com>
|
||||||
Ulrich Windl <ulrich.windl@rz.uni-regensburg.de> for the
|
|
||||||
Providing me with information about the Linux 2.2 kernel
|
|
||||||
functionality compared to 2.0.
|
|
||||||
|
|
||||||
Doug Woodward <dougw@whistler.com>
|
Doug Woodward <dougw@whistler.com>
|
||||||
Advice on configuring for Solaris 2.8 on x86
|
Thomas Zajic <zlatko@zlatko.fdns.net>
|
||||||
|
|
||||||
Many other people have contributed bug reports and suggestions. I'm
|
Many other people have contributed bug reports and suggestions. We are sorry
|
||||||
sorry I can't identify all of you individually.
|
we cannot identify all of you individually.
|
||||||
|
|
||||||
vim:tw=72
|
|
||||||
|
|||||||
784
acquire.c
784
acquire.c
@@ -1,784 +0,0 @@
|
|||||||
/*
|
|
||||||
$Header: /cvs/src/chrony/acquire.c,v 1.24 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
|
||||||
|
|
||||||
**********************************************************************
|
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
**********************************************************************
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Processing to perform the equivalent of what ntpdate does. That is,
|
|
||||||
make a rapid-fire set of measurements to a designated set of
|
|
||||||
sources, and step or slew the local clock to bring it into line with
|
|
||||||
the result.
|
|
||||||
|
|
||||||
This is kept completely separate of the main chronyd processing, by
|
|
||||||
using a separate socket for sending/receiving the measurement
|
|
||||||
packets. That way, ntp_core.c can be kept completely independent of
|
|
||||||
this functionality.
|
|
||||||
|
|
||||||
A few of the finer points of how to construct valid RFC1305 packets
|
|
||||||
and validate responses for this case have been cribbed from the
|
|
||||||
ntpdate source.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sysincl.h"
|
|
||||||
|
|
||||||
#include "acquire.h"
|
|
||||||
#include "memory.h"
|
|
||||||
#include "sched.h"
|
|
||||||
#include "local.h"
|
|
||||||
#include "logging.h"
|
|
||||||
#include "ntp.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "main.h"
|
|
||||||
#include "conf.h"
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
/* Interval between firing off the first sample to successive sources */
|
|
||||||
#define INTER_SOURCE_START (0.2)
|
|
||||||
|
|
||||||
#define MAX_SAMPLES 8
|
|
||||||
|
|
||||||
#define MAX_DEAD_PROBES 4
|
|
||||||
#define N_GOOD_SAMPLES 4
|
|
||||||
|
|
||||||
#define RETRANSMISSION_TIMEOUT (1.0)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
IPAddr ip_addr; /* Address of the server */
|
|
||||||
int sanity; /* Flag indicating whether source
|
|
||||||
looks sane or not */
|
|
||||||
int n_dead_probes; /* Number of probes sent to the server
|
|
||||||
since a good one */
|
|
||||||
int n_samples; /* Number of samples accumulated */
|
|
||||||
int n_total_samples; /* Total number of samples received
|
|
||||||
including useless ones */
|
|
||||||
double offsets[MAX_SAMPLES]; /* In seconds, positive means local
|
|
||||||
clock is fast of reference */
|
|
||||||
double root_distances[MAX_SAMPLES]; /* in seconds */
|
|
||||||
double inter_lo; /* Low end of estimated range of offset */
|
|
||||||
double inter_hi; /* High end of estimated range of offset */
|
|
||||||
|
|
||||||
NTP_int64 last_tx; /* Transmit timestamp in last packet
|
|
||||||
transmitted to source. */
|
|
||||||
|
|
||||||
int timer_running;
|
|
||||||
SCH_TimeoutID timeout_id;
|
|
||||||
} SourceRecord;
|
|
||||||
|
|
||||||
static SourceRecord *sources;
|
|
||||||
static int n_sources;
|
|
||||||
static int n_started_sources;
|
|
||||||
static int n_completed_sources;
|
|
||||||
|
|
||||||
static int init_slew_threshold = -1;
|
|
||||||
|
|
||||||
union sockaddr_in46 {
|
|
||||||
struct sockaddr_in in4;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
struct sockaddr_in6 in6;
|
|
||||||
#endif
|
|
||||||
struct sockaddr u;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int sock_fd4 = -1;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
static int sock_fd6 = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void (*saved_after_hook)(void *) = NULL;
|
|
||||||
static void *saved_after_hook_anything = NULL;
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
double offset;
|
|
||||||
enum {LO, HIGH} type;
|
|
||||||
int index;
|
|
||||||
} Endpoint;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
double lo;
|
|
||||||
double hi;
|
|
||||||
} Interval;
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void read_from_socket(void *anything);
|
|
||||||
static void transmit_timeout(void *x);
|
|
||||||
static void wind_up_acquisition(void);
|
|
||||||
static void start_source_timeout_handler(void *not_used);
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static SCH_TimeoutID source_start_timeout_id;
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
void
|
|
||||||
ACQ_Initialise(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
void
|
|
||||||
ACQ_Finalise(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static int
|
|
||||||
prepare_socket(int family)
|
|
||||||
{
|
|
||||||
unsigned short port_number = CNF_GetAcquisitionPort();
|
|
||||||
int sock_fd;
|
|
||||||
socklen_t addrlen;
|
|
||||||
|
|
||||||
sock_fd = socket(family, SOCK_DGRAM, 0);
|
|
||||||
|
|
||||||
if (sock_fd < 0) {
|
|
||||||
LOG_FATAL(LOGF_Acquire, "Could not open socket : %s", strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (port_number == 0) {
|
|
||||||
/* Don't bother binding this socket - we're not fussed what port
|
|
||||||
number it gets */
|
|
||||||
} else {
|
|
||||||
union sockaddr_in46 my_addr;
|
|
||||||
|
|
||||||
memset(&my_addr, 0, sizeof (my_addr));
|
|
||||||
|
|
||||||
switch (family) {
|
|
||||||
case AF_INET:
|
|
||||||
my_addr.in4.sin_family = family;
|
|
||||||
my_addr.in4.sin_port = htons(port_number);
|
|
||||||
my_addr.in4.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
||||||
addrlen = sizeof (my_addr.in4);
|
|
||||||
break;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case AF_INET6:
|
|
||||||
my_addr.in6.sin6_family = family;
|
|
||||||
my_addr.in6.sin6_port = htons(port_number);
|
|
||||||
my_addr.in6.sin6_addr = in6addr_any;
|
|
||||||
addrlen = sizeof (my_addr.in6);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bind(sock_fd, &my_addr.u, addrlen) < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_Acquire, "Could not bind socket : %s\n", strerror(errno));
|
|
||||||
/* but keep running */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SCH_AddInputFileHandler(sock_fd, read_from_socket, (void *)(long)sock_fd);
|
|
||||||
|
|
||||||
return sock_fd;
|
|
||||||
}
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void
|
|
||||||
initialise_io(int family)
|
|
||||||
{
|
|
||||||
if (family == IPADDR_INET4 || family == IPADDR_UNSPEC)
|
|
||||||
sock_fd4 = prepare_socket(AF_INET);
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (family == IPADDR_INET6 || family == IPADDR_UNSPEC)
|
|
||||||
sock_fd6 = prepare_socket(AF_INET6);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void
|
|
||||||
finalise_io(void)
|
|
||||||
{
|
|
||||||
if (sock_fd4 >= 0) {
|
|
||||||
SCH_RemoveInputFileHandler(sock_fd4);
|
|
||||||
close(sock_fd4);
|
|
||||||
}
|
|
||||||
sock_fd4 = -1;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (sock_fd6 >= 0) {
|
|
||||||
SCH_RemoveInputFileHandler(sock_fd6);
|
|
||||||
close(sock_fd6);
|
|
||||||
}
|
|
||||||
sock_fd6 = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void
|
|
||||||
probe_source(SourceRecord *src)
|
|
||||||
{
|
|
||||||
NTP_Packet pkt;
|
|
||||||
int version = 3;
|
|
||||||
NTP_Mode my_mode = MODE_CLIENT;
|
|
||||||
struct timeval cooked;
|
|
||||||
double local_time_err;
|
|
||||||
union sockaddr_in46 his_addr;
|
|
||||||
int sock_fd;
|
|
||||||
socklen_t addrlen;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf("Sending probe to %s sent=%d samples=%d\n", UTI_IPToString(&src->ip_addr), src->n_probes_sent, src->n_samples);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pkt.lvm = (((LEAP_Unsynchronised << 6) & 0xc0) |
|
|
||||||
((version << 3) & 0x38) |
|
|
||||||
((my_mode) & 0x7));
|
|
||||||
|
|
||||||
pkt.stratum = 0;
|
|
||||||
pkt.poll = 4;
|
|
||||||
pkt.precision = -6; /* as ntpdate */
|
|
||||||
pkt.root_delay = double_to_int32(1.0); /* 1 second */
|
|
||||||
pkt.root_dispersion = double_to_int32(1.0); /* likewise */
|
|
||||||
pkt.reference_id = 0UL;
|
|
||||||
pkt.reference_ts.hi = 0; /* Set to 0 */
|
|
||||||
pkt.reference_ts.lo = 0; /* Set to 0 */
|
|
||||||
pkt.originate_ts.hi = 0; /* Set to 0 */
|
|
||||||
pkt.originate_ts.lo = 0; /* Set to 0 */
|
|
||||||
pkt.receive_ts.hi = 0; /* Set to 0 */
|
|
||||||
pkt.receive_ts.lo = 0; /* Set to 0 */
|
|
||||||
|
|
||||||
/* And do transmission */
|
|
||||||
|
|
||||||
memset(&his_addr, 0, sizeof (his_addr));
|
|
||||||
switch (src->ip_addr.family) {
|
|
||||||
case IPADDR_INET4:
|
|
||||||
his_addr.in4.sin_addr.s_addr = htonl(src->ip_addr.addr.in4);
|
|
||||||
his_addr.in4.sin_port = htons(123); /* Fixed for now */
|
|
||||||
his_addr.in4.sin_family = AF_INET;
|
|
||||||
addrlen = sizeof (his_addr.in4);
|
|
||||||
sock_fd = sock_fd4;
|
|
||||||
break;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case IPADDR_INET6:
|
|
||||||
memcpy(&his_addr.in6.sin6_addr.s6_addr, &src->ip_addr.addr.in6,
|
|
||||||
sizeof (his_addr.in6.sin6_addr.s6_addr));
|
|
||||||
his_addr.in6.sin6_port = htons(123); /* Fixed for now */
|
|
||||||
his_addr.in6.sin6_family = AF_INET6;
|
|
||||||
addrlen = sizeof (his_addr.in6);
|
|
||||||
sock_fd = sock_fd6;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LCL_ReadCookedTime(&cooked, &local_time_err);
|
|
||||||
UTI_TimevalToInt64(&cooked, &pkt.transmit_ts);
|
|
||||||
|
|
||||||
if (sendto(sock_fd, (void *) &pkt, NTP_NORMAL_PACKET_SIZE,
|
|
||||||
0,
|
|
||||||
&his_addr.u, addrlen) < 0) {
|
|
||||||
LOG(LOGS_WARN, LOGF_Acquire, "Could not send to %s : %s",
|
|
||||||
UTI_IPToString(&src->ip_addr),
|
|
||||||
strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
src->last_tx = pkt.transmit_ts;
|
|
||||||
|
|
||||||
++(src->n_dead_probes);
|
|
||||||
src->timer_running = 1;
|
|
||||||
src->timeout_id = SCH_AddTimeoutByDelay(RETRANSMISSION_TIMEOUT, transmit_timeout, (void *) src);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void
|
|
||||||
transmit_timeout(void *x)
|
|
||||||
{
|
|
||||||
SourceRecord *src = (SourceRecord *) x;
|
|
||||||
|
|
||||||
src->timer_running = 0;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf("Timeout expired for server %s\n", UTI_IPToString(&src->ip_addr));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (src->n_dead_probes < MAX_DEAD_PROBES) {
|
|
||||||
probe_source(src);
|
|
||||||
} else {
|
|
||||||
/* Source has croaked or is taking too long to respond */
|
|
||||||
++n_completed_sources;
|
|
||||||
if (n_completed_sources == n_sources) {
|
|
||||||
wind_up_acquisition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
#define MAX_STRATUM 15
|
|
||||||
|
|
||||||
static void
|
|
||||||
process_receive(NTP_Packet *msg, SourceRecord *src, struct timeval *now)
|
|
||||||
{
|
|
||||||
|
|
||||||
unsigned long lvm;
|
|
||||||
int leap, version, mode;
|
|
||||||
double root_delay, root_dispersion;
|
|
||||||
double total_root_delay, total_root_dispersion, total_root_distance;
|
|
||||||
|
|
||||||
struct timeval local_orig, local_average, remote_rx, remote_tx, remote_average;
|
|
||||||
double remote_interval, local_interval;
|
|
||||||
double delta, theta, epsilon;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
/* Most of the checks are from ntpdate */
|
|
||||||
|
|
||||||
/* Need to do something about authentication */
|
|
||||||
|
|
||||||
lvm = msg->lvm;
|
|
||||||
leap = (lvm >> 6) & 0x3;
|
|
||||||
version = (lvm >> 3) & 0x7;
|
|
||||||
mode = lvm & 0x7;
|
|
||||||
|
|
||||||
if ((leap == LEAP_Unsynchronised) ||
|
|
||||||
(version != 3) ||
|
|
||||||
(mode != MODE_SERVER && mode != MODE_PASSIVE)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg->stratum > MAX_STRATUM) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check whether server is responding to our last request */
|
|
||||||
if ((msg->originate_ts.hi != src->last_tx.hi) ||
|
|
||||||
(msg->originate_ts.lo != src->last_tx.lo)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check that the server is sane */
|
|
||||||
if (((msg->originate_ts.hi == 0) && (msg->originate_ts.lo == 0)) ||
|
|
||||||
((msg->receive_ts.hi == 0) && (msg->receive_ts.lo) == 0)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
root_delay = int32_to_double(msg->root_delay);
|
|
||||||
root_dispersion = int32_to_double(msg->root_dispersion);
|
|
||||||
|
|
||||||
UTI_Int64ToTimeval(&src->last_tx, &local_orig);
|
|
||||||
UTI_Int64ToTimeval(&msg->receive_ts, &remote_rx);
|
|
||||||
UTI_Int64ToTimeval(&msg->transmit_ts, &remote_tx);
|
|
||||||
UTI_AverageDiffTimevals(&remote_rx, &remote_tx, &remote_average, &remote_interval);
|
|
||||||
UTI_AverageDiffTimevals(&local_orig, now, &local_average, &local_interval);
|
|
||||||
|
|
||||||
delta = local_interval - remote_interval;
|
|
||||||
|
|
||||||
/* Defined as positive if we are fast. Note this sign convention is
|
|
||||||
opposite to that used in ntp_core.c */
|
|
||||||
|
|
||||||
UTI_DiffTimevalsToDouble(&theta, &local_average, &remote_average);
|
|
||||||
|
|
||||||
/* Could work out epsilon - leave till later */
|
|
||||||
epsilon = 0.0;
|
|
||||||
|
|
||||||
total_root_delay = fabs(delta) + root_delay;
|
|
||||||
total_root_dispersion = epsilon + root_dispersion;
|
|
||||||
total_root_distance = 0.5 * fabs(total_root_delay) + total_root_dispersion;
|
|
||||||
|
|
||||||
n = src->n_samples;
|
|
||||||
#if 0
|
|
||||||
printf("Sample %d theta=%.6f delta=%.6f root_del=%.6f root_disp=%.6f root_dist=%.6f\n",
|
|
||||||
n, theta, delta, total_root_delay, total_root_dispersion, total_root_distance);
|
|
||||||
#endif
|
|
||||||
src->offsets[n] = theta;
|
|
||||||
src->root_distances[n] = total_root_distance;
|
|
||||||
++(src->n_samples);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void
|
|
||||||
read_from_socket(void *anything)
|
|
||||||
{
|
|
||||||
int status;
|
|
||||||
ReceiveBuffer msg;
|
|
||||||
union sockaddr_in46 his_addr;
|
|
||||||
int sock_fd;
|
|
||||||
socklen_t his_addr_len;
|
|
||||||
int flags;
|
|
||||||
int message_length;
|
|
||||||
IPAddr remote_ip;
|
|
||||||
int i, ok;
|
|
||||||
struct timeval now;
|
|
||||||
SourceRecord *src;
|
|
||||||
|
|
||||||
flags = 0;
|
|
||||||
message_length = sizeof(msg);
|
|
||||||
his_addr_len = sizeof(his_addr);
|
|
||||||
|
|
||||||
/* Get timestamp */
|
|
||||||
SCH_GetFileReadyTime(&now);
|
|
||||||
|
|
||||||
sock_fd = (long)anything;
|
|
||||||
status = recvfrom (sock_fd, (char *)&msg, message_length, flags,
|
|
||||||
&his_addr.u, &his_addr_len);
|
|
||||||
|
|
||||||
if (status < 0) {
|
|
||||||
LOG(LOGS_WARN, LOGF_Acquire, "Error reading from socket, %s", strerror(errno));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (his_addr.u.sa_family) {
|
|
||||||
case AF_INET:
|
|
||||||
remote_ip.family = IPADDR_INET4;
|
|
||||||
remote_ip.addr.in4 = ntohl(his_addr.in4.sin_addr.s_addr);
|
|
||||||
break;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case AF_INET6:
|
|
||||||
remote_ip.family = IPADDR_INET6;
|
|
||||||
memcpy(&remote_ip.addr.in6, his_addr.in6.sin6_addr.s6_addr,
|
|
||||||
sizeof (remote_ip.addr.in6));
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf("Got message from %s\n", UTI_IPToString(&remote_ip));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Find matching host */
|
|
||||||
ok = 0;
|
|
||||||
for (i=0; i<n_sources; i++) {
|
|
||||||
if (UTI_CompareIPs(&remote_ip, &sources[i].ip_addr, NULL) == 0) {
|
|
||||||
ok = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ok) {
|
|
||||||
|
|
||||||
src = sources + i;
|
|
||||||
++src->n_total_samples;
|
|
||||||
|
|
||||||
src->n_dead_probes = 0; /* reset this when we actually receive something */
|
|
||||||
|
|
||||||
/* If we got into this function, we know the retransmission timeout has not
|
|
||||||
expired for the source */
|
|
||||||
if (src->timer_running) {
|
|
||||||
SCH_RemoveTimeout(src->timeout_id);
|
|
||||||
src->timer_running = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
process_receive(&msg.ntp_pkt, src, &now);
|
|
||||||
|
|
||||||
/* Check if server done and requeue timeout */
|
|
||||||
if ((src->n_samples >= N_GOOD_SAMPLES) ||
|
|
||||||
(src->n_total_samples >= MAX_SAMPLES)) {
|
|
||||||
++n_completed_sources;
|
|
||||||
#if 0
|
|
||||||
printf("Source %s completed\n", UTI_IPToString(&src->ip_addr));
|
|
||||||
#endif
|
|
||||||
if (n_completed_sources == n_sources) {
|
|
||||||
wind_up_acquisition();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* Send the next probe */
|
|
||||||
probe_source(src);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void
|
|
||||||
start_next_source(void)
|
|
||||||
{
|
|
||||||
probe_source(sources + n_started_sources);
|
|
||||||
#if 0
|
|
||||||
printf("Trying to start source %s\n", UTI_IPToString(&sources[n_started_sources].ip_addr));
|
|
||||||
#endif
|
|
||||||
n_started_sources++;
|
|
||||||
|
|
||||||
if (n_started_sources < n_sources) {
|
|
||||||
source_start_timeout_id = SCH_AddTimeoutByDelay(INTER_SOURCE_START, start_source_timeout_handler, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static int
|
|
||||||
endpoint_compare(const void *a, const void *b)
|
|
||||||
{
|
|
||||||
const Endpoint *aa = (const Endpoint *) a;
|
|
||||||
const Endpoint *bb = (const Endpoint *) b;
|
|
||||||
|
|
||||||
if (aa->offset < bb->offset) {
|
|
||||||
return -1;
|
|
||||||
} else if (aa->offset > bb->offset) {
|
|
||||||
return +1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void
|
|
||||||
process_measurements(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
SourceRecord *s;
|
|
||||||
Endpoint *eps;
|
|
||||||
int i, j;
|
|
||||||
int n_sane_sources;
|
|
||||||
double lo, hi;
|
|
||||||
double inter_lo, inter_hi;
|
|
||||||
|
|
||||||
int depth;
|
|
||||||
int best_depth;
|
|
||||||
int n_at_best_depth;
|
|
||||||
Interval *intervals;
|
|
||||||
double estimated_offset;
|
|
||||||
int index1, index2;
|
|
||||||
|
|
||||||
n_sane_sources = 0;
|
|
||||||
|
|
||||||
/* First, get a consistent interval for each source. Those for
|
|
||||||
which this is not possible are considered to be insane. */
|
|
||||||
|
|
||||||
for (i=0; i<n_sources; i++) {
|
|
||||||
s = sources + i;
|
|
||||||
/* If we got no measurements, the source is insane */
|
|
||||||
if (s->n_samples == 0) {
|
|
||||||
s->sanity = 0;
|
|
||||||
} else {
|
|
||||||
s->sanity = 1; /* so far ... */
|
|
||||||
lo = s->offsets[0] - s->root_distances[0];
|
|
||||||
hi = s->offsets[0] + s->root_distances[0];
|
|
||||||
inter_lo = lo;
|
|
||||||
inter_hi = hi;
|
|
||||||
for (j=1; j<s->n_samples; j++) {
|
|
||||||
lo = s->offsets[j] - s->root_distances[j];
|
|
||||||
hi = s->offsets[j] + s->root_distances[j];
|
|
||||||
if ((inter_hi <= lo) || (inter_lo >= hi)) {
|
|
||||||
/* Oh dear, we won't get an interval for this source */
|
|
||||||
s->sanity = 0;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
inter_lo = (lo < inter_lo) ? inter_lo : lo;
|
|
||||||
inter_hi = (hi > inter_hi) ? inter_hi : hi;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (s->sanity) {
|
|
||||||
s->inter_lo = inter_lo;
|
|
||||||
s->inter_hi = inter_hi;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->sanity) {
|
|
||||||
++n_sane_sources;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now build the endpoint list, similar to the RFC1305 clock
|
|
||||||
selection algorithm. */
|
|
||||||
eps = MallocArray(Endpoint, 2*n_sane_sources);
|
|
||||||
intervals = MallocArray(Interval, n_sane_sources);
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
for (i=0; i<n_sources; i++) {
|
|
||||||
s = sources + i;
|
|
||||||
if (s->sanity) {
|
|
||||||
eps[j].offset = s->inter_lo;
|
|
||||||
eps[j].type = LO;
|
|
||||||
eps[j].index = i;
|
|
||||||
eps[j+1].offset = s->inter_hi;
|
|
||||||
eps[j+1].type = HIGH;
|
|
||||||
eps[j+1].index = i;
|
|
||||||
j += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qsort(eps, 2*n_sane_sources, sizeof(Endpoint), endpoint_compare);
|
|
||||||
|
|
||||||
/* Now do depth searching algorithm */
|
|
||||||
n_at_best_depth = best_depth = depth = 0;
|
|
||||||
for (i=0; i<2*n_sane_sources; i++) {
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
fprintf(stderr, "Endpoint type %s source index %d [ip=%s] offset=%.6f\n",
|
|
||||||
(eps[i].type == LO) ? "LO" : "HIGH",
|
|
||||||
eps[i].index,
|
|
||||||
UTI_IPToString(&sources[eps[i].index].ip_addr),
|
|
||||||
eps[i].offset);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (eps[i].type) {
|
|
||||||
case LO:
|
|
||||||
depth++;
|
|
||||||
if (depth > best_depth) {
|
|
||||||
best_depth = depth;
|
|
||||||
n_at_best_depth = 0;
|
|
||||||
intervals[0].lo = eps[i].offset;
|
|
||||||
} else if (depth == best_depth) {
|
|
||||||
intervals[n_at_best_depth].lo = eps[i].offset;
|
|
||||||
} else {
|
|
||||||
/* Nothing to do */
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HIGH:
|
|
||||||
if (depth == best_depth) {
|
|
||||||
intervals[n_at_best_depth].hi = eps[i].offset;
|
|
||||||
n_at_best_depth++;
|
|
||||||
}
|
|
||||||
|
|
||||||
depth--;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (best_depth > 0) {
|
|
||||||
if ((n_at_best_depth % 2) == 1) {
|
|
||||||
index1 = (n_at_best_depth - 1) / 2;
|
|
||||||
estimated_offset = 0.5 * (intervals[index1].lo + intervals[index1].hi);
|
|
||||||
} else {
|
|
||||||
index2 = (n_at_best_depth / 2);
|
|
||||||
index1 = index2 - 1;
|
|
||||||
estimated_offset = 0.5 * (intervals[index1].lo + intervals[index2].hi);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Apply a step change to the system clock. As per sign
|
|
||||||
convention in local.c and its children, a positive offset means
|
|
||||||
the system clock is fast of the reference, i.e. it needs to be
|
|
||||||
stepped backwards. */
|
|
||||||
|
|
||||||
if (fabs(estimated_offset) > (double) init_slew_threshold) {
|
|
||||||
LOG(LOGS_INFO, LOGF_Acquire, "System's initial offset : %.6f seconds %s of true (step)",
|
|
||||||
fabs(estimated_offset),
|
|
||||||
(estimated_offset >= 0) ? "fast" : "slow");
|
|
||||||
LCL_ApplyStepOffset(estimated_offset);
|
|
||||||
} else {
|
|
||||||
LOG(LOGS_INFO, LOGF_Acquire, "System's initial offset : %.6f seconds %s of true (slew)",
|
|
||||||
fabs(estimated_offset),
|
|
||||||
(estimated_offset >= 0) ? "fast" : "slow");
|
|
||||||
LCL_AccumulateOffset(estimated_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
LOG(LOGS_WARN, LOGF_Acquire, "No intersecting endpoints found");
|
|
||||||
}
|
|
||||||
|
|
||||||
Free(intervals);
|
|
||||||
Free(eps);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void
|
|
||||||
wind_up_acquisition(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Now process measurements */
|
|
||||||
process_measurements();
|
|
||||||
|
|
||||||
Free(sources);
|
|
||||||
|
|
||||||
finalise_io();
|
|
||||||
|
|
||||||
if (saved_after_hook) {
|
|
||||||
(saved_after_hook)(saved_after_hook_anything);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void
|
|
||||||
start_source_timeout_handler(void *not_used)
|
|
||||||
{
|
|
||||||
|
|
||||||
start_next_source();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
void
|
|
||||||
ACQ_StartAcquisition(int n, IPAddr *ip_addrs, int threshold, void (*after_hook)(void *), void *anything)
|
|
||||||
{
|
|
||||||
|
|
||||||
int i, ip4, ip6;
|
|
||||||
|
|
||||||
saved_after_hook = after_hook;
|
|
||||||
saved_after_hook_anything = anything;
|
|
||||||
|
|
||||||
init_slew_threshold = threshold;
|
|
||||||
|
|
||||||
n_started_sources = 0;
|
|
||||||
n_completed_sources = 0;
|
|
||||||
n_sources = n;
|
|
||||||
sources = MallocArray(SourceRecord, n);
|
|
||||||
|
|
||||||
for (i = ip4 = ip6 = 0; i < n; i++) {
|
|
||||||
sources[i].ip_addr = ip_addrs[i];
|
|
||||||
sources[i].n_samples = 0;
|
|
||||||
sources[i].n_total_samples = 0;
|
|
||||||
sources[i].n_dead_probes = 0;
|
|
||||||
if (ip_addrs[i].family == IPADDR_INET4)
|
|
||||||
ip4++;
|
|
||||||
else if (ip_addrs[i].family == IPADDR_INET6)
|
|
||||||
ip6++;
|
|
||||||
}
|
|
||||||
|
|
||||||
initialise_io((ip4 && ip6) ? IPADDR_UNSPEC : (ip4 ? IPADDR_INET4 : IPADDR_INET6));
|
|
||||||
|
|
||||||
/* Start sampling first source */
|
|
||||||
start_next_source();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
23
addressing.h
23
addressing.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/addressing.h,v 1.7 2002/02/28 23:27:08 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -34,25 +30,38 @@
|
|||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
/* This type is used to represent an IPv4 address or IPv6 address.
|
/* This type is used to represent an IPv4 address or IPv6 address.
|
||||||
|
Addresses which are not resolved yet can be represented with an ID.
|
||||||
All parts are in HOST order, NOT network order. */
|
All parts are in HOST order, NOT network order. */
|
||||||
|
|
||||||
#define IPADDR_UNSPEC 0
|
#define IPADDR_UNSPEC 0
|
||||||
#define IPADDR_INET4 1
|
#define IPADDR_INET4 1
|
||||||
#define IPADDR_INET6 2
|
#define IPADDR_INET6 2
|
||||||
|
#define IPADDR_ID 3
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
union {
|
union {
|
||||||
uint32_t in4;
|
uint32_t in4;
|
||||||
uint8_t in6[16];
|
uint8_t in6[16];
|
||||||
|
uint32_t id;
|
||||||
} addr;
|
} addr;
|
||||||
uint16_t family;
|
uint16_t family;
|
||||||
|
uint16_t _pad;
|
||||||
} IPAddr;
|
} IPAddr;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
IPAddr ip_addr;
|
IPAddr ip_addr;
|
||||||
IPAddr local_ip_addr;
|
uint16_t port;
|
||||||
unsigned short port;
|
} IPSockAddr;
|
||||||
} NTP_Remote_Address;
|
|
||||||
|
typedef IPSockAddr NTP_Remote_Address;
|
||||||
|
|
||||||
|
#define INVALID_IF_INDEX -1
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IPAddr ip_addr;
|
||||||
|
int if_index;
|
||||||
|
int sock_fd;
|
||||||
|
} NTP_Local_Address;
|
||||||
|
|
||||||
#endif /* GOT_ADDRESSING_H */
|
#endif /* GOT_ADDRESSING_H */
|
||||||
|
|
||||||
|
|||||||
144
addrfilt.c
144
addrfilt.c
@@ -1,13 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/addrfilt.c,v 1.8 2002/02/28 23:27:08 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997,1998,1999,2000,2001,2002,2005
|
* Copyright (C) Richard P. Curnow 1997,1998,1999,2000,2001,2002,2005
|
||||||
* Copyright (C) Miroslav Lichvar 2009
|
* Copyright (C) Miroslav Lichvar 2009, 2015
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -32,6 +28,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "addrfilt.h"
|
#include "addrfilt.h"
|
||||||
@@ -64,7 +62,7 @@ split_ip6(IPAddr *ip, uint32_t *dst)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
dst[i] = ip->addr.in6[i * 4 + 0] << 24 |
|
dst[i] = (uint32_t)ip->addr.in6[i * 4 + 0] << 24 |
|
||||||
ip->addr.in6[i * 4 + 1] << 16 |
|
ip->addr.in6[i * 4 + 1] << 16 |
|
||||||
ip->addr.in6[i * 4 + 2] << 8 |
|
ip->addr.in6[i * 4 + 2] << 8 |
|
||||||
ip->addr.in6[i * 4 + 3];
|
ip->addr.in6[i * 4 + 3];
|
||||||
@@ -118,8 +116,6 @@ close_node(TableNode *node)
|
|||||||
Free(node->extended);
|
Free(node->extended);
|
||||||
node->extended = NULL;
|
node->extended = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,7 +139,6 @@ open_node(TableNode *node)
|
|||||||
child_node->extended = NULL;
|
child_node->extended = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -204,7 +199,10 @@ set_subnet(TableNode *start_node,
|
|||||||
|
|
||||||
/* How many subnet entries to set : 1->8, 2->4, 3->2 */
|
/* How many subnet entries to set : 1->8, 2->4, 3->2 */
|
||||||
N = 1 << (NBITS-bits_to_go);
|
N = 1 << (NBITS-bits_to_go);
|
||||||
subnet = get_subnet(ip, bits_consumed);
|
|
||||||
|
subnet = get_subnet(ip, bits_consumed) & ~(N - 1);
|
||||||
|
assert(subnet + N <= TABLE_SIZE);
|
||||||
|
|
||||||
if (!(node->extended)) {
|
if (!(node->extended)) {
|
||||||
open_node(node);
|
open_node(node);
|
||||||
}
|
}
|
||||||
@@ -249,6 +247,8 @@ set_subnet_(ADF_AuthTable table,
|
|||||||
set_subnet(&table->base6, ip6, 4, 0, new_state, delete_children) == ADF_SUCCESS)
|
set_subnet(&table->base6, ip6, 4, 0, new_state, delete_children) == ADF_SUCCESS)
|
||||||
return ADF_SUCCESS;
|
return ADF_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ADF_BADSUBNET;
|
return ADF_BADSUBNET;
|
||||||
@@ -361,123 +361,45 @@ ADF_IsAllowed(ADF_AuthTable table,
|
|||||||
case IPADDR_INET6:
|
case IPADDR_INET6:
|
||||||
split_ip6(ip_addr, ip6);
|
split_ip6(ip_addr, ip6);
|
||||||
return check_ip_in_node(&table->base6, ip6);
|
return check_ip_in_node(&table->base6, ip6);
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
#if defined TEST
|
static int
|
||||||
|
is_any_allowed(TableNode *node, State parent)
|
||||||
static void print_node(TableNode *node, uint32_t *addr, int ip_len, int shift, int subnet_bits)
|
|
||||||
{
|
{
|
||||||
uint32_t new_addr[4];
|
State state;
|
||||||
int i;
|
int i;
|
||||||
TableNode *sub_node;
|
|
||||||
|
|
||||||
for (i=0; i<subnet_bits; i++) putchar(' ');
|
state = node->state != AS_PARENT ? node->state : parent;
|
||||||
|
assert(state != AS_PARENT);
|
||||||
|
|
||||||
if (ip_len == 1)
|
|
||||||
printf("%d.%d.%d.%d",
|
|
||||||
((addr[0] >> 24) & 255),
|
|
||||||
((addr[0] >> 16) & 255),
|
|
||||||
((addr[0] >> 8) & 255),
|
|
||||||
((addr[0] ) & 255));
|
|
||||||
else {
|
|
||||||
for (i=0; i<4; i++) {
|
|
||||||
if (addr[i])
|
|
||||||
printf("%d.%d.%d.%d",
|
|
||||||
((addr[i] >> 24) & 255),
|
|
||||||
((addr[i] >> 16) & 255),
|
|
||||||
((addr[i] >> 8) & 255),
|
|
||||||
((addr[i] ) & 255));
|
|
||||||
putchar(i < 3 ? ':' : '\0');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("/%d : %s\n",
|
|
||||||
subnet_bits,
|
|
||||||
(node->state == ALLOW) ? "allow" :
|
|
||||||
(node->state == DENY) ? "deny" : "as parent");
|
|
||||||
if (node->extended) {
|
if (node->extended) {
|
||||||
for (i=0; i<16; i++) {
|
for (i = 0; i < TABLE_SIZE; i++) {
|
||||||
sub_node = &(node->extended[i]);
|
if (is_any_allowed(&node->extended[i], state))
|
||||||
new_addr[0] = addr[0];
|
return 1;
|
||||||
new_addr[1] = addr[1];
|
|
||||||
new_addr[2] = addr[2];
|
|
||||||
new_addr[3] = addr[3];
|
|
||||||
new_addr[ip_len - 1 - shift / 32] |= ((uint32_t)i << (shift % 32));
|
|
||||||
print_node(sub_node, new_addr, ip_len, shift - 4, subnet_bits + 4);
|
|
||||||
}
|
}
|
||||||
|
} else if (state == ALLOW) {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
static void print_table(ADF_AuthTable table)
|
|
||||||
{
|
|
||||||
uint32_t addr[4];
|
|
||||||
|
|
||||||
memset(addr, 0, sizeof (addr));
|
|
||||||
printf("IPv4 table:\n");
|
|
||||||
print_node(&table->base4, addr, 1, 28, 0);
|
|
||||||
|
|
||||||
memset(addr, 0, sizeof (addr));
|
|
||||||
printf("IPv6 table:\n");
|
|
||||||
print_node(&table->base6, addr, 4, 124, 0);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int
|
||||||
|
ADF_IsAnyAllowed(ADF_AuthTable table, int family)
|
||||||
{
|
{
|
||||||
IPAddr ip;
|
switch (family) {
|
||||||
ADF_AuthTable table;
|
case IPADDR_INET4:
|
||||||
table = ADF_CreateTable();
|
return is_any_allowed(&table->base4, AS_PARENT);
|
||||||
|
case IPADDR_INET6:
|
||||||
ip.family = IPADDR_INET4;
|
return is_any_allowed(&table->base6, AS_PARENT);
|
||||||
|
default:
|
||||||
ip.addr.in4 = 0x7e800000;
|
return 0;
|
||||||
ADF_Allow(table, &ip, 9);
|
}
|
||||||
ip.addr.in4 = 0x7ecc0000;
|
|
||||||
ADF_Deny(table, &ip, 14);
|
|
||||||
#if 0
|
|
||||||
ip.addr.in4 = 0x7f000001;
|
|
||||||
ADF_Deny(table, &ip, 32);
|
|
||||||
ip.addr.in4 = 0x7f000000;
|
|
||||||
ADF_Allow(table, &ip, 8);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
printf("allowed: %d\n", ADF_IsAllowed(table, &ip));
|
|
||||||
ip.addr.in4 ^= 1;
|
|
||||||
printf("allowed: %d\n", ADF_IsAllowed(table, &ip));
|
|
||||||
|
|
||||||
ip.family = IPADDR_INET6;
|
|
||||||
|
|
||||||
memcpy(ip.addr.in6, "abcdefghijklmnop", 16);
|
|
||||||
ADF_Deny(table, &ip, 66);
|
|
||||||
ADF_Allow(table, &ip, 59);
|
|
||||||
|
|
||||||
memcpy(ip.addr.in6, "xbcdefghijklmnop", 16);
|
|
||||||
ADF_Deny(table, &ip, 128);
|
|
||||||
ip.addr.in6[15] ^= 3;
|
|
||||||
ADF_Allow(table, &ip, 127);
|
|
||||||
|
|
||||||
printf("allowed: %d\n", ADF_IsAllowed(table, &ip));
|
|
||||||
ip.addr.in4 ^= 1;
|
|
||||||
printf("allowed: %d\n", ADF_IsAllowed(table, &ip));
|
|
||||||
|
|
||||||
print_table(table);
|
|
||||||
|
|
||||||
ADF_DestroyTable(table);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* defined TEST */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/addrfilt.h,v 1.6 2002/02/28 23:27:08 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -76,4 +72,9 @@ extern void ADF_DestroyTable(ADF_AuthTable table);
|
|||||||
extern int ADF_IsAllowed(ADF_AuthTable table,
|
extern int ADF_IsAllowed(ADF_AuthTable table,
|
||||||
IPAddr *ip);
|
IPAddr *ip);
|
||||||
|
|
||||||
|
/* Check if at least one address from a given family is allowed by
|
||||||
|
the rules in the table */
|
||||||
|
extern int ADF_IsAnyAllowed(ADF_AuthTable table,
|
||||||
|
int family);
|
||||||
|
|
||||||
#endif /* GOT_ADDRFILT_H */
|
#endif /* GOT_ADDRFILT_H */
|
||||||
|
|||||||
130
array.c
Normal file
130
array.c
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2014
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Functions implementing an array with automatic memory allocation.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
|
#include "array.h"
|
||||||
|
#include "memory.h"
|
||||||
|
|
||||||
|
struct ARR_Instance_Record {
|
||||||
|
void *data;
|
||||||
|
unsigned int elem_size;
|
||||||
|
unsigned int used;
|
||||||
|
unsigned int allocated;
|
||||||
|
};
|
||||||
|
|
||||||
|
ARR_Instance
|
||||||
|
ARR_CreateInstance(unsigned int elem_size)
|
||||||
|
{
|
||||||
|
ARR_Instance array;
|
||||||
|
|
||||||
|
assert(elem_size > 0);
|
||||||
|
|
||||||
|
array = MallocNew(struct ARR_Instance_Record);
|
||||||
|
|
||||||
|
array->data = NULL;
|
||||||
|
array->elem_size = elem_size;
|
||||||
|
array->used = 0;
|
||||||
|
array->allocated = 0;
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ARR_DestroyInstance(ARR_Instance array)
|
||||||
|
{
|
||||||
|
Free(array->data);
|
||||||
|
Free(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
realloc_array(ARR_Instance array, unsigned int min_size)
|
||||||
|
{
|
||||||
|
assert(min_size <= 2 * min_size);
|
||||||
|
if (array->allocated >= min_size && array->allocated <= 2 * min_size)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (array->allocated < min_size) {
|
||||||
|
while (array->allocated < min_size)
|
||||||
|
array->allocated = array->allocated ? 2 * array->allocated : 1;
|
||||||
|
} else {
|
||||||
|
array->allocated = min_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
array->data = Realloc2(array->data, array->allocated, array->elem_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
ARR_GetNewElement(ARR_Instance array)
|
||||||
|
{
|
||||||
|
array->used++;
|
||||||
|
realloc_array(array, array->used);
|
||||||
|
return ARR_GetElement(array, array->used - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
ARR_GetElement(ARR_Instance array, unsigned int index)
|
||||||
|
{
|
||||||
|
assert(index < array->used);
|
||||||
|
return (void *)((char *)array->data + (size_t)index * array->elem_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
ARR_GetElements(ARR_Instance array)
|
||||||
|
{
|
||||||
|
/* Return a non-NULL pointer when the array has zero size */
|
||||||
|
if (!array->data) {
|
||||||
|
assert(!array->used);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ARR_AppendElement(ARR_Instance array, void *element)
|
||||||
|
{
|
||||||
|
void *e;
|
||||||
|
|
||||||
|
e = ARR_GetNewElement(array);
|
||||||
|
memcpy(e, element, array->elem_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ARR_SetSize(ARR_Instance array, unsigned int size)
|
||||||
|
{
|
||||||
|
realloc_array(array, size);
|
||||||
|
array->used = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
ARR_GetSize(ARR_Instance array)
|
||||||
|
{
|
||||||
|
return array->used;
|
||||||
|
}
|
||||||
56
array.h
Normal file
56
array.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2014
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Header file for array functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GOT_ARRAY_H
|
||||||
|
#define GOT_ARRAY_H
|
||||||
|
|
||||||
|
typedef struct ARR_Instance_Record *ARR_Instance;
|
||||||
|
|
||||||
|
/* Create a new array with given element size */
|
||||||
|
extern ARR_Instance ARR_CreateInstance(unsigned int elem_size);
|
||||||
|
|
||||||
|
/* Destroy the array */
|
||||||
|
extern void ARR_DestroyInstance(ARR_Instance array);
|
||||||
|
|
||||||
|
/* Return pointer to a new element added to the end of the array */
|
||||||
|
extern void *ARR_GetNewElement(ARR_Instance array);
|
||||||
|
|
||||||
|
/* Return element with given index */
|
||||||
|
extern void *ARR_GetElement(ARR_Instance array, unsigned int index);
|
||||||
|
|
||||||
|
/* Return pointer to the internal array of elements */
|
||||||
|
extern void *ARR_GetElements(ARR_Instance array);
|
||||||
|
|
||||||
|
/* Add a new element to the end of the array */
|
||||||
|
extern void ARR_AppendElement(ARR_Instance array, void *element);
|
||||||
|
|
||||||
|
/* Set the size of the array */
|
||||||
|
extern void ARR_SetSize(ARR_Instance array, unsigned int size);
|
||||||
|
|
||||||
|
/* Return current size of the array */
|
||||||
|
extern unsigned int ARR_GetSize(ARR_Instance array);
|
||||||
|
|
||||||
|
#endif
|
||||||
160
broadcast.c
160
broadcast.c
@@ -1,160 +0,0 @@
|
|||||||
/*
|
|
||||||
$Header: /cvs/src/chrony/broadcast.c,v 1.3 2002/02/28 23:27:08 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
|
||||||
|
|
||||||
**********************************************************************
|
|
||||||
* Copyright (C) Richard P. Curnow 1997-2002
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
**********************************************************************
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Deal with broadcast server functions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sysincl.h"
|
|
||||||
#include "memory.h"
|
|
||||||
|
|
||||||
#include "addressing.h"
|
|
||||||
#include "broadcast.h"
|
|
||||||
#include "sched.h"
|
|
||||||
#include "ntp.h"
|
|
||||||
#include "local.h"
|
|
||||||
#include "reference.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "ntp_io.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
NTP_Remote_Address addr;
|
|
||||||
int interval;
|
|
||||||
} Destination;
|
|
||||||
static Destination *destinations = 0;
|
|
||||||
static int n_destinations = 0;
|
|
||||||
static int max_destinations = 0;
|
|
||||||
|
|
||||||
void
|
|
||||||
BRD_Initialise(void)
|
|
||||||
{
|
|
||||||
return; /* Nothing to do */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
void
|
|
||||||
BRD_Finalise(void)
|
|
||||||
{
|
|
||||||
return; /* Nothing to do */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
/* This is a cut-down version of what transmit_packet in ntp_core.c does */
|
|
||||||
|
|
||||||
static void
|
|
||||||
timeout_handler(void *arbitrary)
|
|
||||||
{
|
|
||||||
Destination *d = (Destination *) arbitrary;
|
|
||||||
NTP_Packet message;
|
|
||||||
/* Parameters read from reference module */
|
|
||||||
int version;
|
|
||||||
int leap;
|
|
||||||
int are_we_synchronised, our_stratum;
|
|
||||||
NTP_Leap leap_status;
|
|
||||||
unsigned long our_ref_id;
|
|
||||||
struct timeval our_ref_time;
|
|
||||||
double our_root_delay, our_root_dispersion;
|
|
||||||
double local_time_err;
|
|
||||||
struct timeval local_transmit;
|
|
||||||
|
|
||||||
version = 3;
|
|
||||||
|
|
||||||
LCL_ReadCookedTime(&local_transmit, &local_time_err);
|
|
||||||
REF_GetReferenceParams(&local_transmit,
|
|
||||||
&are_we_synchronised, &leap_status,
|
|
||||||
&our_stratum,
|
|
||||||
&our_ref_id, &our_ref_time,
|
|
||||||
&our_root_delay, &our_root_dispersion);
|
|
||||||
|
|
||||||
|
|
||||||
if (are_we_synchronised) {
|
|
||||||
leap = (int) leap_status;
|
|
||||||
} else {
|
|
||||||
leap = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message.lvm = ((leap << 6) &0xc0) | ((version << 3) & 0x38) | (MODE_BROADCAST & 0x07);
|
|
||||||
message.stratum = our_stratum;
|
|
||||||
message.poll = 6; /* FIXME: what should this be? */
|
|
||||||
message.precision = LCL_GetSysPrecisionAsLog();
|
|
||||||
|
|
||||||
/* If we're sending a client mode packet and we aren't synchronized yet,
|
|
||||||
we might have to set up artificial values for some of these parameters */
|
|
||||||
message.root_delay = double_to_int32(our_root_delay);
|
|
||||||
message.root_dispersion = double_to_int32(our_root_dispersion);
|
|
||||||
|
|
||||||
message.reference_id = htonl((NTP_int32) our_ref_id);
|
|
||||||
|
|
||||||
/* Now fill in timestamps */
|
|
||||||
UTI_TimevalToInt64(&our_ref_time, &message.reference_ts);
|
|
||||||
message.originate_ts.hi = 0UL;
|
|
||||||
message.originate_ts.lo = 0UL;
|
|
||||||
message.receive_ts.hi = 0UL;
|
|
||||||
message.receive_ts.lo = 0UL;
|
|
||||||
|
|
||||||
LCL_ReadCookedTime(&local_transmit, &local_time_err);
|
|
||||||
UTI_TimevalToInt64(&local_transmit, &message.transmit_ts);
|
|
||||||
NIO_SendNormalPacket(&message, &d->addr);
|
|
||||||
|
|
||||||
/* Requeue timeout. Don't care if interval drifts gradually, so just do it
|
|
||||||
* at the end. */
|
|
||||||
SCH_AddTimeoutInClass((double) d->interval, 1.0,
|
|
||||||
SCH_NtpBroadcastClass,
|
|
||||||
timeout_handler, (void *) d);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
void
|
|
||||||
BRD_AddDestination(IPAddr *addr, unsigned short port, int interval)
|
|
||||||
{
|
|
||||||
if (max_destinations == n_destinations) {
|
|
||||||
/* Expand array */
|
|
||||||
max_destinations += 8;
|
|
||||||
if (destinations) {
|
|
||||||
destinations = ReallocArray(Destination, max_destinations, destinations);
|
|
||||||
} else {
|
|
||||||
destinations = MallocArray(Destination, max_destinations);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
destinations[n_destinations].addr.ip_addr = *addr;
|
|
||||||
destinations[n_destinations].addr.local_ip_addr.family = IPADDR_UNSPEC;
|
|
||||||
destinations[n_destinations].addr.port = port;
|
|
||||||
destinations[n_destinations].interval = interval;
|
|
||||||
|
|
||||||
SCH_AddTimeoutInClass((double) interval, 1.0,
|
|
||||||
SCH_NtpBroadcastClass,
|
|
||||||
timeout_handler, (void *)(destinations + n_destinations));
|
|
||||||
|
|
||||||
++n_destinations;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
458
candm.h
458
candm.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/candm.h,v 1.40 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -86,18 +82,41 @@
|
|||||||
#define REQ_MANUAL_DELETE 42
|
#define REQ_MANUAL_DELETE 42
|
||||||
#define REQ_MAKESTEP 43
|
#define REQ_MAKESTEP 43
|
||||||
#define REQ_ACTIVITY 44
|
#define REQ_ACTIVITY 44
|
||||||
#define N_REQUEST_TYPES 45
|
#define REQ_MODIFY_MINSTRATUM 45
|
||||||
|
#define REQ_MODIFY_POLLTARGET 46
|
||||||
|
#define REQ_MODIFY_MAXDELAYDEVRATIO 47
|
||||||
|
#define REQ_RESELECT 48
|
||||||
|
#define REQ_RESELECTDISTANCE 49
|
||||||
|
#define REQ_MODIFY_MAKESTEP 50
|
||||||
|
#define REQ_SMOOTHING 51
|
||||||
|
#define REQ_SMOOTHTIME 52
|
||||||
|
#define REQ_REFRESH 53
|
||||||
|
#define REQ_SERVER_STATS 54
|
||||||
|
#define REQ_CLIENT_ACCESSES_BY_INDEX2 55
|
||||||
|
#define REQ_LOCAL2 56
|
||||||
|
#define REQ_NTP_DATA 57
|
||||||
|
#define REQ_ADD_SERVER2 58
|
||||||
|
#define REQ_ADD_PEER2 59
|
||||||
|
#define REQ_ADD_SERVER3 60
|
||||||
|
#define REQ_ADD_PEER3 61
|
||||||
|
#define REQ_SHUTDOWN 62
|
||||||
|
#define REQ_ONOFFLINE 63
|
||||||
|
#define REQ_ADD_SOURCE 64
|
||||||
|
#define REQ_NTP_SOURCE_NAME 65
|
||||||
|
#define REQ_RESET_SOURCES 66
|
||||||
|
#define REQ_AUTH_DATA 67
|
||||||
|
#define REQ_CLIENT_ACCESSES_BY_INDEX3 68
|
||||||
|
#define REQ_SELECT_DATA 69
|
||||||
|
#define REQ_RELOAD_SOURCES 70
|
||||||
|
#define REQ_DOFFSET2 71
|
||||||
|
#define N_REQUEST_TYPES 72
|
||||||
|
|
||||||
/* Special utoken value used to log on with first exchange being the
|
/* Structure used to exchange timespecs independent of time_t size */
|
||||||
password. (This time value has long since gone by) */
|
|
||||||
#define SPECIAL_UTOKEN 0x10101010
|
|
||||||
|
|
||||||
/* Structure used to exchange timevals independent on size of time_t */
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t tv_sec_high;
|
uint32_t tv_sec_high;
|
||||||
uint32_t tv_sec_low;
|
uint32_t tv_sec_low;
|
||||||
uint32_t tv_nsec;
|
uint32_t tv_nsec;
|
||||||
} Timeval;
|
} Timespec;
|
||||||
|
|
||||||
/* This is used in tv_sec_high for 32-bit timestamps */
|
/* This is used in tv_sec_high for 32-bit timestamps */
|
||||||
#define TV_NOHIGHSEC 0x7fffffff
|
#define TV_NOHIGHSEC 0x7fffffff
|
||||||
@@ -113,6 +132,10 @@ typedef struct {
|
|||||||
pktlength.c, to get the number of bytes that ought to be
|
pktlength.c, to get the number of bytes that ought to be
|
||||||
transmitted for each packet type. */
|
transmitted for each packet type. */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t EOR;
|
||||||
|
} REQ_Null;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
IPAddr mask;
|
IPAddr mask;
|
||||||
IPAddr address;
|
IPAddr address;
|
||||||
@@ -162,24 +185,50 @@ typedef struct {
|
|||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Modify_Maxdelayratio;
|
} REQ_Modify_Maxdelayratio;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IPAddr address;
|
||||||
|
Float new_max_delay_dev_ratio;
|
||||||
|
int32_t EOR;
|
||||||
|
} REQ_Modify_Maxdelaydevratio;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IPAddr address;
|
||||||
|
int32_t new_min_stratum;
|
||||||
|
int32_t EOR;
|
||||||
|
} REQ_Modify_Minstratum;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IPAddr address;
|
||||||
|
int32_t new_poll_target;
|
||||||
|
int32_t EOR;
|
||||||
|
} REQ_Modify_Polltarget;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Float new_max_update_skew;
|
Float new_max_update_skew;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Modify_Maxupdateskew;
|
} REQ_Modify_Maxupdateskew;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Timeval ts;
|
int32_t limit;
|
||||||
|
Float threshold;
|
||||||
|
int32_t EOR;
|
||||||
|
} REQ_Modify_Makestep;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Timespec ts;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Logon;
|
} REQ_Logon;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Timeval ts;
|
Timespec ts;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Settime;
|
} REQ_Settime;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t on_off;
|
int32_t on_off;
|
||||||
int32_t stratum;
|
int32_t stratum;
|
||||||
|
Float distance;
|
||||||
|
int32_t orphan;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Local;
|
} REQ_Local;
|
||||||
|
|
||||||
@@ -188,19 +237,11 @@ typedef struct {
|
|||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Manual;
|
} REQ_Manual;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t EOR;
|
|
||||||
} REQ_N_Sources;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t index;
|
int32_t index;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Source_Data;
|
} REQ_Source_Data;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t EOR;
|
|
||||||
} REQ_Rekey;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
IPAddr ip;
|
IPAddr ip;
|
||||||
int32_t subnet_bits;
|
int32_t subnet_bits;
|
||||||
@@ -212,20 +253,49 @@ typedef struct {
|
|||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Ac_Check;
|
} REQ_Ac_Check;
|
||||||
|
|
||||||
|
/* Source types in NTP source requests */
|
||||||
|
#define REQ_ADDSRC_SERVER 1
|
||||||
|
#define REQ_ADDSRC_PEER 2
|
||||||
|
#define REQ_ADDSRC_POOL 3
|
||||||
|
|
||||||
/* Flags used in NTP source requests */
|
/* Flags used in NTP source requests */
|
||||||
#define REQ_ADDSRC_ONLINE 0x1
|
#define REQ_ADDSRC_ONLINE 0x1
|
||||||
#define REQ_ADDSRC_AUTOOFFLINE 0x2
|
#define REQ_ADDSRC_AUTOOFFLINE 0x2
|
||||||
|
#define REQ_ADDSRC_IBURST 0x4
|
||||||
|
#define REQ_ADDSRC_PREFER 0x8
|
||||||
|
#define REQ_ADDSRC_NOSELECT 0x10
|
||||||
|
#define REQ_ADDSRC_TRUST 0x20
|
||||||
|
#define REQ_ADDSRC_REQUIRE 0x40
|
||||||
|
#define REQ_ADDSRC_INTERLEAVED 0x80
|
||||||
|
#define REQ_ADDSRC_BURST 0x100
|
||||||
|
#define REQ_ADDSRC_NTS 0x200
|
||||||
|
#define REQ_ADDSRC_COPY 0x400
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
IPAddr ip_addr;
|
uint32_t type;
|
||||||
|
uint8_t name[256];
|
||||||
uint32_t port;
|
uint32_t port;
|
||||||
int32_t minpoll;
|
int32_t minpoll;
|
||||||
int32_t maxpoll;
|
int32_t maxpoll;
|
||||||
int32_t presend_minpoll;
|
int32_t presend_minpoll;
|
||||||
|
uint32_t min_stratum;
|
||||||
|
uint32_t poll_target;
|
||||||
|
uint32_t version;
|
||||||
|
uint32_t max_sources;
|
||||||
|
int32_t min_samples;
|
||||||
|
int32_t max_samples;
|
||||||
uint32_t authkey;
|
uint32_t authkey;
|
||||||
|
uint32_t nts_port;
|
||||||
Float max_delay;
|
Float max_delay;
|
||||||
Float max_delay_ratio;
|
Float max_delay_ratio;
|
||||||
|
Float max_delay_dev_ratio;
|
||||||
|
Float min_delay;
|
||||||
|
Float asymmetry;
|
||||||
|
Float offset;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
|
int32_t filter_length;
|
||||||
|
uint32_t cert_set;
|
||||||
|
uint32_t reserved[2];
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_NTP_Source;
|
} REQ_NTP_Source;
|
||||||
|
|
||||||
@@ -234,85 +304,70 @@ typedef struct {
|
|||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Del_Source;
|
} REQ_Del_Source;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t EOR;
|
|
||||||
} REQ_WriteRtc;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Float dfreq;
|
Float dfreq;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Dfreq;
|
} REQ_Dfreq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t sec;
|
Float doffset;
|
||||||
int32_t usec;
|
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Doffset;
|
} REQ_Doffset;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t EOR;
|
|
||||||
} REQ_Tracking;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Sourcestats;
|
} REQ_Sourcestats;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t EOR;
|
|
||||||
} REQ_RTCReport;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t EOR;
|
|
||||||
} REQ_TrimRTC;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t EOR;
|
|
||||||
} REQ_CycleLogs;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
IPAddr ip;
|
|
||||||
uint32_t bits_specd;
|
|
||||||
} REQ_SubnetsAccessed_Subnet;
|
|
||||||
|
|
||||||
#define MAX_SUBNETS_ACCESSED 8
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t n_subnets;
|
|
||||||
REQ_SubnetsAccessed_Subnet subnets[MAX_SUBNETS_ACCESSED];
|
|
||||||
} REQ_SubnetsAccessed;
|
|
||||||
|
|
||||||
/* This is based on the response size rather than the
|
/* This is based on the response size rather than the
|
||||||
request size */
|
request size */
|
||||||
#define MAX_CLIENT_ACCESSES 8
|
#define MAX_CLIENT_ACCESSES 8
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t n_clients;
|
|
||||||
IPAddr client_ips[MAX_CLIENT_ACCESSES];
|
|
||||||
} REQ_ClientAccesses;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t first_index;
|
uint32_t first_index;
|
||||||
uint32_t n_indices;
|
uint32_t n_clients;
|
||||||
|
uint32_t min_hits;
|
||||||
|
uint32_t reset;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_ClientAccessesByIndex;
|
} REQ_ClientAccessesByIndex;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t EOR;
|
|
||||||
} REQ_ManualList;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t index;
|
int32_t index;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_ManualDelete;
|
} REQ_ManualDelete;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Float distance;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_MakeStep;
|
} REQ_ReselectDistance;
|
||||||
|
|
||||||
|
#define REQ_SMOOTHTIME_RESET 0
|
||||||
|
#define REQ_SMOOTHTIME_ACTIVATE 1
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
int32_t option;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Activity;
|
} REQ_SmoothTime;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IPAddr ip_addr;
|
||||||
|
int32_t EOR;
|
||||||
|
} REQ_NTPData;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IPAddr ip_addr;
|
||||||
|
int32_t EOR;
|
||||||
|
} REQ_NTPSourceName;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IPAddr ip_addr;
|
||||||
|
int32_t EOR;
|
||||||
|
} REQ_AuthData;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t index;
|
||||||
|
int32_t EOR;
|
||||||
|
} REQ_SelectData;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
@@ -334,15 +389,41 @@ typedef struct {
|
|||||||
Version 4 : IPv6 addressing added, 64-bit time values, sourcestats
|
Version 4 : IPv6 addressing added, 64-bit time values, sourcestats
|
||||||
and tracking reports extended, added flags to NTP source request,
|
and tracking reports extended, added flags to NTP source request,
|
||||||
trimmed source report, replaced fixed-point format with floating-point
|
trimmed source report, replaced fixed-point format with floating-point
|
||||||
and used also instead of integer microseconds
|
and used also instead of integer microseconds, new commands: modify stratum,
|
||||||
|
modify polltarget, modify maxdelaydevratio, reselect, reselectdistance
|
||||||
|
|
||||||
|
Version 5 : auth data moved to the end of the packet to allow hashes with
|
||||||
|
different sizes, extended sources, tracking and activity reports, dropped
|
||||||
|
subnets accessed and client accesses
|
||||||
|
|
||||||
|
Version 6 : added padding to requests to prevent amplification attack,
|
||||||
|
changed maximum number of samples in manual list to 16, new commands: modify
|
||||||
|
makestep, smoothing, smoothtime
|
||||||
|
|
||||||
|
Support for authentication was removed later in version 6 of the protocol
|
||||||
|
and commands that required authentication are allowed only locally over Unix
|
||||||
|
domain socket.
|
||||||
|
|
||||||
|
Version 6 (no authentication) : changed format of client accesses by index
|
||||||
|
(two times), delta offset, and manual timestamp, added new fields and
|
||||||
|
flags to NTP source request and report, made length of manual list constant,
|
||||||
|
added new commands: authdata, ntpdata, onoffline, refresh, reset,
|
||||||
|
selectdata, serverstats, shutdown, sourcename
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PROTO_VERSION_NUMBER 4
|
#define PROTO_VERSION_NUMBER 6
|
||||||
|
|
||||||
/* The oldest protocol version that is compatible enough with
|
/* The oldest protocol versions that are compatible enough with the current
|
||||||
the current version to report a version mismatch */
|
version to report a version mismatch for the server and the client */
|
||||||
#define PROTO_VERSION_MISMATCH_COMPAT 4
|
#define PROTO_VERSION_MISMATCH_COMPAT_SERVER 5
|
||||||
|
#define PROTO_VERSION_MISMATCH_COMPAT_CLIENT 4
|
||||||
|
|
||||||
|
/* The first protocol version using padding in requests */
|
||||||
|
#define PROTO_VERSION_PADDING 6
|
||||||
|
|
||||||
|
/* The maximum length of padding in request packet, currently
|
||||||
|
defined by CLIENT_ACCESSES_BY_INDEX3 */
|
||||||
|
#define MAX_PADDING_LENGTH 484
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
@@ -356,11 +437,11 @@ typedef struct {
|
|||||||
(count up from zero for same sequence
|
(count up from zero for same sequence
|
||||||
number) */
|
number) */
|
||||||
uint32_t sequence; /* Client's sequence number */
|
uint32_t sequence; /* Client's sequence number */
|
||||||
uint32_t utoken; /* Unique token per incarnation of daemon */
|
uint32_t pad1;
|
||||||
uint32_t token; /* Command token (to prevent replay attack) */
|
uint32_t pad2;
|
||||||
uint32_t auth[4]; /* MD5 authentication of the packet */
|
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
REQ_Null null;
|
||||||
REQ_Online online;
|
REQ_Online online;
|
||||||
REQ_Offline offline;
|
REQ_Offline offline;
|
||||||
REQ_Burst burst;
|
REQ_Burst burst;
|
||||||
@@ -369,35 +450,37 @@ typedef struct {
|
|||||||
REQ_Dump dump;
|
REQ_Dump dump;
|
||||||
REQ_Modify_Maxdelay modify_maxdelay;
|
REQ_Modify_Maxdelay modify_maxdelay;
|
||||||
REQ_Modify_Maxdelayratio modify_maxdelayratio;
|
REQ_Modify_Maxdelayratio modify_maxdelayratio;
|
||||||
|
REQ_Modify_Maxdelaydevratio modify_maxdelaydevratio;
|
||||||
|
REQ_Modify_Minstratum modify_minstratum;
|
||||||
|
REQ_Modify_Polltarget modify_polltarget;
|
||||||
REQ_Modify_Maxupdateskew modify_maxupdateskew;
|
REQ_Modify_Maxupdateskew modify_maxupdateskew;
|
||||||
|
REQ_Modify_Makestep modify_makestep;
|
||||||
REQ_Logon logon;
|
REQ_Logon logon;
|
||||||
REQ_Settime settime;
|
REQ_Settime settime;
|
||||||
REQ_Local local;
|
REQ_Local local;
|
||||||
REQ_Manual manual;
|
REQ_Manual manual;
|
||||||
REQ_N_Sources n_sources;
|
|
||||||
REQ_Source_Data source_data;
|
REQ_Source_Data source_data;
|
||||||
REQ_Rekey rekey;
|
|
||||||
REQ_Allow_Deny allow_deny;
|
REQ_Allow_Deny allow_deny;
|
||||||
REQ_Ac_Check ac_check;
|
REQ_Ac_Check ac_check;
|
||||||
REQ_NTP_Source ntp_source;
|
REQ_NTP_Source ntp_source;
|
||||||
REQ_Del_Source del_source;
|
REQ_Del_Source del_source;
|
||||||
REQ_WriteRtc writertc;
|
|
||||||
REQ_Dfreq dfreq;
|
REQ_Dfreq dfreq;
|
||||||
REQ_Doffset doffset;
|
REQ_Doffset doffset;
|
||||||
REQ_Tracking tracking;
|
|
||||||
REQ_Sourcestats sourcestats;
|
REQ_Sourcestats sourcestats;
|
||||||
REQ_RTCReport rtcreport;
|
|
||||||
REQ_TrimRTC trimrtc;
|
|
||||||
REQ_CycleLogs cyclelogs;
|
|
||||||
REQ_SubnetsAccessed subnets_accessed;
|
|
||||||
REQ_ClientAccesses client_accesses;
|
|
||||||
REQ_ClientAccessesByIndex client_accesses_by_index;
|
REQ_ClientAccessesByIndex client_accesses_by_index;
|
||||||
REQ_ManualList manual_list;
|
|
||||||
REQ_ManualDelete manual_delete;
|
REQ_ManualDelete manual_delete;
|
||||||
REQ_MakeStep make_step;
|
REQ_ReselectDistance reselect_distance;
|
||||||
REQ_Activity activity;
|
REQ_SmoothTime smoothtime;
|
||||||
|
REQ_NTPData ntp_data;
|
||||||
|
REQ_NTPSourceName ntp_source_name;
|
||||||
|
REQ_AuthData auth_data;
|
||||||
|
REQ_SelectData select_data;
|
||||||
} data; /* Command specific parameters */
|
} data; /* Command specific parameters */
|
||||||
|
|
||||||
|
/* Padding used to prevent traffic amplification. It only defines the
|
||||||
|
maximum size of the packet, there is no hole after the data field. */
|
||||||
|
uint8_t padding[MAX_PADDING_LENGTH];
|
||||||
|
|
||||||
} CMD_Request;
|
} CMD_Request;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -422,7 +505,18 @@ typedef struct {
|
|||||||
#define RPY_CLIENT_ACCESSES_BY_INDEX 10
|
#define RPY_CLIENT_ACCESSES_BY_INDEX 10
|
||||||
#define RPY_MANUAL_LIST 11
|
#define RPY_MANUAL_LIST 11
|
||||||
#define RPY_ACTIVITY 12
|
#define RPY_ACTIVITY 12
|
||||||
#define N_REPLY_TYPES 13
|
#define RPY_SMOOTHING 13
|
||||||
|
#define RPY_SERVER_STATS 14
|
||||||
|
#define RPY_CLIENT_ACCESSES_BY_INDEX2 15
|
||||||
|
#define RPY_NTP_DATA 16
|
||||||
|
#define RPY_MANUAL_TIMESTAMP2 17
|
||||||
|
#define RPY_MANUAL_LIST2 18
|
||||||
|
#define RPY_NTP_SOURCE_NAME 19
|
||||||
|
#define RPY_AUTH_DATA 20
|
||||||
|
#define RPY_CLIENT_ACCESSES_BY_INDEX3 21
|
||||||
|
#define RPY_SERVER_STATS2 22
|
||||||
|
#define RPY_SELECT_DATA 23
|
||||||
|
#define N_REPLY_TYPES 24
|
||||||
|
|
||||||
/* Status codes */
|
/* Status codes */
|
||||||
#define STT_SUCCESS 0
|
#define STT_SUCCESS 0
|
||||||
@@ -435,6 +529,7 @@ typedef struct {
|
|||||||
#define STT_BADSUBNET 7
|
#define STT_BADSUBNET 7
|
||||||
#define STT_ACCESSALLOWED 8
|
#define STT_ACCESSALLOWED 8
|
||||||
#define STT_ACCESSDENIED 9
|
#define STT_ACCESSDENIED 9
|
||||||
|
/* Deprecated */
|
||||||
#define STT_NOHOSTACCESS 10
|
#define STT_NOHOSTACCESS 10
|
||||||
#define STT_SOURCEALREADYKNOWN 11
|
#define STT_SOURCEALREADYKNOWN 11
|
||||||
#define STT_TOOMANYSOURCES 12
|
#define STT_TOOMANYSOURCES 12
|
||||||
@@ -445,6 +540,7 @@ typedef struct {
|
|||||||
#define STT_INVALIDAF 17
|
#define STT_INVALIDAF 17
|
||||||
#define STT_BADPKTVERSION 18
|
#define STT_BADPKTVERSION 18
|
||||||
#define STT_BADPKTLENGTH 19
|
#define STT_BADPKTLENGTH 19
|
||||||
|
#define STT_INVALIDNAME 21
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
@@ -459,18 +555,21 @@ typedef struct {
|
|||||||
#define RPY_SD_MD_PEER 1
|
#define RPY_SD_MD_PEER 1
|
||||||
#define RPY_SD_MD_REF 2
|
#define RPY_SD_MD_REF 2
|
||||||
|
|
||||||
#define RPY_SD_ST_SYNC 0
|
#define RPY_SD_ST_SELECTED 0
|
||||||
#define RPY_SD_ST_UNREACH 1
|
#define RPY_SD_ST_NONSELECTABLE 1
|
||||||
#define RPY_SD_ST_FALSETICKER 2
|
#define RPY_SD_ST_FALSETICKER 2
|
||||||
#define RPY_SD_ST_JITTERY 3
|
#define RPY_SD_ST_JITTERY 3
|
||||||
#define RPY_SD_ST_OTHER 4
|
#define RPY_SD_ST_UNSELECTED 4
|
||||||
|
#define RPY_SD_ST_SELECTABLE 5
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
IPAddr ip_addr;
|
IPAddr ip_addr;
|
||||||
uint16_t poll;
|
int16_t poll;
|
||||||
uint16_t stratum;
|
uint16_t stratum;
|
||||||
uint16_t state;
|
uint16_t state;
|
||||||
uint16_t mode;
|
uint16_t mode;
|
||||||
|
uint16_t flags;
|
||||||
|
uint16_t reachability;
|
||||||
uint32_t since_sample;
|
uint32_t since_sample;
|
||||||
Float orig_latest_meas;
|
Float orig_latest_meas;
|
||||||
Float latest_meas;
|
Float latest_meas;
|
||||||
@@ -481,14 +580,18 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t ref_id;
|
uint32_t ref_id;
|
||||||
IPAddr ip_addr;
|
IPAddr ip_addr;
|
||||||
uint32_t stratum;
|
uint16_t stratum;
|
||||||
Timeval ref_time;
|
uint16_t leap_status;
|
||||||
|
Timespec ref_time;
|
||||||
Float current_correction;
|
Float current_correction;
|
||||||
|
Float last_offset;
|
||||||
|
Float rms_offset;
|
||||||
Float freq_ppm;
|
Float freq_ppm;
|
||||||
Float resid_freq_ppm;
|
Float resid_freq_ppm;
|
||||||
Float skew_ppm;
|
Float skew_ppm;
|
||||||
Float root_delay;
|
Float root_delay;
|
||||||
Float root_dispersion;
|
Float root_dispersion;
|
||||||
|
Float last_update_interval;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} RPY_Tracking;
|
} RPY_Tracking;
|
||||||
|
|
||||||
@@ -507,7 +610,7 @@ typedef struct {
|
|||||||
} RPY_Sourcestats;
|
} RPY_Sourcestats;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Timeval ref_time;
|
Timespec ref_time;
|
||||||
uint16_t n_samples;
|
uint16_t n_samples;
|
||||||
uint16_t n_runs;
|
uint16_t n_runs;
|
||||||
uint32_t span_seconds;
|
uint32_t span_seconds;
|
||||||
@@ -517,7 +620,7 @@ typedef struct {
|
|||||||
} RPY_Rtc;
|
} RPY_Rtc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t centiseconds;
|
Float offset;
|
||||||
Float dfreq_ppm;
|
Float dfreq_ppm;
|
||||||
Float new_afreq_ppm;
|
Float new_afreq_ppm;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
@@ -525,42 +628,45 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
IPAddr ip;
|
IPAddr ip;
|
||||||
uint32_t bits_specd;
|
uint32_t ntp_hits;
|
||||||
uint32_t bitmap[8];
|
uint32_t nke_hits;
|
||||||
} RPY_SubnetsAccessed_Subnet;
|
uint32_t cmd_hits;
|
||||||
|
uint32_t ntp_drops;
|
||||||
typedef struct {
|
uint32_t nke_drops;
|
||||||
uint32_t n_subnets;
|
uint32_t cmd_drops;
|
||||||
RPY_SubnetsAccessed_Subnet subnets[MAX_SUBNETS_ACCESSED];
|
int8_t ntp_interval;
|
||||||
} RPY_SubnetsAccessed;
|
int8_t nke_interval;
|
||||||
|
int8_t cmd_interval;
|
||||||
typedef struct {
|
int8_t ntp_timeout_interval;
|
||||||
IPAddr ip;
|
|
||||||
uint32_t client_hits;
|
|
||||||
uint32_t peer_hits;
|
|
||||||
uint32_t cmd_hits_auth;
|
|
||||||
uint32_t cmd_hits_normal;
|
|
||||||
uint32_t cmd_hits_bad;
|
|
||||||
uint32_t last_ntp_hit_ago;
|
uint32_t last_ntp_hit_ago;
|
||||||
|
uint32_t last_nke_hit_ago;
|
||||||
uint32_t last_cmd_hit_ago;
|
uint32_t last_cmd_hit_ago;
|
||||||
} RPY_ClientAccesses_Client;
|
} RPY_ClientAccesses_Client;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t n_clients;
|
|
||||||
RPY_ClientAccesses_Client clients[MAX_CLIENT_ACCESSES];
|
|
||||||
} RPY_ClientAccesses;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t n_indices; /* how many indices there are in the server's table */
|
uint32_t n_indices; /* how many indices there are in the server's table */
|
||||||
uint32_t next_index; /* the index 1 beyond those processed on this call */
|
uint32_t next_index; /* the index 1 beyond those processed on this call */
|
||||||
uint32_t n_clients; /* the number of valid entries in the following array */
|
uint32_t n_clients; /* the number of valid entries in the following array */
|
||||||
RPY_ClientAccesses_Client clients[MAX_CLIENT_ACCESSES];
|
RPY_ClientAccesses_Client clients[MAX_CLIENT_ACCESSES];
|
||||||
|
int32_t EOR;
|
||||||
} RPY_ClientAccessesByIndex;
|
} RPY_ClientAccessesByIndex;
|
||||||
|
|
||||||
#define MAX_MANUAL_LIST_SAMPLES 32
|
typedef struct {
|
||||||
|
uint32_t ntp_hits;
|
||||||
|
uint32_t nke_hits;
|
||||||
|
uint32_t cmd_hits;
|
||||||
|
uint32_t ntp_drops;
|
||||||
|
uint32_t nke_drops;
|
||||||
|
uint32_t cmd_drops;
|
||||||
|
uint32_t log_drops;
|
||||||
|
uint32_t ntp_auth_hits;
|
||||||
|
int32_t EOR;
|
||||||
|
} RPY_ServerStats;
|
||||||
|
|
||||||
|
#define MAX_MANUAL_LIST_SAMPLES 16
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Timeval when;
|
Timespec when;
|
||||||
Float slewed_offset;
|
Float slewed_offset;
|
||||||
Float orig_offset;
|
Float orig_offset;
|
||||||
Float residual;
|
Float residual;
|
||||||
@@ -569,6 +675,7 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t n_samples;
|
uint32_t n_samples;
|
||||||
RPY_ManualListSample samples[MAX_MANUAL_LIST_SAMPLES];
|
RPY_ManualListSample samples[MAX_MANUAL_LIST_SAMPLES];
|
||||||
|
int32_t EOR;
|
||||||
} RPY_ManualList;
|
} RPY_ManualList;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -576,9 +683,100 @@ typedef struct {
|
|||||||
int32_t offline;
|
int32_t offline;
|
||||||
int32_t burst_online;
|
int32_t burst_online;
|
||||||
int32_t burst_offline;
|
int32_t burst_offline;
|
||||||
|
int32_t unresolved;
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} RPY_Activity;
|
} RPY_Activity;
|
||||||
|
|
||||||
|
#define RPY_SMT_FLAG_ACTIVE 0x1
|
||||||
|
#define RPY_SMT_FLAG_LEAPONLY 0x2
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t flags;
|
||||||
|
Float offset;
|
||||||
|
Float freq_ppm;
|
||||||
|
Float wander_ppm;
|
||||||
|
Float last_update_ago;
|
||||||
|
Float remaining_time;
|
||||||
|
int32_t EOR;
|
||||||
|
} RPY_Smoothing;
|
||||||
|
|
||||||
|
#define RPY_NTP_FLAGS_TESTS 0x3ff
|
||||||
|
#define RPY_NTP_FLAG_INTERLEAVED 0x4000
|
||||||
|
#define RPY_NTP_FLAG_AUTHENTICATED 0x8000
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IPAddr remote_addr;
|
||||||
|
IPAddr local_addr;
|
||||||
|
uint16_t remote_port;
|
||||||
|
uint8_t leap;
|
||||||
|
uint8_t version;
|
||||||
|
uint8_t mode;
|
||||||
|
uint8_t stratum;
|
||||||
|
int8_t poll;
|
||||||
|
int8_t precision;
|
||||||
|
Float root_delay;
|
||||||
|
Float root_dispersion;
|
||||||
|
uint32_t ref_id;
|
||||||
|
Timespec ref_time;
|
||||||
|
Float offset;
|
||||||
|
Float peer_delay;
|
||||||
|
Float peer_dispersion;
|
||||||
|
Float response_time;
|
||||||
|
Float jitter_asymmetry;
|
||||||
|
uint16_t flags;
|
||||||
|
uint8_t tx_tss_char;
|
||||||
|
uint8_t rx_tss_char;
|
||||||
|
uint32_t total_tx_count;
|
||||||
|
uint32_t total_rx_count;
|
||||||
|
uint32_t total_valid_count;
|
||||||
|
uint32_t reserved[4];
|
||||||
|
int32_t EOR;
|
||||||
|
} RPY_NTPData;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t name[256];
|
||||||
|
int32_t EOR;
|
||||||
|
} RPY_NTPSourceName;
|
||||||
|
|
||||||
|
#define RPY_AD_MD_NONE 0
|
||||||
|
#define RPY_AD_MD_SYMMETRIC 1
|
||||||
|
#define RPY_AD_MD_NTS 2
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t mode;
|
||||||
|
uint16_t key_type;
|
||||||
|
uint32_t key_id;
|
||||||
|
uint16_t key_length;
|
||||||
|
uint16_t ke_attempts;
|
||||||
|
uint32_t last_ke_ago;
|
||||||
|
uint16_t cookies;
|
||||||
|
uint16_t cookie_length;
|
||||||
|
uint16_t nak;
|
||||||
|
uint16_t pad;
|
||||||
|
int32_t EOR;
|
||||||
|
} RPY_AuthData;
|
||||||
|
|
||||||
|
#define RPY_SD_OPTION_NOSELECT 0x1
|
||||||
|
#define RPY_SD_OPTION_PREFER 0x2
|
||||||
|
#define RPY_SD_OPTION_TRUST 0x4
|
||||||
|
#define RPY_SD_OPTION_REQUIRE 0x8
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t ref_id;
|
||||||
|
IPAddr ip_addr;
|
||||||
|
uint8_t state_char;
|
||||||
|
uint8_t authentication;
|
||||||
|
uint8_t leap;
|
||||||
|
uint8_t pad;
|
||||||
|
uint16_t conf_options;
|
||||||
|
uint16_t eff_options;
|
||||||
|
uint32_t last_sample_ago;
|
||||||
|
Float score;
|
||||||
|
Float lo_limit;
|
||||||
|
Float hi_limit;
|
||||||
|
int32_t EOR;
|
||||||
|
} RPY_SelectData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
uint8_t pkt_type;
|
uint8_t pkt_type;
|
||||||
@@ -587,14 +785,12 @@ typedef struct {
|
|||||||
uint16_t command; /* Which command is being replied to */
|
uint16_t command; /* Which command is being replied to */
|
||||||
uint16_t reply; /* Which format of reply this is */
|
uint16_t reply; /* Which format of reply this is */
|
||||||
uint16_t status; /* Status of command processing */
|
uint16_t status; /* Status of command processing */
|
||||||
uint16_t number; /* Which packet this is in reply sequence */
|
uint16_t pad1; /* Padding for compatibility and 4 byte alignment */
|
||||||
uint16_t total; /* Number of replies to expect in this sequence */
|
uint16_t pad2;
|
||||||
uint16_t pad1; /* Get up to 4 byte alignment */
|
uint16_t pad3;
|
||||||
uint32_t sequence; /* Echo of client's sequence number */
|
uint32_t sequence; /* Echo of client's sequence number */
|
||||||
uint32_t utoken; /* Unique token per incarnation of daemon */
|
uint32_t pad4;
|
||||||
uint32_t token; /* New command token (only if command was successfully
|
uint32_t pad5;
|
||||||
authenticated) */
|
|
||||||
uint32_t auth[4]; /* MD5 authentication of the packet */
|
|
||||||
|
|
||||||
union {
|
union {
|
||||||
RPY_Null null;
|
RPY_Null null;
|
||||||
@@ -604,11 +800,15 @@ typedef struct {
|
|||||||
RPY_Tracking tracking;
|
RPY_Tracking tracking;
|
||||||
RPY_Sourcestats sourcestats;
|
RPY_Sourcestats sourcestats;
|
||||||
RPY_Rtc rtc;
|
RPY_Rtc rtc;
|
||||||
RPY_SubnetsAccessed subnets_accessed;
|
|
||||||
RPY_ClientAccesses client_accesses;
|
|
||||||
RPY_ClientAccessesByIndex client_accesses_by_index;
|
RPY_ClientAccessesByIndex client_accesses_by_index;
|
||||||
|
RPY_ServerStats server_stats;
|
||||||
RPY_ManualList manual_list;
|
RPY_ManualList manual_list;
|
||||||
RPY_Activity activity;
|
RPY_Activity activity;
|
||||||
|
RPY_Smoothing smoothing;
|
||||||
|
RPY_NTPData ntp_data;
|
||||||
|
RPY_NTPSourceName ntp_source_name;
|
||||||
|
RPY_AuthData auth_data;
|
||||||
|
RPY_SelectData select_data;
|
||||||
} data; /* Reply specific parameters */
|
} data; /* Reply specific parameters */
|
||||||
|
|
||||||
} CMD_Reply;
|
} CMD_Reply;
|
||||||
|
|||||||
70
chrony.1
70
chrony.1
@@ -1,70 +0,0 @@
|
|||||||
.TH CHRONY 1 "December 04, 2009" chrony "User's Manual"
|
|
||||||
.SH NAME
|
|
||||||
chrony \- programs for keeping computer clocks accurate
|
|
||||||
|
|
||||||
.SH SYNOPSIS
|
|
||||||
\fBchronyc\fR [\fIOPTIONS\fR]
|
|
||||||
|
|
||||||
\fBchronyd\fR [\fIOPTIONS\fR]
|
|
||||||
|
|
||||||
.SH DESCRIPTION
|
|
||||||
\fBchrony\fR is a pair of programs for keeping computer clocks accurate.
|
|
||||||
\fIchronyd\fR is a background (daemon) program and \fIchronyc\fR is a
|
|
||||||
command-line interface to it. Time reference sources for chronyd can be
|
|
||||||
RFC1305 NTP servers, human (via keyboard and \fIchronyc\fR), or the computer's
|
|
||||||
real-time clock at boot time (Linux only). chronyd can determine the rate at
|
|
||||||
which the computer gains or loses time and compensate for it while no external
|
|
||||||
reference is present. Its use of NTP servers can be switched on and off
|
|
||||||
(through \fIchronyc\fR) to support computers with dial-up/intermittent access
|
|
||||||
to the Internet, and it can also act as an RFC1305-compatible NTP server.
|
|
||||||
|
|
||||||
.SH USAGE
|
|
||||||
\fIchronyc\fR is a command-line interface program which can be used to
|
|
||||||
monitor \fIchronyd\fR's performance and to change various operating
|
|
||||||
parateters whilst it is running.
|
|
||||||
|
|
||||||
\fIchronyd\fR's main function is to obtain measurements of the true (UTC)
|
|
||||||
time from one of several sources, and correct the system clock
|
|
||||||
accordingly. It also works out the rate at which the system clock
|
|
||||||
gains or loses time and uses this information to keep it accurate
|
|
||||||
between measurements from the reference.
|
|
||||||
|
|
||||||
The reference time can be derived from either Network Time Protocol
|
|
||||||
(NTP) servers, reference clocks, or wristwatch-and-keyboard (via \fIchronyc\fR).
|
|
||||||
The main source of information about the Network Time Protocol is
|
|
||||||
\fIhttp://www.eecis.udel.edu/~ntp\fR.
|
|
||||||
|
|
||||||
It is designed so that it can work on computers which only have
|
|
||||||
intermittent access to reference sources, for example computers which
|
|
||||||
use a dial-up account to access the Internet. Of course, it will work
|
|
||||||
on computers with permanent connections too.
|
|
||||||
|
|
||||||
In addition, for Linux 2.0.x (for x >= 32) or 2.2 onwards, chronyd can monitor
|
|
||||||
the system's real time clock performance, so the system can maintain accurate
|
|
||||||
time even across reboots.
|
|
||||||
|
|
||||||
Typical accuracies available between 2 machines are
|
|
||||||
|
|
||||||
On an ethernet LAN : 100-200 microseconds, often much better
|
|
||||||
On a V32bis dial-up modem connection : 10's of milliseconds (from one
|
|
||||||
session to the next)
|
|
||||||
|
|
||||||
With a good reference clock the accuracy can reach one microsecond.
|
|
||||||
|
|
||||||
\fIchronyd\fR can also operate as an RFC1305-compatible NTP server and peer.
|
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR chronyc(1),
|
|
||||||
.BR chrony(1)
|
|
||||||
|
|
||||||
.I http://chrony.tuxfamily.org/
|
|
||||||
|
|
||||||
.SH AUTHOR
|
|
||||||
Richard Curnow <rc@rc0.org.uk>
|
|
||||||
|
|
||||||
This man-page was written by Jan Schaumann <jschauma@netmeister.org> as part
|
|
||||||
of "The Missing Man Pages Project". Please see
|
|
||||||
\fIhttp://www.netmeister.org/misc/m2p2/index.html\fR for details.
|
|
||||||
|
|
||||||
The complete chrony documentation is supplied in texinfo format.
|
|
||||||
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
.TH chrony.conf 5 "December 04, 2009" chrony "Configuration Files"
|
|
||||||
.SH NAME
|
|
||||||
chrony.conf \- chronyd configuration file
|
|
||||||
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B /etc/chrony.conf
|
|
||||||
|
|
||||||
.SH DESCRIPTION
|
|
||||||
\fIchrony\fR is a pair of programs for maintaining the accuracy of computer
|
|
||||||
clocks. \fIchronyd\fR is a background daemon program that can be started at
|
|
||||||
boot time.
|
|
||||||
|
|
||||||
Assuming that you have found some servers, you need to set up a
|
|
||||||
configuration file to run \fIchrony\fR. The (compiled-in) default location
|
|
||||||
for this file is \fB/etc/chrony.conf\fR. Assuming that your ntp servers
|
|
||||||
are called `a.b.c' and `d.e.f', your \fBchrony.conf\fR file could contain
|
|
||||||
as a minimum
|
|
||||||
|
|
||||||
server a.b.c
|
|
||||||
server d.e.f
|
|
||||||
server g.h.i
|
|
||||||
|
|
||||||
However, you will probably want to include some of the other directives
|
|
||||||
described in detail in the documentation supplied with the distribution
|
|
||||||
(\fIchrony.txt\fR and \fIchrony.texi\fR). The following directives will be
|
|
||||||
particularly useful : `driftfile', `commandkey', `keyfile'. The smallest
|
|
||||||
useful configuration file would look something like
|
|
||||||
|
|
||||||
server a.b.c
|
|
||||||
server d.e.f
|
|
||||||
server g.h.i
|
|
||||||
keyfile /etc/chrony.keys
|
|
||||||
commandkey 1
|
|
||||||
driftfile /etc/chrony.drift
|
|
||||||
|
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR chrony(1),
|
|
||||||
.BR chronyc(1),
|
|
||||||
.BR chronyd(8)
|
|
||||||
|
|
||||||
.I http://chrony.tuxfamily.org/
|
|
||||||
|
|
||||||
.SH AUTHOR
|
|
||||||
Richard Curnow <rc@rc0.org.uk>
|
|
||||||
|
|
||||||
This man-page was written by Jan Schaumann <jschauma@netmeister.org> as part of "The Missing
|
|
||||||
Man Pages Project". Please see \fIhttp://www.netmeister.org/misc/m2p2/index.html\fR
|
|
||||||
for details.
|
|
||||||
|
|
||||||
The complete chrony documentation is supplied in texinfo format.
|
|
||||||
|
|
||||||
29
chrony.lsm
29
chrony.lsm
@@ -1,29 +0,0 @@
|
|||||||
Begin3
|
|
||||||
Title: chrony
|
|
||||||
Version: 1.18
|
|
||||||
Entered-date: 01APR02
|
|
||||||
Description: A pair of programs for keeping computer clocks accurate.
|
|
||||||
chronyd is a background (daemon) program and chronyc is a
|
|
||||||
command-line interface to it. Time reference sources for
|
|
||||||
chronyd can be RFC1305 NTP servers, human (via keyboard and
|
|
||||||
chronyc), and the computer's real-time clock at boot time
|
|
||||||
(Linux only). chronyd can determine the rate at which the
|
|
||||||
computer gains or loses time and compensate for it whilst no
|
|
||||||
external reference is present. chronyd's use of NTP servers
|
|
||||||
can be switched on and off (through chronyc) to support
|
|
||||||
computers with dial-up/intermittent access to the
|
|
||||||
Internet. chronyd can also act as an RFC1305-compatible NTP
|
|
||||||
server.
|
|
||||||
Keywords: time NTP RFC1305 RTC adjtime
|
|
||||||
Author: rc@rc0.org.uk (Richard Curnow)
|
|
||||||
Maintained-by: rc@rc0.org.uk (Richard Curnow)
|
|
||||||
Primary-site: chrony.tuxfamily.org
|
|
||||||
295k chrony-1.18.tar.gz
|
|
||||||
2k chrony.lsm
|
|
||||||
Platforms: Linux 2.0/2.1/2.2/2.3/2.4 (x86, powerpc)
|
|
||||||
Solaris 2.5/6/7/8, SunOS 4.1.4. (Sparc)
|
|
||||||
BSDI/386.
|
|
||||||
NetBSD
|
|
||||||
Solaris 2.8 (x86)
|
|
||||||
Copying-policy: GPL
|
|
||||||
End
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
Summary: An NTP client/server
|
|
||||||
Name: chrony
|
|
||||||
Version: @@VERSION@@
|
|
||||||
Release: 1
|
|
||||||
Source: chrony-%{version}.tar.gz
|
|
||||||
Copyright: GPL
|
|
||||||
Group: Applications/Utilities
|
|
||||||
Packager: Richard P. Curnow <rc@rc0.org.uk>
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(id -u -n)
|
|
||||||
Requires: info
|
|
||||||
|
|
||||||
%description
|
|
||||||
A pair of programs for keeping computer clocks accurate. chronyd is a
|
|
||||||
background (daemon) program and chronyc is a command-line interface to it.
|
|
||||||
Time reference sources for chronyd can be RFC1305 NTP servers, human (via
|
|
||||||
keyboard and chronyc), and the computer's real-time clock at boot time (Linux
|
|
||||||
only). chronyd can determine the rate at which the computer gains or loses
|
|
||||||
time and compensate for it whilst no external reference is present. chronyd's
|
|
||||||
use of NTP servers can be switched on and off (through chronyc) to support
|
|
||||||
computers with dial-up/intermittent access to the Internet. chronyd can also
|
|
||||||
act as an RFC1305-compatible NTP server.
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%setup
|
|
||||||
|
|
||||||
%build
|
|
||||||
./configure --prefix=%{_prefix} --mandir=%{_mandir}
|
|
||||||
make CC=gcc CFLAGS=-O2 prefix=%{_prefix}
|
|
||||||
make chrony.txt prefix=%{_prefix}
|
|
||||||
make chrony.info prefix=%{_prefix}
|
|
||||||
|
|
||||||
%install
|
|
||||||
rm -rf $RPM_BUILD_ROOT
|
|
||||||
cd $RPM_BUILD_DIR/chrony-%{version}
|
|
||||||
make install DESTDIR=$RPM_BUILD_ROOT prefix=%{_prefix}
|
|
||||||
mkdir -p $RPM_BUILD_ROOT%{_infodir}
|
|
||||||
cp chrony.info* $RPM_BUILD_ROOT%{_infodir}
|
|
||||||
|
|
||||||
%files
|
|
||||||
%{_sbindir}/chronyd
|
|
||||||
%{_bindir}/chronyc
|
|
||||||
%{_infodir}/chrony.info*
|
|
||||||
%{_mandir}/man1/chrony.1.gz
|
|
||||||
%{_mandir}/man1/chronyc.1.gz
|
|
||||||
%{_mandir}/man5/chrony.conf.5.gz
|
|
||||||
%{_mandir}/man8/chronyd.8.gz
|
|
||||||
%doc README
|
|
||||||
%doc chrony.txt
|
|
||||||
%doc COPYING
|
|
||||||
%doc examples/chrony.conf.example
|
|
||||||
%doc examples/chrony.keys.example
|
|
||||||
|
|
||||||
4248
chrony.texi
4248
chrony.texi
File diff suppressed because it is too large
Load Diff
@@ -1,67 +0,0 @@
|
|||||||
/* Taken from /usr/include/linux/timex.h. Avoids the need to
|
|
||||||
* include kernel header files. */
|
|
||||||
|
|
||||||
#ifndef CHRONY_TIMEX_H
|
|
||||||
#define CHRONY_TIMEX_H
|
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
struct timex {
|
|
||||||
unsigned int modes; /* mode selector */
|
|
||||||
long offset; /* time offset (usec) */
|
|
||||||
long freq; /* frequency offset (scaled ppm) */
|
|
||||||
long maxerror; /* maximum error (usec) */
|
|
||||||
long esterror; /* estimated error (usec) */
|
|
||||||
int status; /* clock command/status */
|
|
||||||
long constant; /* pll time constant */
|
|
||||||
long precision; /* clock precision (usec) (read only) */
|
|
||||||
long tolerance; /* clock frequency tolerance (ppm)
|
|
||||||
* (read only)
|
|
||||||
*/
|
|
||||||
struct timeval time; /* (read only) */
|
|
||||||
long tick; /* (modified) usecs between clock ticks */
|
|
||||||
|
|
||||||
long ppsfreq; /* pps frequency (scaled ppm) (ro) */
|
|
||||||
long jitter; /* pps jitter (us) (ro) */
|
|
||||||
int shift; /* interval duration (s) (shift) (ro) */
|
|
||||||
long stabil; /* pps stability (scaled ppm) (ro) */
|
|
||||||
long jitcnt; /* jitter limit exceeded (ro) */
|
|
||||||
long calcnt; /* calibration intervals (ro) */
|
|
||||||
long errcnt; /* calibration errors (ro) */
|
|
||||||
long stbcnt; /* stability limit exceeded (ro) */
|
|
||||||
|
|
||||||
int :32; int :32; int :32; int :32;
|
|
||||||
int :32; int :32; int :32; int :32;
|
|
||||||
int :32; int :32; int :32; int :32;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ADJ_FREQUENCY 0x0002 /* frequency offset */
|
|
||||||
#define ADJ_STATUS 0x0010 /* clock status */
|
|
||||||
#define ADJ_TICK 0x4000 /* tick value */
|
|
||||||
#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
|
|
||||||
#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
|
|
||||||
|
|
||||||
#define SHIFT_USEC 16 /* frequency offset scale (shift) */
|
|
||||||
|
|
||||||
#define STA_PLL 0x0001 /* enable PLL updates (rw) */
|
|
||||||
#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
|
|
||||||
#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
|
|
||||||
#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */
|
|
||||||
|
|
||||||
#define STA_INS 0x0010 /* insert leap (rw) */
|
|
||||||
#define STA_DEL 0x0020 /* delete leap (rw) */
|
|
||||||
#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
|
|
||||||
#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
|
|
||||||
|
|
||||||
#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
|
|
||||||
#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
|
|
||||||
#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
|
|
||||||
#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
|
|
||||||
|
|
||||||
#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
|
|
||||||
|
|
||||||
/* This doesn't seem to be in any include files !! */
|
|
||||||
|
|
||||||
extern int adjtimex(struct timex *);
|
|
||||||
|
|
||||||
#endif /* CHRONY_TIMEX_H */
|
|
||||||
66
chronyc.1
66
chronyc.1
@@ -1,66 +0,0 @@
|
|||||||
.TH CHRONYC 1 "December 04, 2009" chrony "User's Manual"
|
|
||||||
.SH NAME
|
|
||||||
chronyc \- command-line interface for chronyd
|
|
||||||
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B chronyc
|
|
||||||
[\fIOPTIONS\fR]
|
|
||||||
|
|
||||||
.SH DESCRIPTION
|
|
||||||
\fIchrony\fR is a pair of programs for maintaining the accuracy of computer
|
|
||||||
clocks.
|
|
||||||
|
|
||||||
\fBchronyc\fR is a command-line interface program which can be used to
|
|
||||||
monitor \fIchronyd\fR's performance and to change various operating
|
|
||||||
parateters whilst it is running.
|
|
||||||
|
|
||||||
.SH USAGE
|
|
||||||
A detailed description of all commands supported by \fBchronyc\fR is available
|
|
||||||
via the documentation supplied with the distribution (\fIchrony.txt\fR and
|
|
||||||
\fIchrony.texi\fR).
|
|
||||||
|
|
||||||
.SH OPTIONS
|
|
||||||
A summary of the options supported by \fBchronyc\fR is included below.
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-h\fR \fIhostname\fR
|
|
||||||
specify hostname
|
|
||||||
.TP
|
|
||||||
\fB\-p\fR \fIport-number\fR
|
|
||||||
specify port-number
|
|
||||||
.TP
|
|
||||||
\fB\-n\fR
|
|
||||||
display raw IP addresses (don't attempt to look up hostnames)
|
|
||||||
.TP
|
|
||||||
\fB\-4\fR
|
|
||||||
resolve hostnames only to IPv4 addresses
|
|
||||||
.TP
|
|
||||||
\fB\-6\fR
|
|
||||||
resolve hostnames only to IPv6 addresses
|
|
||||||
.TP
|
|
||||||
\fIcommand\fR
|
|
||||||
specify command. If no command is given, chronyc will read commands
|
|
||||||
interactively.
|
|
||||||
|
|
||||||
|
|
||||||
.SH VERSION
|
|
||||||
1.24
|
|
||||||
|
|
||||||
.SH BUGS
|
|
||||||
To report bugs, please visit \fIhttp://chrony.tuxfamily.org\fR
|
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR chronyd(8),
|
|
||||||
.BR chrony(1)
|
|
||||||
|
|
||||||
.I http://chrony.tuxfamily.org/
|
|
||||||
|
|
||||||
.SH AUTHOR
|
|
||||||
Richard Curnow <rc@rc0.org.uk>
|
|
||||||
|
|
||||||
This man-page was written by Jan Schaumann <jschauma@netmeister.org> as part of "The Missing
|
|
||||||
Man Pages Project". Please see \fIhttp://www.netmeister.org/misc/m2p2/index.html\fR
|
|
||||||
for details.
|
|
||||||
|
|
||||||
The complete chrony documentation is supplied in texinfo format.
|
|
||||||
|
|
||||||
133
chronyd.8
133
chronyd.8
@@ -1,133 +0,0 @@
|
|||||||
.TH CHRONYD 8 "December 04, 2009" chrony "System Administration"
|
|
||||||
.SH NAME
|
|
||||||
chronyd \- chrony background daemon
|
|
||||||
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B chronyd
|
|
||||||
[\fIOPTIONS\fR]
|
|
||||||
|
|
||||||
.SH DESCRIPTION
|
|
||||||
\fIchrony\fR is a pair of programs for maintaining the accuracy of computer
|
|
||||||
clocks. \fBchronyd\fR is a background daemon program that can be started at boot
|
|
||||||
time.
|
|
||||||
|
|
||||||
\fBchronyd\fR is a daemon which runs in background on the
|
|
||||||
system. It obtains measurements (e.g. via the network) of the
|
|
||||||
system's offset relative to other systems, and adjusts the system
|
|
||||||
time accordingly. For isolated systems, the user can periodically
|
|
||||||
enter the correct time by hand (using \fIchronyc\fR). In either case,
|
|
||||||
\fBchronyd\fR determines the rate at which the computer
|
|
||||||
gains or loses time, and compensates for this.
|
|
||||||
|
|
||||||
.SH USAGE
|
|
||||||
\fBchronyd\fR is usually started at boot-time and requires superuser
|
|
||||||
priviliges.
|
|
||||||
|
|
||||||
If \fBchronyd\fR has been installed to its default location
|
|
||||||
\fI/usr/local/sbin/chronyd\fR, starting it is simply a matter of entering the
|
|
||||||
command:
|
|
||||||
|
|
||||||
\fI/usr/local/sbin/chronyd\fR
|
|
||||||
|
|
||||||
Information messages and warnings will be logged to syslog.
|
|
||||||
|
|
||||||
|
|
||||||
.SH OPTIONS
|
|
||||||
A summary of the options supported by \fBchronyd\fR is included below.
|
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-P\fR \fIpriority\fR
|
|
||||||
This option will select the SCHED_FIFO real-time scheduler at the specified
|
|
||||||
priority (which must be between 0 and 100). This mode is supported only on
|
|
||||||
Linux.
|
|
||||||
.TP
|
|
||||||
.B \-m
|
|
||||||
This option will lock chronyd into RAM so that it will never be paged out.
|
|
||||||
This mode is only supported on Linux.
|
|
||||||
.TP
|
|
||||||
.B \-d
|
|
||||||
When run in this mode, the program will not detach itself from the
|
|
||||||
terminal, and all messages will be sent to the terminal instead of
|
|
||||||
to syslog.
|
|
||||||
.TP
|
|
||||||
\fB\-f\fR \fIconf-file\fR
|
|
||||||
This option can be used to specify an alternate location for the
|
|
||||||
configuration file (default \fI/etc/chrony.conf\fR).
|
|
||||||
.TP
|
|
||||||
.B \-r
|
|
||||||
This option will reload sample histories for each of the servers being used.
|
|
||||||
These histories are created by using the \fIdump\fR command in \fIchronyc\fR,
|
|
||||||
or by setting the \fIdumponexit\fR directive in the configuration file. This
|
|
||||||
option is useful if you want to stop and restart \fBchronyd\fR briefly for any
|
|
||||||
reason, e.g. to install a new version. However, it only makes sense on
|
|
||||||
systems where the kernel can maintain clock compensation whilst not under
|
|
||||||
\fBchronyd\fR's control. The only version where this happens so far is Linux.
|
|
||||||
On systems where this is not the case, e.g. Solaris and SunOS the option
|
|
||||||
should not be used.
|
|
||||||
.TP
|
|
||||||
.B \-s
|
|
||||||
This option will set the system clock from the computer's real-time
|
|
||||||
clock. This is analogous to supplying the \fI-s\fR flag to the
|
|
||||||
\fI/sbin/clock\fR program during the Linux boot sequence.
|
|
||||||
|
|
||||||
Support for real-time clocks is limited at present - the criteria
|
|
||||||
are described in the section on the \fIrtcfile\fR directive in the
|
|
||||||
documentation supplied with the distribution.
|
|
||||||
|
|
||||||
If \fBchronyd\fR cannot support the real time clock on your computer,
|
|
||||||
this option cannot be used and a warning message will be logged to
|
|
||||||
the syslog.
|
|
||||||
|
|
||||||
If used in conjunction with the \fB-r\fR flag, \fBchronyd\fR will attempt
|
|
||||||
to preserve the old samples after setting the system clock from
|
|
||||||
the real time clock. This can be used to allow \fBchronyd\fR to
|
|
||||||
perform long term averaging of the gain or loss rate across system
|
|
||||||
reboots, and is useful for dial-up systems that are shut down when
|
|
||||||
not in use. For this to work well, it relies on \fBchronyd\fR having
|
|
||||||
been able to determine accurate statistics for the difference
|
|
||||||
between the real time clock and system clock last time the
|
|
||||||
computer was on.
|
|
||||||
.TP
|
|
||||||
\fB\-u\fR \fIuser\fR
|
|
||||||
When this option is used, chronyd will drop root privileges to the specified
|
|
||||||
user. So far, it works only on Linux when compiled with capabilities support.
|
|
||||||
.TP
|
|
||||||
.B \-v
|
|
||||||
This option displays \fBchronyd\fR's version number to the terminal and exits
|
|
||||||
.TP
|
|
||||||
.B \-4
|
|
||||||
Resolve hostnames only to IPv4 addresses.
|
|
||||||
.TP
|
|
||||||
.B \-6
|
|
||||||
Resolve hostnames only to IPv6 addresses.
|
|
||||||
|
|
||||||
.SH FILES
|
|
||||||
\fI/etc/chrony.conf\fR
|
|
||||||
|
|
||||||
.SH VERSION
|
|
||||||
Version 1.24
|
|
||||||
|
|
||||||
.SH BUGS
|
|
||||||
To report bugs, please visit \fIhttp://chrony.tuxfamily.org/\fR
|
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
\fBchronyd\fR is documented in detail in the documentation supplied with the
|
|
||||||
distribution (\fIchrony.txt\fR and \fIchrony.texi\fR) and is also available
|
|
||||||
from \fIhttp://go.to/chrony\fR
|
|
||||||
|
|
||||||
.BR chrony(1),
|
|
||||||
.BR chronyc(1),
|
|
||||||
.BR chrony.conf(5),
|
|
||||||
.BR clock(8),
|
|
||||||
.BR xntpd(8),
|
|
||||||
.BR ntpd(8)
|
|
||||||
|
|
||||||
.SH AUTHOR
|
|
||||||
Richard Curnow <rc@rc0.org.uk>
|
|
||||||
|
|
||||||
This man-page was written by Jan Schaumann <jschauma@netmeister.org> as part
|
|
||||||
of "The Missing Man Pages Project". Please see
|
|
||||||
\fIhttp://www.netmeister.org/misc/m2p2/index.html\fR for details.
|
|
||||||
|
|
||||||
The complete chrony documentation is supplied in texinfo format.
|
|
||||||
|
|
||||||
991
clientlog.c
991
clientlog.c
File diff suppressed because it is too large
Load Diff
64
clientlog.h
64
clientlog.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/clientlog.h,v 1.9 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -35,55 +31,27 @@
|
|||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
#include "reports.h"
|
#include "reports.h"
|
||||||
|
|
||||||
/* Enough to hold flags for 256 hosts in a class C */
|
typedef enum {
|
||||||
typedef uint32_t CLG_Bitmap[8];
|
CLG_NTP = 0,
|
||||||
|
CLG_NTSKE,
|
||||||
|
CLG_CMDMON,
|
||||||
|
} CLG_Service;
|
||||||
|
|
||||||
extern void CLG_Initialise(void);
|
extern void CLG_Initialise(void);
|
||||||
extern void CLG_Finalise(void);
|
extern void CLG_Finalise(void);
|
||||||
extern void CLG_LogNTPClientAccess(IPAddr *client, time_t now);
|
extern int CLG_GetClientIndex(IPAddr *client);
|
||||||
extern void CLG_LogNTPPeerAccess(IPAddr *client, time_t now);
|
extern int CLG_LogServiceAccess(CLG_Service service, IPAddr *client, struct timespec *now);
|
||||||
|
extern int CLG_LimitServiceRate(CLG_Service service, int index);
|
||||||
/* When logging command packets, there are several subtypes */
|
extern void CLG_LogAuthNtpRequest(void);
|
||||||
|
extern void CLG_GetNtpTimestamps(int index, NTP_int64 **rx_ts, NTP_int64 **tx_ts);
|
||||||
typedef enum {
|
extern int CLG_GetNtpMinPoll(void);
|
||||||
CLG_CMD_AUTH, /* authenticated */
|
|
||||||
CLG_CMD_NORMAL, /* normal */
|
|
||||||
CLG_CMD_BAD_PKT /* bad version or packet length */
|
|
||||||
} CLG_Command_Type;
|
|
||||||
|
|
||||||
extern void CLG_LogCommandAccess(IPAddr *client, CLG_Command_Type type, time_t now);
|
|
||||||
|
|
||||||
/* And some reporting functions, for use by chronyc. */
|
/* And some reporting functions, for use by chronyc. */
|
||||||
/* TBD */
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
CLG_SUCCESS, /* All is well */
|
|
||||||
CLG_EMPTYSUBNET, /* No hosts logged in requested subnet */
|
|
||||||
CLG_BADSUBNET, /* Subnet requested is not 0, 8, 16 or 24 bits */
|
|
||||||
CLG_INACTIVE, /* Facility not active */
|
|
||||||
CLG_INDEXTOOLARGE /* Node index is higher than number of nodes present */
|
|
||||||
} CLG_Status;
|
|
||||||
|
|
||||||
/* For bits=0, 8, 16, flag which immediate subnets of that subnet are
|
|
||||||
known. For bits=24, flag which hosts in that subnet are known.
|
|
||||||
Other values, return 0 (failed) */
|
|
||||||
|
|
||||||
extern CLG_Status CLG_GetSubnetBitmap(IPAddr *subnet, int bits, CLG_Bitmap result);
|
|
||||||
|
|
||||||
extern CLG_Status
|
|
||||||
CLG_GetClientAccessReportByIP(IPAddr *ip, RPT_ClientAccess_Report *report, time_t now);
|
|
||||||
|
|
||||||
CLG_Status
|
|
||||||
CLG_GetClientAccessReportByIndex(int index, RPT_ClientAccessByIndex_Report *report,
|
|
||||||
time_t now, unsigned long *n_indices);
|
|
||||||
|
|
||||||
/* And an iterating function, to call 'fn' for each client or peer
|
|
||||||
that has accessed us since 'since'. */
|
|
||||||
|
|
||||||
extern void CLG_IterateNTPClients
|
|
||||||
(void (*fn)(IPAddr *client, void *arb),
|
|
||||||
void *arb,
|
|
||||||
time_t since);
|
|
||||||
|
|
||||||
|
extern int CLG_GetNumberOfIndices(void);
|
||||||
|
extern int CLG_GetClientAccessReportByIndex(int index, int reset, uint32_t min_hits,
|
||||||
|
RPT_ClientAccessByIndex_Report *report,
|
||||||
|
struct timespec *now);
|
||||||
|
extern void CLG_GetServerStatsReport(RPT_ServerStatsReport *report);
|
||||||
|
|
||||||
#endif /* GOT_CLIENTLOG_H */
|
#endif /* GOT_CLIENTLOG_H */
|
||||||
|
|||||||
48
cmac.h
Normal file
48
cmac.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2019
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Header file for CMAC.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GOT_CMAC_H
|
||||||
|
#define GOT_CMAC_H
|
||||||
|
|
||||||
|
/* Avoid overlapping with the hash enumeration */
|
||||||
|
typedef enum {
|
||||||
|
CMC_INVALID = 0,
|
||||||
|
CMC_AES128 = 13,
|
||||||
|
CMC_AES256 = 14,
|
||||||
|
} CMC_Algorithm;
|
||||||
|
|
||||||
|
typedef struct CMC_Instance_Record *CMC_Instance;
|
||||||
|
|
||||||
|
extern int CMC_GetKeyLength(CMC_Algorithm algorithm);
|
||||||
|
extern CMC_Instance CMC_CreateInstance(CMC_Algorithm algorithm, const unsigned char *key,
|
||||||
|
int length);
|
||||||
|
extern int CMC_Hash(CMC_Instance inst, const void *in, int in_len,
|
||||||
|
unsigned char *out, int out_len);
|
||||||
|
extern void CMC_DestroyInstance(CMC_Instance inst);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
117
cmac_nettle.c
Normal file
117
cmac_nettle.c
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2019
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Support for AES128 and AES256 CMAC in Nettle.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
|
#include <nettle/cmac.h>
|
||||||
|
|
||||||
|
#include "cmac.h"
|
||||||
|
#include "memory.h"
|
||||||
|
|
||||||
|
struct CMC_Instance_Record {
|
||||||
|
int key_length;
|
||||||
|
union {
|
||||||
|
struct cmac_aes128_ctx aes128;
|
||||||
|
struct cmac_aes256_ctx aes256;
|
||||||
|
} context;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
CMC_GetKeyLength(CMC_Algorithm algorithm)
|
||||||
|
{
|
||||||
|
if (algorithm == CMC_AES128)
|
||||||
|
return AES128_KEY_SIZE;
|
||||||
|
else if (algorithm == CMC_AES256)
|
||||||
|
return AES256_KEY_SIZE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
CMC_Instance
|
||||||
|
CMC_CreateInstance(CMC_Algorithm algorithm, const unsigned char *key, int length)
|
||||||
|
{
|
||||||
|
CMC_Instance inst;
|
||||||
|
|
||||||
|
if (length <= 0 || length != CMC_GetKeyLength(algorithm))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
inst = MallocNew(struct CMC_Instance_Record);
|
||||||
|
inst->key_length = length;
|
||||||
|
|
||||||
|
switch (length) {
|
||||||
|
case AES128_KEY_SIZE:
|
||||||
|
cmac_aes128_set_key(&inst->context.aes128, key);
|
||||||
|
break;
|
||||||
|
case AES256_KEY_SIZE:
|
||||||
|
cmac_aes256_set_key(&inst->context.aes256, key);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
CMC_Hash(CMC_Instance inst, const void *in, int in_len, unsigned char *out, int out_len)
|
||||||
|
{
|
||||||
|
if (in_len < 0 || out_len < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (out_len > CMAC128_DIGEST_SIZE)
|
||||||
|
out_len = CMAC128_DIGEST_SIZE;
|
||||||
|
|
||||||
|
switch (inst->key_length) {
|
||||||
|
case AES128_KEY_SIZE:
|
||||||
|
cmac_aes128_update(&inst->context.aes128, in_len, in);
|
||||||
|
cmac_aes128_digest(&inst->context.aes128, out_len, out);
|
||||||
|
break;
|
||||||
|
case AES256_KEY_SIZE:
|
||||||
|
cmac_aes256_update(&inst->context.aes256, in_len, in);
|
||||||
|
cmac_aes256_digest(&inst->context.aes256, out_len, out);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return out_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
CMC_DestroyInstance(CMC_Instance inst)
|
||||||
|
{
|
||||||
|
Free(inst);
|
||||||
|
}
|
||||||
5
cmdmon.h
5
cmdmon.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/cmdmon.h,v 1.8 2002/02/28 23:27:09 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -37,6 +33,7 @@ extern void CAM_Initialise(void);
|
|||||||
|
|
||||||
extern void CAM_Finalise(void);
|
extern void CAM_Finalise(void);
|
||||||
|
|
||||||
|
extern void CAM_OpenUnixSocket(void);
|
||||||
extern int CAM_AddAccessRestriction(IPAddr *ip_addr, int subnet_bits, int allow, int all);
|
extern int CAM_AddAccessRestriction(IPAddr *ip_addr, int subnet_bits, int allow, int all);
|
||||||
extern int CAM_CheckAccessRestriction(IPAddr *ip_addr);
|
extern int CAM_CheckAccessRestriction(IPAddr *ip_addr);
|
||||||
|
|
||||||
|
|||||||
373
cmdparse.c
373
cmdparse.c
@@ -1,12 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/cmdparse.c,v 1.12 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
|
* Copyright (C) Miroslav Lichvar 2013-2014, 2016
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -30,133 +27,277 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "cmdparse.h"
|
#include "cmdparse.h"
|
||||||
|
#include "memory.h"
|
||||||
#include "nameserv.h"
|
#include "nameserv.h"
|
||||||
|
#include "ntp.h"
|
||||||
#define MAXLEN 2047
|
#include "util.h"
|
||||||
#define SMAXLEN "2047"
|
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
CPS_Status
|
int
|
||||||
CPS_ParseNTPSourceAdd(const char *line, CPS_NTP_Source *src)
|
CPS_ParseNTPSourceAdd(char *line, CPS_NTP_Source *src)
|
||||||
{
|
{
|
||||||
int ok, n, done;
|
char *hostname, *cmd;
|
||||||
char cmd[MAXLEN+1], hostname[MAXLEN+1];
|
int n;
|
||||||
CPS_Status result;
|
|
||||||
|
|
||||||
src->port = 123;
|
src->port = SRC_DEFAULT_PORT;
|
||||||
src->params.minpoll = 6;
|
src->params.minpoll = SRC_DEFAULT_MINPOLL;
|
||||||
src->params.maxpoll = 10;
|
src->params.maxpoll = SRC_DEFAULT_MAXPOLL;
|
||||||
src->params.presend_minpoll = 0;
|
src->params.connectivity = SRC_ONLINE;
|
||||||
src->params.authkey = INACTIVE_AUTHKEY;
|
|
||||||
src->params.max_delay = 16.0;
|
|
||||||
src->params.max_delay_ratio = 16384.0;
|
|
||||||
src->params.online = 1;
|
|
||||||
src->params.auto_offline = 0;
|
src->params.auto_offline = 0;
|
||||||
|
src->params.presend_minpoll = SRC_DEFAULT_PRESEND_MINPOLL;
|
||||||
|
src->params.burst = 0;
|
||||||
|
src->params.iburst = 0;
|
||||||
|
src->params.min_stratum = SRC_DEFAULT_MINSTRATUM;
|
||||||
|
src->params.poll_target = SRC_DEFAULT_POLLTARGET;
|
||||||
|
src->params.version = 0;
|
||||||
|
src->params.max_sources = SRC_DEFAULT_MAXSOURCES;
|
||||||
|
src->params.min_samples = SRC_DEFAULT_MINSAMPLES;
|
||||||
|
src->params.max_samples = SRC_DEFAULT_MAXSAMPLES;
|
||||||
|
src->params.filter_length = 0;
|
||||||
|
src->params.interleaved = 0;
|
||||||
|
src->params.sel_options = 0;
|
||||||
|
src->params.nts = 0;
|
||||||
|
src->params.nts_port = SRC_DEFAULT_NTSPORT;
|
||||||
|
src->params.copy = 0;
|
||||||
|
src->params.authkey = INACTIVE_AUTHKEY;
|
||||||
|
src->params.cert_set = SRC_DEFAULT_CERTSET;
|
||||||
|
src->params.max_delay = SRC_DEFAULT_MAXDELAY;
|
||||||
|
src->params.max_delay_ratio = SRC_DEFAULT_MAXDELAYRATIO;
|
||||||
|
src->params.max_delay_dev_ratio = SRC_DEFAULT_MAXDELAYDEVRATIO;
|
||||||
|
src->params.min_delay = 0.0;
|
||||||
|
src->params.asymmetry = SRC_DEFAULT_ASYMMETRY;
|
||||||
|
src->params.offset = 0.0;
|
||||||
|
|
||||||
result = CPS_Success;
|
hostname = line;
|
||||||
|
line = CPS_SplitWord(line);
|
||||||
ok = 0;
|
|
||||||
if (sscanf(line, "%" SMAXLEN "s%n", hostname, &n) == 1) {
|
if (!*hostname)
|
||||||
if (DNS_Name2IPAddress(hostname, &src->ip_addr, 1)) {
|
return 0;
|
||||||
ok = 1;
|
|
||||||
|
src->name = hostname;
|
||||||
|
|
||||||
|
/* Parse options */
|
||||||
|
for (; *line; line += n) {
|
||||||
|
cmd = line;
|
||||||
|
line = CPS_SplitWord(line);
|
||||||
|
n = 0;
|
||||||
|
|
||||||
|
if (!strcasecmp(cmd, "auto_offline")) {
|
||||||
|
src->params.auto_offline = 1;
|
||||||
|
} else if (!strcasecmp(cmd, "burst")) {
|
||||||
|
src->params.burst = 1;
|
||||||
|
} else if (!strcasecmp(cmd, "copy")) {
|
||||||
|
src->params.copy = 1;
|
||||||
|
} else if (!strcasecmp(cmd, "iburst")) {
|
||||||
|
src->params.iburst = 1;
|
||||||
|
} else if (!strcasecmp(cmd, "offline")) {
|
||||||
|
src->params.connectivity = SRC_OFFLINE;
|
||||||
|
} else if (!strcasecmp(cmd, "noselect")) {
|
||||||
|
src->params.sel_options |= SRC_SELECT_NOSELECT;
|
||||||
|
} else if (!strcasecmp(cmd, "prefer")) {
|
||||||
|
src->params.sel_options |= SRC_SELECT_PREFER;
|
||||||
|
} else if (!strcasecmp(cmd, "require")) {
|
||||||
|
src->params.sel_options |= SRC_SELECT_REQUIRE;
|
||||||
|
} else if (!strcasecmp(cmd, "trust")) {
|
||||||
|
src->params.sel_options |= SRC_SELECT_TRUST;
|
||||||
|
} else if (!strcasecmp(cmd, "certset")) {
|
||||||
|
if (sscanf(line, "%"SCNu32"%n", &src->params.cert_set, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "key")) {
|
||||||
|
if (sscanf(line, "%"SCNu32"%n", &src->params.authkey, &n) != 1 ||
|
||||||
|
src->params.authkey == INACTIVE_AUTHKEY)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "asymmetry")) {
|
||||||
|
if (sscanf(line, "%lf%n", &src->params.asymmetry, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "filter")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.filter_length, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "maxdelay")) {
|
||||||
|
if (sscanf(line, "%lf%n", &src->params.max_delay, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "maxdelayratio")) {
|
||||||
|
if (sscanf(line, "%lf%n", &src->params.max_delay_ratio, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "maxdelaydevratio")) {
|
||||||
|
if (sscanf(line, "%lf%n", &src->params.max_delay_dev_ratio, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "maxpoll")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.maxpoll, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "maxsamples")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.max_samples, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "maxsources")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.max_sources, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "mindelay")) {
|
||||||
|
if (sscanf(line, "%lf%n", &src->params.min_delay, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "minpoll")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.minpoll, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "minsamples")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.min_samples, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "minstratum")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.min_stratum, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "nts")) {
|
||||||
|
src->params.nts = 1;
|
||||||
|
} else if (!strcasecmp(cmd, "ntsport")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.nts_port, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "offset")) {
|
||||||
|
if (sscanf(line, "%lf%n", &src->params.offset, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "port")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->port, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "polltarget")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.poll_target, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "presend")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.presend_minpoll, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "version")) {
|
||||||
|
if (sscanf(line, "%d%n", &src->params.version, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "xleave")) {
|
||||||
|
src->params.interleaved = 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ok) {
|
return 1;
|
||||||
result = CPS_BadHost;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
line += n;
|
|
||||||
|
|
||||||
/* Parse subfields */
|
|
||||||
ok = 1;
|
|
||||||
done = 0;
|
|
||||||
do {
|
|
||||||
if (sscanf(line, "%" SMAXLEN "s%n", cmd, &n) == 1) {
|
|
||||||
|
|
||||||
line += n;
|
|
||||||
|
|
||||||
if (!strncasecmp(cmd, "port", 4)) {
|
|
||||||
if (sscanf(line, "%hu%n", &src->port, &n) != 1) {
|
|
||||||
result = CPS_BadPort;
|
|
||||||
ok = 0;
|
|
||||||
done = 1;
|
|
||||||
} else {
|
|
||||||
line += n;
|
|
||||||
}
|
|
||||||
} else if (!strncasecmp(cmd, "minpoll", 7)) {
|
|
||||||
if (sscanf(line, "%d%n", &src->params.minpoll, &n) != 1) {
|
|
||||||
result = CPS_BadMinpoll;
|
|
||||||
ok = 0;
|
|
||||||
done = 1;
|
|
||||||
} else {
|
|
||||||
line += n;
|
|
||||||
}
|
|
||||||
} else if (!strncasecmp(cmd, "maxpoll", 7)) {
|
|
||||||
if (sscanf(line, "%d%n", &src->params.maxpoll, &n) != 1) {
|
|
||||||
result = CPS_BadMaxpoll;
|
|
||||||
ok = 0;
|
|
||||||
done = 1;
|
|
||||||
} else {
|
|
||||||
line += n;
|
|
||||||
}
|
|
||||||
} else if (!strncasecmp(cmd, "presend", 7)) {
|
|
||||||
if (sscanf(line, "%d%n", &src->params.presend_minpoll, &n) != 1) {
|
|
||||||
result = CPS_BadPresend;
|
|
||||||
ok = 0;
|
|
||||||
done = 1;
|
|
||||||
} else {
|
|
||||||
line += n;
|
|
||||||
}
|
|
||||||
/* This MUST come before the following one ! */
|
|
||||||
} else if (!strncasecmp(cmd, "maxdelayratio", 13)) {
|
|
||||||
if (sscanf(line, "%lf%n", &src->params.max_delay_ratio, &n) != 1) {
|
|
||||||
result = CPS_BadMaxdelayratio;
|
|
||||||
ok = 0;
|
|
||||||
done = 1;
|
|
||||||
} else {
|
|
||||||
line += n;
|
|
||||||
}
|
|
||||||
} else if (!strncasecmp(cmd, "maxdelay", 8)) {
|
|
||||||
if (sscanf(line, "%lf%n", &src->params.max_delay, &n) != 1) {
|
|
||||||
result = CPS_BadMaxdelay;
|
|
||||||
ok = 0;
|
|
||||||
done = 1;
|
|
||||||
} else {
|
|
||||||
line += n;
|
|
||||||
}
|
|
||||||
} else if (!strncasecmp(cmd, "key", 3)) {
|
|
||||||
if (sscanf(line, "%lu%n", &src->params.authkey, &n) != 1) {
|
|
||||||
result = CPS_BadKey;
|
|
||||||
ok = 0;
|
|
||||||
done = 1;
|
|
||||||
} else {
|
|
||||||
line += n;
|
|
||||||
}
|
|
||||||
} else if (!strncasecmp(cmd, "offline", 7)) {
|
|
||||||
src->params.online = 0;
|
|
||||||
|
|
||||||
} else if (!strncasecmp(cmd, "auto_offline", 12)) {
|
|
||||||
src->params.auto_offline = 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
result = CPS_BadOption;
|
|
||||||
ok = 0;
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
} while (!done);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
CPS_ParseLocal(char *line, int *stratum, int *orphan, double *distance)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
char *cmd;
|
||||||
|
|
||||||
|
*stratum = 10;
|
||||||
|
*distance = 1.0;
|
||||||
|
*orphan = 0;
|
||||||
|
|
||||||
|
while (*line) {
|
||||||
|
cmd = line;
|
||||||
|
line = CPS_SplitWord(line);
|
||||||
|
|
||||||
|
if (!strcasecmp(cmd, "stratum")) {
|
||||||
|
if (sscanf(line, "%d%n", stratum, &n) != 1 ||
|
||||||
|
*stratum >= NTP_MAX_STRATUM || *stratum <= 0)
|
||||||
|
return 0;
|
||||||
|
} else if (!strcasecmp(cmd, "orphan")) {
|
||||||
|
*orphan = 1;
|
||||||
|
n = 0;
|
||||||
|
} else if (!strcasecmp(cmd, "distance")) {
|
||||||
|
if (sscanf(line, "%lf%n", distance, &n) != 1)
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
line += n;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
CPS_NormalizeLine(char *line)
|
||||||
|
{
|
||||||
|
char *p, *q;
|
||||||
|
int space = 1, first = 1;
|
||||||
|
|
||||||
|
/* Remove white-space at beginning and replace white-spaces with space char */
|
||||||
|
for (p = q = line; *p; p++) {
|
||||||
|
if (isspace((unsigned char)*p)) {
|
||||||
|
if (!space)
|
||||||
|
*q++ = ' ';
|
||||||
|
space = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Discard comment lines */
|
||||||
|
if (first && strchr("!;#%", *p))
|
||||||
|
break;
|
||||||
|
|
||||||
|
*q++ = *p;
|
||||||
|
space = first = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Strip trailing space */
|
||||||
|
if (q > line && q[-1] == ' ')
|
||||||
|
q--;
|
||||||
|
|
||||||
|
*q = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
char *
|
||||||
|
CPS_SplitWord(char *line)
|
||||||
|
{
|
||||||
|
char *p = line, *q = line;
|
||||||
|
|
||||||
|
/* Skip white-space before the word */
|
||||||
|
while (*q && isspace((unsigned char)*q))
|
||||||
|
q++;
|
||||||
|
|
||||||
|
/* Move the word to the beginning */
|
||||||
|
while (*q && !isspace((unsigned char)*q))
|
||||||
|
*p++ = *q++;
|
||||||
|
|
||||||
|
/* Find the next word */
|
||||||
|
while (*q && isspace((unsigned char)*q))
|
||||||
|
q++;
|
||||||
|
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
|
/* Return pointer to the next word or NUL */
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
CPS_ParseKey(char *line, uint32_t *id, const char **type, char **key)
|
||||||
|
{
|
||||||
|
char *s1, *s2, *s3, *s4;
|
||||||
|
|
||||||
|
s1 = line;
|
||||||
|
s2 = CPS_SplitWord(s1);
|
||||||
|
s3 = CPS_SplitWord(s2);
|
||||||
|
s4 = CPS_SplitWord(s3);
|
||||||
|
|
||||||
|
/* Require two or three words */
|
||||||
|
if (!*s2 || *s4)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (sscanf(s1, "%"SCNu32, id) != 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (*s3) {
|
||||||
|
*type = s2;
|
||||||
|
*key = s3;
|
||||||
|
} else {
|
||||||
|
*type = "MD5";
|
||||||
|
*key = s2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|||||||
33
cmdparse.h
33
cmdparse.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/cmdparse.h,v 1.7 2002/02/28 23:27:09 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -34,28 +30,25 @@
|
|||||||
#include "srcparams.h"
|
#include "srcparams.h"
|
||||||
#include "addressing.h"
|
#include "addressing.h"
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
CPS_Success,
|
|
||||||
CPS_BadOption,
|
|
||||||
CPS_BadHost,
|
|
||||||
CPS_BadPort,
|
|
||||||
CPS_BadMinpoll,
|
|
||||||
CPS_BadMaxpoll,
|
|
||||||
CPS_BadPresend,
|
|
||||||
CPS_BadMaxdelayratio,
|
|
||||||
CPS_BadMaxdelay,
|
|
||||||
CPS_BadKey
|
|
||||||
} CPS_Status;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
IPAddr ip_addr;
|
char *name;
|
||||||
unsigned short port;
|
int port;
|
||||||
SourceParameters params;
|
SourceParameters params;
|
||||||
} CPS_NTP_Source;
|
} CPS_NTP_Source;
|
||||||
|
|
||||||
/* Parse a command to add an NTP server or peer */
|
/* Parse a command to add an NTP server or peer */
|
||||||
extern CPS_Status CPS_ParseNTPSourceAdd(const char *line, CPS_NTP_Source *src);
|
extern int CPS_ParseNTPSourceAdd(char *line, CPS_NTP_Source *src);
|
||||||
|
|
||||||
|
/* Parse a command to enable local reference */
|
||||||
|
extern int CPS_ParseLocal(char *line, int *stratum, int *orphan, double *distance);
|
||||||
|
|
||||||
|
/* Remove extra white-space and comments */
|
||||||
|
extern void CPS_NormalizeLine(char *line);
|
||||||
|
|
||||||
|
/* Terminate first word and return pointer to the next word */
|
||||||
|
extern char *CPS_SplitWord(char *line);
|
||||||
|
|
||||||
|
/* Parse a key from keyfile */
|
||||||
|
extern int CPS_ParseKey(char *line, uint32_t *id, const char **type, char **key);
|
||||||
|
|
||||||
#endif /* GOT_CMDPARSE_H */
|
#endif /* GOT_CMDPARSE_H */
|
||||||
|
|||||||
114
conf.h
114
conf.h
@@ -1,12 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/conf.h,v 1.25 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
|
* Copyright (C) Miroslav Lichvar 2013-2014
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -32,51 +29,138 @@
|
|||||||
#define GOT_CONF_H
|
#define GOT_CONF_H
|
||||||
|
|
||||||
#include "addressing.h"
|
#include "addressing.h"
|
||||||
|
#include "reference.h"
|
||||||
|
#include "sources.h"
|
||||||
|
|
||||||
|
extern void CNF_Initialise(int restarted, int client_only);
|
||||||
|
extern void CNF_Finalise(void);
|
||||||
|
|
||||||
|
extern void CNF_EnablePrint(void);
|
||||||
|
|
||||||
extern char *CNF_GetRtcDevice(void);
|
extern char *CNF_GetRtcDevice(void);
|
||||||
|
|
||||||
extern void CNF_ReadFile(const char *filename);
|
extern void CNF_ReadFile(const char *filename);
|
||||||
|
extern void CNF_ParseLine(const char *filename, int number, char *line);
|
||||||
|
|
||||||
|
extern void CNF_CreateDirs(uid_t uid, gid_t gid);
|
||||||
|
|
||||||
|
extern void CNF_AddInitSources(void);
|
||||||
extern void CNF_AddSources(void);
|
extern void CNF_AddSources(void);
|
||||||
extern void CNF_AddBroadcasts(void);
|
extern void CNF_AddBroadcasts(void);
|
||||||
extern void CNF_AddRefclocks(void);
|
extern void CNF_AddRefclocks(void);
|
||||||
|
|
||||||
extern void CNF_ProcessInitStepSlew(void (*after_hook)(void *), void *anything);
|
extern void CNF_ReloadSources(void);
|
||||||
|
|
||||||
extern unsigned short CNF_GetAcquisitionPort(void);
|
extern int CNF_GetAcquisitionPort(void);
|
||||||
extern unsigned short CNF_GetNTPPort(void);
|
extern int CNF_GetNTPPort(void);
|
||||||
extern char *CNF_GetDriftFile(void);
|
extern char *CNF_GetDriftFile(void);
|
||||||
extern char *CNF_GetLogDir(void);
|
extern char *CNF_GetLogDir(void);
|
||||||
extern char *CNF_GetDumpDir(void);
|
extern char *CNF_GetDumpDir(void);
|
||||||
extern int CNF_GetLogMeasurements(void);
|
extern int CNF_GetLogBanner(void);
|
||||||
|
extern int CNF_GetLogMeasurements(int *raw);
|
||||||
extern int CNF_GetLogStatistics(void);
|
extern int CNF_GetLogStatistics(void);
|
||||||
extern int CNF_GetLogTracking(void);
|
extern int CNF_GetLogTracking(void);
|
||||||
extern int CNF_GetLogRtc(void);
|
extern int CNF_GetLogRtc(void);
|
||||||
extern int CNF_GetLogRefclocks(void);
|
extern int CNF_GetLogRefclocks(void);
|
||||||
|
extern int CNF_GetLogTempComp(void);
|
||||||
extern char *CNF_GetKeysFile(void);
|
extern char *CNF_GetKeysFile(void);
|
||||||
extern char *CNF_GetRtcFile(void);
|
extern char *CNF_GetRtcFile(void);
|
||||||
extern unsigned long CNF_GetCommandKey(void);
|
|
||||||
extern int CNF_GetDumpOnExit(void);
|
|
||||||
extern int CNF_GetManualEnabled(void);
|
extern int CNF_GetManualEnabled(void);
|
||||||
extern int CNF_GetCommandPort(void);
|
extern int CNF_GetCommandPort(void);
|
||||||
extern int CNF_GetRTCOnUTC(void);
|
extern int CNF_GetRtcOnUtc(void);
|
||||||
extern void CNF_GetLogChange(int *enabled, double *threshold);
|
extern int CNF_GetRtcSync(void);
|
||||||
|
extern void CNF_GetMakeStep(int *limit, double *threshold);
|
||||||
|
extern void CNF_GetMaxChange(int *delay, int *ignore, double *offset);
|
||||||
|
extern double CNF_GetLogChange(void);
|
||||||
extern void CNF_GetMailOnChange(int *enabled, double *threshold, char **user);
|
extern void CNF_GetMailOnChange(int *enabled, double *threshold, char **user);
|
||||||
extern int CNF_GetNoClientLog(void);
|
extern int CNF_GetNoClientLog(void);
|
||||||
extern unsigned long CNF_GetClientLogLimit(void);
|
extern unsigned long CNF_GetClientLogLimit(void);
|
||||||
|
extern void CNF_GetFallbackDrifts(int *min, int *max);
|
||||||
extern void CNF_GetBindAddress(int family, IPAddr *addr);
|
extern void CNF_GetBindAddress(int family, IPAddr *addr);
|
||||||
|
extern void CNF_GetBindAcquisitionAddress(int family, IPAddr *addr);
|
||||||
extern void CNF_GetBindCommandAddress(int family, IPAddr *addr);
|
extern void CNF_GetBindCommandAddress(int family, IPAddr *addr);
|
||||||
|
extern char *CNF_GetBindNtpInterface(void);
|
||||||
|
extern char *CNF_GetBindAcquisitionInterface(void);
|
||||||
|
extern char *CNF_GetBindCommandInterface(void);
|
||||||
|
extern char *CNF_GetBindCommandPath(void);
|
||||||
|
extern int CNF_GetNtpDscp(void);
|
||||||
|
extern char *CNF_GetNtpSigndSocket(void);
|
||||||
extern char *CNF_GetPidFile(void);
|
extern char *CNF_GetPidFile(void);
|
||||||
extern void CNF_GetLinuxHz(int *set, int *hz);
|
extern REF_LeapMode CNF_GetLeapSecMode(void);
|
||||||
extern void CNF_GetLinuxFreqScale(int *set, double *freq_scale);
|
extern char *CNF_GetLeapSecTimezone(void);
|
||||||
|
|
||||||
/* Value returned in ppm, as read from file */
|
/* Value returned in ppm, as read from file */
|
||||||
extern double CNF_GetMaxUpdateSkew(void);
|
extern double CNF_GetMaxUpdateSkew(void);
|
||||||
extern int CNF_AllowLocalReference(int *stratum);
|
extern double CNF_GetMaxClockError(void);
|
||||||
|
extern double CNF_GetMaxDrift(void);
|
||||||
|
extern double CNF_GetCorrectionTimeRatio(void);
|
||||||
|
extern double CNF_GetMaxSlewRate(void);
|
||||||
|
extern double CNF_GetClockPrecision(void);
|
||||||
|
|
||||||
|
extern SRC_AuthSelectMode CNF_GetAuthSelectMode(void);
|
||||||
|
extern double CNF_GetMaxDistance(void);
|
||||||
|
extern double CNF_GetMaxJitter(void);
|
||||||
|
extern double CNF_GetReselectDistance(void);
|
||||||
|
extern double CNF_GetStratumWeight(void);
|
||||||
|
extern double CNF_GetCombineLimit(void);
|
||||||
|
|
||||||
|
extern int CNF_AllowLocalReference(int *stratum, int *orphan, double *distance);
|
||||||
|
|
||||||
extern void CNF_SetupAccessRestrictions(void);
|
extern void CNF_SetupAccessRestrictions(void);
|
||||||
|
|
||||||
extern int CNF_GetSchedPriority(void);
|
extern int CNF_GetSchedPriority(void);
|
||||||
extern int CNF_GetLockMemory(void);
|
extern int CNF_GetLockMemory(void);
|
||||||
|
|
||||||
|
extern int CNF_GetNTPRateLimit(int *interval, int *burst, int *leak);
|
||||||
|
extern int CNF_GetNtsRateLimit(int *interval, int *burst, int *leak);
|
||||||
|
extern int CNF_GetCommandRateLimit(int *interval, int *burst, int *leak);
|
||||||
|
extern void CNF_GetSmooth(double *max_freq, double *max_wander, int *leap_only);
|
||||||
|
extern void CNF_GetTempComp(char **file, double *interval, char **point_file, double *T0, double *k0, double *k1, double *k2);
|
||||||
|
|
||||||
|
extern char *CNF_GetUser(void);
|
||||||
|
|
||||||
|
extern int CNF_GetMaxSamples(void);
|
||||||
|
extern int CNF_GetMinSamples(void);
|
||||||
|
|
||||||
|
extern int CNF_GetMinSources(void);
|
||||||
|
|
||||||
|
extern double CNF_GetRtcAutotrim(void);
|
||||||
|
extern char *CNF_GetHwclockFile(void);
|
||||||
|
|
||||||
|
extern int CNF_GetInitSources(void);
|
||||||
|
extern double CNF_GetInitStepThreshold(void);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CNF_HWTS_RXFILTER_ANY,
|
||||||
|
CNF_HWTS_RXFILTER_NONE,
|
||||||
|
CNF_HWTS_RXFILTER_NTP,
|
||||||
|
CNF_HWTS_RXFILTER_ALL,
|
||||||
|
} CNF_HwTs_RxFilter;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *name;
|
||||||
|
int minpoll;
|
||||||
|
int min_samples;
|
||||||
|
int max_samples;
|
||||||
|
int nocrossts;
|
||||||
|
CNF_HwTs_RxFilter rxfilter;
|
||||||
|
double precision;
|
||||||
|
double tx_comp;
|
||||||
|
double rx_comp;
|
||||||
|
} CNF_HwTsInterface;
|
||||||
|
|
||||||
|
extern int CNF_GetHwTsInterface(unsigned int index, CNF_HwTsInterface **iface);
|
||||||
|
|
||||||
|
extern char *CNF_GetNtsDumpDir(void);
|
||||||
|
extern char *CNF_GetNtsNtpServer(void);
|
||||||
|
extern int CNF_GetNtsServerCertAndKeyFiles(const char ***certs, const char ***keys);
|
||||||
|
extern int CNF_GetNtsServerPort(void);
|
||||||
|
extern int CNF_GetNtsServerProcesses(void);
|
||||||
|
extern int CNF_GetNtsServerConnections(void);
|
||||||
|
extern int CNF_GetNtsRefresh(void);
|
||||||
|
extern int CNF_GetNtsRotate(void);
|
||||||
|
extern int CNF_GetNtsTrustedCertsPaths(const char ***paths, uint32_t **ids);
|
||||||
|
extern int CNF_GetNoSystemCert(void);
|
||||||
|
extern int CNF_GetNoCertTimeCheck(void);
|
||||||
|
|
||||||
#endif /* GOT_CONF_H */
|
#endif /* GOT_CONF_H */
|
||||||
|
|||||||
@@ -1,339 +0,0 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 2, June 1991
|
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
License is intended to guarantee your freedom to share and change free
|
|
||||||
software--to make sure the software is free for all its users. This
|
|
||||||
General Public License applies to most of the Free Software
|
|
||||||
Foundation's software and to any other program whose authors commit to
|
|
||||||
using it. (Some other Free Software Foundation software is covered by
|
|
||||||
the GNU Lesser General Public License instead.) You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
this service if you wish), that you receive source code or can get it
|
|
||||||
if you want it, that you can change the software or use pieces of it
|
|
||||||
in new free programs; and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
anyone to deny you these rights or to ask you to surrender the rights.
|
|
||||||
These restrictions translate to certain responsibilities for you if you
|
|
||||||
distribute copies of the software, or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must give the recipients all the rights that
|
|
||||||
you have. You must make sure that they, too, receive or can get the
|
|
||||||
source code. And you must show them these terms so they know their
|
|
||||||
rights.
|
|
||||||
|
|
||||||
We protect your rights with two steps: (1) copyright the software, and
|
|
||||||
(2) offer you this license which gives you legal permission to copy,
|
|
||||||
distribute and/or modify the software.
|
|
||||||
|
|
||||||
Also, for each author's protection and ours, we want to make certain
|
|
||||||
that everyone understands that there is no warranty for this free
|
|
||||||
software. If the software is modified by someone else and passed on, we
|
|
||||||
want its recipients to know that what they have is not the original, so
|
|
||||||
that any problems introduced by others will not reflect on the original
|
|
||||||
authors' reputations.
|
|
||||||
|
|
||||||
Finally, any free program is threatened constantly by software
|
|
||||||
patents. We wish to avoid the danger that redistributors of a free
|
|
||||||
program will individually obtain patent licenses, in effect making the
|
|
||||||
program proprietary. To prevent this, we have made it clear that any
|
|
||||||
patent must be licensed for everyone's free use or not licensed at all.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License applies to any program or other work which contains
|
|
||||||
a notice placed by the copyright holder saying it may be distributed
|
|
||||||
under the terms of this General Public License. The "Program", below,
|
|
||||||
refers to any such program or work, and a "work based on the Program"
|
|
||||||
means either the Program or any derivative work under copyright law:
|
|
||||||
that is to say, a work containing the Program or a portion of it,
|
|
||||||
either verbatim or with modifications and/or translated into another
|
|
||||||
language. (Hereinafter, translation is included without limitation in
|
|
||||||
the term "modification".) Each licensee is addressed as "you".
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running the Program is not restricted, and the output from the Program
|
|
||||||
is covered only if its contents constitute a work based on the
|
|
||||||
Program (independent of having been made by running the Program).
|
|
||||||
Whether that is true depends on what the Program does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Program's
|
|
||||||
source code as you receive it, in any medium, provided that you
|
|
||||||
conspicuously and appropriately publish on each copy an appropriate
|
|
||||||
copyright notice and disclaimer of warranty; keep intact all the
|
|
||||||
notices that refer to this License and to the absence of any warranty;
|
|
||||||
and give any other recipients of the Program a copy of this License
|
|
||||||
along with the Program.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy, and
|
|
||||||
you may at your option offer warranty protection in exchange for a fee.
|
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Program or any portion
|
|
||||||
of it, thus forming a work based on the Program, and copy and
|
|
||||||
distribute such modifications or work under the terms of Section 1
|
|
||||||
above, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) You must cause the modified files to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
b) You must cause any work that you distribute or publish, that in
|
|
||||||
whole or in part contains or is derived from the Program or any
|
|
||||||
part thereof, to be licensed as a whole at no charge to all third
|
|
||||||
parties under the terms of this License.
|
|
||||||
|
|
||||||
c) If the modified program normally reads commands interactively
|
|
||||||
when run, you must cause it, when started running for such
|
|
||||||
interactive use in the most ordinary way, to print or display an
|
|
||||||
announcement including an appropriate copyright notice and a
|
|
||||||
notice that there is no warranty (or else, saying that you provide
|
|
||||||
a warranty) and that users may redistribute the program under
|
|
||||||
these conditions, and telling the user how to view a copy of this
|
|
||||||
License. (Exception: if the Program itself is interactive but
|
|
||||||
does not normally print such an announcement, your work based on
|
|
||||||
the Program is not required to print an announcement.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Program,
|
|
||||||
and can be reasonably considered independent and separate works in
|
|
||||||
themselves, then this License, and its terms, do not apply to those
|
|
||||||
sections when you distribute them as separate works. But when you
|
|
||||||
distribute the same sections as part of a whole which is a work based
|
|
||||||
on the Program, the distribution of the whole must be on the terms of
|
|
||||||
this License, whose permissions for other licensees extend to the
|
|
||||||
entire whole, and thus to each and every part regardless of who wrote it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Program.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Program
|
|
||||||
with the Program (or with a work based on the Program) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may copy and distribute the Program (or a work based on it,
|
|
||||||
under Section 2) in object code or executable form under the terms of
|
|
||||||
Sections 1 and 2 above provided that you also do one of the following:
|
|
||||||
|
|
||||||
a) Accompany it with the complete corresponding machine-readable
|
|
||||||
source code, which must be distributed under the terms of Sections
|
|
||||||
1 and 2 above on a medium customarily used for software interchange; or,
|
|
||||||
|
|
||||||
b) Accompany it with a written offer, valid for at least three
|
|
||||||
years, to give any third party, for a charge no more than your
|
|
||||||
cost of physically performing source distribution, a complete
|
|
||||||
machine-readable copy of the corresponding source code, to be
|
|
||||||
distributed under the terms of Sections 1 and 2 above on a medium
|
|
||||||
customarily used for software interchange; or,
|
|
||||||
|
|
||||||
c) Accompany it with the information you received as to the offer
|
|
||||||
to distribute corresponding source code. (This alternative is
|
|
||||||
allowed only for noncommercial distribution and only if you
|
|
||||||
received the program in object code or executable form with such
|
|
||||||
an offer, in accord with Subsection b above.)
|
|
||||||
|
|
||||||
The source code for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For an executable work, complete source
|
|
||||||
code means all the source code for all modules it contains, plus any
|
|
||||||
associated interface definition files, plus the scripts used to
|
|
||||||
control compilation and installation of the executable. However, as a
|
|
||||||
special exception, the source code distributed need not include
|
|
||||||
anything that is normally distributed (in either source or binary
|
|
||||||
form) with the major components (compiler, kernel, and so on) of the
|
|
||||||
operating system on which the executable runs, unless that component
|
|
||||||
itself accompanies the executable.
|
|
||||||
|
|
||||||
If distribution of executable or object code is made by offering
|
|
||||||
access to copy from a designated place, then offering equivalent
|
|
||||||
access to copy the source code from the same place counts as
|
|
||||||
distribution of the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
4. You may not copy, modify, sublicense, or distribute the Program
|
|
||||||
except as expressly provided under this License. Any attempt
|
|
||||||
otherwise to copy, modify, sublicense or distribute the Program is
|
|
||||||
void, and will automatically terminate your rights under this License.
|
|
||||||
However, parties who have received copies, or rights, from you under
|
|
||||||
this License will not have their licenses terminated so long as such
|
|
||||||
parties remain in full compliance.
|
|
||||||
|
|
||||||
5. You are not required to accept this License, since you have not
|
|
||||||
signed it. However, nothing else grants you permission to modify or
|
|
||||||
distribute the Program or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Program (or any work based on the
|
|
||||||
Program), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Program or works based on it.
|
|
||||||
|
|
||||||
6. Each time you redistribute the Program (or any work based on the
|
|
||||||
Program), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute or modify the Program subject to
|
|
||||||
these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
|
||||||
You are not responsible for enforcing compliance by third parties to
|
|
||||||
this License.
|
|
||||||
|
|
||||||
7. If, as a consequence of a court judgment or allegation of patent
|
|
||||||
infringement or for any other reason (not limited to patent issues),
|
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot
|
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you
|
|
||||||
may not distribute the Program at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Program by
|
|
||||||
all those who receive copies directly or indirectly through you, then
|
|
||||||
the only way you could satisfy both it and this License would be to
|
|
||||||
refrain entirely from distribution of the Program.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under
|
|
||||||
any particular circumstance, the balance of the section is intended to
|
|
||||||
apply and the section as a whole is intended to apply in other
|
|
||||||
circumstances.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
|
||||||
patents or other property right claims or to contest validity of any
|
|
||||||
such claims; this section has the sole purpose of protecting the
|
|
||||||
integrity of the free software distribution system, which is
|
|
||||||
implemented by public license practices. Many people have made
|
|
||||||
generous contributions to the wide range of software distributed
|
|
||||||
through that system in reliance on consistent application of that
|
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
|
||||||
to distribute software through any other system and a licensee cannot
|
|
||||||
impose that choice.
|
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
|
||||||
be a consequence of the rest of this License.
|
|
||||||
|
|
||||||
8. If the distribution and/or use of the Program is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Program under this License
|
|
||||||
may add an explicit geographical distribution limitation excluding
|
|
||||||
those countries, so that distribution is permitted only in or among
|
|
||||||
countries not thus excluded. In such case, this License incorporates
|
|
||||||
the limitation as if written in the body of this License.
|
|
||||||
|
|
||||||
9. The Free Software Foundation may publish revised and/or new versions
|
|
||||||
of the General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program
|
|
||||||
specifies a version number of this License which applies to it and "any
|
|
||||||
later version", you have the option of following the terms and conditions
|
|
||||||
either of that version or of any later version published by the Free
|
|
||||||
Software Foundation. If the Program does not specify a version number of
|
|
||||||
this License, you may choose any version ever published by the Free Software
|
|
||||||
Foundation.
|
|
||||||
|
|
||||||
10. If you wish to incorporate parts of the Program into other free
|
|
||||||
programs whose distribution conditions are different, write to the author
|
|
||||||
to ask for permission. For software which is copyrighted by the Free
|
|
||||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
|
||||||
make exceptions for this. Our decision will be guided by the two goals
|
|
||||||
of preserving the free status of all derivatives of our free software and
|
|
||||||
of promoting the sharing and reuse of software generally.
|
|
||||||
|
|
||||||
NO WARRANTY
|
|
||||||
|
|
||||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
|
||||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
|
||||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
|
||||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
|
||||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
|
||||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
|
||||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
|
||||||
REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
|
||||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
|
||||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
|
||||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
|
||||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
|
||||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
||||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
convey the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program is interactive, make it output a short notice like this
|
|
||||||
when it starts in an interactive mode:
|
|
||||||
|
|
||||||
Gnomovision version 69, Copyright (C) year name of author
|
|
||||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, the commands you use may
|
|
||||||
be called something other than `show w' and `show c'; they could even be
|
|
||||||
mouse-clicks or menu items--whatever suits your program.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or your
|
|
||||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
|
||||||
necessary. Here is a sample; alter the names:
|
|
||||||
|
|
||||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
|
||||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
|
||||||
|
|
||||||
<signature of Ty Coon>, 1 April 1989
|
|
||||||
Ty Coon, President of Vice
|
|
||||||
|
|
||||||
This General Public License does not permit incorporating your program into
|
|
||||||
proprietary programs. If your program is a subroutine library, you may
|
|
||||||
consider it more useful to permit linking proprietary applications with the
|
|
||||||
library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License.
|
|
||||||
@@ -1,583 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
# Copyright (C) Paul Elliott 2002
|
|
||||||
my($copyrighttext) = <<'EOF';
|
|
||||||
# Copyright (C) Paul Elliott 2002
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
# SEE COPYING FOR DETAILS
|
|
||||||
EOF
|
|
||||||
|
|
||||||
#modules we use.
|
|
||||||
|
|
||||||
use Socket;
|
|
||||||
use Getopt::Std;
|
|
||||||
use Net::DNS;
|
|
||||||
use Tie::Syslog;
|
|
||||||
use File::Temp qw/ :mktemp /;
|
|
||||||
use File::Copy;
|
|
||||||
|
|
||||||
local($res) = new Net::DNS::Resolver;
|
|
||||||
|
|
||||||
#dns lookup of IP address.
|
|
||||||
#returns ip or errorstring.
|
|
||||||
sub gethostaddr($) #get ip address from host
|
|
||||||
{
|
|
||||||
my($host) = shift;
|
|
||||||
$query = $res->search($host);
|
|
||||||
if ($query) {
|
|
||||||
foreach $rr ($query->answer) {
|
|
||||||
next unless $rr->type eq "A";
|
|
||||||
print $rr->address, "\n" if $pedebug;
|
|
||||||
return $rr->address;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
print "query failed: ", $res->errorstring, "\n" if $pedebug;
|
|
||||||
return $res->errorstring;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#send messages to syslog
|
|
||||||
|
|
||||||
sub Log($$)
|
|
||||||
{
|
|
||||||
if ($log) {
|
|
||||||
my($level) = shift;
|
|
||||||
my($mess) =shift;
|
|
||||||
|
|
||||||
tie *MYLOG, 'Tie::Syslog',$level,$0,'pid','unix';
|
|
||||||
print MYLOG $mess;
|
|
||||||
|
|
||||||
untie *MYLOG;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#send message to output or syslog
|
|
||||||
#and die.
|
|
||||||
|
|
||||||
sub BadDie($)
|
|
||||||
{
|
|
||||||
my($myerr) =$!;
|
|
||||||
my($mess)=shift;
|
|
||||||
|
|
||||||
if($log){
|
|
||||||
tie *MYLOG, 'Tie::Syslog','local0.err',$0,'pid','unix';
|
|
||||||
print MYLOG $mess;
|
|
||||||
print MYLOG $myerr;
|
|
||||||
|
|
||||||
untie *MYLOG;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print "$mess\n$myerr\n";
|
|
||||||
}
|
|
||||||
die $mess;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub isIpAddr($) #return true if looks like ip address
|
|
||||||
{
|
|
||||||
my($ip) = shift;
|
|
||||||
return 1 if ( $ip =~ m/$ipOnlyPAT/ );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
sub isHostname($) #return true if looks like ip address
|
|
||||||
{
|
|
||||||
my($ip) = shift;
|
|
||||||
return 1 if ( $ip =~ m/$hostnameOnlyPAT/ );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#send commands to chronyc by piping.
|
|
||||||
sub chronyc($) #send commands to chronyc
|
|
||||||
{
|
|
||||||
my($command) = shift;
|
|
||||||
my($err) = "/var/tmp/chronyc.log";
|
|
||||||
my($chronyP) = "/usr/local/bin/chronyc";
|
|
||||||
open(CHRONY, "| $chronyP 1>$err 2>&1");
|
|
||||||
|
|
||||||
print CHRONY "$passwd$command\n";
|
|
||||||
|
|
||||||
close(CHRONY);
|
|
||||||
|
|
||||||
Log('local0.info',"chronyc command issued=$command");
|
|
||||||
#look at status lines till return bad.
|
|
||||||
open( IN, "<$err");
|
|
||||||
my($status);
|
|
||||||
while (<IN>) {
|
|
||||||
$status = $_;
|
|
||||||
|
|
||||||
unless ( m/\A200 OK/ ) {
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$status ="" if ( $status =~ m/\A200 OK/ );
|
|
||||||
close(IN);
|
|
||||||
unlink $err;
|
|
||||||
Log('local0.info',"chronyc results=$status");
|
|
||||||
return $status;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#common patterns
|
|
||||||
|
|
||||||
# an ip address patern
|
|
||||||
local($ipPAT) = qr/\d{1,3}(?:\.\d{1,3}){3}/;
|
|
||||||
# an hostname pattern
|
|
||||||
local($hostnamePAT) = qr/\w+(?:\.\w+)*/;
|
|
||||||
#line with hostname only
|
|
||||||
local($hostnameOnlyPAT) = qr/\A$hostnamePAT\Z/;
|
|
||||||
#line with ip address only
|
|
||||||
local($ipOnlyPAT) =qr/\A$ipPAT\Z/;
|
|
||||||
|
|
||||||
#options hash
|
|
||||||
my(%opts);
|
|
||||||
|
|
||||||
|
|
||||||
getopts('nuadslPSC', \%opts);
|
|
||||||
|
|
||||||
local($log) = ( $opts{'l'} ) ? 1 : 0;
|
|
||||||
|
|
||||||
my($offline) = !( $opts{'n'} ) ;
|
|
||||||
my($offlineS) = ( $opts{'n'} ) ? " " : " offline" ;
|
|
||||||
|
|
||||||
# paul elliotts secret debug var. no one will ever find out about it.
|
|
||||||
local($pedebug)=( ($ENV{"PAULELLIOTTDEBUG"}) or ($opts{P}) );
|
|
||||||
|
|
||||||
if ($opts{C}) {
|
|
||||||
|
|
||||||
print $copyrighttext;
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
print <<"EOF" unless $opts{'S'};
|
|
||||||
$0, Copyright (C) 2002 Paul Elliott
|
|
||||||
$0 comes with ABSOLUTELY NO WARRANTY; for details
|
|
||||||
invoke $0 -C. This is free software, and you are welcome
|
|
||||||
to redistribute it under certain conditions; invoke $0 -C
|
|
||||||
for details.
|
|
||||||
EOF
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local($passwd);
|
|
||||||
|
|
||||||
# password to send to chronyc
|
|
||||||
my($pl) = $ENV{"CHRONYPASSWORD"};
|
|
||||||
|
|
||||||
#password comand to send to chronyc
|
|
||||||
if ( $pl ) {
|
|
||||||
$passwd = "password $pl\n";
|
|
||||||
} else {
|
|
||||||
$passwd = "";
|
|
||||||
}
|
|
||||||
print "passwd=$passwd\n" if ($pedebug);
|
|
||||||
|
|
||||||
my(%host2ip);
|
|
||||||
|
|
||||||
# hash of arrays. host2ip{$host}[0] is ip address for this host
|
|
||||||
# host2ip{$host}[1] is rest of paramenters for this host exc offline.
|
|
||||||
|
|
||||||
#if debuging do chrony.conf in current directory.
|
|
||||||
my($listfile) =( ($pedebug) ? "./chrony.conf" : "/etc/chrony.conf") ;
|
|
||||||
|
|
||||||
# This section reads in the old data about
|
|
||||||
# hostnames IP addresses and server parameters
|
|
||||||
# data is stored as it would be in chrony.conf
|
|
||||||
# file i.e.:
|
|
||||||
#># HOSTNAME
|
|
||||||
#>server IPADDR minpoll 5 maxpoll 10 maxdelay 0.4 offline
|
|
||||||
#
|
|
||||||
# the parameter offline is omitted if the -n switch is specified.
|
|
||||||
# first parameter is the filename of the file usually
|
|
||||||
# is /etc/DNSchrony.conf
|
|
||||||
# this is where we store the list of DNS hosts.
|
|
||||||
# hosts with static IP address shold be kept in chrony.conf
|
|
||||||
|
|
||||||
# this is header that marks dnyamic host section
|
|
||||||
my($noedithead)=<<'EOF';
|
|
||||||
## DNSchrony dynamic dns server section. DO NOT EDIT
|
|
||||||
## per entry FORMAT:
|
|
||||||
## |--------------------------------------------|
|
|
||||||
## |#HOSTNAME |
|
|
||||||
## |server IP-ADDRESS extra-params [ offline ] |
|
|
||||||
## |--------------------------------------------|
|
|
||||||
EOF
|
|
||||||
#patern that recognizes above.
|
|
||||||
my($noeditheadPAT) =
|
|
||||||
qr/\#\#\s+DNSchrony\s+dynamic\s+dns\s+server\s+section\.\s+DO\s+NOT\s+EDIT\s*/;
|
|
||||||
|
|
||||||
#end of header marker.
|
|
||||||
my($noeditheadend)=<<'EOF';
|
|
||||||
## END OF DNSchrony dynamic dns server section.
|
|
||||||
EOF
|
|
||||||
|
|
||||||
#pattern that matches above.
|
|
||||||
my($noeditheadendPAT)=
|
|
||||||
qr/\#\#\s+END\s+OF\s+DNSchrony\s+dynamic\s+dns\s+server\s+section.\s*/;
|
|
||||||
|
|
||||||
#array to hold non dns portion of chrony.conf
|
|
||||||
my(@chronyDconf);
|
|
||||||
|
|
||||||
|
|
||||||
my($ip);
|
|
||||||
my($rest);
|
|
||||||
my($host);
|
|
||||||
|
|
||||||
# for each entry in the list of hosts....
|
|
||||||
open(READIN, "<$listfile") or BadDie("Can not open $listfile");
|
|
||||||
|
|
||||||
# read till dynamic patern read save in @chronyDconf
|
|
||||||
|
|
||||||
while ( <READIN> ) {
|
|
||||||
|
|
||||||
my($line) = $_;
|
|
||||||
|
|
||||||
last if ( m/\A$noeditheadPAT\Z/ );
|
|
||||||
|
|
||||||
push(@chronyDconf,$line);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
while ( <READIN> ) {
|
|
||||||
|
|
||||||
#end loop when end of header encountered
|
|
||||||
last if ( m/\A$noeditheadendPAT/ );
|
|
||||||
|
|
||||||
# parse the line giving ip address, extra pamamters, and host
|
|
||||||
#do host comment line first
|
|
||||||
($host) = m{
|
|
||||||
\A\#\s*
|
|
||||||
($hostnamePAT)
|
|
||||||
\s*\z
|
|
||||||
}xio;
|
|
||||||
|
|
||||||
#no match skip this line.
|
|
||||||
next unless ( $host );
|
|
||||||
|
|
||||||
# read next line
|
|
||||||
$_ = <READIN>;
|
|
||||||
|
|
||||||
# parse out ip address extra parameters.
|
|
||||||
($ip,$rest) =
|
|
||||||
m{
|
|
||||||
\A
|
|
||||||
\s*
|
|
||||||
server #server comand
|
|
||||||
\s+
|
|
||||||
($ipPAT) #ip address
|
|
||||||
(?ixo: \s )
|
|
||||||
\s*
|
|
||||||
(
|
|
||||||
(?(?!
|
|
||||||
(?iox: offline )? #skip to offline #
|
|
||||||
\s* #or #
|
|
||||||
\Z
|
|
||||||
).)*
|
|
||||||
)
|
|
||||||
(?ixo:
|
|
||||||
\s*
|
|
||||||
(?ixo: offline )? #consume to #
|
|
||||||
\s*
|
|
||||||
\Z
|
|
||||||
)
|
|
||||||
}xio ;
|
|
||||||
|
|
||||||
#if failure again.
|
|
||||||
next unless ( $ip );
|
|
||||||
|
|
||||||
$rest =~ s/\s*\z//; #remove trail blanks
|
|
||||||
#from parameters
|
|
||||||
# store the data in the list
|
|
||||||
# key is host name value is
|
|
||||||
# array [0] is ip address
|
|
||||||
# [1] is other parameters
|
|
||||||
$host2ip{$host} = [$ip,$rest] ;
|
|
||||||
print "ip=$ip rest=$rest host=$host<\n" if $pedebug;
|
|
||||||
|
|
||||||
}
|
|
||||||
#read trailing line into @chronyDconf
|
|
||||||
while ( <READIN> ) {
|
|
||||||
|
|
||||||
push(@chronyDconf,$_);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
close(READIN) or BadDie("can not close $listfile");
|
|
||||||
|
|
||||||
#if the add command:
|
|
||||||
# command can be HOST=IPADDRESS OTHER_PARAMETERS
|
|
||||||
# means add the server trust the ip address geven with out a dns lookup
|
|
||||||
# good for when dns is down but we know the ip addres
|
|
||||||
# or
|
|
||||||
# HOST OTHER_PARAMETERS
|
|
||||||
#we lookup the ip address with dns.
|
|
||||||
|
|
||||||
if ($opts{'a'}) {
|
|
||||||
my($param)= shift;
|
|
||||||
|
|
||||||
|
|
||||||
# parse the param is it hostname
|
|
||||||
if ( ($host,$ip) = $param =~ m/\A($hostnamePAT)=($ipPAT)\Z/ ) {
|
|
||||||
printf "ip=$ip host=$host\n" if ($pedebug);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$host = $param;
|
|
||||||
|
|
||||||
# get the ip address
|
|
||||||
$ip = gethostaddr($host);
|
|
||||||
|
|
||||||
if ( ! isIpAddr($ip) or ! isHostname($host) ) {
|
|
||||||
print "query failed: ", $ip, "host=$host\n" if $pedebug;
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf "ip=$ip host=$host\n" if ($pedebug);
|
|
||||||
|
|
||||||
# add the server using chronyc
|
|
||||||
my($status) = chronyc("add server $ip $rest");
|
|
||||||
if ($status) { #chronyc error
|
|
||||||
print "chronyc failed, status=$status\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get rest of arguements
|
|
||||||
$rest = join( ' ', @ARGV);
|
|
||||||
print "rest=$rest\n" if ($pedebug);
|
|
||||||
|
|
||||||
#save node in hash
|
|
||||||
$host2ip{$host} = [$ip,$rest] ;
|
|
||||||
print "ip=$ip rest=$rest host=$host<\n" if $pedebug;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#delete command if arguement is ip address
|
|
||||||
#just delete it
|
|
||||||
#if a hostname look it up
|
|
||||||
#then delete it.
|
|
||||||
|
|
||||||
if ($opts{'d'}) {
|
|
||||||
$host = shift;
|
|
||||||
|
|
||||||
#get host name is it ap address
|
|
||||||
if ( isIpAddr($host) ) { # if ip address
|
|
||||||
my($hostIT);
|
|
||||||
my($found) =0;
|
|
||||||
foreach $hostIT (keys(%host2ip) ) { #search for match
|
|
||||||
if ( $host2ip{$hostIT}[0] eq $host) {
|
|
||||||
$found=1; #record match
|
|
||||||
}
|
|
||||||
} #end of search
|
|
||||||
if ($found) { #if match found
|
|
||||||
my($status) = chronyc("delete $host"); #chronyc
|
|
||||||
if ($status) { #chronyc error
|
|
||||||
print "chronyc failed, status=$status\n";
|
|
||||||
exit 1;
|
|
||||||
} else { #reiterate
|
|
||||||
foreach $hostIT (keys(%host2ip) ) {
|
|
||||||
if ( $host2ip{$hostIT}[0] eq $host) {
|
|
||||||
delete $host2ip{$hostIT}; #deleting match hosts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} else { #else not ip address
|
|
||||||
#must be hostname
|
|
||||||
if ( ! $host2ip{$host} ) {
|
|
||||||
print "No such host as $host listed\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
#get ip address
|
|
||||||
$ip=gethostaddr($host);
|
|
||||||
if ( ! isIpAddr($ip) ) { #no ip address
|
|
||||||
print "query failed: ", $ip, "\n" if $pedebug;
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf "ip=$ip host=$host\n" if ($pedebug);
|
|
||||||
|
|
||||||
my($listed_host_ip) = $host2ip{$host}[0]; # get the ip address saved
|
|
||||||
|
|
||||||
if ( $ip ne $listed_host_ip) {
|
|
||||||
print
|
|
||||||
"Info: listed host ip=>$listed_host_ip".
|
|
||||||
"< is different from DNS ip=>$ip<\n";
|
|
||||||
$ip = $listed_host_ip;
|
|
||||||
}
|
|
||||||
|
|
||||||
# delete the server
|
|
||||||
my($status) = chronyc("delete $listed_host_ip\n");
|
|
||||||
|
|
||||||
if ($status) {
|
|
||||||
print "chronyc failed, status=$status\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
#delete table entry
|
|
||||||
delete$host2ip{$host};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#update for each host who's dns ip address has changed
|
|
||||||
#delete the old server and add the new. update the record.
|
|
||||||
if ($opts{'u'}) {
|
|
||||||
my($command);
|
|
||||||
|
|
||||||
my(%prospective); # store new IP address we
|
|
||||||
#are thinking of changing.
|
|
||||||
|
|
||||||
Log('local0.info',
|
|
||||||
"Now searching for modified DNS entries.");
|
|
||||||
|
|
||||||
foreach $host (keys(%host2ip)) { #for each listed host
|
|
||||||
my($old_ip) = $host2ip{$host}[0]; #get old ip
|
|
||||||
$rest = $host2ip{$host}[1]; #extra params
|
|
||||||
|
|
||||||
$ip = gethostaddr($host); #get new ip from dns
|
|
||||||
#if error
|
|
||||||
if ( ! isIpAddr($ip) or ! isHostname($host) ) {
|
|
||||||
print "query failed: ", $ip, "host=$host\n";
|
|
||||||
|
|
||||||
Log('local0.err',"query failed: ". $ip . "host=$host");
|
|
||||||
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
next if($ip eq $old_ip); #if ip not changed, skip
|
|
||||||
|
|
||||||
Log('local0.info',"Ip address for $host has changed. Old IP address=".
|
|
||||||
"$old_ip, new IP address=$ip");
|
|
||||||
# add command to delete old host, add the new.
|
|
||||||
$command = $command . "delete $old_ip\n" .
|
|
||||||
"add server $ip $rest\n";
|
|
||||||
|
|
||||||
# we are now thinking about changing this host ip
|
|
||||||
$prospective{$host} = [$ip,$rest];
|
|
||||||
}
|
|
||||||
# submit all the accumulated chronyc commands if any.
|
|
||||||
if ($command) {
|
|
||||||
$status = chronyc($command);
|
|
||||||
if ($status) {
|
|
||||||
print "chronyc failed, status=$status\n";
|
|
||||||
Log('local0.err',"query failed: ". $ip . "host=$host");
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
} else { #if no commands exit
|
|
||||||
exit 0; #because no rewrite of file needed
|
|
||||||
}
|
|
||||||
|
|
||||||
#copy prospective modifications back into main table.
|
|
||||||
#we now know that all these mods were done with chronyc
|
|
||||||
foreach $host (keys(%prospective)) {
|
|
||||||
my($ip) = $prospective{$host}[0];
|
|
||||||
$rest = $prospective{$host}[1];
|
|
||||||
$host2ip{$host} = [$ip,$rest];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#starting for each entry we have read in from the old list
|
|
||||||
# add the server in chronyc
|
|
||||||
# this option is seldom used.
|
|
||||||
|
|
||||||
if ($opts{'s'}) {
|
|
||||||
my($command)="";
|
|
||||||
|
|
||||||
foreach $host (keys(%host2ip)) {
|
|
||||||
$command = $command . "add server $host2ip{$host}[0] ".
|
|
||||||
"$host2ip{$host}[1]\n";
|
|
||||||
}
|
|
||||||
my($status) = chronyc($command);
|
|
||||||
if ($status) {
|
|
||||||
print "chronyc failed, status=$status\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
# write out the data file in format
|
|
||||||
#># HOSTNAME
|
|
||||||
#>server IPADDRESS extra parameters [offline]
|
|
||||||
# offline is omitted if -n switch is specified.
|
|
||||||
|
|
||||||
my(@value);
|
|
||||||
my($such);
|
|
||||||
{
|
|
||||||
# to start out we write to temporary file.
|
|
||||||
(my($writeout) , my($outname)) = mkstemp( "${listfile}.outXXXXXXX");
|
|
||||||
|
|
||||||
$outname or BadDie("can not open for $listfile");
|
|
||||||
|
|
||||||
|
|
||||||
# save the chrony.conf part!
|
|
||||||
# and write the DYNAMIC header
|
|
||||||
print $writeout @chronyDconf, $noedithead;
|
|
||||||
|
|
||||||
|
|
||||||
# for each entry
|
|
||||||
foreach $host (keys(%host2ip) ){
|
|
||||||
|
|
||||||
#write the record
|
|
||||||
|
|
||||||
# write the comment that indicates the hostname
|
|
||||||
# and the server command.
|
|
||||||
print $writeout
|
|
||||||
"\# $host\nserver $host2ip{$host}[0] $host2ip{$host}[1]${offlineS}\n" ;
|
|
||||||
|
|
||||||
print
|
|
||||||
"server $host2ip{$host}[0] $host2ip{$host}[1]${offlineS}\# $host\n"
|
|
||||||
if $pedebug;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#WRITE THE end of dnyamic marker comment
|
|
||||||
print $writeout $noeditheadend;
|
|
||||||
|
|
||||||
# close the output file which was a temporary file.
|
|
||||||
close($writeout) or BadDie("can not close $outname");
|
|
||||||
|
|
||||||
# we now begin a intracate dance to make the the temporary
|
|
||||||
# the main chrony.conf
|
|
||||||
#
|
|
||||||
# if there is a chrony.conf.BAK save it to a temporary.
|
|
||||||
# rename chrony.conf to chrony.conf.BAK
|
|
||||||
# rename the temporary to chrony.conf
|
|
||||||
# if there already was a chrony.conf.BAK, unlink the copy of this.
|
|
||||||
|
|
||||||
my($backname) = "$listfile\.BAK";
|
|
||||||
my($backplain) = ( -f $backname );
|
|
||||||
my($saveback);
|
|
||||||
#if chrony.conf.BAK exists rename to a temporary.
|
|
||||||
if ($backplain ) {
|
|
||||||
|
|
||||||
$saveback = mktemp("${backname}.bakXXXXXXX");
|
|
||||||
move($backname,$saveback) or
|
|
||||||
BadDie "unable to move $backname to $savename";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# rename old chrony.conf to chrony.conf.BAK
|
|
||||||
move($listfile,$backname) or
|
|
||||||
BadDie "unable to move $listfile to $backname";
|
|
||||||
|
|
||||||
# rename our output to chrony.conf
|
|
||||||
move($outname,$listfile) or
|
|
||||||
BadDie "unable to move $outname to $listfile";
|
|
||||||
|
|
||||||
#if there was a temporary chrony.conf.BAK that we saved to temp
|
|
||||||
#unlink it
|
|
||||||
unlink($saveback) or BadDie "unable to unlink $saveback" if($backplain);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/bash
|
|
||||||
|
|
||||||
# $1 is chrony password.
|
|
||||||
# $2 is hostname to add or hostname=ipaddres
|
|
||||||
# $3-$9 is rest of extra server parameters
|
|
||||||
|
|
||||||
FIRST="$1"
|
|
||||||
HOST="$2"
|
|
||||||
shift 2
|
|
||||||
|
|
||||||
#remaining parameters a the other paramaters to server command
|
|
||||||
#excluding "offline"
|
|
||||||
ARGS="$*"
|
|
||||||
|
|
||||||
#if none use default taken from chrony documentation.
|
|
||||||
DEF="minpoll 5 maxpoll 10 maxdelay 0.4"
|
|
||||||
|
|
||||||
DARGS=${ARGS:-$DEF}
|
|
||||||
|
|
||||||
CHRONYPASSWORD=$FIRST \
|
|
||||||
/usr/local/bin/DNSchrony.pl -a "$HOST" "$DARGS"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/bash
|
|
||||||
|
|
||||||
# $1 is chrony password.
|
|
||||||
# $2 host to be deleted if ip nn.n.n.n then no DNS used
|
|
||||||
|
|
||||||
CHRONYPASSWORD=$1 \
|
|
||||||
/usr/local/bin/DNSchrony.pl -d $2
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/bash
|
|
||||||
|
|
||||||
# $1 is chrony password.
|
|
||||||
|
|
||||||
|
|
||||||
CHRONYPASSWORD=$1 \
|
|
||||||
/usr/local/bin/DNSchrony.pl -ulS
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
Copyright (C) Paul Elliott 2002
|
|
||||||
|
|
||||||
|
|
||||||
DNSchrony.pl version -2.0
|
|
||||||
|
|
||||||
Problem: If you look at the list of secondary NTP servers:
|
|
||||||
http://www.eecis.udel.edu/~mills/ntp/clock2.htm
|
|
||||||
|
|
||||||
you will find statements like this:
|
|
||||||
|
|
||||||
"Note: IP addresses are subject to change; please use DNS"
|
|
||||||
|
|
||||||
These servers represent a problem for chrony. Chrony is a program
|
|
||||||
designed to work on hosts with an intermittent connection to the
|
|
||||||
internet. Often no DNS is available when chrony starts. As chrony
|
|
||||||
is currently designed, chronyd never sees a DNS host name. If a
|
|
||||||
user specifies one when using chronyc's "add server" command, the
|
|
||||||
DNS lookup is done by chronyc and an IP address is passed to chronyd.
|
|
||||||
|
|
||||||
One can imagine I suppose, a redesign to chrony in which chronyd
|
|
||||||
keeps track of DNS changes. But this has problems, all the time
|
|
||||||
chronyd is fooling around with DNS, it would not be keeping track
|
|
||||||
of its prime function, what the clocks and NTP servers are saying.
|
|
||||||
This could result in poorer performance. Or perhaps you say that
|
|
||||||
chronyd should be multi threaded. One thread to fool with DNS
|
|
||||||
and another to keep track of time. But this introduces a great
|
|
||||||
deal of complexity, and complexity is the enemy of elegant robust
|
|
||||||
code. Besides, Richard probably has better things to do.
|
|
||||||
|
|
||||||
I have attempted to address this problem with a humble perl script,
|
|
||||||
which I now release under the GPL: DNSchrony.pl
|
|
||||||
|
|
||||||
PLEA FOR HELP FROM EXPERIENCED PERL HACKERS.
|
|
||||||
|
|
||||||
Please go thru the code and find errors and improvements.
|
|
||||||
I am not quite an polished perl hacker. Please fix bugs and
|
|
||||||
make improvements. It needs better documentation. Someone
|
|
||||||
who knows how, put in some POD.
|
|
||||||
|
|
||||||
END OF PLEA
|
|
||||||
|
|
||||||
Philosophy of DNSchrony.pl: keep a list of servers that use
|
|
||||||
DNS. From time to time, hopefully when DNS is up, go thru
|
|
||||||
the list lookup all the hostnames and see if any ip addresses have
|
|
||||||
changed. If any have changed, update our list and do chronyc
|
|
||||||
"delete" and "add server" commands so that chronyd now talks to
|
|
||||||
the right NTP server.
|
|
||||||
|
|
||||||
Additional nuance: keep the list in /etc/chrony.conf in the
|
|
||||||
form of comments starting with "#" and "server" commands
|
|
||||||
legal in a chrony.conf file. Format of a list entry:
|
|
||||||
|
|
||||||
# hostname
|
|
||||||
server IP-ADDRESS extra server parameters
|
|
||||||
|
|
||||||
These entries are delimited by special comments that allow
|
|
||||||
DNSchrony.pl to find them and also tell humans not to mess with them.
|
|
||||||
|
|
||||||
Example of such a section of a chrony.conf file:
|
|
||||||
|
|
||||||
dumpdir /var/log/chrony
|
|
||||||
rtcfile /etc/chrony.rtc
|
|
||||||
|
|
||||||
## DNSchrony dynamic dns server section. DO NOT EDIT
|
|
||||||
## per entry FORMAT:
|
|
||||||
## |--------------------------------------------|
|
|
||||||
## |#HOSTNAME |
|
|
||||||
## |server IP-ADDRESS extra-params [ offline ] |
|
|
||||||
## |--------------------------------------------|
|
|
||||||
# tock.greyware.com
|
|
||||||
server 208.14.208.44 minpoll 5 maxpoll 10 maxdelay 0.4 offline
|
|
||||||
# tick.greyware.com
|
|
||||||
server 208.14.208.19 minpoll 5 maxpoll 10 maxdelay 0.4 offline
|
|
||||||
# ntppub.tamu.edu
|
|
||||||
server 128.194.254.9 minpoll 5 maxpoll 10 maxdelay 0.4 offline
|
|
||||||
## END OF DNSchrony dynamic dns server section.
|
|
||||||
|
|
||||||
This allows the list of dynamic DNS servers to be preserved
|
|
||||||
when chronyd is stoped/started.
|
|
||||||
|
|
||||||
All servers that do not have ip addresses subject to change
|
|
||||||
should be put in the regular part of chrony.conf as described
|
|
||||||
in the chrony documentation.
|
|
||||||
|
|
||||||
Security philosophy: DNSchrony does no security checking but
|
|
||||||
relies on other security factors.
|
|
||||||
|
|
||||||
Users without the privilege to modify /etc/chrony.conf and the
|
|
||||||
directory /etc will be unable to use DNSchrony to do so, because
|
|
||||||
of file protections. DNSchrony passes thru passwords to chronyc.
|
|
||||||
Users that do not know the correct chronyc password will be
|
|
||||||
unable to get chronyd do do anything. Thus, DNSchrony passes
|
|
||||||
the buck to these other security features.
|
|
||||||
|
|
||||||
INSTALLATION:
|
|
||||||
|
|
||||||
copy the files: DNSchronyADD DNSchronyUPDATE DNSchronyDELETE DNSchrony.pl
|
|
||||||
to /usr/local/bin. Backup the file /etc/chrony.conf leave hosts
|
|
||||||
with static ip addresses in this file.
|
|
||||||
|
|
||||||
DNSchrony uses the following perl modules. See that they are installed.
|
|
||||||
Get them from CPAN if needed.
|
|
||||||
|
|
||||||
Net::DNS, Tie::Syslog, Getopt::Std, Socket, File.
|
|
||||||
|
|
||||||
Cause DNSchronyUPDATE bash script to run from time to time when DNS
|
|
||||||
is working. If you have a dialup, one way to do this would be to
|
|
||||||
modify your /etc/ppp/ip-up.local file as follows:
|
|
||||||
|
|
||||||
cat <<EOF | /usr/local/bin/chronyc
|
|
||||||
password mysecret
|
|
||||||
online
|
|
||||||
EOF
|
|
||||||
# update all of the dynamic servers and save the result.
|
|
||||||
# do not wait for response
|
|
||||||
|
|
||||||
nohup /usr/local/bin/DNSchronyUPDATE mysecret >/dev/null 2>&1 &
|
|
||||||
|
|
||||||
Since this file contains the chronyc password you will want to set the
|
|
||||||
file permissions so that just everybody will not be able to read
|
|
||||||
it. But you already did that when you put in the chronyc command. Any
|
|
||||||
other way to make DNSchronyUPDATE run perodicly when DNS is up will
|
|
||||||
also work.
|
|
||||||
|
|
||||||
To add a server with a varying IP address one could run:
|
|
||||||
/usr/local/bin/DNSchronyADD mysecret tock.greyware.com
|
|
||||||
|
|
||||||
or if you want to specify different server parameters you
|
|
||||||
could say:
|
|
||||||
|
|
||||||
/usr/local/bin/DNSchronyADD mysecret tock.greyware.com "minpoll 10 maxpoll 20 maxdelay 0.8"
|
|
||||||
|
|
||||||
The DNSchronyADD's default for these parameters is:
|
|
||||||
"minpoll 5 maxpoll 10 maxdelay 0.4" values that are often shown
|
|
||||||
as examples in the chrony documentation.
|
|
||||||
|
|
||||||
If DNS is not running now but you know the IP address, you can say:
|
|
||||||
/usr/local/bin/DNSchronyADD mysecret tock.greyware.com=208.14.208.44
|
|
||||||
|
|
||||||
Of course, the IP address will be checked next time DNSchronyUPDATE
|
|
||||||
runs.
|
|
||||||
|
|
||||||
To delete dynamic DNS a server:
|
|
||||||
/usr/local/bin/DNSchronyDELETE mysecret tock.greyware.com
|
|
||||||
|
|
||||||
To change parameters delete and re-add.
|
|
||||||
|
|
||||||
Of course, in all of the above "mysecret" is your chronyc password
|
|
||||||
which SHOULD NOT BE "mysecret".
|
|
||||||
----------------------------------------------
|
|
||||||
DNSchrony.pl is covered by the GPL
|
|
||||||
# Copyright (C) Paul Elliott 2002
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
# SEE COPYING FOR DETAILS
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#example file /etc/ppp/ip-up.local
|
|
||||||
#originally from SuSE distribution
|
|
||||||
#modified for chrony
|
|
||||||
cat <<EOF | /usr/local/bin/chronyc
|
|
||||||
password mysecret
|
|
||||||
online
|
|
||||||
EOF
|
|
||||||
# update all of the dynamic servers and save the result.
|
|
||||||
# do not wait for response
|
|
||||||
|
|
||||||
nohup /usr/local/bin/DNSchronyUPDATE mysecret >/dev/null 2>&1 &
|
|
||||||
#other stuff who knows?
|
|
||||||
|
|
||||||
# The following lines added for Linux-HA support # Heartbeat
|
|
||||||
DEVFILE=`echo $DEVICE | sed -e 's!^/dev/!!' -e 's!/!.!g'` # Heartbeat
|
|
||||||
OUTFILE=/var/run/ppp.d/$DEVFILE # Heartbeat
|
|
||||||
( # Heartbeat
|
|
||||||
echo "$IPREMOTE" # Heartbeat
|
|
||||||
echo "$IFNAME" # Heartbeat
|
|
||||||
echo "$PPPD_PID" # Heartbeat
|
|
||||||
echo "$IPLOCAL" # Heartbeat
|
|
||||||
) > $OUTFILE # Heartbeat
|
|
||||||
103
contrib/bryan_christianson_1/README.txt
Normal file
103
contrib/bryan_christianson_1/README.txt
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
Notes for installing chrony on macOS
|
||||||
|
Author: Bryan Christianson (bryan@whatroute.net)
|
||||||
|
------------------------------------------------
|
||||||
|
|
||||||
|
These files are for those admins/users who would prefer to install chrony
|
||||||
|
from the source distribution and are intended as guidelines rather than
|
||||||
|
being definitive. They can be edited with a plain text editor, such as
|
||||||
|
vi, emacs or your favourite IDE (Xcode)
|
||||||
|
|
||||||
|
It is assumed you are comfortable with installing software from the
|
||||||
|
terminal command line and know how to use sudo to acquire root access.
|
||||||
|
|
||||||
|
If you are not familiar with the macOS command line then
|
||||||
|
please consider using ChronyControl from http://whatroute.net/chronycontrol.html
|
||||||
|
|
||||||
|
ChronyControl provides a gui wrapper for installing these files and sets the
|
||||||
|
necessary permissions on each file.
|
||||||
|
|
||||||
|
|
||||||
|
Install the chrony software
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
You will need xcode and the commandline additions to build and install chrony.
|
||||||
|
These can be obtained from Apple's website via the App Store.
|
||||||
|
|
||||||
|
cd to the chrony directory
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
chrony is now installed in default locations (/usr/local/sbin/chronyd,
|
||||||
|
/usr/local/bin/chronyc)
|
||||||
|
|
||||||
|
Create a chrony.conf file - see the chrony website for details
|
||||||
|
|
||||||
|
The support files here assume the following directives are specified in the
|
||||||
|
chrony.conf file
|
||||||
|
|
||||||
|
keyfile /etc/chrony.d/chrony.keys
|
||||||
|
driftfile /var/db/chrony/chrony.drift
|
||||||
|
bindcmdaddress /var/db/chrony/chronyd.sock
|
||||||
|
logdir /var/log/chrony
|
||||||
|
dumpdir /var/db/chrony
|
||||||
|
|
||||||
|
Install this file as /etc/chrony.d/chrony.conf and create
|
||||||
|
the directories specified in the above directives if they don't exist.
|
||||||
|
You will need root permissions to create the directories.
|
||||||
|
|
||||||
|
|
||||||
|
Running chronyd
|
||||||
|
---------------
|
||||||
|
At this point chronyd *could* be run as a daemon. Apple discourage running
|
||||||
|
daemons and their preferred method uses the launchd facility. The
|
||||||
|
support files here provide a launchd configuration file for chronyd and also
|
||||||
|
a shell script and launchd configuration file to rotate the chronyd logs on a daily basis.
|
||||||
|
|
||||||
|
|
||||||
|
Support files
|
||||||
|
-------------
|
||||||
|
Dates and sizes may differ
|
||||||
|
-rw-r--r-- 1 yourname staff 2084 4 Aug 22:54 README.txt
|
||||||
|
-rwxr-xr-x 1 yourname staff 676 4 Aug 21:18 chronylogrotate.sh
|
||||||
|
-rw-r--r-- 1 yourname staff 543 18 Jul 20:10 org.tuxfamily.chronyc.plist
|
||||||
|
-rw-r--r-- 1 yourname staff 511 19 Jun 18:30 org.tuxfamily.chronyd.plist
|
||||||
|
|
||||||
|
If you have used chrony support directories other than those suggested, you
|
||||||
|
will need to edit each file and make the appropriate changes.
|
||||||
|
|
||||||
|
|
||||||
|
Installing the support files
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
1. chronylogrotate.sh
|
||||||
|
This is a simple shell script that deletes old log files. Unfortunately because
|
||||||
|
of the need to run chronyc, the standard macOS logrotation does not work with
|
||||||
|
chrony logs.
|
||||||
|
|
||||||
|
This script runs on a daily basis under control of launchd and should be
|
||||||
|
installed in the /usr/local/bin directory
|
||||||
|
|
||||||
|
sudo cp chronylogrotate.sh /usr/local/bin
|
||||||
|
sudo chmod +x /usr/local/bin/chronylogrotate.sh
|
||||||
|
sudo chown root:wheel /usr/local/bin/chronylogrotate.sh
|
||||||
|
|
||||||
|
|
||||||
|
2. org.tuxfamily.chronyc.plist
|
||||||
|
This file is the launchd plist that runs logrotation each day. You may
|
||||||
|
wish to edit this file to change the time of day at which the rotation
|
||||||
|
will run, currently 04:05 am
|
||||||
|
|
||||||
|
sudo cp org.tuxfamily.chronyc.plist /Library/LaunchDaemons
|
||||||
|
sudo chown root:wheel /Library/LaunchDaemons/org.tuxfamily.chronyc.plist
|
||||||
|
sudo chmod 0644 /Library/LaunchDaemons/org.tuxfamily.chronyc.plist
|
||||||
|
sudo launchctl load -w /Library/LaunchDaemons/org.tuxfamily.chronyc.plist
|
||||||
|
|
||||||
|
|
||||||
|
3. org.tuxfamily.chronyd.plist
|
||||||
|
This file is the launchd plist that runs chronyd when the Macintosh starts.
|
||||||
|
|
||||||
|
sudo cp org.tuxfamily.chronyd.plist /Library/LaunchDaemons
|
||||||
|
sudo chown root:wheel /Library/LaunchDaemons/org.tuxfamily.chronyd.plist
|
||||||
|
sudo chmod 0644 /Library/LaunchDaemons/org.tuxfamily.chronyd.plist
|
||||||
|
sudo launchctl load -w /Library/LaunchDaemons/org.tuxfamily.chronyd.plist
|
||||||
58
contrib/bryan_christianson_1/chronylogrotate.sh
Executable file
58
contrib/bryan_christianson_1/chronylogrotate.sh
Executable file
@@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
#
|
||||||
|
# **********************************************************************
|
||||||
|
# * Copyright (C) Bryan Christianson 2015
|
||||||
|
# *
|
||||||
|
# * This program is free software; you can redistribute it and/or modify
|
||||||
|
# * it under the terms of version 2 of the GNU General Public License as
|
||||||
|
# * published by the Free Software Foundation.
|
||||||
|
# *
|
||||||
|
# * This program is distributed in the hope that it will be useful, but
|
||||||
|
# * WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# * General Public License for more details.
|
||||||
|
# *
|
||||||
|
# * You should have received a copy of the GNU General Public License along
|
||||||
|
# * with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
# * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
# *
|
||||||
|
# **********************************************************************
|
||||||
|
|
||||||
|
LOGDIR=/var/log/chrony
|
||||||
|
|
||||||
|
rotate () {
|
||||||
|
prefix=$1
|
||||||
|
|
||||||
|
rm -f $prefix.log.10
|
||||||
|
|
||||||
|
for (( count=9; count>= 0; count-- ))
|
||||||
|
do
|
||||||
|
next=$(( $count+1 ))
|
||||||
|
if [ -f $prefix.log.$count ]; then
|
||||||
|
mv $prefix.log.$count $prefix.log.$next
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -f $prefix.log ]; then
|
||||||
|
mv $prefix.log $prefix.log.0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ ! -e "$LOGDIR" ]; then
|
||||||
|
logger -s "missing directory: $LOGDIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $LOGDIR
|
||||||
|
|
||||||
|
rotate measurements
|
||||||
|
rotate statistics
|
||||||
|
rotate tracking
|
||||||
|
|
||||||
|
#
|
||||||
|
# signal chronyd via chronyc
|
||||||
|
/usr/local/bin/chronyc cyclelogs > /dev/null
|
||||||
|
|
||||||
|
exit $?
|
||||||
22
contrib/bryan_christianson_1/org.tuxfamily.chronyc.plist
Normal file
22
contrib/bryan_christianson_1/org.tuxfamily.chronyc.plist
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>org.tuxfamily.logrotate</string>
|
||||||
|
<key>KeepAlive</key>
|
||||||
|
<false/>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>/bin/sh</string>
|
||||||
|
<string>/usr/local/bin/chronylogrotate.sh</string>
|
||||||
|
</array>
|
||||||
|
<key>StartCalendarInterval</key>
|
||||||
|
<dict>
|
||||||
|
<key>Minute</key>
|
||||||
|
<integer>5</integer>
|
||||||
|
<key>Hour</key>
|
||||||
|
<integer>4</integer>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
19
contrib/bryan_christianson_1/org.tuxfamily.chronyd.plist
Normal file
19
contrib/bryan_christianson_1/org.tuxfamily.chronyd.plist
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>org.tuxfamily.chronyd</string>
|
||||||
|
<key>Program</key>
|
||||||
|
<string>/usr/local/sbin/chronyd</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>chronyd</string>
|
||||||
|
<string>-n</string>
|
||||||
|
<string>-f</string>
|
||||||
|
<string>/private/etc/chrony.d/chrony.conf</string>
|
||||||
|
</array>
|
||||||
|
<key>KeepAlive</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
76
doc/Makefile.in
Normal file
76
doc/Makefile.in
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
ADOC = asciidoctor
|
||||||
|
ADOC_FLAGS =
|
||||||
|
SED = sed
|
||||||
|
HTML_TO_TXT = w3m -dump -T text/html
|
||||||
|
|
||||||
|
MAN_FILES = chrony.conf.man chronyc.man chronyd.man
|
||||||
|
TXT_FILES = faq.txt installation.txt
|
||||||
|
HTML_FILES = $(MAN_FILES:%.man=%.html) $(TXT_FILES:%.txt=%.html)
|
||||||
|
MAN_IN_FILES = $(MAN_FILES:%.man=%.man.in)
|
||||||
|
|
||||||
|
SYSCONFDIR = @SYSCONFDIR@
|
||||||
|
BINDIR = @BINDIR@
|
||||||
|
SBINDIR = @SBINDIR@
|
||||||
|
MANDIR = @MANDIR@
|
||||||
|
DOCDIR = @DOCDIR@
|
||||||
|
CHRONYRUNDIR = @CHRONYRUNDIR@
|
||||||
|
CHRONYVARDIR = @CHRONYVARDIR@
|
||||||
|
CHRONY_VERSION = @CHRONY_VERSION@
|
||||||
|
DEFAULT_USER = @DEFAULT_USER@
|
||||||
|
DEFAULT_HWCLOCK_FILE = @DEFAULT_HWCLOCK_FILE@
|
||||||
|
DEFAULT_PID_FILE = @DEFAULT_PID_FILE@
|
||||||
|
DEFAULT_RTC_DEVICE = @DEFAULT_RTC_DEVICE@
|
||||||
|
|
||||||
|
SED_COMMANDS = "s%\@SYSCONFDIR\@%$(SYSCONFDIR)%g;\
|
||||||
|
s%\@BINDIR\@%$(BINDIR)%g;\
|
||||||
|
s%\@SBINDIR\@%$(SBINDIR)%g;\
|
||||||
|
s%\@CHRONY_VERSION\@%$(CHRONY_VERSION)%g;\
|
||||||
|
s%\@DEFAULT_HWCLOCK_FILE\@%$(DEFAULT_HWCLOCK_FILE)%g;\
|
||||||
|
s%\@DEFAULT_PID_FILE\@%$(DEFAULT_PID_FILE)%g;\
|
||||||
|
s%\@DEFAULT_RTC_DEVICE\@%$(DEFAULT_RTC_DEVICE)%g;\
|
||||||
|
s%\@DEFAULT_USER\@%$(DEFAULT_USER)%g;\
|
||||||
|
s%\@CHRONYRUNDIR\@%$(CHRONYRUNDIR)%g;\
|
||||||
|
s%\@CHRONYVARDIR\@%$(CHRONYVARDIR)%g;"
|
||||||
|
|
||||||
|
man: $(MAN_FILES) $(MAN_IN_FILES)
|
||||||
|
html: $(HTML_FILES)
|
||||||
|
txt: $(TXT_FILES)
|
||||||
|
docs: man html
|
||||||
|
|
||||||
|
%.html: %.adoc
|
||||||
|
$(ADOC) $(ADOC_FLAGS) -b html -o - $< | $(SED) -e $(SED_COMMANDS) > $@
|
||||||
|
|
||||||
|
%.man.in: %.adoc
|
||||||
|
$(ADOC) $(ADOC_FLAGS) -b manpage -o $@ $<
|
||||||
|
|
||||||
|
%.man: %.man.in
|
||||||
|
$(SED) -e $(SED_COMMANDS) < $< > $@
|
||||||
|
|
||||||
|
%.txt: %.html
|
||||||
|
$(HTML_TO_TXT) < $< > $@
|
||||||
|
|
||||||
|
install: $(MAN_FILES)
|
||||||
|
[ -d $(DESTDIR)$(MANDIR)/man1 ] || mkdir -p $(DESTDIR)$(MANDIR)/man1
|
||||||
|
[ -d $(DESTDIR)$(MANDIR)/man5 ] || mkdir -p $(DESTDIR)$(MANDIR)/man5
|
||||||
|
[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
|
||||||
|
cp chronyc.man $(DESTDIR)$(MANDIR)/man1/chronyc.1
|
||||||
|
chmod 644 $(DESTDIR)$(MANDIR)/man1/chronyc.1
|
||||||
|
cp chronyd.man $(DESTDIR)$(MANDIR)/man8/chronyd.8
|
||||||
|
chmod 644 $(DESTDIR)$(MANDIR)/man8/chronyd.8
|
||||||
|
cp chrony.conf.man $(DESTDIR)$(MANDIR)/man5/chrony.conf.5
|
||||||
|
chmod 644 $(DESTDIR)$(MANDIR)/man5/chrony.conf.5
|
||||||
|
|
||||||
|
install-docs: $(HTML_FILES)
|
||||||
|
[ -d $(DESTDIR)$(DOCDIR) ] || mkdir -p $(DESTDIR)$(DOCDIR)
|
||||||
|
for f in $(HTML_FILES); do \
|
||||||
|
cp $$f $(DESTDIR)$(DOCDIR); \
|
||||||
|
chmod 644 $(DESTDIR)$(DOCDIR)/$$f; \
|
||||||
|
done
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(MAN_FILES) $(TXT_FILES) $(HTML_FILES)
|
||||||
|
rm -f $(MAN_IN_FILES)
|
||||||
|
|
||||||
|
distclean:
|
||||||
|
rm -f $(MAN_FILES) $(TXT_FILES) $(HTML_FILES)
|
||||||
|
rm -f Makefile
|
||||||
2908
doc/chrony.conf.adoc
Normal file
2908
doc/chrony.conf.adoc
Normal file
File diff suppressed because it is too large
Load Diff
1459
doc/chronyc.adoc
Normal file
1459
doc/chronyc.adoc
Normal file
File diff suppressed because it is too large
Load Diff
211
doc/chronyd.adoc
Normal file
211
doc/chronyd.adoc
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
// This file is part of chrony
|
||||||
|
//
|
||||||
|
// Copyright (C) Richard P. Curnow 1997-2003
|
||||||
|
// Copyright (C) Miroslav Lichvar 2009-2017
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of version 2 of the GNU General Public License as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
= chronyd(8)
|
||||||
|
:doctype: manpage
|
||||||
|
:man manual: System Administration
|
||||||
|
:man source: chrony @CHRONY_VERSION@
|
||||||
|
|
||||||
|
== NAME
|
||||||
|
|
||||||
|
chronyd - chrony daemon
|
||||||
|
|
||||||
|
== SYNOPSIS
|
||||||
|
|
||||||
|
*chronyd* [_OPTION_]... [_DIRECTIVE_]...
|
||||||
|
|
||||||
|
== DESCRIPTION
|
||||||
|
|
||||||
|
*chronyd* is a daemon for synchronisation of the system clock. It can
|
||||||
|
synchronise the clock with NTP servers, reference clocks (e.g. a GPS receiver),
|
||||||
|
and manual input using wristwatch and keyboard via *chronyc*. It can also
|
||||||
|
operate as an NTPv4 (RFC 5905) server and peer to provide a time service to
|
||||||
|
other computers in the network.
|
||||||
|
|
||||||
|
If no configuration directives are specified on the command line, *chronyd*
|
||||||
|
will read them from a configuration file. The compiled-in default location of
|
||||||
|
the file is _@SYSCONFDIR@/chrony.conf_.
|
||||||
|
|
||||||
|
Informational messages, warnings, and errors will be logged to syslog.
|
||||||
|
|
||||||
|
== OPTIONS
|
||||||
|
|
||||||
|
*-4*::
|
||||||
|
With this option hostnames will be resolved only to IPv4 addresses and only
|
||||||
|
IPv4 sockets will be created.
|
||||||
|
|
||||||
|
*-6*::
|
||||||
|
With this option hostnames will be resolved only to IPv6 addresses and only
|
||||||
|
IPv6 sockets will be created.
|
||||||
|
|
||||||
|
*-f* _file_::
|
||||||
|
This option can be used to specify an alternate location for the configuration
|
||||||
|
file. The compiled-in default value is _@SYSCONFDIR@/chrony.conf_.
|
||||||
|
|
||||||
|
*-n*::
|
||||||
|
When run in this mode, the program will not detach itself from the terminal.
|
||||||
|
|
||||||
|
*-d*::
|
||||||
|
When run in this mode, the program will not detach itself from the terminal,
|
||||||
|
and all messages will be written to the terminal instead of syslog. If
|
||||||
|
*chronyd* was compiled with enabled support for debugging, this option can be
|
||||||
|
used twice to enable debug messages.
|
||||||
|
|
||||||
|
*-l* _file_::
|
||||||
|
This option enables writing of log messages to a file instead of syslog or the
|
||||||
|
terminal.
|
||||||
|
|
||||||
|
*-L* _level_::
|
||||||
|
This option specifies the minimum severity level of messages to be written to
|
||||||
|
the log file, syslog, or terminal. The following levels can be specified:
|
||||||
|
0 (informational), 1 (warning), 2 (non-fatal error), and 3 (fatal error). The
|
||||||
|
default value is 0.
|
||||||
|
|
||||||
|
*-p*::
|
||||||
|
When run in this mode, *chronyd* will print the configuration and exit. It will
|
||||||
|
not detach from the terminal. This option can be used to verify the syntax of
|
||||||
|
the configuration and get the whole configuration, even if it is split into
|
||||||
|
multiple files and read by the *include* or *confdir* directive.
|
||||||
|
|
||||||
|
*-q*::
|
||||||
|
When run in this mode, *chronyd* will set the system clock once and exit. It
|
||||||
|
will not detach from the terminal.
|
||||||
|
|
||||||
|
*-Q*::
|
||||||
|
This option is similar to the *-q* option, except it only prints the offset
|
||||||
|
without making any corrections of the clock and it allows *chronyd* to be
|
||||||
|
started without root privileges.
|
||||||
|
|
||||||
|
*-r*::
|
||||||
|
This option will try to reload and then delete files containing sample
|
||||||
|
histories for each of the servers and reference clocks being used. The
|
||||||
|
files are expected to be in the directory specified by the
|
||||||
|
<<chrony.conf.adoc#dumpdir,*dumpdir*>>
|
||||||
|
directive in the configuration file. This option is useful if you want to stop
|
||||||
|
and restart *chronyd* briefly for any reason, e.g. to install a new version.
|
||||||
|
However, it should be used only on systems where the kernel can maintain clock
|
||||||
|
compensation whilst not under *chronyd*'s control (i.e. Linux, FreeBSD, NetBSD,
|
||||||
|
Solaris, and macOS 10.13 or later).
|
||||||
|
|
||||||
|
*-R*::
|
||||||
|
When this option is used, the <<chrony.conf.adoc#initstepslew,*initstepslew*>>
|
||||||
|
directive and the <<chrony.conf.adoc#makestep,*makestep*>> directive used with
|
||||||
|
a positive limit will be ignored. This option is useful when restarting
|
||||||
|
*chronyd* and can be used in conjunction with the *-r* option.
|
||||||
|
|
||||||
|
*-s*::
|
||||||
|
This option will set the system clock from the computer's real-time clock (RTC)
|
||||||
|
or to the last modification time of the file specified by the
|
||||||
|
<<chrony.conf.adoc#driftfile,*driftfile*>> directive. Real-time clocks are
|
||||||
|
supported only on Linux.
|
||||||
|
+
|
||||||
|
If used in conjunction with the *-r* flag, *chronyd* will attempt to preserve
|
||||||
|
the old samples after setting the system clock from the RTC. This can be used
|
||||||
|
to allow *chronyd* to perform long term averaging of the gain or loss rate
|
||||||
|
across system reboots, and is useful for systems with intermittent access to
|
||||||
|
network that are shut down when not in use. For this to work well, it relies
|
||||||
|
on *chronyd* having been able to determine accurate statistics for the
|
||||||
|
difference between the RTC and system clock last time the computer was on.
|
||||||
|
+
|
||||||
|
If the last modification time of the drift file is later than both the current
|
||||||
|
time and the RTC time, the system time will be set to it to restore the time
|
||||||
|
when *chronyd* was previously stopped. This is useful on computers that have no
|
||||||
|
RTC or the RTC is broken (e.g. it has no battery).
|
||||||
|
|
||||||
|
*-t* _timeout_::
|
||||||
|
This option sets a timeout (in seconds) after which *chronyd* will exit. If the
|
||||||
|
clock is not synchronised, it will exit with a non-zero status. This is useful
|
||||||
|
with the *-q* or *-Q* option to shorten the maximum time waiting for
|
||||||
|
measurements, or with the *-r* option to limit the time when *chronyd* is
|
||||||
|
running, but still allow it to adjust the frequency of the system clock.
|
||||||
|
|
||||||
|
*-u* _user_::
|
||||||
|
This option sets the name of the system user to which *chronyd* will switch
|
||||||
|
after start in order to drop root privileges. It overrides the
|
||||||
|
<<chrony.conf.adoc#user,*user*>> directive. The compiled-in default value is
|
||||||
|
_@DEFAULT_USER@_.
|
||||||
|
+
|
||||||
|
On Linux, *chronyd* needs to be compiled with support for the *libcap* library.
|
||||||
|
On macOS, FreeBSD, NetBSD and Solaris *chronyd* forks into two processes.
|
||||||
|
The child process retains root privileges, but can only perform a very limited
|
||||||
|
range of privileged system calls on behalf of the parent.
|
||||||
|
|
||||||
|
*-U*::
|
||||||
|
This option disables a check for root privileges to allow *chronyd* to be
|
||||||
|
started under a non-root user, assuming the process will have all capabilities
|
||||||
|
(e.g. provided by the service manager) and access to all files, directories,
|
||||||
|
and devices, needed to operate correctly in the specified configuration. Note
|
||||||
|
that different capabilities might be needed with different configurations and
|
||||||
|
different Linux kernel versions. Starting *chronyd* under a non-root user is
|
||||||
|
not recommended when the configuration is not known, or at least limited to
|
||||||
|
specific directives.
|
||||||
|
|
||||||
|
*-F* _level_::
|
||||||
|
This option configures a system call filter when *chronyd* is compiled with
|
||||||
|
support for the Linux secure computing (seccomp) facility. In level 1 the
|
||||||
|
process is killed when a forbidden system call is made, in level -1 the SIGSYS
|
||||||
|
signal is thrown instead and in level 0 the filter is disabled. The default
|
||||||
|
value is 0.
|
||||||
|
+
|
||||||
|
It is recommended to enable the filter only when it is known to work on the
|
||||||
|
version of the system where *chrony* is installed as the filter needs to allow
|
||||||
|
also system calls made from libraries that *chronyd* is using (e.g. libc) and
|
||||||
|
different versions or implementations of the libraries might make different
|
||||||
|
system calls. If the filter is missing some system call, *chronyd* could be
|
||||||
|
killed even in normal operation.
|
||||||
|
|
||||||
|
*-P* _priority_::
|
||||||
|
On Linux, this option will select the SCHED_FIFO real-time scheduler at the
|
||||||
|
specified priority (which must be between 0 and 100). On macOS, this option
|
||||||
|
must have either a value of 0 to disable the thread time
|
||||||
|
constraint policy or 1 for the policy to be enabled. Other systems do not
|
||||||
|
support this option. The default value is 0.
|
||||||
|
|
||||||
|
*-m*::
|
||||||
|
This option will lock *chronyd* into RAM so that it will never be paged out.
|
||||||
|
This mode is only supported on Linux.
|
||||||
|
|
||||||
|
*-x*::
|
||||||
|
This option disables the control of the system clock. *chronyd* will not try to
|
||||||
|
make any adjustments of the clock. It will assume the clock is free running and
|
||||||
|
still track its offset and frequency relative to the estimated true time. This
|
||||||
|
option allows *chronyd* to be started without the capability to adjust or set
|
||||||
|
the system clock (e.g. in some containers) to operate as an NTP server.
|
||||||
|
|
||||||
|
*-v*, *--version*::
|
||||||
|
With this option *chronyd* will print version number to the terminal and exit.
|
||||||
|
|
||||||
|
*-h*, *--help*::
|
||||||
|
With this option *chronyd* will print a help message to the terminal and exit.
|
||||||
|
|
||||||
|
== FILES
|
||||||
|
|
||||||
|
_@SYSCONFDIR@/chrony.conf_
|
||||||
|
|
||||||
|
== SEE ALSO
|
||||||
|
|
||||||
|
<<chronyc.adoc#,*chronyc(1)*>>, <<chrony.conf.adoc#,*chrony.conf(5)*>>
|
||||||
|
|
||||||
|
== BUGS
|
||||||
|
|
||||||
|
For instructions on how to report bugs, please visit
|
||||||
|
https://chrony.tuxfamily.org/.
|
||||||
|
|
||||||
|
== AUTHORS
|
||||||
|
|
||||||
|
chrony was written by Richard Curnow, Miroslav Lichvar, and others.
|
||||||
900
doc/faq.adoc
Normal file
900
doc/faq.adoc
Normal file
@@ -0,0 +1,900 @@
|
|||||||
|
// This file is part of chrony
|
||||||
|
//
|
||||||
|
// Copyright (C) Richard P. Curnow 1997-2003
|
||||||
|
// Copyright (C) Miroslav Lichvar 2014-2016, 2020
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of version 2 of the GNU General Public License as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
= Frequently Asked Questions
|
||||||
|
:toc:
|
||||||
|
:numbered:
|
||||||
|
|
||||||
|
== `chrony` compared to other programs
|
||||||
|
|
||||||
|
=== How does `chrony` compare to `ntpd`?
|
||||||
|
|
||||||
|
`chrony` and `ntpd` are two different implementations of the Network Time
|
||||||
|
Protocol (NTP).
|
||||||
|
|
||||||
|
`chrony` is a newer implementation, which was designed to work well in a wider
|
||||||
|
range of conditions. It can usually synchronise the system clock faster and
|
||||||
|
with better time accuracy. It has many features, but it does not implement some
|
||||||
|
of the less useful NTP modes like broadcast client or multicast server/client.
|
||||||
|
|
||||||
|
If your computer is connected to the Internet only for few minutes at a time,
|
||||||
|
the network connection is often congested, you turn your computer off or
|
||||||
|
suspend it frequently, the clock is not very stable (e.g. there are rapid
|
||||||
|
changes in the temperature or it is a virtual machine), or you want to use NTP
|
||||||
|
on an isolated network with no hardware reference clocks in sight, `chrony`
|
||||||
|
will probably work better for you.
|
||||||
|
|
||||||
|
For a more detailed comparison of features and performance, see the
|
||||||
|
https://chrony.tuxfamily.org/comparison.html[comparison page] on the `chrony`
|
||||||
|
website.
|
||||||
|
|
||||||
|
== Configuration issues
|
||||||
|
|
||||||
|
=== What is the minimum recommended configuration for an NTP client?
|
||||||
|
|
||||||
|
First, the client needs to know which NTP servers it should ask for the current
|
||||||
|
time. They are specified by the `server` or `pool` directive. The `pool`
|
||||||
|
directive is used with names that resolve to multiple addresses of different
|
||||||
|
servers. For reliable operation, the client should have at least three servers.
|
||||||
|
|
||||||
|
The `iburst` option enables a burst of requests to speed up the initial
|
||||||
|
synchronisation.
|
||||||
|
|
||||||
|
To stabilise the initial synchronisation on the next start, the estimated drift
|
||||||
|
of the system clock is saved to a file specified by the `driftfile` directive.
|
||||||
|
|
||||||
|
If the system clock can be far from the true time after boot for any reason,
|
||||||
|
`chronyd` should be allowed to correct it quickly by stepping instead of
|
||||||
|
slewing, which would take a very long time. The `makestep` directive does
|
||||||
|
that.
|
||||||
|
|
||||||
|
In order to keep the real-time clock (RTC) close to the true time, so the
|
||||||
|
system time is reasonably close to the true time when it is initialised on the
|
||||||
|
next boot from the RTC, the `rtcsync` directive enables a mode in which the
|
||||||
|
system time is periodically copied to the RTC. It is supported on Linux and
|
||||||
|
macOS.
|
||||||
|
|
||||||
|
If you wanted to use public NTP servers from the
|
||||||
|
https://www.pool.ntp.org/[pool.ntp.org] project, the minimal _chrony.conf_ file
|
||||||
|
could be:
|
||||||
|
|
||||||
|
----
|
||||||
|
pool pool.ntp.org iburst
|
||||||
|
driftfile /var/lib/chrony/drift
|
||||||
|
makestep 1 3
|
||||||
|
rtcsync
|
||||||
|
----
|
||||||
|
|
||||||
|
=== How do I make an NTP server?
|
||||||
|
|
||||||
|
By default, `chronyd` does not operate as an NTP server. You need to add an
|
||||||
|
`allow` directive to the _chrony.conf_ file in order for `chronyd` to open the
|
||||||
|
server NTP port and respond to client requests.
|
||||||
|
|
||||||
|
----
|
||||||
|
allow 192.168.1.0/24
|
||||||
|
----
|
||||||
|
|
||||||
|
An `allow` directive with no specified subnet allows access from all IPv4 and
|
||||||
|
IPv6 addresses.
|
||||||
|
|
||||||
|
=== Should all computers on a LAN be clients of an external server?
|
||||||
|
|
||||||
|
It depends on the requirements. Usually, the best configuration is to make one
|
||||||
|
computer the server, with the others as clients of it. Add a `local` directive
|
||||||
|
to the server's _chrony.conf_ file. This configuration will be better because
|
||||||
|
|
||||||
|
* the load on the external connection is less
|
||||||
|
* the load on the external NTP server(s) is less
|
||||||
|
* if your external connection goes down, the computers on the LAN
|
||||||
|
will maintain a common time with each other.
|
||||||
|
|
||||||
|
=== Must I specify servers by IP address if DNS is not available on `chronyd` start?
|
||||||
|
|
||||||
|
No, `chronyd` will keep trying to resolve
|
||||||
|
the names specified by the `server`, `pool`, and `peer` directives in an
|
||||||
|
increasing interval until it succeeds. The `online` command can be issued from
|
||||||
|
`chronyc` to force `chronyd` to try to resolve the names immediately.
|
||||||
|
|
||||||
|
=== How can I make `chronyd` more secure?
|
||||||
|
|
||||||
|
If you do not need to use `chronyc`, or you want to run `chronyc` only
|
||||||
|
under the root or _chrony_ user (which can access `chronyd` through a Unix
|
||||||
|
domain socket), you can disable the IPv4 and IPv6 command sockets (by default
|
||||||
|
listening on localhost) by adding `cmdport 0` to the configuration file.
|
||||||
|
|
||||||
|
You can specify an unprivileged user with the `-u` option, or the `user`
|
||||||
|
directive in the _chrony.conf_ file, to which `chronyd` will switch after start
|
||||||
|
in order to drop root privileges. The configure script has a `--with-user`
|
||||||
|
option, which sets the default user. On Linux, `chronyd` needs to be compiled
|
||||||
|
with support for the `libcap` library. On other systems, `chronyd` forks into
|
||||||
|
two processes. The child process retains root privileges, but can only perform
|
||||||
|
a very limited range of privileged system calls on behalf of the parent.
|
||||||
|
|
||||||
|
Also, if `chronyd` is compiled with support for the Linux secure computing
|
||||||
|
(seccomp) facility, you can enable a system call filter with the `-F` option.
|
||||||
|
It will significantly reduce the kernel attack surface and possibly prevent
|
||||||
|
kernel exploits from the `chronyd` process if it is compromised. It is
|
||||||
|
recommended to enable the filter only when it is known to work on the version of
|
||||||
|
the system where `chrony` is installed as the filter needs to allow also system
|
||||||
|
calls made from libraries that `chronyd` is using (e.g. libc) and different
|
||||||
|
versions or implementations of the libraries might make different system calls.
|
||||||
|
If the filter is missing some system call, `chronyd` could be killed even in
|
||||||
|
normal operation.
|
||||||
|
|
||||||
|
=== How can I make the system clock more secure?
|
||||||
|
|
||||||
|
An NTP client synchronising the system clock to an NTP server is susceptible to
|
||||||
|
various attacks, which can break applications and network protocols relying on
|
||||||
|
accuracy of the clock (e.g. DNSSEC, Kerberos, TLS, WireGuard).
|
||||||
|
|
||||||
|
Generally, a man-in-the-middle (MITM) attacker between the client and server
|
||||||
|
can
|
||||||
|
|
||||||
|
* make fake responses, or modify real responses from the server, to create an
|
||||||
|
arbitrarily large time and frequency offset, make the server appear more
|
||||||
|
accurate, insert a leap second, etc.
|
||||||
|
* delay the requests and/or responses to create a limited time offset and
|
||||||
|
temporarily also a limited frequency offset
|
||||||
|
* drop the requests or responses to prevent updates of the clock with new
|
||||||
|
measurements
|
||||||
|
* redirect the requests to a different server
|
||||||
|
|
||||||
|
The attacks can be combined for a greater effect. The attacker can delay
|
||||||
|
packets to create a significant frequency offset first and then drop all
|
||||||
|
subsequent packets to let the clock quickly drift away from the true time.
|
||||||
|
The attacker might also be able to control the server's clock.
|
||||||
|
|
||||||
|
Some attacks cannot be prevented. Monitoring is needed for detection, e.g. the
|
||||||
|
reachability register in the `sources` report shows missing packets. The extent
|
||||||
|
to which the attacker can control the client's clock depends on its
|
||||||
|
configuration.
|
||||||
|
|
||||||
|
Enable authentication to prevent `chronyd` from accepting modified, fake, or
|
||||||
|
redirected packets. It can be enabled with a symmetric key specified by the
|
||||||
|
`key` option, or Network Time Security (NTS) by the `nts` option (supported
|
||||||
|
since `chrony` version 4.0). The server needs to support the selected
|
||||||
|
authentication mechanism. Symmetric keys have to be configured on both client
|
||||||
|
and server, and each client must have its own key (one per server).
|
||||||
|
|
||||||
|
The maximum offset that the attacker can insert in an NTP measurement by
|
||||||
|
delaying packets can be limited by the `maxdelay` option. The default value is
|
||||||
|
3 seconds. The measured delay is reported as the peer delay in the `ntpdata`
|
||||||
|
report and `measurements` log. Set the `maxdelay` option to a value larger than
|
||||||
|
the maximum value that is normally observed. Note that the delay can increase
|
||||||
|
significantly even when not under an attack, e.g. when the network is congested
|
||||||
|
or the routing has changed.
|
||||||
|
|
||||||
|
The maximum accepted change in time offset between clock updates can be limited
|
||||||
|
by the `maxchange` directive. Larger changes in the offset will be ignored or
|
||||||
|
cause `chronyd` to exit. Note that the attacker can get around this limit by
|
||||||
|
splitting the offset into multiple smaller offsets and/or creating a large
|
||||||
|
frequency offset. When this directive is used, `chronyd` will have to be
|
||||||
|
restarted after a successful attack. It will not be able to recover on its own.
|
||||||
|
It must not be restarted automatically (e.g. by the service manager).
|
||||||
|
|
||||||
|
The impact of a large accepted time offset can be reduced by disabling clock
|
||||||
|
steps, i.e. by not using the `makestep` and `initstepslew` directives. The
|
||||||
|
offset will be slowly corrected by speeding up or slowing down the clock at a
|
||||||
|
rate which can be limited by the `maxslewrate` directive. Disabling clock steps
|
||||||
|
completely is practical only if the clock cannot gain a larger error on its
|
||||||
|
own, e.g. when the computer is shut down or suspended, and the `maxslewrate`
|
||||||
|
limit is large enough to correct an expected error in an acceptable time. The
|
||||||
|
`rtcfile` directive with the `-s` option can be used to compensate for the RTC
|
||||||
|
drift.
|
||||||
|
|
||||||
|
A more practical approach is to enable `makestep` for a limited number of clock
|
||||||
|
updates (the 2nd argument of the directive) and limit the offset change in all
|
||||||
|
updates by the `maxchange` directive. The attacker will be able to make only a
|
||||||
|
limited step and only if the attack starts in a short window after booting the
|
||||||
|
computer, or when `chronyd` is restarted without the `-R` option.
|
||||||
|
|
||||||
|
The frequency offset can be limited by the `maxdrift` directive. The measured
|
||||||
|
frequency offset is reported in the drift file, `tracking` report, and
|
||||||
|
`tracking` log. Set `maxdrift` to a value larger than the maximum absolute
|
||||||
|
value that is normally observed. Note that the frequency of the clock can
|
||||||
|
change due to aging of the crystal, differences in calibration of the clock
|
||||||
|
source between reboots, migrated virtual machine, etc. A typical computer clock
|
||||||
|
has a drift smaller than 100 parts per million (ppm), but much larger drifts
|
||||||
|
are possible (e.g. in some virtual machines).
|
||||||
|
|
||||||
|
Use only trusted servers, which you expect to be well configured and managed,
|
||||||
|
using authentication for their own servers, etc. Use multiple servers, ideally
|
||||||
|
in different locations. The attacker will have to deal with a majority of the
|
||||||
|
servers in order to pass the source selection and update the clock with a large
|
||||||
|
offset. Use the `minsources` directive to increase the required number of
|
||||||
|
selectable sources to make the selection more robust.
|
||||||
|
|
||||||
|
Do not specify servers as peers. The symmetric mode is less secure than the
|
||||||
|
client/server mode. If not authenticated, it is vulnerable to off-path
|
||||||
|
denial-of-service attacks, and even when it is authenticated, it is still
|
||||||
|
susceptible to replay attacks.
|
||||||
|
|
||||||
|
Mixing of authenticated and unauthenticated servers should generally be
|
||||||
|
avoided. If mixing is necessary (e.g. for a more accurate and stable
|
||||||
|
synchronisation to a closer server which does not support authentication), the
|
||||||
|
authenticated servers should be configured as trusted and required to not allow
|
||||||
|
the unauthenticated servers to override the authenticated servers in the source
|
||||||
|
selection. Since `chrony` version 4.0, the selection options are enabled in
|
||||||
|
such a case automatically. This behaviour can be disabled or modified by the
|
||||||
|
`authselmode` directive.
|
||||||
|
|
||||||
|
An example of a client configuration limiting the impact of the attacks could
|
||||||
|
be
|
||||||
|
|
||||||
|
----
|
||||||
|
server foo.example.net iburst nts maxdelay 0.1
|
||||||
|
server bar.example.net iburst nts maxdelay 0.2
|
||||||
|
server baz.example.net iburst nts maxdelay 0.05
|
||||||
|
server qux.example.net iburst nts maxdelay 0.1
|
||||||
|
server quux.example.net iburst nts maxdelay 0.1
|
||||||
|
minsources 3
|
||||||
|
maxchange 100 0 0
|
||||||
|
makestep 0.001 1
|
||||||
|
maxdrift 100
|
||||||
|
maxslewrate 100
|
||||||
|
driftfile /var/lib/chrony/drift
|
||||||
|
ntsdumpdir /var/lib/chrony
|
||||||
|
rtcsync
|
||||||
|
----
|
||||||
|
|
||||||
|
=== How can I improve the accuracy of the system clock with NTP sources?
|
||||||
|
|
||||||
|
Select NTP servers that are well synchronised, stable and close to your
|
||||||
|
network. It is better to use more than one server. Three or four is usually
|
||||||
|
recommended as the minimum, so `chronyd` can detect servers that serve false
|
||||||
|
time and combine measurements from multiple sources.
|
||||||
|
|
||||||
|
If you have a network card with hardware timestamping supported on Linux, it
|
||||||
|
can be enabled by the `hwtimestamp` directive. It should make local receive and
|
||||||
|
transmit timestamps of NTP packets much more stable and accurate.
|
||||||
|
|
||||||
|
The `server` directive has some useful options: `minpoll`, `maxpoll`,
|
||||||
|
`polltarget`, `maxdelay`, `maxdelayratio`, `maxdelaydevratio`, `xleave`,
|
||||||
|
`filter`.
|
||||||
|
|
||||||
|
The first three options set the minimum and maximum allowed polling interval,
|
||||||
|
and how should be the actual interval adjusted in the specified range. Their
|
||||||
|
default values are 6 (64 seconds) for `minpoll`, 10 (1024 seconds) for
|
||||||
|
`maxpoll` and 8 (samples) for `polltarget`. The default values should be used
|
||||||
|
for general servers on the Internet. With your own NTP servers, or if you have
|
||||||
|
permission to poll some servers more frequently, setting these options for
|
||||||
|
shorter polling intervals might significantly improve the accuracy of the
|
||||||
|
system clock.
|
||||||
|
|
||||||
|
The optimal polling interval depends mainly on two factors, stability of the
|
||||||
|
network latency and stability of the system clock (which mainly depends on the
|
||||||
|
temperature sensitivity of the crystal oscillator and the maximum rate of the
|
||||||
|
temperature change).
|
||||||
|
|
||||||
|
Generally, if the `sourcestats` command usually reports a small number of
|
||||||
|
samples retained for a source (e.g. fewer than 16), a shorter polling interval
|
||||||
|
should be considered. If the number of samples is usually at the maximum of 64,
|
||||||
|
a longer polling interval might work better.
|
||||||
|
|
||||||
|
An example of the directive for an NTP server on the Internet that you are
|
||||||
|
allowed to poll frequently could be
|
||||||
|
|
||||||
|
----
|
||||||
|
server foo.example.net minpoll 4 maxpoll 6 polltarget 16
|
||||||
|
----
|
||||||
|
|
||||||
|
An example using shorter polling intervals with a server located in the same
|
||||||
|
LAN could be
|
||||||
|
|
||||||
|
----
|
||||||
|
server ntp.local minpoll 2 maxpoll 4 polltarget 30
|
||||||
|
----
|
||||||
|
|
||||||
|
The maxdelay options are useful to ignore measurements with an unusually large
|
||||||
|
delay (e.g. due to congestion in the network) and improve the stability of the
|
||||||
|
synchronisation. The `maxdelaydevratio` option could be added to the example
|
||||||
|
with local NTP server
|
||||||
|
|
||||||
|
----
|
||||||
|
server ntp.local minpoll 2 maxpoll 4 polltarget 30 maxdelaydevratio 2
|
||||||
|
----
|
||||||
|
|
||||||
|
If your server supports the interleaved mode (e.g. it is running `chronyd`),
|
||||||
|
the `xleave` option should be added to the `server` directive to enable the
|
||||||
|
server to provide the client with more accurate transmit timestamps (kernel or
|
||||||
|
preferably hardware). For example:
|
||||||
|
|
||||||
|
----
|
||||||
|
server ntp.local minpoll 2 maxpoll 4 xleave
|
||||||
|
----
|
||||||
|
|
||||||
|
When combined with local hardware timestamping, good network switches, and even
|
||||||
|
shorter polling intervals, a sub-microsecond accuracy and stability of a few
|
||||||
|
tens of nanoseconds might be possible. For example:
|
||||||
|
|
||||||
|
----
|
||||||
|
server ntp.local minpoll 0 maxpoll 0 xleave
|
||||||
|
hwtimestamp eth0
|
||||||
|
----
|
||||||
|
|
||||||
|
For best stability, the CPU should be running at a constant frequency (i.e.
|
||||||
|
disabled power saving and performance boosting). Energy-Efficient Ethernet
|
||||||
|
(EEE) should be disabled in the network. The switches should be configured to
|
||||||
|
prioritize NTP packets, especially if the network is expected to be heavily
|
||||||
|
loaded. The `dscp` directive can be used to set the Differentiated Services
|
||||||
|
Code Point in transmitted NTP packets if needed.
|
||||||
|
|
||||||
|
If it is acceptable for NTP clients in the network to send requests at a high
|
||||||
|
rate, a sub-second polling interval can be specified. A median filter
|
||||||
|
can be enabled in order to update the clock at a reduced rate with more stable
|
||||||
|
measurements. For example:
|
||||||
|
|
||||||
|
----
|
||||||
|
server ntp.local minpoll -6 maxpoll -6 filter 15 xleave
|
||||||
|
hwtimestamp eth0 minpoll -6
|
||||||
|
----
|
||||||
|
|
||||||
|
=== Does `chronyd` have an ntpdate mode?
|
||||||
|
|
||||||
|
Yes. With the `-q` option `chronyd` will set the system clock once and exit.
|
||||||
|
With the `-Q` option it will print the measured offset without setting the
|
||||||
|
clock. If you do not want to use a configuration file, NTP servers can be
|
||||||
|
specified on the command line. For example:
|
||||||
|
|
||||||
|
----
|
||||||
|
# chronyd -q 'pool pool.ntp.org iburst'
|
||||||
|
----
|
||||||
|
|
||||||
|
The command above would normally take about 5 seconds if the servers were
|
||||||
|
well synchronised and responding to all requests. If not synchronised or
|
||||||
|
responding, it would take about 10 seconds for `chronyd` to give up and exit
|
||||||
|
with a non-zero status. A faster configuration is possible. A single server can
|
||||||
|
be used instead of four servers, the number of measurements can be reduced with
|
||||||
|
the `maxsamples` option to one (supported since `chrony` version 4.0), and a
|
||||||
|
timeout can be specified with the `-t` option. The following command would take
|
||||||
|
only up to about one second.
|
||||||
|
|
||||||
|
----
|
||||||
|
# chronyd -q -t 1 'server pool.ntp.org iburst maxsamples 1'
|
||||||
|
----
|
||||||
|
|
||||||
|
It is not recommended to run `chronyd` with the `-q` option periodically (e.g.
|
||||||
|
from a cron job) as a replacement for the daemon mode, because it performs
|
||||||
|
significantly worse (e.g. the clock is stepped and its frequency is not
|
||||||
|
corrected). If you must run it this way and you are using a public NTP server,
|
||||||
|
make sure `chronyd` does not always start around the first second of a minute,
|
||||||
|
e.g. by adding a random sleep before the `chronyd` command. Public servers
|
||||||
|
typically receive large bursts of requests around the first second as there is
|
||||||
|
a large number of NTP clients started from cron with no delay.
|
||||||
|
|
||||||
|
=== Can `chronyd` be configured to control the clock like `ntpd`?
|
||||||
|
|
||||||
|
It is not possible to perfectly emulate `ntpd`, but there are some options that
|
||||||
|
can configure `chronyd` to behave more like `ntpd` if there is a reason to
|
||||||
|
prefer that.
|
||||||
|
|
||||||
|
In the following example the `minsamples` directive slows down the response to
|
||||||
|
changes in the frequency and offset of the clock. The `maxslewrate` and
|
||||||
|
`corrtimeratio` directives reduce the maximum frequency error due to an offset
|
||||||
|
correction and the `maxdrift` directive reduces the maximum assumed frequency
|
||||||
|
error of the clock. The `makestep` directive enables a step threshold and the
|
||||||
|
`maxchange` directive enables a panic threshold. The `maxclockerror` directive
|
||||||
|
increases the minimum dispersion rate.
|
||||||
|
|
||||||
|
----
|
||||||
|
minsamples 32
|
||||||
|
maxslewrate 500
|
||||||
|
corrtimeratio 100
|
||||||
|
maxdrift 500
|
||||||
|
makestep 0.128 -1
|
||||||
|
maxchange 1000 1 1
|
||||||
|
maxclockerror 15
|
||||||
|
----
|
||||||
|
|
||||||
|
Note that increasing `minsamples` might cause the offsets in the `tracking` and
|
||||||
|
`sourcestats` reports/logs to be significantly smaller than the actual offsets
|
||||||
|
and be unsuitable for monitoring.
|
||||||
|
|
||||||
|
=== Can NTP server be separated from NTP client?
|
||||||
|
|
||||||
|
Yes, it is possible to run multiple instances of `chronyd` on a computer at the
|
||||||
|
same time. One can operate primarily as an NTP client to synchronise the system
|
||||||
|
clock and another as a server for other computers. If they use the same
|
||||||
|
filesystem, they need to be configured with different pidfiles, Unix domain
|
||||||
|
command sockets, and any other file or directory specified in the configuration
|
||||||
|
file. If they run in the same network namespace, they need to use different NTP
|
||||||
|
and command ports, or bind the ports to different addresses or interfaces.
|
||||||
|
|
||||||
|
The server instance should be started with the `-x` option to prevent it from
|
||||||
|
adjusting the system clock and interfering with the client instance. It can be
|
||||||
|
configured as a client to synchronise its NTP clock to other servers, or the
|
||||||
|
client instance running on the same computer. In the latter case, the `copy`
|
||||||
|
option (added in `chrony` version 4.1) can be used to assume the reference ID
|
||||||
|
and stratum of the client instance, which enables detection of synchronisation
|
||||||
|
loops with its own clients.
|
||||||
|
|
||||||
|
On Linux, starting with `chrony` version 4.0, it is possible to run multiple
|
||||||
|
server instances sharing a port to better utilise multiple cores of the CPU.
|
||||||
|
Note that for rate limiting and client/server interleaved mode to work well
|
||||||
|
it is necessary that all packets received from the same address are handled by
|
||||||
|
the same server instance.
|
||||||
|
|
||||||
|
An example configuration of the client instance could be
|
||||||
|
|
||||||
|
----
|
||||||
|
pool pool.ntp.org iburst
|
||||||
|
allow 127.0.0.1
|
||||||
|
port 11123
|
||||||
|
driftfile /var/lib/chrony/drift
|
||||||
|
makestep 1 3
|
||||||
|
rtcsync
|
||||||
|
----
|
||||||
|
|
||||||
|
and configuration of the first server instance could be
|
||||||
|
|
||||||
|
----
|
||||||
|
server 127.0.0.1 port 11123 minpoll 0 maxpoll 0 copy
|
||||||
|
allow
|
||||||
|
cmdport 11323
|
||||||
|
bindcmdaddress /var/run/chrony/chronyd-server1.sock
|
||||||
|
pidfile /var/run/chronyd-server1.pid
|
||||||
|
driftfile /var/lib/chrony/drift-server1
|
||||||
|
----
|
||||||
|
|
||||||
|
=== Should be a leap smear enabled on NTP server?
|
||||||
|
|
||||||
|
With the `smoothtime` and `leapsecmode` directives it is possible to enable a
|
||||||
|
server leap smear in order to hide leap seconds from clients and force them to
|
||||||
|
follow a slow server's adjustment instead.
|
||||||
|
|
||||||
|
This feature should be used only in local networks and only when necessary,
|
||||||
|
e.g. when the clients cannot be configured to handle the leap seconds as
|
||||||
|
needed, or their number is so large that configuring them all would be
|
||||||
|
impractical. The clients should use only one leap-smearing server, or multiple
|
||||||
|
identically configured leap-smearing servers. Note that some clients can get
|
||||||
|
leap seconds from other sources (e.g. with the `leapsectz` directive in
|
||||||
|
`chrony`) and they will not work correctly with a leap smearing server.
|
||||||
|
|
||||||
|
=== Does `chrony` support PTP?
|
||||||
|
|
||||||
|
No, the Precision Time Protocol (PTP) is not supported and there are no plans
|
||||||
|
to support it. It is a complex protocol, which shares some issues with the
|
||||||
|
NTP broadcast mode. One of the main differences between NTP and PTP is that PTP
|
||||||
|
was designed to be easily supported in hardware (e.g. network switches and
|
||||||
|
routers) in order to make more stable and accurate measurements. PTP relies on
|
||||||
|
the hardware support. NTP does not rely on any support in the hardware, but if
|
||||||
|
it had the same support as PTP, it could perform equally well.
|
||||||
|
|
||||||
|
On Linux, `chrony` supports hardware clocks that some NICs have for PTP. They
|
||||||
|
are called PTP hardware clocks (PHC). They can be used as reference clocks
|
||||||
|
(specified by the `refclock` directive) and for hardware timestamping of NTP
|
||||||
|
packets (enabled by the `hwtimestamp` directive) if the NIC can timestamp other
|
||||||
|
packets than PTP, which is usually the case at least for transmitted packets.
|
||||||
|
The `ethtool -T` command can be used to verify the timestamping support.
|
||||||
|
|
||||||
|
=== What happened to the `commandkey` and `generatecommandkey` directives?
|
||||||
|
|
||||||
|
They were removed in version 2.2. Authentication is no longer supported in the
|
||||||
|
command protocol. Commands that required authentication are now allowed only
|
||||||
|
through a Unix domain socket, which is accessible only by the root and _chrony_
|
||||||
|
users. If you need to configure `chronyd` remotely or locally without the root
|
||||||
|
password, please consider using ssh and/or sudo to run `chronyc` under the root
|
||||||
|
or _chrony_ user on the host where `chronyd` is running.
|
||||||
|
|
||||||
|
== Computer is not synchronising
|
||||||
|
|
||||||
|
This is the most common problem. There are a number of reasons, see the
|
||||||
|
following questions.
|
||||||
|
|
||||||
|
=== Behind a firewall?
|
||||||
|
|
||||||
|
Check the `Reach` value printed by the ``chronyc``'s `sources` command. If it
|
||||||
|
is zero, it means `chronyd` did not get any valid responses from the NTP server
|
||||||
|
you are trying to use. If there is a firewall between you and the server, the
|
||||||
|
packets might be blocked. Try using a tool like `wireshark` or `tcpdump` to see
|
||||||
|
if you are getting any responses from the server.
|
||||||
|
|
||||||
|
When `chronyd` is receiving responses from the servers, the output of the
|
||||||
|
`sources` command issued few minutes after `chronyd` start might look like
|
||||||
|
this:
|
||||||
|
|
||||||
|
----
|
||||||
|
MS Name/IP address Stratum Poll Reach LastRx Last sample
|
||||||
|
===============================================================================
|
||||||
|
^* foo.example.net 2 6 377 34 +484us[ -157us] +/- 30ms
|
||||||
|
^- bar.example.net 2 6 377 34 +33ms[ +32ms] +/- 47ms
|
||||||
|
^+ baz.example.net 3 6 377 35 -1397us[-2033us] +/- 60ms
|
||||||
|
----
|
||||||
|
|
||||||
|
=== Are NTP servers specified with the `offline` option?
|
||||||
|
|
||||||
|
Check that the ``chronyc``'s `online` and `offline` commands are used
|
||||||
|
appropriately (e.g. in the system networking scripts). The `activity` command
|
||||||
|
prints the number of sources that are currently online and offline. For
|
||||||
|
example:
|
||||||
|
|
||||||
|
----
|
||||||
|
200 OK
|
||||||
|
3 sources online
|
||||||
|
0 sources offline
|
||||||
|
0 sources doing burst (return to online)
|
||||||
|
0 sources doing burst (return to offline)
|
||||||
|
0 sources with unknown address
|
||||||
|
----
|
||||||
|
|
||||||
|
=== Is name resolution working correctly?
|
||||||
|
|
||||||
|
NTP servers specified by their hostname (instead of an IP address) have to have
|
||||||
|
their names resolved before `chronyd` can send any requests to them. If the
|
||||||
|
`activity` command prints a non-zero number of sources with unknown address,
|
||||||
|
there is an issue with the resolution. Typically, a DNS server is specified in
|
||||||
|
_/etc/resolv.conf_. Make sure it is working correctly.
|
||||||
|
|
||||||
|
Since `chrony` version 4.0, you can run `chronyc -N sources -a` command to
|
||||||
|
print all sources, even those that do not have a known address yet, with their
|
||||||
|
names as they were specified in the configuration. This can be useful to verify
|
||||||
|
that the names specified in the configuration are used as expected.
|
||||||
|
|
||||||
|
=== Is `chronyd` allowed to step the system clock?
|
||||||
|
|
||||||
|
By default, `chronyd` adjusts the clock gradually by slowing it down or
|
||||||
|
speeding it up. If the clock is too far from the true time, it will take
|
||||||
|
a long time to correct the error. The `System time` value printed by the
|
||||||
|
``chronyc``'s `tracking` command is the remaining correction that needs to be
|
||||||
|
applied to the system clock.
|
||||||
|
|
||||||
|
The `makestep` directive can be used to allow `chronyd` to step the clock. For
|
||||||
|
example, if _chrony.conf_ had
|
||||||
|
|
||||||
|
----
|
||||||
|
makestep 1 3
|
||||||
|
----
|
||||||
|
|
||||||
|
the clock would be stepped in the first three updates if its offset was larger
|
||||||
|
than one second. Normally, it is recommended to allow the step only in the first
|
||||||
|
few updates, but in some cases (e.g. a computer without an RTC or virtual
|
||||||
|
machine which can be suspended and resumed with an incorrect time) it might be
|
||||||
|
necessary to allow the step on any clock update. The example above would change
|
||||||
|
to
|
||||||
|
|
||||||
|
----
|
||||||
|
makestep 1 -1
|
||||||
|
----
|
||||||
|
|
||||||
|
=== Using NTS?
|
||||||
|
|
||||||
|
The Network Time Security (NTS) mechanism uses Transport Layer Security (TLS)
|
||||||
|
to establish the keys needed for authentication of NTP packets.
|
||||||
|
|
||||||
|
Run the `authdata` command to check whether the key establishment was
|
||||||
|
successful:
|
||||||
|
|
||||||
|
----
|
||||||
|
# chronyc -N authdata
|
||||||
|
Name/IP address Mode KeyID Type KLen Last Atmp NAK Cook CLen
|
||||||
|
=========================================================================
|
||||||
|
foo.example.net NTS 1 15 256 33m 0 0 8 100
|
||||||
|
bar.example.net NTS 1 15 256 33m 0 0 8 100
|
||||||
|
baz.example.net NTS 1 15 256 33m 0 0 8 100
|
||||||
|
----
|
||||||
|
|
||||||
|
The KeyID, Type, and KLen columns should have non-zero values. If they are
|
||||||
|
zero, check the system log for error messages from `chronyd`. One possible
|
||||||
|
cause of failure is a firewall blocking the client's connection to the server's
|
||||||
|
TCP port 4460.
|
||||||
|
|
||||||
|
Another possible cause of failure is a certificate that is failing to verify
|
||||||
|
because the client's clock is wrong. This is a chicken-and-egg problem with NTS.
|
||||||
|
You might need to manually correct the date, or temporarily disable NTS, in
|
||||||
|
order to get NTS working. If your computer has an RTC and it is backed up by a
|
||||||
|
good battery, this operation should be needed only once, assuming the RTC will
|
||||||
|
be set periodically with the `rtcsync` directive, or compensated with the
|
||||||
|
`rtcfile` directive and the `-s` option.
|
||||||
|
|
||||||
|
If the computer does not have an RTC or battery, you can use the `-s` option
|
||||||
|
without `rtcfile` directive to restore time of the last shutdown or reboot from
|
||||||
|
the drift file. The clock will start behind the true time, but if the computer
|
||||||
|
was not shut down for too long and the server's certificate was not renewed too
|
||||||
|
close to its expiration, it should be sufficient for the time checks to
|
||||||
|
succeed.
|
||||||
|
|
||||||
|
As a last resort, you can disable the time checks by the `nocerttimecheck`
|
||||||
|
directive. This has some important security implications. To reduce the
|
||||||
|
security risk, you can use the `nosystemcert` and `ntstrustedcerts` directives
|
||||||
|
to disable the system's default trusted certificate authorities and trust only
|
||||||
|
a minimal set of selected authorities needed to validate the certificates of
|
||||||
|
used NTP servers.
|
||||||
|
|
||||||
|
=== Using a Windows NTP server?
|
||||||
|
|
||||||
|
A common issue with Windows NTP servers is that they report a very large root
|
||||||
|
dispersion (e.g. three seconds or more), which causes `chronyd` to ignore the
|
||||||
|
server for being too inaccurate. The `sources` command might show a valid
|
||||||
|
measurement, but the server is not selected for synchronisation. You can check
|
||||||
|
the root dispersion of the server with the ``chronyc``'s `ntpdata` command.
|
||||||
|
|
||||||
|
The `maxdistance` value needs to be increased in _chrony.conf_ to enable
|
||||||
|
synchronisation to such a server. For example:
|
||||||
|
|
||||||
|
----
|
||||||
|
maxdistance 16.0
|
||||||
|
----
|
||||||
|
|
||||||
|
=== An unreachable source is selected?
|
||||||
|
|
||||||
|
When `chronyd` is configured with multiple time sources, it tries to select the
|
||||||
|
most accurate and stable sources for synchronisation of the system clock. They
|
||||||
|
are marked with the _*_ or _+_ symbol in the report printed by the `sources`
|
||||||
|
command.
|
||||||
|
|
||||||
|
When the best source (marked with the _*_ symbol) becomes unreachable (e.g. NTP
|
||||||
|
server stops responding), `chronyd` will not immediately switch
|
||||||
|
to the second best source in an attempt to minimise the error of the clock. It
|
||||||
|
will let the clock run free for as long as its estimated error (in terms of
|
||||||
|
root distance) based on previous measurements is smaller than the estimated
|
||||||
|
error of the second source, and there is still an interval which contains some
|
||||||
|
measurements from both sources.
|
||||||
|
|
||||||
|
If the first source was significantly better than the second source, it can
|
||||||
|
take many hours before the second source is selected, depending on its polling
|
||||||
|
interval. You can force a faster reselection by increasing the clock error rate
|
||||||
|
(`maxclockerror` directive), shortening the polling interval (`maxpoll`
|
||||||
|
option), or reducing the number of samples (`maxsamples` option).
|
||||||
|
|
||||||
|
=== Does selected source drop new measurements?
|
||||||
|
|
||||||
|
`chronyd` can drop a large number of successive NTP measurements if they are
|
||||||
|
not passing some of the NTP tests. The `sources` command can report for a
|
||||||
|
selected source the fully-reachable value of 377 in the Reach column and at the
|
||||||
|
same time a LastRx value that is much larger than the current polling interval.
|
||||||
|
If the source is online, this indicates that a number of measurements was
|
||||||
|
dropped. You can use the `ntpdata` command to check the NTP tests for the last
|
||||||
|
measurement. Usually, it is the test C which fails.
|
||||||
|
|
||||||
|
This can be an issue when there is a long-lasting increase in the measured
|
||||||
|
delay, e.g. due to a routing change in the network. Unfortunately, `chronyd`
|
||||||
|
does not know for how long it should wait for the delay to come back to the
|
||||||
|
original values, or whether it is a permanent increase and it should start from
|
||||||
|
scratch.
|
||||||
|
|
||||||
|
The test C is an adaptive filter. It can take many hours before it accepts
|
||||||
|
a measurement with the larger delay, and even much longer before it drops all
|
||||||
|
measurements with smaller delay, which determine an expected delay used by the
|
||||||
|
test. You can use the `reset sources` command to drop all measurements
|
||||||
|
immediately (available in chrony 4.0 and later). If this issue happens
|
||||||
|
frequently, you can effectively disable the test by setting the
|
||||||
|
`maxdelaydevratio` option to a very large value (e.g. 1000000), or speed up the
|
||||||
|
recovery by increasing the clock error rate with the `maxclockerror` directive.
|
||||||
|
|
||||||
|
=== Using a PPS reference clock?
|
||||||
|
|
||||||
|
A pulse-per-second (PPS) reference clock requires a non-PPS time source to
|
||||||
|
determine which second of UTC corresponds to each pulse. If it is another
|
||||||
|
reference clock specified with the `lock` option in the `refclock` directive,
|
||||||
|
the offset between the two reference clocks must be smaller than 0.2 seconds in
|
||||||
|
order for the PPS reference clock to work. With NMEA reference clocks it is
|
||||||
|
common to have a larger offset. It needs to be corrected with the `offset`
|
||||||
|
option.
|
||||||
|
|
||||||
|
One approach to find out a good value of the `offset` option is to configure
|
||||||
|
the reference clocks with the `noselect` option and compare them to an NTP
|
||||||
|
server. For example, if the `sourcestats` command showed
|
||||||
|
|
||||||
|
----
|
||||||
|
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
|
||||||
|
==============================================================================
|
||||||
|
PPS0 0 0 0 +0.000 2000.000 +0ns 4000ms
|
||||||
|
NMEA 58 30 231 -96.494 38.406 +504ms 6080us
|
||||||
|
foo.example.net 7 3 200 -2.991 16.141 -107us 492us
|
||||||
|
----
|
||||||
|
|
||||||
|
the offset of the NMEA source would need to be increased by about 0.504
|
||||||
|
seconds. It does not have to be very accurate. As long as the offset of the
|
||||||
|
NMEA reference clock stays below 0.2 seconds, the PPS reference clock should be
|
||||||
|
able to determine the seconds corresponding to the pulses and allow the samples
|
||||||
|
to be used for synchronisation.
|
||||||
|
|
||||||
|
== Issues with `chronyc`
|
||||||
|
|
||||||
|
=== I keep getting the error `506 Cannot talk to daemon`
|
||||||
|
|
||||||
|
When accessing `chronyd` remotely, make sure that the _chrony.conf_ file (on
|
||||||
|
the computer where `chronyd` is running) has a `cmdallow` entry for the
|
||||||
|
computer you are running `chronyc` on and an appropriate `bindcmdaddress`
|
||||||
|
directive. This is not necessary for localhost.
|
||||||
|
|
||||||
|
Perhaps `chronyd` is not running. Try using the `ps` command (e.g. on Linux,
|
||||||
|
`ps -auxw`) to see if it is running. Or try `netstat -a` and see if the UDP
|
||||||
|
port 323 is listening. If `chronyd` is not running, you might have a problem
|
||||||
|
with the way you are trying to start it (e.g. at boot time).
|
||||||
|
|
||||||
|
Perhaps you have a firewall set up in a way that blocks packets on the UDP
|
||||||
|
port 323. You need to amend the firewall configuration in this case.
|
||||||
|
|
||||||
|
=== I keep getting the error `501 Not authorised`
|
||||||
|
|
||||||
|
This error indicates that `chronyc` sent the command to `chronyd` using a UDP
|
||||||
|
socket instead of the Unix domain socket (e.g. _/var/run/chrony/chronyd.sock_),
|
||||||
|
which is required for some commands. For security reasons, only the root and
|
||||||
|
_chrony_ users are allowed to access the socket.
|
||||||
|
|
||||||
|
It is also possible that the socket does not exist. `chronyd` will not create
|
||||||
|
the socket if the directory has a wrong owner or permissions. In this case
|
||||||
|
there should be an error message from `chronyd` in the system log.
|
||||||
|
|
||||||
|
=== What is the reference ID reported by the `tracking` command?
|
||||||
|
|
||||||
|
The reference ID is a 32-bit value used in NTP to prevent synchronisation
|
||||||
|
loops.
|
||||||
|
|
||||||
|
In `chrony` versions before 3.0 it was printed in the
|
||||||
|
quad-dotted notation, even if the reference source did not actually have an
|
||||||
|
IPv4 address. For IPv4 addresses, the reference ID is equal to the address, but
|
||||||
|
for IPv6 addresses it is the first 32 bits of the MD5 sum of the address. For
|
||||||
|
reference clocks, the reference ID is the value specified with the `refid`
|
||||||
|
option in the `refclock` directive.
|
||||||
|
|
||||||
|
Since version 3.0, the reference ID is printed as a hexadecimal number to avoid
|
||||||
|
confusion with IPv4 addresses.
|
||||||
|
|
||||||
|
If you need to get the IP address of the current reference source, use the `-n`
|
||||||
|
option to disable resolving of IP addresses and read the second field (printed
|
||||||
|
in parentheses) on the `Reference ID` line.
|
||||||
|
|
||||||
|
=== Is the `chronyc` / `chronyd` protocol documented anywhere?
|
||||||
|
|
||||||
|
Only by the source code. See _cmdmon.c_ (`chronyd` side) and _client.c_
|
||||||
|
(`chronyc` side).
|
||||||
|
|
||||||
|
== Real-time clock issues
|
||||||
|
|
||||||
|
=== What is the real-time clock (RTC)?
|
||||||
|
|
||||||
|
This is the clock which keeps the time even when your computer is turned off.
|
||||||
|
It is used to initialise the system clock on boot. It normally does not drift
|
||||||
|
more than few seconds per day.
|
||||||
|
|
||||||
|
There are two approaches how `chronyd` can work with it. One is to use the
|
||||||
|
`rtcsync` directive, which tells `chronyd` to enable a kernel mode which sets
|
||||||
|
the RTC from the system clock every 11 minutes. `chronyd` itself will not touch
|
||||||
|
the RTC. If the computer is not turned off for a long time, the RTC should
|
||||||
|
still be close to the true time when the system clock will be initialised from
|
||||||
|
it on the next boot.
|
||||||
|
|
||||||
|
The other option is to use the `rtcfile` directive, which tells `chronyd` to
|
||||||
|
monitor the rate at which the RTC gains or loses time. When `chronyd` is
|
||||||
|
started with the `-s` option on the next boot, it will set the system time from
|
||||||
|
the RTC and also compensate for the drift it has measured previously. The
|
||||||
|
`rtcautotrim` directive can be used to keep the RTC close to the true time, but
|
||||||
|
it is not strictly necessary if its only purpose is to set the system clock when
|
||||||
|
`chronyd` is started on boot. See the documentation for details.
|
||||||
|
|
||||||
|
=== Does `hwclock` have to be disabled?
|
||||||
|
|
||||||
|
The `hwclock` program is run by default in the boot and/or shutdown
|
||||||
|
scripts in some Linux installations. With the kernel RTC synchronisation
|
||||||
|
(`rtcsync` directive), the RTC will be set also every 11 minutes as long as the
|
||||||
|
system clock is synchronised. If you want to use ``chronyd``'s RTC monitoring
|
||||||
|
(`rtcfile` directive), it is important to disable `hwclock` in the shutdown
|
||||||
|
procedure. If you do not do that, it will overwrite the RTC with a new value, unknown
|
||||||
|
to `chronyd`. At the next reboot, `chronyd` started with the `-s` option will
|
||||||
|
compensate this (wrong) time with its estimate of how far the RTC has drifted
|
||||||
|
whilst the power was off, giving a meaningless initial system time.
|
||||||
|
|
||||||
|
There is no need to remove `hwclock` from the boot process, as long as `chronyd`
|
||||||
|
is started after it has run.
|
||||||
|
|
||||||
|
=== I just keep getting the `513 RTC driver not running` message
|
||||||
|
|
||||||
|
For the real-time clock support to work, you need the following three
|
||||||
|
things
|
||||||
|
|
||||||
|
* an RTC in your computer
|
||||||
|
* a Linux kernel with enabled RTC support
|
||||||
|
* an `rtcfile` directive in your _chrony.conf_ file
|
||||||
|
|
||||||
|
=== I get `Could not open /dev/rtc, Device or resource busy` in my syslog file
|
||||||
|
|
||||||
|
Some other program running on the system might be using the device.
|
||||||
|
|
||||||
|
=== When I start `chronyd`, the log says `Could not enable RTC interrupt : Invalid argument` (or it may say `disable`)
|
||||||
|
|
||||||
|
Your real-time clock hardware might not support the required ioctl requests:
|
||||||
|
|
||||||
|
* `RTC_UIE_ON`
|
||||||
|
* `RTC_UIE_OFF`
|
||||||
|
|
||||||
|
A possible solution could be to build the Linux kernel with support for software
|
||||||
|
emulation instead; try enabling the following configuration option when building
|
||||||
|
the Linux kernel:
|
||||||
|
|
||||||
|
* `CONFIG_RTC_INTF_DEV_UIE_EMUL`
|
||||||
|
|
||||||
|
=== What if my computer does not have an RTC or backup battery?
|
||||||
|
|
||||||
|
In this case you can still use the `-s` option to set the system clock to the
|
||||||
|
last modification time of the drift file, which should correspond to the system
|
||||||
|
time when `chronyd` was previously stopped. The initial system time will be
|
||||||
|
increasing across reboots and applications started after `chronyd` will not
|
||||||
|
observe backward steps.
|
||||||
|
|
||||||
|
== NTP-specific issues
|
||||||
|
|
||||||
|
=== Can `chronyd` be driven from broadcast/multicast NTP servers?
|
||||||
|
|
||||||
|
No, the broadcast/multicast client mode is not supported and there is currently
|
||||||
|
no plan to implement it. While this mode can simplify configuration
|
||||||
|
of clients in large networks, it is inherently less accurate and less secure
|
||||||
|
(even with authentication) than the ordinary client/server mode.
|
||||||
|
|
||||||
|
When configuring a large number of clients in a network, it is recommended to
|
||||||
|
use the `pool` directive with a DNS name which resolves to addresses of
|
||||||
|
multiple NTP servers. The clients will automatically replace the servers when
|
||||||
|
they become unreachable, or otherwise unsuitable for synchronisation, with new
|
||||||
|
servers from the pool.
|
||||||
|
|
||||||
|
Even with very modest hardware, an NTP server can serve time to hundreds of
|
||||||
|
thousands of clients using the ordinary client/server mode.
|
||||||
|
|
||||||
|
=== Can `chronyd` transmit broadcast NTP packets?
|
||||||
|
|
||||||
|
Yes, the `broadcast` directive can be used to enable the broadcast server mode
|
||||||
|
to serve time to clients in the network which support the broadcast client mode
|
||||||
|
(it is not supported in `chronyd`). Note that this mode should generally be
|
||||||
|
avoided. See the previous question.
|
||||||
|
|
||||||
|
=== Can `chronyd` keep the system clock a fixed offset away from real time?
|
||||||
|
|
||||||
|
Yes. Starting from version 3.0, an offset can be specified by the `offset`
|
||||||
|
option for all time sources in the _chrony.conf_ file.
|
||||||
|
|
||||||
|
=== What happens if the network connection is dropped without using ``chronyc``'s `offline` command first?
|
||||||
|
|
||||||
|
`chronyd` will keep trying to access the sources that it thinks are online, and
|
||||||
|
it will take longer before new measurements are actually made and the clock is
|
||||||
|
corrected when the network is connected again. If the sources were set to
|
||||||
|
offline, `chronyd` would make new measurements immediately after issuing the
|
||||||
|
`online` command.
|
||||||
|
|
||||||
|
Unless the network connection lasts only few minutes (less than the maximum
|
||||||
|
polling interval), the delay is usually not a problem, and it might be acceptable
|
||||||
|
to keep all sources online all the time.
|
||||||
|
|
||||||
|
=== Why is an offset measured between two computers synchronised to each another?
|
||||||
|
|
||||||
|
When two computers are synchronised to each other using the client/server or
|
||||||
|
symmetric NTP mode, there is an expectation that NTP measurements between the
|
||||||
|
two computers made on both ends show an average offset close to zero.
|
||||||
|
|
||||||
|
With `chronyd` that can be expected only when the interleaved mode is enabled
|
||||||
|
by the `xleave` option. Otherwise, `chronyd` will use different transmit
|
||||||
|
timestamps (e.g. daemon timestamp vs kernel timestamp) for serving time and
|
||||||
|
synchronisation of its own clock, which will cause the other computer to
|
||||||
|
measure a significant offset.
|
||||||
|
|
||||||
|
== Operating systems
|
||||||
|
|
||||||
|
=== Does `chrony` support Windows?
|
||||||
|
|
||||||
|
No. The `chronyc` program (the command-line client used for configuring
|
||||||
|
`chronyd` while it is running) has been successfully built and run under
|
||||||
|
Cygwin in the past. `chronyd` is not portable, because part of it is
|
||||||
|
very system-dependent. It needs adapting to work with Windows'
|
||||||
|
equivalent of the adjtimex() call, and it needs to be made to work as a
|
||||||
|
service.
|
||||||
|
|
||||||
|
=== Are there any plans to support Windows?
|
||||||
|
|
||||||
|
We have no plans to do this. Anyone is welcome to pick this work up and
|
||||||
|
contribute it back to the project.
|
||||||
200
doc/installation.adoc
Normal file
200
doc/installation.adoc
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
// This file is part of chrony
|
||||||
|
//
|
||||||
|
// Copyright (C) Richard P. Curnow 1997-2003
|
||||||
|
// Copyright (C) Miroslav Lichvar 2009-2016
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of version 2 of the GNU General Public License as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
= Installation
|
||||||
|
|
||||||
|
The software is distributed as source code which has to be compiled. The source
|
||||||
|
code is supplied in the form of a gzipped tar file, which unpacks to a
|
||||||
|
subdirectory identifying the name and version of the program.
|
||||||
|
|
||||||
|
A C compiler (e.g. `gcc` or `clang`) and GNU Make are needed to build `chrony`.
|
||||||
|
The following libraries with their development files, and programs, are needed
|
||||||
|
to enable optional features:
|
||||||
|
|
||||||
|
* pkg-config: detection of development libraries
|
||||||
|
* Nettle, NSS, or LibTomCrypt: secure hash functions (`SECHASH`)
|
||||||
|
* libcap: dropping root privileges on Linux (`DROPROOT`)
|
||||||
|
* libseccomp: system call filter on Linux (`SCFILTER`)
|
||||||
|
* GnuTLS and Nettle: Network Time Security (`NTS`)
|
||||||
|
* Editline: line editing in `chronyc` (`READLINE`)
|
||||||
|
* timepps.h header: PPS reference clock
|
||||||
|
* Asciidoctor: documentation in HTML format
|
||||||
|
* Bash: test suite
|
||||||
|
|
||||||
|
The following programs are needed when building `chrony` from the git
|
||||||
|
repository instead of a released tar file:
|
||||||
|
|
||||||
|
* Asciidoctor: manual pages
|
||||||
|
* Bison: parser for chronyc settime command
|
||||||
|
|
||||||
|
After unpacking the source code, change directory into it, and type
|
||||||
|
|
||||||
|
----
|
||||||
|
./configure
|
||||||
|
----
|
||||||
|
|
||||||
|
This is a shell script that automatically determines the system type. There is
|
||||||
|
an optional parameter `--prefix`, which indicates the directory tree where the
|
||||||
|
software should be installed. For example,
|
||||||
|
|
||||||
|
----
|
||||||
|
./configure --prefix=/opt/free
|
||||||
|
----
|
||||||
|
|
||||||
|
will install the `chronyd` daemon into `/opt/free/sbin` and the `chronyc`
|
||||||
|
control program into `/opt/free/bin`. The default value for the prefix is
|
||||||
|
`/usr/local`.
|
||||||
|
|
||||||
|
The `configure` script assumes you want to use `gcc` as your compiler. If you
|
||||||
|
want to use a different compiler, you can configure this way:
|
||||||
|
|
||||||
|
----
|
||||||
|
CC=cc ./configure --prefix=/opt/free
|
||||||
|
----
|
||||||
|
|
||||||
|
for Bourne-family shells, or
|
||||||
|
|
||||||
|
----
|
||||||
|
setenv CC cc
|
||||||
|
setenv CFLAGS -O
|
||||||
|
./configure --prefix=/opt/free
|
||||||
|
----
|
||||||
|
|
||||||
|
for C-family shells.
|
||||||
|
|
||||||
|
If the software cannot (yet) be built on your system, an error message will be
|
||||||
|
shown. Otherwise, `Makefile` will be generated.
|
||||||
|
|
||||||
|
On Linux, if development files for the libcap library are available, `chronyd`
|
||||||
|
will be built with support for dropping root privileges. On other systems no
|
||||||
|
extra library is needed. The default user which `chronyd` should run as can be
|
||||||
|
specified with the `--with-user` option of the `configure` script.
|
||||||
|
|
||||||
|
If development files for the POSIX threads library are available, `chronyd`
|
||||||
|
will be built with support for asynchronous resolving of hostnames specified in
|
||||||
|
the `server`, `peer`, and `pool` directives. This allows `chronyd` operating as
|
||||||
|
a server to respond to client requests when resolving a hostname. If you don't
|
||||||
|
want to enable the support, specify the `--disable-asyncdns` flag to
|
||||||
|
`configure`.
|
||||||
|
|
||||||
|
If development files for the https://www.lysator.liu.se/~nisse/nettle/[Nettle],
|
||||||
|
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS[NSS], or
|
||||||
|
https://www.libtom.net/LibTomCrypt/[libtomcrypt] library are available,
|
||||||
|
`chronyd` will be built with support for other cryptographic hash functions
|
||||||
|
than MD5, which can be used for NTP authentication with a symmetric key. If you
|
||||||
|
don't want to enable the support, specify the `--disable-sechash` flag to
|
||||||
|
`configure`.
|
||||||
|
|
||||||
|
If development files for the editline library are available,
|
||||||
|
`chronyc` will be built with line editing support. If you don't want this,
|
||||||
|
specify the `--disable-readline` flag to `configure`.
|
||||||
|
|
||||||
|
If a `timepps.h` header is available (e.g. from the
|
||||||
|
http://linuxpps.org[LinuxPPS project]), `chronyd` will be built with PPS API
|
||||||
|
reference clock driver. If the header is installed in a location that isn't
|
||||||
|
normally searched by the compiler, you can add it to the searched locations by
|
||||||
|
setting the `CPPFLAGS` variable to `-I/path/to/timepps`.
|
||||||
|
|
||||||
|
The `--help` option can be specified to `configure` to print all options
|
||||||
|
supported by the script.
|
||||||
|
|
||||||
|
Now type
|
||||||
|
|
||||||
|
----
|
||||||
|
make
|
||||||
|
----
|
||||||
|
|
||||||
|
to build the programs.
|
||||||
|
|
||||||
|
If you want to build the manual in HTML, type
|
||||||
|
|
||||||
|
----
|
||||||
|
make docs
|
||||||
|
----
|
||||||
|
|
||||||
|
Once the programs have been successfully compiled, they need to be installed in
|
||||||
|
their target locations. This step normally needs to be performed by the
|
||||||
|
superuser, and requires the following command to be entered.
|
||||||
|
|
||||||
|
----
|
||||||
|
make install
|
||||||
|
----
|
||||||
|
|
||||||
|
This will install the binaries and man pages.
|
||||||
|
|
||||||
|
To install the HTML version of the manual, enter the command
|
||||||
|
|
||||||
|
----
|
||||||
|
make install-docs
|
||||||
|
----
|
||||||
|
|
||||||
|
Now that the software is successfully installed, the next step is to set up a
|
||||||
|
configuration file. The default location of the file is _/etc/chrony.conf_.
|
||||||
|
Several examples of configuration with comments are included in the examples
|
||||||
|
directory. Suppose you want to use public NTP servers from the pool.ntp.org
|
||||||
|
project as your time reference. A minimal useful configuration file could be
|
||||||
|
|
||||||
|
----
|
||||||
|
pool pool.ntp.org iburst
|
||||||
|
makestep 1.0 3
|
||||||
|
rtcsync
|
||||||
|
----
|
||||||
|
|
||||||
|
Then, `chronyd` can be run. For security reasons, it's recommended to create an
|
||||||
|
unprivileged user for `chronyd` and specify it with the `-u` command-line
|
||||||
|
option or the `user` directive in the configuration file, or set the default
|
||||||
|
user with the `--with-user` configure option before building.
|
||||||
|
|
||||||
|
== Support for system call filtering
|
||||||
|
|
||||||
|
`chronyd` can be built with support for the Linux secure computing (seccomp)
|
||||||
|
facility. This requires development files for the
|
||||||
|
https://github.com/seccomp/libseccomp[libseccomp] library and the
|
||||||
|
`--enable-scfilter` option specified to `configure`. The `-F` option of
|
||||||
|
`chronyd` will enable a system call filter, which should significantly reduce
|
||||||
|
the kernel attack surface and possibly prevent kernel exploits from `chronyd`
|
||||||
|
if it is compromised.
|
||||||
|
|
||||||
|
== Extra options for package builders
|
||||||
|
|
||||||
|
The `configure` and `make` procedures have some extra options that may be
|
||||||
|
useful if you are building a distribution package for `chrony`.
|
||||||
|
|
||||||
|
The `--mandir=DIR` option to `configure` specifies an installation directory
|
||||||
|
for the man pages. This overrides the `man` subdirectory of the argument to the
|
||||||
|
`--prefix` option.
|
||||||
|
|
||||||
|
----
|
||||||
|
./configure --prefix=/usr --mandir=/usr/share/man
|
||||||
|
----
|
||||||
|
|
||||||
|
to set both options together.
|
||||||
|
|
||||||
|
The final option is the `DESTDIR` option to the `make` command. For example,
|
||||||
|
you could use the commands
|
||||||
|
|
||||||
|
----
|
||||||
|
./configure --prefix=/usr --mandir=/usr/share/man
|
||||||
|
make all docs
|
||||||
|
make install DESTDIR=./tmp
|
||||||
|
cd tmp
|
||||||
|
tar cvf - . | gzip -9 > chrony.tar.gz
|
||||||
|
----
|
||||||
|
|
||||||
|
to build a package. When untarred within the root directory, this will install
|
||||||
|
the files to the intended final locations.
|
||||||
20
examples/chrony-wait.service
Normal file
20
examples/chrony-wait.service
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Wait for chrony to synchronize system clock
|
||||||
|
Documentation=man:chronyc(1)
|
||||||
|
After=chronyd.service
|
||||||
|
Requires=chronyd.service
|
||||||
|
Before=time-sync.target
|
||||||
|
Wants=time-sync.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
# Wait for chronyd to update the clock and the remaining
|
||||||
|
# correction to be less than 0.1 seconds
|
||||||
|
ExecStart=/usr/bin/chronyc -h 127.0.0.1,::1 waitsync 0 0.1 0.0 1
|
||||||
|
# Wait for at most 3 minutes
|
||||||
|
TimeoutStartSec=180
|
||||||
|
RemainAfterExit=yes
|
||||||
|
StandardOutput=null
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
12
examples/chrony.conf.example1
Normal file
12
examples/chrony.conf.example1
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Use public NTP servers from the pool.ntp.org project.
|
||||||
|
pool pool.ntp.org iburst
|
||||||
|
|
||||||
|
# Record the rate at which the system clock gains/losses time.
|
||||||
|
driftfile /var/lib/chrony/drift
|
||||||
|
|
||||||
|
# Allow the system clock to be stepped in the first three updates
|
||||||
|
# if its offset is larger than 1 second.
|
||||||
|
makestep 1.0 3
|
||||||
|
|
||||||
|
# Enable kernel synchronization of the real-time clock (RTC).
|
||||||
|
rtcsync
|
||||||
47
examples/chrony.conf.example2
Normal file
47
examples/chrony.conf.example2
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Use public servers from the pool.ntp.org project.
|
||||||
|
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
|
||||||
|
pool pool.ntp.org iburst
|
||||||
|
|
||||||
|
# Record the rate at which the system clock gains/losses time.
|
||||||
|
driftfile /var/lib/chrony/drift
|
||||||
|
|
||||||
|
# Allow the system clock to be stepped in the first three updates
|
||||||
|
# if its offset is larger than 1 second.
|
||||||
|
makestep 1.0 3
|
||||||
|
|
||||||
|
# Enable kernel synchronization of the real-time clock (RTC).
|
||||||
|
rtcsync
|
||||||
|
|
||||||
|
# Enable hardware timestamping on all interfaces that support it.
|
||||||
|
#hwtimestamp *
|
||||||
|
|
||||||
|
# Increase the minimum number of selectable sources required to adjust
|
||||||
|
# the system clock.
|
||||||
|
#minsources 2
|
||||||
|
|
||||||
|
# Allow NTP client access from local network.
|
||||||
|
#allow 192.168.0.0/16
|
||||||
|
|
||||||
|
# Serve time even if not synchronized to a time source.
|
||||||
|
#local stratum 10
|
||||||
|
|
||||||
|
# Require authentication (nts or key option) for all NTP sources.
|
||||||
|
#authselectmode require
|
||||||
|
|
||||||
|
# Specify file containing keys for NTP authentication.
|
||||||
|
#keyfile /etc/chrony.keys
|
||||||
|
|
||||||
|
# Save NTS keys and cookies.
|
||||||
|
ntsdumpdir /var/lib/chrony
|
||||||
|
|
||||||
|
# Insert/delete leap seconds by slewing instead of stepping.
|
||||||
|
#leapsecmode slew
|
||||||
|
|
||||||
|
# Get TAI-UTC offset and leap seconds from the system tz database.
|
||||||
|
#leapsectz right/UTC
|
||||||
|
|
||||||
|
# Specify directory for log files.
|
||||||
|
logdir /var/log/chrony
|
||||||
|
|
||||||
|
# Select which information is logged.
|
||||||
|
#log measurements statistics tracking
|
||||||
@@ -5,22 +5,6 @@
|
|||||||
# want to enable. The more obscure options are not included. Refer
|
# want to enable. The more obscure options are not included. Refer
|
||||||
# to the documentation for these.
|
# to the documentation for these.
|
||||||
#
|
#
|
||||||
# Copyright 2002 Richard P. Curnow
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of version 2 of the GNU General Public License as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful, but
|
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
# General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
### COMMENTS
|
### COMMENTS
|
||||||
# Any of the following lines are comments (you have a choice of
|
# Any of the following lines are comments (you have a choice of
|
||||||
@@ -40,47 +24,53 @@
|
|||||||
# more 'NTP servers'. You will probably find that your Internet Service
|
# more 'NTP servers'. You will probably find that your Internet Service
|
||||||
# Provider or company have one or more NTP servers that you can specify.
|
# Provider or company have one or more NTP servers that you can specify.
|
||||||
# Failing that, there are a lot of public NTP servers. There is a list
|
# Failing that, there are a lot of public NTP servers. There is a list
|
||||||
# you can access at
|
# you can access at http://support.ntp.org/bin/view/Servers/WebHome or
|
||||||
# http://www.eecis.udel.edu/~mills/ntp/servers.htm.
|
# you can use servers from the pool.ntp.org project.
|
||||||
|
|
||||||
! server ntp0.your-isp.com
|
! server foo.example.net iburst
|
||||||
! server ntp1.your-isp.com
|
! server bar.example.net iburst
|
||||||
! server ntp.public-server.org
|
! server baz.example.net iburst
|
||||||
|
|
||||||
|
! pool pool.ntp.org iburst
|
||||||
|
|
||||||
# However, for dial-up use you probably want these instead. The word
|
|
||||||
# 'offline' means that the server is not visible at boot time. Use
|
|
||||||
# chronyc's 'online' command to tell chronyd that these servers have
|
|
||||||
# become visible after you go on-line.
|
|
||||||
|
|
||||||
! server ntp0.your-isp.com offline
|
|
||||||
! server ntp1.your-isp.com offline
|
|
||||||
! server ntp.public-server.org offline
|
|
||||||
|
|
||||||
# You may want to specify NTP 'peers' instead. If you run a network
|
|
||||||
# with a lot of computers and want several computers running chrony to
|
|
||||||
# have the 'front-line' interface to the public NTP servers, you can
|
|
||||||
# 'peer' these machines together to increase robustness.
|
|
||||||
|
|
||||||
! peer ntp0.my-company.com
|
|
||||||
|
|
||||||
# There are other options to the 'server' and 'peer' directives that you
|
|
||||||
# might want to use. For example, you can ignore measurements whose
|
|
||||||
# round-trip-time is too large (indicating that the measurement is
|
|
||||||
# probably useless, because you don't know which way the measurement
|
|
||||||
# message got held up.) Consult the full documentation for details.
|
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
### AVOIDING POTENTIALLY BOGUS CHANGES TO YOUR CLOCK
|
### AVOIDING POTENTIALLY BOGUS CHANGES TO YOUR CLOCK
|
||||||
#
|
#
|
||||||
# To avoid changes being made to your computer's gain/loss compensation
|
# To avoid changes being made to your computer's gain/loss compensation
|
||||||
# when the measurement history is too erratic, you might want to enable
|
# when the measurement history is too erratic, you might want to enable
|
||||||
# one of the following lines. The first seems good for dial-up (or
|
# one of the following lines. The first seems good with servers on the
|
||||||
# other high-latency connections like slow leased lines), the second
|
# Internet, the second seems OK for a LAN environment.
|
||||||
# seems OK for a LAN environment.
|
|
||||||
|
|
||||||
! maxupdateskew 100
|
! maxupdateskew 100
|
||||||
! maxupdateskew 5
|
! maxupdateskew 5
|
||||||
|
|
||||||
|
# If you want to increase the minimum number of selectable sources
|
||||||
|
# required to update the system clock in order to make the
|
||||||
|
# synchronisation more reliable, uncomment (and edit) the following
|
||||||
|
# line.
|
||||||
|
|
||||||
|
! minsources 2
|
||||||
|
|
||||||
|
# If your computer has a good stable clock (e.g. it is not a virtual
|
||||||
|
# machine), you might also want to reduce the maximum assumed drift
|
||||||
|
# (frequency error) of the clock (the value is specified in ppm).
|
||||||
|
|
||||||
|
! maxdrift 100
|
||||||
|
|
||||||
|
# By default, chronyd allows synchronisation to an unauthenticated NTP
|
||||||
|
# source (i.e. specified without the nts and key options) if it agrees with
|
||||||
|
# a majority of authenticated NTP sources, or if no authenticated source is
|
||||||
|
# specified. If you don't want chronyd to ever synchronise to an
|
||||||
|
# unauthenticated NTP source, uncomment the first from the following lines.
|
||||||
|
# If you don't want to synchronise to an unauthenticated NTP source only
|
||||||
|
# when an authenticated source is specified, uncomment the second line.
|
||||||
|
# If you want chronyd to ignore authentication in the source selection,
|
||||||
|
# uncomment the third line.
|
||||||
|
|
||||||
|
! authselectmode require
|
||||||
|
! authselectmode prefer
|
||||||
|
! authselectmode ignore
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
### FILENAMES ETC
|
### FILENAMES ETC
|
||||||
# Chrony likes to keep information about your computer's clock in files.
|
# Chrony likes to keep information about your computer's clock in files.
|
||||||
@@ -89,61 +79,83 @@
|
|||||||
# immediately so that it doesn't gain or lose any more time. You
|
# immediately so that it doesn't gain or lose any more time. You
|
||||||
# generally want this, so it is uncommented.
|
# generally want this, so it is uncommented.
|
||||||
|
|
||||||
driftfile /etc/chrony.drift
|
driftfile /var/lib/chrony/drift
|
||||||
|
|
||||||
# If you want to use the program called chronyc to configure aspects of
|
# If you want to enable NTP authentication with symmetric keys, you will need
|
||||||
# chronyd's operation once it is running (e.g. tell it the Internet link
|
# to uncomment the following line and edit the file to set up the keys.
|
||||||
# has gone up or down), you need a password. This is stored in the
|
|
||||||
# following keys file. (You also need keys to support authenticated NTP
|
|
||||||
# exchanges between cooperating machines.) Again, this option is
|
|
||||||
# assumed by default.
|
|
||||||
|
|
||||||
keyfile /etc/chrony.keys
|
! keyfile /etc/chrony.keys
|
||||||
|
|
||||||
# Tell chronyd which numbered key in the file is used as the password
|
# If you specify an NTP server with the nts option to enable authentication
|
||||||
# for chronyc. (You can pick any integer up to 2**32-1. '1' is just a
|
# with the Network Time Security (NTS) mechanism, or enable server NTS with
|
||||||
# default. Using another value will _NOT_ increase security.)
|
# the ntsservercert and ntsserverkey directives below, the following line will
|
||||||
|
# allow the client/server to save the NTS keys and cookies in order to reduce
|
||||||
|
# the number of key establishments (NTS-KE sessions).
|
||||||
|
|
||||||
commandkey 1
|
ntsdumpdir /var/lib/chrony
|
||||||
|
|
||||||
|
# If chronyd is configured to act as an NTP server and you want to enable NTS
|
||||||
|
# for its clients, you will need a TLS certificate and private key. Uncomment
|
||||||
|
# and edit the following lines to specify the locations of the certificate and
|
||||||
|
# key.
|
||||||
|
|
||||||
|
! ntsservercert /etc/.../foo.example.net.crt
|
||||||
|
! ntsserverkey /etc/.../foo.example.net.key
|
||||||
|
|
||||||
# chronyd can save the measurement history for the servers to files when
|
# chronyd can save the measurement history for the servers to files when
|
||||||
# it it exits. This is useful in 2 situations:
|
# it exits. This is useful in 2 situations:
|
||||||
#
|
#
|
||||||
# 1. On Linux, if you stop chronyd and restart it with '-r' (e.g. after
|
# 1. If you stop chronyd and restart it with the '-r' option (e.g. after
|
||||||
# an upgrade), the old measurements will still be relevant when chronyd
|
# an upgrade), the old measurements will still be relevant when chronyd
|
||||||
# is restarted. This will reduce the time needed to get accurate
|
# is restarted. This will reduce the time needed to get accurate
|
||||||
# gain/loss measurements, especially with a dial-up link.
|
# gain/loss measurements.
|
||||||
#
|
#
|
||||||
# 2. Again on Linux, if you use the RTC support and start chronyd with
|
# 2. On Linux, if you use the RTC support and start chronyd with
|
||||||
# '-r -s' on bootup, measurements from the last boot will still be
|
# '-r -s' on bootup, measurements from the last boot will still be
|
||||||
# useful (the real time clock is used to 'flywheel' chronyd between
|
# useful (the real time clock is used to 'flywheel' chronyd between
|
||||||
# boots).
|
# boots).
|
||||||
#
|
#
|
||||||
# Enable these two options to use this.
|
# Uncomment the following line to use this.
|
||||||
|
|
||||||
! dumponexit
|
! dumpdir /var/lib/chrony
|
||||||
! dumpdir /var/log/chrony
|
|
||||||
|
|
||||||
# chronyd writes its process ID to a file. If you try to start a second
|
# chronyd writes its process ID to a file. If you try to start a second
|
||||||
# copy of chronyd, it will detect that the process named in the file is
|
# copy of chronyd, it will detect that the process named in the file is
|
||||||
# still running and bail out. If you want to change the path to the PID
|
# still running and bail out. If you want to change the path to the PID
|
||||||
# file, uncomment this line and edit it. The default path is shown.
|
# file, uncomment this line and edit it. The default path is shown.
|
||||||
|
|
||||||
! pidfile /var/run/chronyd.pid
|
! pidfile /var/run/chrony/chronyd.pid
|
||||||
|
|
||||||
|
# If the system timezone database is kept up to date and includes the
|
||||||
|
# right/UTC timezone, chronyd can use it to determine the current
|
||||||
|
# TAI-UTC offset and when will the next leap second occur.
|
||||||
|
|
||||||
|
! leapsectz right/UTC
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
### INITIAL CLOCK CORRECTION
|
### INITIAL CLOCK CORRECTION
|
||||||
# This option is only useful if your NTP servers are visible at boot
|
# This option is useful to quickly correct the clock on start if it's
|
||||||
# time. This probably means you are on a LAN. If so, the following
|
# off by a large amount. The value '1.0' means that if the error is less
|
||||||
# option will choose the best-looking of the servers and correct the
|
# than 1 second, it will be gradually removed by speeding up or slowing
|
||||||
# system time to that. The value '10' means that if the error is less
|
# down your computer's clock until it is correct. If the error is above
|
||||||
# than 10 seconds, it will be gradually removed by speeding up or
|
# 1 second, an immediate time jump will be applied to correct it. The
|
||||||
# slowing down your computer's clock until it is correct. If the error
|
# value '3' means the step is allowed only in the first three updates of
|
||||||
# is above 10 seconds, an immediate time jump will be applied to correct
|
# the clock. Some software can get upset if the system clock jumps
|
||||||
# it. Some software can get upset if the system clock jumps (especially
|
# (especially backwards), so be careful!
|
||||||
# backwards), so be careful!
|
|
||||||
|
|
||||||
! initstepslew 10 ntp0.your-company.com ntp1.your-company.com ntp2.your-company.com
|
! makestep 1.0 3
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
### LEAP SECONDS
|
||||||
|
# A leap second is an occasional one-second correction of the UTC
|
||||||
|
# time scale. By default, chronyd tells the kernel to insert/delete
|
||||||
|
# the leap second, which makes a backward/forward step to correct the
|
||||||
|
# clock for it. As with the makestep directive, this jump can upset
|
||||||
|
# some applications. If you prefer chronyd to make a gradual
|
||||||
|
# correction, causing the clock to be off for a longer time, uncomment
|
||||||
|
# the following line.
|
||||||
|
|
||||||
|
! leapsecmode slew
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
### LOGGING
|
### LOGGING
|
||||||
@@ -164,8 +176,6 @@ commandkey 1
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
### ACTING AS AN NTP SERVER
|
### ACTING AS AN NTP SERVER
|
||||||
# You might want the computer to be an NTP server for other computers.
|
# You might want the computer to be an NTP server for other computers.
|
||||||
# e.g. you might be running chronyd on a dial-up machine that has a LAN
|
|
||||||
# sitting behind it with several 'satellite' computers on it.
|
|
||||||
#
|
#
|
||||||
# By default, chronyd does not allow any clients to access it. You need
|
# By default, chronyd does not allow any clients to access it. You need
|
||||||
# to explicitly enable access using 'allow' and 'deny' directives.
|
# to explicitly enable access using 'allow' and 'deny' directives.
|
||||||
@@ -181,15 +191,6 @@ commandkey 1
|
|||||||
# You can have as many allow and deny directives as you need. The order
|
# You can have as many allow and deny directives as you need. The order
|
||||||
# is unimportant.
|
# is unimportant.
|
||||||
|
|
||||||
# If you want chronyd to act as an NTP broadcast server, enable and edit
|
|
||||||
# (and maybe copy) the following line. This means that a broadcast
|
|
||||||
# packet is sent to the address 192.168.1.255 every 60 seconds. The
|
|
||||||
# address MUST correspond to the broadcast address of one of the network
|
|
||||||
# interfaces on your machine. If you have multiple network interfaces,
|
|
||||||
# add a broadcast line for each.
|
|
||||||
|
|
||||||
! broadcast 60 192.168.1.255
|
|
||||||
|
|
||||||
# If you want to present your computer's time for others to synchronise
|
# If you want to present your computer's time for others to synchronise
|
||||||
# with, even if you don't seem to be synchronised to any NTP servers
|
# with, even if you don't seem to be synchronised to any NTP servers
|
||||||
# yourself, enable the following line. The value 10 may be varied
|
# yourself, enable the following line. The value 10 may be varied
|
||||||
@@ -204,16 +205,22 @@ commandkey 1
|
|||||||
# machine accesses it. The information can be accessed by the 'clients'
|
# machine accesses it. The information can be accessed by the 'clients'
|
||||||
# command of chronyc. You can disable this facility by uncommenting the
|
# command of chronyc. You can disable this facility by uncommenting the
|
||||||
# following line. This will save a bit of memory if you have many
|
# following line. This will save a bit of memory if you have many
|
||||||
# clients.
|
# clients and it will also disable support for the interleaved mode.
|
||||||
|
|
||||||
! noclientlog
|
! noclientlog
|
||||||
|
|
||||||
# The clientlog size is limited to 512KB by default. If you have many
|
# The clientlog size is limited to 512KB by default. If you have many
|
||||||
# clients, especially in many different subnets, you might want to
|
# clients, you might want to increase the limit.
|
||||||
# increase the limit.
|
|
||||||
|
|
||||||
! clientloglimit 4194304
|
! clientloglimit 4194304
|
||||||
|
|
||||||
|
# By default, chronyd tries to respond to all valid NTP requests from
|
||||||
|
# allowed addresses. If you want to limit the response rate for NTP
|
||||||
|
# clients that are sending requests too frequently, uncomment and edit
|
||||||
|
# the following line.
|
||||||
|
|
||||||
|
! ratelimit interval 3 burst 8
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
### REPORTING BIG CLOCK CHANGES
|
### REPORTING BIG CLOCK CHANGES
|
||||||
# Perhaps you want to know if chronyd suddenly detects any large error
|
# Perhaps you want to know if chronyd suddenly detects any large error
|
||||||
@@ -231,13 +238,19 @@ commandkey 1
|
|||||||
# several people, you need to set up a mailing list or sendmail alias
|
# several people, you need to set up a mailing list or sendmail alias
|
||||||
# for them and use the address of that.)
|
# for them and use the address of that.)
|
||||||
|
|
||||||
! mailonchange wibble@foobar.org 0.5
|
! mailonchange wibble@foo.example.net 0.5
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
### COMMAND ACCESS
|
### COMMAND ACCESS
|
||||||
# The program chronyc is used to show the current operation of chronyd
|
# The program chronyc is used to show the current operation of chronyd
|
||||||
# and to change parts of its configuration whilst it is running.
|
# and to change parts of its configuration whilst it is running.
|
||||||
|
|
||||||
|
# By default chronyd binds to the loopback interface. Uncomment the
|
||||||
|
# following lines to allow receiving command packets from remote hosts.
|
||||||
|
|
||||||
|
! bindcmdaddress 0.0.0.0
|
||||||
|
! bindcmdaddress ::
|
||||||
|
|
||||||
# Normally, chronyd will only allow connections from chronyc on the same
|
# Normally, chronyd will only allow connections from chronyc on the same
|
||||||
# machine as itself. This is for security. If you have a subnet
|
# machine as itself. This is for security. If you have a subnet
|
||||||
# 192.168.*.* and you want to be able to use chronyc from any machine on
|
# 192.168.*.* and you want to be able to use chronyc from any machine on
|
||||||
@@ -250,17 +263,20 @@ commandkey 1
|
|||||||
# syntax and meaning is the same as for 'allow' and 'deny', except that
|
# syntax and meaning is the same as for 'allow' and 'deny', except that
|
||||||
# 'cmdallow' and 'cmddeny' control access to the chronyd's command port.
|
# 'cmdallow' and 'cmddeny' control access to the chronyd's command port.
|
||||||
|
|
||||||
# NOTE, even if the host where you run chronyc is granted access, you
|
# Rate limiting can be enabled also for command packets. (Note,
|
||||||
# still need a command key set up and you have to know the password to
|
# commands from localhost are never limited.)
|
||||||
# put into chronyc to allow you to modify chronyd's parameters. By
|
|
||||||
# default all you can do is view information about chronyd's operation.
|
|
||||||
|
|
||||||
# Some people have reported that the need the following line to allow
|
! cmdratelimit interval -4 burst 16
|
||||||
# chronyc to work even on the same machine. This should not be
|
|
||||||
# necessary, and the problem is being investigated. You can leave this
|
|
||||||
# line enabled, as it's benign otherwise.
|
|
||||||
|
|
||||||
cmdallow 127.0.0.1
|
#######################################################################
|
||||||
|
### HARDWARE TIMESTAMPING
|
||||||
|
# On Linux, if the network interface controller and its driver support
|
||||||
|
# hardware timestamping, it can significantly improve the accuracy of
|
||||||
|
# synchronisation. It can be enabled on specified interfaces only, or it
|
||||||
|
# can be enabled on all interfaces that support it.
|
||||||
|
|
||||||
|
! hwtimestamp eth0
|
||||||
|
! hwtimestamp *
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
### REAL TIME CLOCK
|
### REAL TIME CLOCK
|
||||||
@@ -273,7 +289,7 @@ cmdallow 127.0.0.1
|
|||||||
# You need to have 'enhanced RTC support' compiled into your Linux
|
# You need to have 'enhanced RTC support' compiled into your Linux
|
||||||
# kernel. (Note, these options apply only to Linux.)
|
# kernel. (Note, these options apply only to Linux.)
|
||||||
|
|
||||||
! rtcfile /etc/chrony.rtc
|
! rtcfile /var/lib/chrony/rtc
|
||||||
|
|
||||||
# Your RTC can be set to keep Universal Coordinated Time (UTC) or local
|
# Your RTC can be set to keep Universal Coordinated Time (UTC) or local
|
||||||
# time. (Local time means UTC +/- the effect of your timezone.) If you
|
# time. (Local time means UTC +/- the effect of your timezone.) If you
|
||||||
@@ -291,6 +307,12 @@ cmdallow 127.0.0.1
|
|||||||
|
|
||||||
! rtcdevice /dev/misc/rtc
|
! rtcdevice /dev/misc/rtc
|
||||||
|
|
||||||
|
# Alternatively, if not using the -s option, this directive can be used
|
||||||
|
# to enable a mode in which the RTC is periodically set to the system
|
||||||
|
# time, with no tracking of its drift.
|
||||||
|
|
||||||
|
! rtcsync
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
### REAL TIME SCHEDULER
|
### REAL TIME SCHEDULER
|
||||||
# This directive tells chronyd to use the real-time FIFO scheduler with the
|
# This directive tells chronyd to use the real-time FIFO scheduler with the
|
||||||
@@ -1,27 +1,13 @@
|
|||||||
#######################################################################
|
# This is an example chrony keys file. It enables authentication of NTP
|
||||||
# $Header: /cvs/src/chrony/examples/chrony.keys.example,v 1.1 2002/01/31 00:00:08 richard Exp $
|
# packets with symmetric keys when its location is specified by the keyfile
|
||||||
|
# directive in chrony.conf(5). It should be readable only by root and the
|
||||||
|
# user under which chronyd is running.
|
||||||
#
|
#
|
||||||
# This is an example chrony keys file. You should copy it to /etc/chrony.keys
|
# Don't use the example keys! It's recommended to generate random keys using
|
||||||
# after editing it to set up the key(s) you want to use. In most situations,
|
# the chronyc keygen command.
|
||||||
# you will require a single key (the 'commandkey') so that you can supply a
|
|
||||||
# password to chronyc to enable you to modify chronyd's operation whilst it is
|
|
||||||
# running.
|
|
||||||
#
|
|
||||||
# Copyright 2002 Richard P. Curnow
|
|
||||||
#
|
|
||||||
#######################################################################
|
|
||||||
# A valid key line looks like this
|
|
||||||
|
|
||||||
1 a_key
|
# Examples of valid keys:
|
||||||
|
|
||||||
# It must consist of an integer, followed by whitespace, followed by a block of
|
|
||||||
# text with no spaces in it. (You cannot put a space in a key). If you wanted
|
|
||||||
# to use the above line as your commandkey (i.e. chronyc password), you would
|
|
||||||
# put the following line into chrony.conf (remove the # from the start):
|
|
||||||
|
|
||||||
# commandkey 1
|
|
||||||
|
|
||||||
# You might want to define more keys if you use the MD5 authentication facility
|
|
||||||
# in the network time protocol to authenticate request/response packets between
|
|
||||||
# trusted clients and servers.
|
|
||||||
|
|
||||||
|
#1 MD5 AVeryLongAndRandomPassword
|
||||||
|
#2 MD5 HEX:12114855C7931009B4049EF3EFC48A139C3F989F
|
||||||
|
#3 SHA1 HEX:B2159C05D6A219673A3B7E896B6DE07F6A440995
|
||||||
|
|||||||
8
examples/chrony.logrotate
Normal file
8
examples/chrony.logrotate
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/var/log/chrony/*.log {
|
||||||
|
missingok
|
||||||
|
nocreate
|
||||||
|
sharedscripts
|
||||||
|
postrotate
|
||||||
|
/usr/bin/chronyc cyclelogs > /dev/null 2>&1 || true
|
||||||
|
endscript
|
||||||
|
}
|
||||||
43
examples/chrony.nm-dispatcher.dhcp
Normal file
43
examples/chrony.nm-dispatcher.dhcp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# This is a NetworkManager dispatcher script for chronyd to update
|
||||||
|
# its NTP sources passed from DHCP options. Note that this script is
|
||||||
|
# specific to NetworkManager-dispatcher due to use of the
|
||||||
|
# DHCP4_NTP_SERVERS environment variable.
|
||||||
|
|
||||||
|
export LC_ALL=C
|
||||||
|
|
||||||
|
interface=$1
|
||||||
|
action=$2
|
||||||
|
|
||||||
|
chronyc=/usr/bin/chronyc
|
||||||
|
default_server_options=iburst
|
||||||
|
server_dir=/var/run/chrony-dhcp
|
||||||
|
|
||||||
|
dhcp_server_file=$server_dir/$interface.sources
|
||||||
|
# DHCP4_NTP_SERVERS is passed from DHCP options by NetworkManager.
|
||||||
|
nm_dhcp_servers=$DHCP4_NTP_SERVERS
|
||||||
|
|
||||||
|
add_servers_from_dhcp() {
|
||||||
|
rm -f "$dhcp_server_file"
|
||||||
|
for server in $nm_dhcp_servers; do
|
||||||
|
echo "server $server $default_server_options" >> "$dhcp_server_file"
|
||||||
|
done
|
||||||
|
$chronyc reload sources > /dev/null 2>&1 || :
|
||||||
|
}
|
||||||
|
|
||||||
|
clear_servers_from_dhcp() {
|
||||||
|
if [ -f "$dhcp_server_file" ]; then
|
||||||
|
rm -f "$dhcp_server_file"
|
||||||
|
$chronyc reload sources > /dev/null 2>&1 || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir -p $server_dir
|
||||||
|
|
||||||
|
if [ "$action" = "up" ] || [ "$action" = "dhcp4-change" ]; then
|
||||||
|
add_servers_from_dhcp
|
||||||
|
elif [ "$action" = "down" ]; then
|
||||||
|
clear_servers_from_dhcp
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
17
examples/chrony.nm-dispatcher.onoffline
Normal file
17
examples/chrony.nm-dispatcher.onoffline
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# This is a NetworkManager dispatcher / networkd-dispatcher script for
|
||||||
|
# chronyd to set its NTP sources online or offline when a network interface
|
||||||
|
# is configured or removed
|
||||||
|
|
||||||
|
export LC_ALL=C
|
||||||
|
|
||||||
|
chronyc=/usr/bin/chronyc
|
||||||
|
|
||||||
|
# For NetworkManager consider only up/down events
|
||||||
|
[ $# -ge 2 ] && [ "$2" != "up" ] && [ "$2" != "down" ] && exit 0
|
||||||
|
|
||||||
|
# Note: for networkd-dispatcher routable.d ~= on and off.d ~= off
|
||||||
|
|
||||||
|
$chronyc onoffline > /dev/null 2>&1
|
||||||
|
|
||||||
|
exit 0
|
||||||
18
examples/chronyd.service
Normal file
18
examples/chronyd.service
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=NTP client/server
|
||||||
|
Documentation=man:chronyd(8) man:chrony.conf(5)
|
||||||
|
After=ntpdate.service sntp.service ntpd.service
|
||||||
|
Conflicts=ntpd.service systemd-timesyncd.service
|
||||||
|
ConditionCapability=CAP_SYS_TIME
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
PIDFile=/run/chrony/chronyd.pid
|
||||||
|
EnvironmentFile=-/etc/sysconfig/chronyd
|
||||||
|
ExecStart=/usr/sbin/chronyd $OPTIONS
|
||||||
|
PrivateTmp=yes
|
||||||
|
ProtectHome=yes
|
||||||
|
ProtectSystem=full
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
366
faq.txt
366
faq.txt
@@ -1,366 +0,0 @@
|
|||||||
@@PROLOGUE
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Frequently asked questions</title>
|
|
||||||
<meta name="description" content="Chrony FAQ (frequently asked questions)">
|
|
||||||
<meta name="keywords" content="chrony,network time protocol,NTP,RFC 1305,dial-up connection,real time clock,RTC,Linux,FAQ,frequently asked questns">
|
|
||||||
<?php
|
|
||||||
$root = ".";
|
|
||||||
include "$root/styles.php";
|
|
||||||
?>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<?php
|
|
||||||
include 'main_banner.php';
|
|
||||||
include 'header.php';
|
|
||||||
?>
|
|
||||||
<?php pretty_h1("Introduction") ?>
|
|
||||||
<p>
|
|
||||||
This is a set of questions and answers to common problems and issues.
|
|
||||||
<p>
|
|
||||||
As we receive more emails about the software, we will add new questions
|
|
||||||
to this page.
|
|
||||||
<hr>
|
|
||||||
<p>
|
|
||||||
The developers can be reached via the chrony-dev mailing list. See
|
|
||||||
<a href="#question_1.4">question 1.4.</a> for details.
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<br clear=all>
|
|
||||||
@@ENDPROLOGUE
|
|
||||||
S: Administrative issues
|
|
||||||
|
|
||||||
Q: Where can I get chrony source code?
|
|
||||||
Tarballs are available via the <b>Download</b> link on the Chrony
|
|
||||||
Web site. For the current development from the developers' version control
|
|
||||||
system see the <b>Git</b> link on the Web site.
|
|
||||||
|
|
||||||
Q: Are there any packaged versions of chrony?
|
|
||||||
We are aware of packages for Debian, Fedora, Gentoo, Mandriva, Slackware,
|
|
||||||
and Ubuntu. We are not involved with how these are built or distributed.
|
|
||||||
|
|
||||||
Q: Where is the home page?
|
|
||||||
It is currently at <a href="http://chrony.tuxfamily.org/">http://chrony.tuxfamily.org/</a>.
|
|
||||||
|
|
||||||
Q: Is there a mailing list?
|
|
||||||
Yes, it's currently at chrony-users@chrony.tuxfamily.org. There is a low-volume
|
|
||||||
list called chrony-announce which is just for announcements of new releases or
|
|
||||||
similar matters of high importance. You can join the lists by sending a
|
|
||||||
message with the subject subscribe to <a href="mailto:chrony-users-request@chrony.tuxfamily.org">chrony-users-request@chrony.tuxfamily.org</a> or
|
|
||||||
<a href="mailto:chrony-announce-request@chrony.tuxfamily.org">chrony-announce-request@chrony.tuxfamily.org</a> respectively.
|
|
||||||
|
|
||||||
For those who want to contribute to the development of chrony, there is a
|
|
||||||
developers' mailing list. You can subscribe by sending mail with the
|
|
||||||
subject subscribe to
|
|
||||||
<a href="mailto:chrony-dev-request@chrony.tuxfamily.org">chrony-dev-request@chrony.tuxfamily.org</a>.
|
|
||||||
|
|
||||||
Q: What licence is applied to chrony?
|
|
||||||
Starting from version 1.15, chrony is licensed under the GNU General Public
|
|
||||||
License, Version 2. Versions prior to 1.15 were licensed under a custom BSD-like
|
|
||||||
license.
|
|
||||||
|
|
||||||
S: Chrony compared to other programs
|
|
||||||
Q: How does chrony compare to xntpd?
|
|
||||||
If your computer is permenently connected, or connected for long periods (that
|
|
||||||
is, for the several hours it takes xntpd to settle down), or you need to
|
|
||||||
support hardware reference clocks to your computer, then xntpd will work fine.
|
|
||||||
Apart from not supporting hardware clocks, chrony will work fine too.
|
|
||||||
|
|
||||||
If your computer connects to the 'net for 5 minutes once a day (or something
|
|
||||||
like that), or you turn your (Linux v2.0) computer off when you're not using
|
|
||||||
it, or you want to use NTP on an isolated network with no hardware clocks in
|
|
||||||
sight, chrony will work much better for you.
|
|
||||||
|
|
||||||
The reason I wrote chrony was that I could not get xntpd to do
|
|
||||||
anything sensible on my PC at home, which is connected to the 'net for
|
|
||||||
about 5 minutes once or twice a day, mainly to upload/download email
|
|
||||||
and news. Nowadays it is also turned off for 22-23 hours a day, when
|
|
||||||
not in use. I wanted a program which would :
|
|
||||||
|
|
||||||
- slew the time to correct it when I go online and NTP servers become visible
|
|
||||||
|
|
||||||
- determine the rate at which the computer gains or loses time and use this
|
|
||||||
information to keep it reasonably correct between connects to the 'net. This
|
|
||||||
has to be done using a method that does not care about the intermittent
|
|
||||||
availability of the references or the fact the computer is turned off between
|
|
||||||
groups of measurements..
|
|
||||||
|
|
||||||
- maintain the time across reboots, by working out the error and drift rate of
|
|
||||||
the computer's real-time clock and using this information to set the system
|
|
||||||
clock correctly at boot up. (In the last few months, it became impossible for
|
|
||||||
me to leave my computer powered permanently.)
|
|
||||||
|
|
||||||
Also, when working with isolated networks with no true time references
|
|
||||||
at all, I found xntpd gave me no help with managing the local clock's
|
|
||||||
gain/loss rate on the NTP master node (which I set from my watch). I
|
|
||||||
added some automated support in chrony to deal with this.
|
|
||||||
|
|
||||||
S: Compilation issues
|
|
||||||
Q:How do I apply source patches?
|
|
||||||
Sometimes we release source patches rather than a full version when we need to
|
|
||||||
provide a fix for small problems. Supposing you have chrony-1.X.tar.gz and a
|
|
||||||
source patch chrony-1.X-1.X.1.gz. The steps required are:
|
|
||||||
|
|
||||||
tar xzvf ../chrony-1.X.tar.gz
|
|
||||||
cd chrony-1.X
|
|
||||||
gunzip < ../../chrony-1.X-1.X.1.gz | patch -p1
|
|
||||||
./configure
|
|
||||||
make
|
|
||||||
make install
|
|
||||||
|
|
||||||
Q:Can I compile chrony with an ANSI-C compiler that is not GCC v2.x?
|
|
||||||
I have had reports that chrony can be compiled with GCC v1.42, by using the
|
|
||||||
following trick when running make
|
|
||||||
|
|
||||||
make CC='gcc -D__FUNCTION__=\"function_not_available\"'
|
|
||||||
|
|
||||||
(this gets around the lack of a __FUNCTION__ macro in GCC v1.)
|
|
||||||
|
|
||||||
The same trick may be enough to allow other compilers to be used.
|
|
||||||
|
|
||||||
Q: I get errors like 'client.c:44: readline/readline.h: file not found'
|
|
||||||
Read the section about 'readline' in the INSTALL file or in chrony.txt. You
|
|
||||||
may need to disable readline support (e.g. if you haven't got readline
|
|
||||||
installed at all, or just don't want it), or specify the location of the
|
|
||||||
readline files (e.g. if you've installed them in a non-standard place).
|
|
||||||
|
|
||||||
Q: I have RedHat 7.3 and can't compile rtc_linux.c (error in spinlock.h)
|
|
||||||
The following solution has been found for this. Enter the following 3 commands
|
|
||||||
(as root):
|
|
||||||
|
|
||||||
cd /usr/include/
|
|
||||||
mv linux linux.rh
|
|
||||||
ln -s /usr/src/linux/include/linux ./linux
|
|
||||||
|
|
||||||
The problem seems to be that RedHat provide their own kernel header files in
|
|
||||||
/usr/include/linux. Besides differing from those used by your current kernel,
|
|
||||||
if you compiled it yourself, they also seem to have been changed in a way that
|
|
||||||
causes a problem compiling chrony. Chrony compiles fine with standard kernel
|
|
||||||
header files.
|
|
||||||
|
|
||||||
There have also been reports that just replacing the file
|
|
||||||
/usr/src/linux/spinlock.h by the equivalent file from a vanilla kernel source
|
|
||||||
tree is sufficient to fix the problem.
|
|
||||||
|
|
||||||
Note : from version 1.21 onwards, this problem no longer exists. The kernel
|
|
||||||
header files are no longer included.
|
|
||||||
|
|
||||||
S: Selection of NTP servers
|
|
||||||
Q: I have several computers on a LAN. Should I make one the master, or make them all clients of an external server?
|
|
||||||
I think the best configuration is to make one computer the master, with the
|
|
||||||
others as clients of it. Add a 'local' directive to the master's chrony.conf
|
|
||||||
file. This configuration will be better because
|
|
||||||
|
|
||||||
* the load on the external connection is less
|
|
||||||
* the load on the external NTP server(s) is less
|
|
||||||
* if your external connection goes down, the computers on the LAN will maintain
|
|
||||||
a common time with each other.
|
|
||||||
|
|
||||||
S: Addressing issues
|
|
||||||
Q: I get the following error message : "Could not get IP adress for localhost"
|
|
||||||
Add a line like the following to your /etc/hosts file
|
|
||||||
127.0.0.1 localhost
|
|
||||||
|
|
||||||
Q: I have problems if I put the names of my NTP servers in the chrony.conf file.
|
|
||||||
If you have no connection to the Internet at boot time, chrony won't be able to
|
|
||||||
turn the names into IP addresses when it starts. There seem to be 2 solutions:
|
|
||||||
|
|
||||||
1. Put the numeric IP addresses in the chrony.conf file
|
|
||||||
or
|
|
||||||
2. Put the server->IP address mappings in your /etc/hosts file and ensure that
|
|
||||||
/etc/host.conf reads 'order hosts,bind'.
|
|
||||||
|
|
||||||
The problem is that chronyd (currently) isn't designed in a way that allows
|
|
||||||
hostname->IP address lookups during normal operation. I hope to work on this
|
|
||||||
problem very soon.
|
|
||||||
|
|
||||||
S: My computer is not synchronising.
|
|
||||||
This is the most common problem. There are a number of reasons, see the
|
|
||||||
following questions.
|
|
||||||
|
|
||||||
Q: Behind a firewall?
|
|
||||||
If there is a firewall between you and the NTP server you're trying to use,
|
|
||||||
the packets may be blocked. Try using a tool like etherfind or tcpdump to see
|
|
||||||
if you're getting responses from the server. If you have an external modem,
|
|
||||||
see if the receive light blinks straight after the transmit light (when the
|
|
||||||
link is quiet apart from the NTP traffic.) Try adding 'log measurements' to
|
|
||||||
the chrony.conf file and look in the measurements.log file after chrony has
|
|
||||||
been running for a short period. See if any measurements appear.
|
|
||||||
|
|
||||||
Most people run chronyd on the firewall itself, to avoid all issues of UDP
|
|
||||||
packet forwarding and/or masquerading.
|
|
||||||
|
|
||||||
Q: Do you have a non-permanant (i.e. intermittent) Internet connection?
|
|
||||||
Check that you're using chronyc's 'online' and 'offline' commands
|
|
||||||
appropriately. Again, check in measurements.log to see if you're getting any
|
|
||||||
data back from the server.
|
|
||||||
|
|
||||||
Q: In measurements.log, do the '7' and '8' flag columns always show zero?
|
|
||||||
Do you have a 'local stratum X' directive in the chrony.conf file? If X is
|
|
||||||
lower than the stratum of the server you're trying to use, this situation will
|
|
||||||
arise. You should always make X quite high (e.g. 10) in this directive.
|
|
||||||
|
|
||||||
S: Issues with chronyd
|
|
||||||
|
|
||||||
Q: chronyd crashes after a syslog message "adjtimex failed for set frequency"
|
|
||||||
The usual cause is that the kernel is running with a different value of 'HZ'
|
|
||||||
(the timer interrupt rate) than the value that was found in the kernel header
|
|
||||||
files when chrony was compiled. The chrony.conf file can include options to
|
|
||||||
modify the HZ value (see the discussion of linux_hz and linux_freq_scale in the
|
|
||||||
documentation), however the problem is to find the value of HZ being used.
|
|
||||||
|
|
||||||
S: Issues with chronyc
|
|
||||||
|
|
||||||
Q: I keep getting the error '510 No command access from this host --- Reply not authenticated'.
|
|
||||||
Make sure that the chrony.conf file (on the computer where chronyd is running)
|
|
||||||
has a 'cmdallow' entry for the computer you are running chronyc on. This
|
|
||||||
shouldn't be necessary for localhost, but some people still seem to need an
|
|
||||||
entry like 'cmdallow 127.0.0.1'. (It would be good to understand why problem
|
|
||||||
only affects some people).
|
|
||||||
|
|
||||||
Q: I cannot log in from chronyc to carry out privileged tasks.
|
|
||||||
This is the second most common problem.
|
|
||||||
|
|
||||||
Perhaps your /etc/chrony.keys file is badly formatted. Make sure that the
|
|
||||||
final line has a line feed at the end, otherwise the key on that line will work
|
|
||||||
as though the last character is missing. (Note, this bug was fixed in version
|
|
||||||
1.16.)
|
|
||||||
|
|
||||||
Q: When I enter a command and hit <Return>, chronyc hangs
|
|
||||||
This probably means that chronyc cannot communicate with chronyd.
|
|
||||||
|
|
||||||
Perhaps chronyd is not running. Try using the ps command (e.g. on Linux, 'ps
|
|
||||||
-auxw') to see if it's running. Or try 'netstat -a' and see if the ports
|
|
||||||
123/udp and 323/udp are listening. If chronyd is not running, you may have a
|
|
||||||
problem with the way you are trying to start it (e.g. at boot time).
|
|
||||||
|
|
||||||
Perhaps you have a firewall set up in a way that blocks packets on port
|
|
||||||
323/udp. You need to amend the firewall configuration in this case.
|
|
||||||
|
|
||||||
Q: Is the chronyc<->chronyd protocol documented anywhere?
|
|
||||||
Only by the source code :-) See cmdmon.c (chronyd side) and client.c (chronyc
|
|
||||||
side).
|
|
||||||
|
|
||||||
S: Real-time clock issues.
|
|
||||||
Q: What is the real-time clock (RTC)?
|
|
||||||
This is the clock which keeps the time even when your computer is turned off.
|
|
||||||
It works with 1 second resolution. chronyd can monitor the rate at which the
|
|
||||||
real-time clock gains or loses time, and compensate for it when you set the
|
|
||||||
system time from it at the next reboot. See the documentation for details.
|
|
||||||
|
|
||||||
Q: I want to use chronyd's real-time clock support. Must I disable hwclock?
|
|
||||||
The hwclock program is often set-up by default in the boot and shutdown scripts
|
|
||||||
with many Linux installations. If you want to use chronyd's real-time clock
|
|
||||||
support, the important thing is to disable hwclock in the <b>shutdown</b>
|
|
||||||
procedure. If you don't, it will over-write the RTC with a new value, unknown
|
|
||||||
to chronyd. At the next reboot, chronyd will compensate this (wrong) time with
|
|
||||||
its estimate of how far the RTC has drifted whilst the power was off, giving a
|
|
||||||
meaningless initial system time.
|
|
||||||
|
|
||||||
There is no need to remove hwclock from the boot process, as long as chronyd is
|
|
||||||
started after it has run.
|
|
||||||
|
|
||||||
Q: I just keep getting the '513 RTC driver not running' message
|
|
||||||
For the real time clock support to work, you need the following three things:
|
|
||||||
|
|
||||||
* a kernel that is supported (e.g. 2.2 onwards)
|
|
||||||
* enhanced RTC support compiled into the kernel
|
|
||||||
* an 'rtcfile' directive in your chrony.conf file.
|
|
||||||
|
|
||||||
S: Problems with isolated networks.
|
|
||||||
|
|
||||||
Q: When I use the 'settime' command, chronyd crashes.
|
|
||||||
If you enter times that are too far away from the real time, chronyd will
|
|
||||||
think the system clock runs fast or slow by an excessive amount. The required
|
|
||||||
compensation factor will be outside the bounds for the adjtimex() system call.
|
|
||||||
chronyd will crash when it tries to apply such an excessive adjustment.
|
|
||||||
|
|
||||||
S: Microsoft Windows
|
|
||||||
|
|
||||||
Q: Does chrony support Windows?
|
|
||||||
No. The chronyc program (the command-line client used for configuring
|
|
||||||
chronyd while it is running) has been successfully built and run under Cygwin
|
|
||||||
in the past. chronyd is not portable, because part of it is very
|
|
||||||
system-dependent. It needs adapting to work with Windows' equivalent of the
|
|
||||||
adjtimex() call, and it needs to be made to work as an NT service.
|
|
||||||
|
|
||||||
Q: Are there any plans to support Windows?
|
|
||||||
We have no plans to do this. Anyone is welcome to pick this work up and
|
|
||||||
contribute it back to the project.
|
|
||||||
|
|
||||||
Q: What alternative NTP clients are there for Windows?
|
|
||||||
Some of the names we've seen mentioned are
|
|
||||||
- Automachron
|
|
||||||
- NetTime (nettime.sourceforge.net)
|
|
||||||
|
|
||||||
S: NTP-specific issues
|
|
||||||
Q: Can chrony be driven from broadcast NTP servers?
|
|
||||||
No. I remember looking at how they worked when I was first writing chrony.
|
|
||||||
Since the 'target market' then was dial-up systems, broadcast packets were not
|
|
||||||
relevant so I didn't bother working out how to deal with the complexities of
|
|
||||||
doing the delay estimation.
|
|
||||||
|
|
||||||
I no longer have root access to a LAN environment to develop and test broadcast
|
|
||||||
server support. Neither have I the time to work on this. I would be very
|
|
||||||
happy to accept a patch from anyone who can develop, test and debug the
|
|
||||||
necessary changes!
|
|
||||||
|
|
||||||
Q: Can chronyd transmit broadcast NTP packets (e.g. to synchronise other computers on a private LAN)?
|
|
||||||
Yes. Starting from version 1.17, chrony has this capability.
|
|
||||||
|
|
||||||
Q: Can chrony keep the system clock a fixed offset away from real time?
|
|
||||||
I have not experimented much, but I don't believe this would be possible as
|
|
||||||
the program currently stands.
|
|
||||||
|
|
||||||
Q: What happens if the network connection is dropped without using chronyc's 'offline' command first?
|
|
||||||
In this case chronyd will keep trying to access the server(s) that it thinks
|
|
||||||
are online. Eventually it will decide that they are unreachable and no longer
|
|
||||||
consider itself synchronised to them. If you have other computers on your LAN
|
|
||||||
accessing the computer that is affected this way, they too will become
|
|
||||||
'unsynchronised', unless you have the 'local' directive set up on the master
|
|
||||||
computer.
|
|
||||||
|
|
||||||
The 'auto_offline' option to the 'server' entry in the chrony.conf file may be
|
|
||||||
useful to avoid this situation.
|
|
||||||
|
|
||||||
S: Development
|
|
||||||
|
|
||||||
Q: Can I get the source via git from anywhere?
|
|
||||||
Yes. See the Git link at <a
|
|
||||||
href="http://chrony.tuxfamily.org/">http://chrony.tuxfamily.org</a> for
|
|
||||||
information.
|
|
||||||
|
|
||||||
S: Linux-specific issues
|
|
||||||
|
|
||||||
Q: Why does the source code include kernel header files?
|
|
||||||
The program needs to see the definitions of structures used to interact with
|
|
||||||
the real time clock (via /dev/rtc) and with the adjtimex() system call. Sadly
|
|
||||||
this has led to a number of compilation problems with newer kernels which have
|
|
||||||
been increasingly hard to fix in a way that makes the code compilable on all
|
|
||||||
Linux kernel versions (from 2.0 up anyway, I doubt 1.x still works.) Hopefully
|
|
||||||
the situation will not deteriorate further with future kernel versions.
|
|
||||||
|
|
||||||
Q: I get "Could not open /dev/rtc, Device or resource busy" in my syslog file.
|
|
||||||
Check that you haven't accidentally got two copies of chronyd running (perhaps
|
|
||||||
defined in different start-up scripts.)
|
|
||||||
|
|
||||||
S: Solaris-specific issues
|
|
||||||
Q: On Solaris 2.8, I get an error message about not being able to open kvm to change dosynctodr.
|
|
||||||
(The dosynctodr variable controls whether Solaris couples the equivalent of its
|
|
||||||
BIOS clock into its system clock at regular intervals). The Solaris port of
|
|
||||||
chrony was developed in the Solaris 2.5 era. Some aspect of the Solaris kernel
|
|
||||||
has changed which prevents the same technique working. I no longer have root
|
|
||||||
access to any Solaris machines to work on this, and am reliant on somebody
|
|
||||||
developing the patch and testing it. A good starting point would be to see if
|
|
||||||
xntpd has been modified to work for Solaris 2.8.
|
|
||||||
|
|
||||||
@@EPILOGUE
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
Back to
|
|
||||||
<a href="mailto:rc@rc0.org.uk?subject=chrony">the author</a>'s
|
|
||||||
<a href="http://www.rc0.org.uk/">main page</a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ENDEPILOGUE
|
|
||||||
140
faqgen.pl
140
faqgen.pl
@@ -1,140 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
|
|
||||||
# $Header
|
|
||||||
|
|
||||||
# Copyright 2001 Richard P. Curnow
|
|
||||||
# LICENCE
|
|
||||||
|
|
||||||
# A script to generate an HTML FAQ page from a text input file. The input is assumed to consist of the following:
|
|
||||||
# Lines starting with 'S:'. These introduce sections.
|
|
||||||
# Lines starting with 'Q:'. These are the topics of questions.
|
|
||||||
# Body text (either as an introduction to the sections, or as answers to the questions.
|
|
||||||
# The body text is set as pre-formatted.
|
|
||||||
|
|
||||||
$| = 1;
|
|
||||||
|
|
||||||
@prologue = ();
|
|
||||||
@epilogue = ();
|
|
||||||
|
|
||||||
@sections=(); # section titles
|
|
||||||
@sect_text=(); # introductory text in sections
|
|
||||||
|
|
||||||
@questions=(); # questions in sections
|
|
||||||
@answers=(); # answers to questions
|
|
||||||
|
|
||||||
$sn = -1;
|
|
||||||
$had_q = 0;
|
|
||||||
|
|
||||||
#{{{ Parse input
|
|
||||||
while (<>) {
|
|
||||||
if (m/\@\@PROLOG/o) {
|
|
||||||
while (<>) {
|
|
||||||
last if (m/^\@\@ENDPROLOG/);
|
|
||||||
push (@prologue, $_);
|
|
||||||
}
|
|
||||||
} elsif (m/\@\@EPILOG/o) {
|
|
||||||
while (<>) {
|
|
||||||
last if (m/^\@\@ENDEPILOG/);
|
|
||||||
push (@epilogue, $_);
|
|
||||||
}
|
|
||||||
} elsif (m/^[sS]:[ \t]*(.*)$/) {
|
|
||||||
chomp;
|
|
||||||
$qn = -1;
|
|
||||||
++$sn;
|
|
||||||
$sections[$sn] = &guard($1);
|
|
||||||
$sect_text[$sn] = "";
|
|
||||||
$questions[$sn] = [ ];
|
|
||||||
$answers[$sn] = [ ];
|
|
||||||
$had_q = 0;
|
|
||||||
} elsif (/^[qQ]:[ \t]*(.*)$/) {
|
|
||||||
chomp;
|
|
||||||
die unless ($sn >= 0);
|
|
||||||
++$qn;
|
|
||||||
$questions[$sn]->[$qn] = &guard($1);
|
|
||||||
$had_q = 1;
|
|
||||||
} else {
|
|
||||||
if ($had_q) {
|
|
||||||
if ($qn >= 0) {
|
|
||||||
$answers[$sn]->[$qn] .= $_;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($sect_text[$sn] ne "" || $_ !~ /^\s*$/) {
|
|
||||||
$sect_text[$sn] .= $_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#}}}
|
|
||||||
|
|
||||||
# Emit file header
|
|
||||||
if ($#prologue >= 0) {
|
|
||||||
print @prologue;
|
|
||||||
} else {
|
|
||||||
print <<EOF;
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>
|
|
||||||
Chrony Frequently Asked Questions
|
|
||||||
</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<font face=\"arial,helvetica\" size=+4><b>Table of contents</b></font>
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
# Emit table of contents
|
|
||||||
print "<ul>\n";
|
|
||||||
for $sn (0 .. $#sections) {
|
|
||||||
print "<b><li> <a href=\"#section_".($sn+1)."\">".($sn+1).".</a> ".$sections[$sn]."</b>\n";
|
|
||||||
print " <ul>\n";
|
|
||||||
for $qn (0 .. $#{$questions[$sn]}) {
|
|
||||||
$sq = ($sn+1).".".($qn+1);
|
|
||||||
print " <li> <a href=\"#question_".$sq."\">".$sq.".</a> ".$questions[$sn]->[$qn]."\n";
|
|
||||||
#print " <li> ".$sq.". ".$questions[$sn]->[$qn]."\n";
|
|
||||||
}
|
|
||||||
print " </ul>\n";
|
|
||||||
}
|
|
||||||
print "</ul>\n";
|
|
||||||
|
|
||||||
# Emit main sections
|
|
||||||
for $sn (0 .. $#sections) {
|
|
||||||
print "<hr>\n";
|
|
||||||
print "<a name=section_".($sn+1).">\n";
|
|
||||||
#print "<b><font size=+2 face=\"arial,helvetica\">".($sn+1).". ".$sections[$sn]."</font></b>\n";
|
|
||||||
print "<?php pretty_h2(\"".($sn+1).". ".$sections[$sn]."\"); ?>\n";
|
|
||||||
if ($sect_text[$sn] ne "") {
|
|
||||||
print "<pre>\n";
|
|
||||||
print $sect_text[$sn];
|
|
||||||
print "</pre>\n";
|
|
||||||
}
|
|
||||||
for $qn (0 .. $#{$questions[$sn]}) {
|
|
||||||
$sq = ($sn+1).".".($qn+1);
|
|
||||||
print "<p>\n";
|
|
||||||
print "<a name=question_".$sq.">\n";
|
|
||||||
print "<font size=+1 face=\"arial,helvetica\">".$sq.". ".$questions[$sn]->[$qn]."</font>\n";
|
|
||||||
print "<pre>\n";
|
|
||||||
print $answers[$sn]->[$qn];
|
|
||||||
print "</pre>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Print footer
|
|
||||||
if ($#epilogue >= 0) {
|
|
||||||
print @epilogue;
|
|
||||||
} else {
|
|
||||||
print <<EOF;
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#{{{ sub guard {
|
|
||||||
sub guard {
|
|
||||||
# Hide wierd tags etc
|
|
||||||
my ($x) = @_;
|
|
||||||
return $x;
|
|
||||||
}
|
|
||||||
#}}}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -8,12 +8,7 @@
|
|||||||
** This code is in the public domain and has no copyright.
|
** This code is in the public domain and has no copyright.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#include "config.h"
|
||||||
# include <config.h>
|
|
||||||
# ifdef HAVE_ALLOCA_H
|
|
||||||
# include <alloca.h>
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Since the code of getdate.y is not included in the Emacs executable
|
/* Since the code of getdate.y is not included in the Emacs executable
|
||||||
itself, there is no need to #define static in this file. Even if
|
itself, there is no need to #define static in this file. Even if
|
||||||
@@ -711,7 +706,7 @@ LookupWord (buff)
|
|||||||
/* Make it lowercase. */
|
/* Make it lowercase. */
|
||||||
for (p = buff; *p; p++)
|
for (p = buff; *p; p++)
|
||||||
if (ISUPPER ((unsigned char) *p))
|
if (ISUPPER ((unsigned char) *p))
|
||||||
*p = tolower (*p);
|
*p = tolower ((unsigned char) *p);
|
||||||
|
|
||||||
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
|
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
56
hash.h
Normal file
56
hash.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2012
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Header file for crypto hashing.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GOT_HASH_H
|
||||||
|
#define GOT_HASH_H
|
||||||
|
|
||||||
|
/* length of hash values produced by SHA512 */
|
||||||
|
#define MAX_HASH_LENGTH 64
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
HSH_INVALID = 0,
|
||||||
|
HSH_MD5 = 1,
|
||||||
|
HSH_SHA1 = 2,
|
||||||
|
HSH_SHA256 = 3,
|
||||||
|
HSH_SHA384 = 4,
|
||||||
|
HSH_SHA512 = 5,
|
||||||
|
HSH_SHA3_224 = 6,
|
||||||
|
HSH_SHA3_256 = 7,
|
||||||
|
HSH_SHA3_384 = 8,
|
||||||
|
HSH_SHA3_512 = 9,
|
||||||
|
HSH_TIGER = 10,
|
||||||
|
HSH_WHIRLPOOL = 11,
|
||||||
|
} HSH_Algorithm;
|
||||||
|
|
||||||
|
extern int HSH_GetHashId(HSH_Algorithm algorithm);
|
||||||
|
|
||||||
|
extern int HSH_Hash(int id, const void *in1, int in1_len, const void *in2, int in2_len,
|
||||||
|
unsigned char *out, int out_len);
|
||||||
|
|
||||||
|
extern void HSH_Finalise(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/acquire.h,v 1.9 2002/02/28 23:27:07 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2002
|
* Copyright (C) Miroslav Lichvar 2012
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -25,25 +21,51 @@
|
|||||||
|
|
||||||
=======================================================================
|
=======================================================================
|
||||||
|
|
||||||
Header file for acquisition module
|
Routines implementing crypto hashing using internal MD5 implementation.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GOT_ACQUIRE_H
|
#include "config.h"
|
||||||
#define GOT_ACQUIRE_H
|
#include "sysincl.h"
|
||||||
|
#include "hash.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#include "addressing.h"
|
#include "md5.c"
|
||||||
|
|
||||||
typedef struct ACQ_SourceRecord *ACQ_Source;
|
static MD5_CTX ctx;
|
||||||
|
|
||||||
extern void ACQ_Initialise(void);
|
int
|
||||||
|
HSH_GetHashId(HSH_Algorithm algorithm)
|
||||||
|
{
|
||||||
|
/* only MD5 is supported */
|
||||||
|
if (algorithm != HSH_MD5)
|
||||||
|
return -1;
|
||||||
|
|
||||||
extern void ACQ_Finalise(void);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern void ACQ_StartAcquisition(int n, IPAddr *ip_addrs, int init_slew_threshold,
|
int
|
||||||
void (*after_hook)(void *), void *anything);
|
HSH_Hash(int id, const void *in1, int in1_len, const void *in2, int in2_len,
|
||||||
|
unsigned char *out, int out_len)
|
||||||
|
{
|
||||||
|
if (in1_len < 0 || in2_len < 0 || out_len < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
extern void ACQ_AccumulateSample(ACQ_Source acq_source, double offset, double root_distance);
|
MD5Init(&ctx);
|
||||||
|
MD5Update(&ctx, in1, in1_len);
|
||||||
|
if (in2)
|
||||||
|
MD5Update(&ctx, in2, in2_len);
|
||||||
|
MD5Final(&ctx);
|
||||||
|
|
||||||
extern void ACQ_MissedSample(ACQ_Source acq_source);
|
out_len = MIN(out_len, 16);
|
||||||
|
|
||||||
#endif /* GOT_ACQUIRE_H */
|
memcpy(out, ctx.digest, out_len);
|
||||||
|
|
||||||
|
return out_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HSH_Finalise(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
121
hash_nettle.c
Normal file
121
hash_nettle.c
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2018
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Routines implementing crypto hashing using the nettle library.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
|
#include <nettle/nettle-meta.h>
|
||||||
|
|
||||||
|
#include "hash.h"
|
||||||
|
#include "memory.h"
|
||||||
|
|
||||||
|
struct hash {
|
||||||
|
const HSH_Algorithm algorithm;
|
||||||
|
const char *int_name;
|
||||||
|
const struct nettle_hash *nettle_hash;
|
||||||
|
void *context;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct hash hashes[] = {
|
||||||
|
{ HSH_MD5, "md5", NULL, NULL },
|
||||||
|
{ HSH_SHA1, "sha1", NULL, NULL },
|
||||||
|
{ HSH_SHA256, "sha256", NULL, NULL },
|
||||||
|
{ HSH_SHA384, "sha384", NULL, NULL },
|
||||||
|
{ HSH_SHA512, "sha512", NULL, NULL },
|
||||||
|
{ HSH_SHA3_224, "sha3_224", NULL, NULL },
|
||||||
|
{ HSH_SHA3_256, "sha3_256", NULL, NULL },
|
||||||
|
{ HSH_SHA3_384, "sha3_384", NULL, NULL },
|
||||||
|
{ HSH_SHA3_512, "sha3_512", NULL, NULL },
|
||||||
|
{ 0, NULL, NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
HSH_GetHashId(HSH_Algorithm algorithm)
|
||||||
|
{
|
||||||
|
int id, nid;
|
||||||
|
|
||||||
|
for (id = 0; hashes[id].algorithm != 0; id++) {
|
||||||
|
if (hashes[id].algorithm == algorithm)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hashes[id].algorithm == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (hashes[id].context)
|
||||||
|
return id;
|
||||||
|
|
||||||
|
for (nid = 0; nettle_hashes[nid]; nid++) {
|
||||||
|
if (!strcmp(hashes[id].int_name, nettle_hashes[nid]->name))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nettle_hashes[nid] || !nettle_hashes[nid]->context_size || !nettle_hashes[nid]->init)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
hashes[id].nettle_hash = nettle_hashes[nid];
|
||||||
|
hashes[id].context = Malloc(hashes[id].nettle_hash->context_size);
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
HSH_Hash(int id, const void *in1, int in1_len, const void *in2, int in2_len,
|
||||||
|
unsigned char *out, int out_len)
|
||||||
|
{
|
||||||
|
const struct nettle_hash *hash;
|
||||||
|
void *context;
|
||||||
|
|
||||||
|
if (in1_len < 0 || in2_len < 0 || out_len < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
hash = hashes[id].nettle_hash;
|
||||||
|
context = hashes[id].context;
|
||||||
|
|
||||||
|
if (out_len > hash->digest_size)
|
||||||
|
out_len = hash->digest_size;
|
||||||
|
|
||||||
|
hash->init(context);
|
||||||
|
hash->update(context, in1_len, in1);
|
||||||
|
if (in2)
|
||||||
|
hash->update(context, in2_len, in2);
|
||||||
|
hash->digest(context, out_len, out);
|
||||||
|
|
||||||
|
return out_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HSH_Finalise(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; hashes[i].algorithm != 0; i++) {
|
||||||
|
if (hashes[i].context)
|
||||||
|
Free(hashes[i].context);
|
||||||
|
}
|
||||||
|
}
|
||||||
111
hash_nss.c
Normal file
111
hash_nss.c
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2012
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Routines implementing crypto hashing using NSSLOWHASH API of the NSS library.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <nss.h>
|
||||||
|
#include <hasht.h>
|
||||||
|
#include <nsslowhash.h>
|
||||||
|
|
||||||
|
#include "hash.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
static NSSLOWInitContext *ictx;
|
||||||
|
|
||||||
|
struct hash {
|
||||||
|
HASH_HashType type;
|
||||||
|
HSH_Algorithm algorithm;
|
||||||
|
NSSLOWHASHContext *context;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct hash hashes[] = {
|
||||||
|
{ HASH_AlgMD5, HSH_MD5, NULL },
|
||||||
|
{ HASH_AlgSHA1, HSH_SHA1, NULL },
|
||||||
|
{ HASH_AlgSHA256, HSH_SHA256, NULL },
|
||||||
|
{ HASH_AlgSHA384, HSH_SHA384, NULL },
|
||||||
|
{ HASH_AlgSHA512, HSH_SHA512, NULL },
|
||||||
|
{ 0, 0, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
HSH_GetHashId(HSH_Algorithm algorithm)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; hashes[i].algorithm != 0; i++) {
|
||||||
|
if (hashes[i].algorithm == algorithm)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hashes[i].algorithm == 0)
|
||||||
|
return -1; /* not found */
|
||||||
|
|
||||||
|
if (!ictx && !(ictx = NSSLOW_Init()))
|
||||||
|
return -1; /* couldn't init NSS */
|
||||||
|
|
||||||
|
if (!hashes[i].context &&
|
||||||
|
!(hashes[i].context = NSSLOWHASH_NewContext(ictx, hashes[i].type)))
|
||||||
|
return -1; /* couldn't init hash */
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
HSH_Hash(int id, const void *in1, int in1_len, const void *in2, int in2_len,
|
||||||
|
unsigned char *out, int out_len)
|
||||||
|
{
|
||||||
|
unsigned char buf[MAX_HASH_LENGTH];
|
||||||
|
unsigned int ret = 0;
|
||||||
|
|
||||||
|
if (in1_len < 0 || in2_len < 0 || out_len < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
NSSLOWHASH_Begin(hashes[id].context);
|
||||||
|
NSSLOWHASH_Update(hashes[id].context, in1, in1_len);
|
||||||
|
if (in2)
|
||||||
|
NSSLOWHASH_Update(hashes[id].context, in2, in2_len);
|
||||||
|
NSSLOWHASH_End(hashes[id].context, buf, &ret, sizeof (buf));
|
||||||
|
|
||||||
|
ret = MIN(ret, out_len);
|
||||||
|
memcpy(out, buf, ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HSH_Finalise(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; hashes[i].algorithm != 0; i++) {
|
||||||
|
if (hashes[i].context)
|
||||||
|
NSSLOWHASH_Destroy(hashes[i].context);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ictx)
|
||||||
|
NSSLOW_Shutdown(ictx);
|
||||||
|
}
|
||||||
123
hash_tomcrypt.c
Normal file
123
hash_tomcrypt.c
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2012, 2018
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Routines implementing crypto hashing using tomcrypt library.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <tomcrypt.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "hash.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
struct hash {
|
||||||
|
HSH_Algorithm algorithm;
|
||||||
|
const char *int_name;
|
||||||
|
const struct ltc_hash_descriptor *desc;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct hash hashes[] = {
|
||||||
|
{ HSH_MD5, "md5", &md5_desc },
|
||||||
|
#ifdef LTC_SHA1
|
||||||
|
{ HSH_SHA1, "sha1", &sha1_desc },
|
||||||
|
#endif
|
||||||
|
#ifdef LTC_SHA256
|
||||||
|
{ HSH_SHA256, "sha256", &sha256_desc },
|
||||||
|
#endif
|
||||||
|
#ifdef LTC_SHA384
|
||||||
|
{ HSH_SHA384, "sha384", &sha384_desc },
|
||||||
|
#endif
|
||||||
|
#ifdef LTC_SHA512
|
||||||
|
{ HSH_SHA512, "sha512", &sha512_desc },
|
||||||
|
#endif
|
||||||
|
#ifdef LTC_SHA3
|
||||||
|
{ HSH_SHA3_224, "sha3-224", &sha3_224_desc },
|
||||||
|
{ HSH_SHA3_256, "sha3-256", &sha3_256_desc },
|
||||||
|
{ HSH_SHA3_384, "sha3-384", &sha3_384_desc },
|
||||||
|
{ HSH_SHA3_512, "sha3-512", &sha3_512_desc },
|
||||||
|
#endif
|
||||||
|
#ifdef LTC_TIGER
|
||||||
|
{ HSH_TIGER, "tiger", &tiger_desc },
|
||||||
|
#endif
|
||||||
|
#ifdef LTC_WHIRLPOOL
|
||||||
|
{ HSH_WHIRLPOOL, "whirlpool", &whirlpool_desc },
|
||||||
|
#endif
|
||||||
|
{ 0, NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
HSH_GetHashId(HSH_Algorithm algorithm)
|
||||||
|
{
|
||||||
|
int i, h;
|
||||||
|
|
||||||
|
for (i = 0; hashes[i].algorithm != 0; i++) {
|
||||||
|
if (hashes[i].algorithm == algorithm)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hashes[i].algorithm == 0)
|
||||||
|
return -1; /* not found */
|
||||||
|
|
||||||
|
h = find_hash(hashes[i].int_name);
|
||||||
|
if (h >= 0)
|
||||||
|
return h; /* already registered */
|
||||||
|
|
||||||
|
/* register and try again */
|
||||||
|
register_hash(hashes[i].desc);
|
||||||
|
|
||||||
|
return find_hash(hashes[i].int_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
HSH_Hash(int id, const void *in1, int in1_len, const void *in2, int in2_len,
|
||||||
|
unsigned char *out, int out_len)
|
||||||
|
{
|
||||||
|
unsigned char buf[MAX_HASH_LENGTH];
|
||||||
|
unsigned long len;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (in1_len < 0 || in2_len < 0 || out_len < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
len = sizeof (buf);
|
||||||
|
if (in2)
|
||||||
|
r = hash_memory_multi(id, buf, &len,
|
||||||
|
in1, (unsigned long)in1_len,
|
||||||
|
in2, (unsigned long)in2_len, NULL, 0);
|
||||||
|
else
|
||||||
|
r = hash_memory(id, in1, in1_len, buf, &len);
|
||||||
|
|
||||||
|
if (r != CRYPT_OK)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
len = MIN(len, out_len);
|
||||||
|
memcpy(out, buf, len);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HSH_Finalise(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
227
hwclock.c
Normal file
227
hwclock.c
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2016-2018
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Tracking of hardware clocks (e.g. RTC, PHC)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
|
#include "array.h"
|
||||||
|
#include "hwclock.h"
|
||||||
|
#include "local.h"
|
||||||
|
#include "logging.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "regress.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
/* Minimum and maximum number of samples per clock */
|
||||||
|
#define MIN_SAMPLES 2
|
||||||
|
#define MAX_SAMPLES 64
|
||||||
|
|
||||||
|
/* Maximum acceptable frequency offset of the clock */
|
||||||
|
#define MAX_FREQ_OFFSET (2.0 / 3.0)
|
||||||
|
|
||||||
|
struct HCL_Instance_Record {
|
||||||
|
/* HW and local reference timestamp */
|
||||||
|
struct timespec hw_ref;
|
||||||
|
struct timespec local_ref;
|
||||||
|
|
||||||
|
/* Samples stored as intervals (uncorrected for frequency error)
|
||||||
|
relative to local_ref and hw_ref */
|
||||||
|
double *x_data;
|
||||||
|
double *y_data;
|
||||||
|
|
||||||
|
/* Minimum, maximum and current number of samples */
|
||||||
|
int min_samples;
|
||||||
|
int max_samples;
|
||||||
|
int n_samples;
|
||||||
|
|
||||||
|
/* Maximum error of the last sample */
|
||||||
|
double last_err;
|
||||||
|
|
||||||
|
/* Minimum interval between samples */
|
||||||
|
double min_separation;
|
||||||
|
|
||||||
|
/* Flag indicating the offset and frequency values are valid */
|
||||||
|
int valid_coefs;
|
||||||
|
|
||||||
|
/* Estimated offset and frequency of HW clock relative to local clock */
|
||||||
|
double offset;
|
||||||
|
double frequency;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_slew(struct timespec *raw, struct timespec *cooked, double dfreq,
|
||||||
|
double doffset, LCL_ChangeType change_type, void *anything)
|
||||||
|
{
|
||||||
|
HCL_Instance clock;
|
||||||
|
double delta;
|
||||||
|
|
||||||
|
clock = anything;
|
||||||
|
|
||||||
|
if (clock->n_samples)
|
||||||
|
UTI_AdjustTimespec(&clock->local_ref, cooked, &clock->local_ref, &delta, dfreq, doffset);
|
||||||
|
if (clock->valid_coefs)
|
||||||
|
clock->frequency /= 1.0 - dfreq;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
HCL_Instance
|
||||||
|
HCL_CreateInstance(int min_samples, int max_samples, double min_separation)
|
||||||
|
{
|
||||||
|
HCL_Instance clock;
|
||||||
|
|
||||||
|
min_samples = CLAMP(MIN_SAMPLES, min_samples, MAX_SAMPLES);
|
||||||
|
max_samples = CLAMP(MIN_SAMPLES, max_samples, MAX_SAMPLES);
|
||||||
|
max_samples = MAX(min_samples, max_samples);
|
||||||
|
|
||||||
|
clock = MallocNew(struct HCL_Instance_Record);
|
||||||
|
clock->x_data = MallocArray(double, max_samples);
|
||||||
|
clock->y_data = MallocArray(double, max_samples);
|
||||||
|
clock->x_data[max_samples - 1] = 0.0;
|
||||||
|
clock->y_data[max_samples - 1] = 0.0;
|
||||||
|
clock->min_samples = min_samples;
|
||||||
|
clock->max_samples = max_samples;
|
||||||
|
clock->n_samples = 0;
|
||||||
|
clock->valid_coefs = 0;
|
||||||
|
clock->min_separation = min_separation;
|
||||||
|
|
||||||
|
LCL_AddParameterChangeHandler(handle_slew, clock);
|
||||||
|
|
||||||
|
return clock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void HCL_DestroyInstance(HCL_Instance clock)
|
||||||
|
{
|
||||||
|
LCL_RemoveParameterChangeHandler(handle_slew, clock);
|
||||||
|
Free(clock->y_data);
|
||||||
|
Free(clock->x_data);
|
||||||
|
Free(clock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
HCL_NeedsNewSample(HCL_Instance clock, struct timespec *now)
|
||||||
|
{
|
||||||
|
if (!clock->n_samples ||
|
||||||
|
fabs(UTI_DiffTimespecsToDouble(now, &clock->local_ref)) >= clock->min_separation)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
HCL_AccumulateSample(HCL_Instance clock, struct timespec *hw_ts,
|
||||||
|
struct timespec *local_ts, double err)
|
||||||
|
{
|
||||||
|
double hw_delta, local_delta, local_freq, raw_freq;
|
||||||
|
int i, n_runs, best_start;
|
||||||
|
|
||||||
|
local_freq = 1.0 - LCL_ReadAbsoluteFrequency() / 1.0e6;
|
||||||
|
|
||||||
|
/* Shift old samples */
|
||||||
|
if (clock->n_samples) {
|
||||||
|
if (clock->n_samples >= clock->max_samples)
|
||||||
|
clock->n_samples--;
|
||||||
|
|
||||||
|
hw_delta = UTI_DiffTimespecsToDouble(hw_ts, &clock->hw_ref);
|
||||||
|
local_delta = UTI_DiffTimespecsToDouble(local_ts, &clock->local_ref) / local_freq;
|
||||||
|
|
||||||
|
if (hw_delta <= 0.0 || local_delta < clock->min_separation / 2.0) {
|
||||||
|
clock->n_samples = 0;
|
||||||
|
DEBUG_LOG("HW clock reset interval=%f", local_delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = clock->max_samples - clock->n_samples; i < clock->max_samples; i++) {
|
||||||
|
clock->y_data[i - 1] = clock->y_data[i] - hw_delta;
|
||||||
|
clock->x_data[i - 1] = clock->x_data[i] - local_delta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clock->n_samples++;
|
||||||
|
clock->hw_ref = *hw_ts;
|
||||||
|
clock->local_ref = *local_ts;
|
||||||
|
clock->last_err = err;
|
||||||
|
|
||||||
|
/* Get new coefficients */
|
||||||
|
clock->valid_coefs =
|
||||||
|
RGR_FindBestRobustRegression(clock->x_data + clock->max_samples - clock->n_samples,
|
||||||
|
clock->y_data + clock->max_samples - clock->n_samples,
|
||||||
|
clock->n_samples, 1.0e-10, &clock->offset, &raw_freq,
|
||||||
|
&n_runs, &best_start);
|
||||||
|
|
||||||
|
if (!clock->valid_coefs) {
|
||||||
|
DEBUG_LOG("HW clock needs more samples");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clock->frequency = raw_freq / local_freq;
|
||||||
|
|
||||||
|
/* Drop unneeded samples */
|
||||||
|
if (clock->n_samples > clock->min_samples)
|
||||||
|
clock->n_samples -= MIN(best_start, clock->n_samples - clock->min_samples);
|
||||||
|
|
||||||
|
/* If the fit doesn't cross the error interval of the last sample,
|
||||||
|
or the frequency is not sane, drop all samples and start again */
|
||||||
|
if (fabs(clock->offset) > err ||
|
||||||
|
fabs(clock->frequency - 1.0) > MAX_FREQ_OFFSET) {
|
||||||
|
DEBUG_LOG("HW clock reset");
|
||||||
|
clock->n_samples = 0;
|
||||||
|
clock->valid_coefs = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_LOG("HW clock samples=%d offset=%e freq=%e raw_freq=%e err=%e ref_diff=%e",
|
||||||
|
clock->n_samples, clock->offset, clock->frequency - 1.0, raw_freq - 1.0, err,
|
||||||
|
UTI_DiffTimespecsToDouble(&clock->hw_ref, &clock->local_ref));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
HCL_CookTime(HCL_Instance clock, struct timespec *raw, struct timespec *cooked, double *err)
|
||||||
|
{
|
||||||
|
double offset, elapsed;
|
||||||
|
|
||||||
|
if (!clock->valid_coefs)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
elapsed = UTI_DiffTimespecsToDouble(raw, &clock->hw_ref);
|
||||||
|
offset = elapsed / clock->frequency - clock->offset;
|
||||||
|
UTI_AddDoubleToTimespec(&clock->local_ref, offset, cooked);
|
||||||
|
|
||||||
|
/* Fow now, just return the error of the last sample */
|
||||||
|
if (err)
|
||||||
|
*err = clock->last_err;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
49
hwclock.h
Normal file
49
hwclock.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2016
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Header for tracking of hardware clocks */
|
||||||
|
|
||||||
|
#ifndef GOT_HWCLOCK_H
|
||||||
|
#define GOT_HWCLOCK_H
|
||||||
|
|
||||||
|
typedef struct HCL_Instance_Record *HCL_Instance;
|
||||||
|
|
||||||
|
/* Create a new HW clock instance */
|
||||||
|
extern HCL_Instance HCL_CreateInstance(int min_samples, int max_samples,
|
||||||
|
double min_separation);
|
||||||
|
|
||||||
|
/* Destroy a HW clock instance */
|
||||||
|
extern void HCL_DestroyInstance(HCL_Instance clock);
|
||||||
|
|
||||||
|
/* Check if a new sample should be accumulated at this time */
|
||||||
|
extern int HCL_NeedsNewSample(HCL_Instance clock, struct timespec *now);
|
||||||
|
|
||||||
|
/* Accumulate a new sample */
|
||||||
|
extern void HCL_AccumulateSample(HCL_Instance clock, struct timespec *hw_ts,
|
||||||
|
struct timespec *local_ts, double err);
|
||||||
|
|
||||||
|
/* Convert raw hardware time to cooked local time */
|
||||||
|
extern int HCL_CookTime(HCL_Instance clock, struct timespec *raw, struct timespec *cooked,
|
||||||
|
double *err);
|
||||||
|
|
||||||
|
#endif
|
||||||
75
io_linux.h
75
io_linux.h
@@ -1,75 +0,0 @@
|
|||||||
/* Taken from <asm-$foo/ioctl.h> in the Linux kernel sources.
|
|
||||||
* The ioctl.h file is pretty similar from one architecture to another.
|
|
||||||
* */
|
|
||||||
#ifndef IO_LINUX_H
|
|
||||||
#define IO_LINUX_H
|
|
||||||
|
|
||||||
/* Hmm. These constants vary a bit between systems. */
|
|
||||||
/* (__sh__ includes both sh and sh64) */
|
|
||||||
/* (__s390__ includes both s390 and s390x) */
|
|
||||||
#if defined(__i386__) || defined(__sh__) || defined(__arm__) || defined(__x86_64__) || defined(__s390__)
|
|
||||||
#define CHRONY_IOC_NRBITS 8
|
|
||||||
#define CHRONY_IOC_TYPEBITS 8
|
|
||||||
#define CHRONY_IOC_SIZEBITS 14
|
|
||||||
#define CHRONY_IOC_DIRBITS 2
|
|
||||||
|
|
||||||
#define CHRONY_IOC_NONE 0U
|
|
||||||
#define CHRONY_IOC_WRITE 1U
|
|
||||||
#define CHRONY_IOC_READ 2U
|
|
||||||
|
|
||||||
#elif defined(__alpha__) || defined(__sparc__) || defined(__ppc__) || defined(__ppc64__) || defined(__sparc64__)
|
|
||||||
#define CHRONY_IOC_NRBITS 8
|
|
||||||
#define CHRONY_IOC_TYPEBITS 8
|
|
||||||
#define CHRONY_IOC_SIZEBITS 13
|
|
||||||
#define CHRONY_IOC_DIRBITS 2
|
|
||||||
|
|
||||||
#define CHRONY_IOC_NONE 1U
|
|
||||||
#define CHRONY_IOC_READ 2U
|
|
||||||
#define CHRONY_IOC_WRITE 4U
|
|
||||||
|
|
||||||
#elif defined(__mips__) || defined(__mips32__) || defined(__powerpc__)
|
|
||||||
#define CHRONY_IOC_NRBITS 8
|
|
||||||
#define CHRONY_IOC_TYPEBITS 8
|
|
||||||
#define CHRONY_IOC_SIZEBITS 13
|
|
||||||
#define CHRONY_IOC_DIRBITS 3
|
|
||||||
#define CHRONY_IOC_NONE 1U
|
|
||||||
#define CHRONY_IOC_READ 2U
|
|
||||||
#define CHRONY_IOC_WRITE 4U
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error "I don't know the values of the _IOC_* constants for your architecture"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CHRONY_IOC_NRMASK ((1 << CHRONY_IOC_NRBITS)-1)
|
|
||||||
#define CHRONY_IOC_TYPEMASK ((1 << CHRONY_IOC_TYPEBITS)-1)
|
|
||||||
#define CHRONY_IOC_SIZEMASK ((1 << CHRONY_IOC_SIZEBITS)-1)
|
|
||||||
#define CHRONY_IOC_DIRMASK ((1 << CHRONY_IOC_DIRBITS)-1)
|
|
||||||
|
|
||||||
#define CHRONY_IOC_NRSHIFT 0
|
|
||||||
#define CHRONY_IOC_TYPESHIFT (CHRONY_IOC_NRSHIFT+CHRONY_IOC_NRBITS)
|
|
||||||
#define CHRONY_IOC_SIZESHIFT (CHRONY_IOC_TYPESHIFT+CHRONY_IOC_TYPEBITS)
|
|
||||||
#define CHRONY_IOC_DIRSHIFT (CHRONY_IOC_SIZESHIFT+CHRONY_IOC_SIZEBITS)
|
|
||||||
|
|
||||||
#define CHRONY_IOC(dir,type,nr,size) \
|
|
||||||
(((dir) << CHRONY_IOC_DIRSHIFT) | \
|
|
||||||
((type) << CHRONY_IOC_TYPESHIFT) | \
|
|
||||||
((nr) << CHRONY_IOC_NRSHIFT) | \
|
|
||||||
((size) << CHRONY_IOC_SIZESHIFT))
|
|
||||||
|
|
||||||
/* used to create numbers */
|
|
||||||
#define CHRONY_IO(type,nr) CHRONY_IOC(CHRONY_IOC_NONE,(type),(nr),0)
|
|
||||||
#define CHRONY_IOR(type,nr,size) CHRONY_IOC(CHRONY_IOC_READ,(type),(nr),sizeof(size))
|
|
||||||
#define CHRONY_IOW(type,nr,size) CHRONY_IOC(CHRONY_IOC_WRITE,(type),(nr),sizeof(size))
|
|
||||||
#define CHRONY_IOWR(type,nr,size) CHRONY_IOC(CHRONY_IOC_READ|CHRONY_IOC_WRITE,(type),(nr),sizeof(size))
|
|
||||||
|
|
||||||
#define RTC_UIE_ON CHRONY_IO('p', 0x03) /* Update int. enable on */
|
|
||||||
#define RTC_UIE_OFF CHRONY_IO('p', 0x04) /* ... off */
|
|
||||||
|
|
||||||
#define RTC_RD_TIME CHRONY_IOR('p', 0x09, struct rtc_time) /* Read RTC time */
|
|
||||||
#define RTC_SET_TIME CHRONY_IOW('p', 0x0a, struct rtc_time) /* Set RTC time */
|
|
||||||
|
|
||||||
/* From mc146818.h */
|
|
||||||
#define RTC_UIE 0x10 /* update-finished interrupt enable */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
449
keys.c
449
keys.c
@@ -1,12 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/keys.c,v 1.12 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
|
* Copyright (C) Miroslav Lichvar 2012-2016, 2019-2020
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -29,41 +26,82 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "config.h"
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
|
#include "array.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
|
#include "cmac.h"
|
||||||
|
#include "cmdparse.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "local.h"
|
||||||
|
#include "logging.h"
|
||||||
|
|
||||||
|
/* Consider 80 bits as the absolute minimum for a secure key */
|
||||||
|
#define MIN_SECURE_KEY_LENGTH 10
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NTP_MAC,
|
||||||
|
CMAC,
|
||||||
|
} KeyClass;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned long id;
|
uint32_t id;
|
||||||
char *val;
|
int type;
|
||||||
int len;
|
int length;
|
||||||
|
KeyClass class;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
unsigned char *value;
|
||||||
|
int hash_id;
|
||||||
|
} ntp_mac;
|
||||||
|
CMC_Instance cmac;
|
||||||
|
} data;
|
||||||
} Key;
|
} Key;
|
||||||
|
|
||||||
#define MAX_KEYS 256
|
static ARR_Instance keys;
|
||||||
|
|
||||||
static int n_keys;
|
|
||||||
static Key keys[MAX_KEYS];
|
|
||||||
|
|
||||||
static int command_key_valid;
|
|
||||||
static int command_key_pos;
|
|
||||||
static int cache_valid;
|
static int cache_valid;
|
||||||
static unsigned long cache_key_id;
|
static uint32_t cache_key_id;
|
||||||
static int cache_key_pos;
|
static int cache_key_pos;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_keys(void)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
Key *key;
|
||||||
|
|
||||||
|
for (i = 0; i < ARR_GetSize(keys); i++) {
|
||||||
|
key = ARR_GetElement(keys, i);
|
||||||
|
switch (key->class) {
|
||||||
|
case NTP_MAC:
|
||||||
|
Free(key->data.ntp_mac.value);
|
||||||
|
break;
|
||||||
|
case CMAC:
|
||||||
|
CMC_DestroyInstance(key->data.cmac);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ARR_SetSize(keys, 0);
|
||||||
|
cache_valid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
KEY_Initialise(void)
|
KEY_Initialise(void)
|
||||||
{
|
{
|
||||||
n_keys = 0;
|
keys = ARR_CreateInstance(sizeof (Key));
|
||||||
command_key_valid = 0;
|
|
||||||
cache_valid = 0;
|
cache_valid = 0;
|
||||||
KEY_Reload();
|
KEY_Reload();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -71,8 +109,35 @@ KEY_Initialise(void)
|
|||||||
void
|
void
|
||||||
KEY_Finalise(void)
|
KEY_Finalise(void)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
free_keys();
|
||||||
return;
|
ARR_DestroyInstance(keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static Key *
|
||||||
|
get_key(unsigned int index)
|
||||||
|
{
|
||||||
|
return ((Key *)ARR_GetElements(keys)) + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
/* Decode key encoded in ASCII or HEX */
|
||||||
|
|
||||||
|
static int
|
||||||
|
decode_key(char *key)
|
||||||
|
{
|
||||||
|
int len = strlen(key);
|
||||||
|
|
||||||
|
if (!strncmp(key, "ASCII:", 6)) {
|
||||||
|
memmove(key, key + 6, len - 6);
|
||||||
|
return len - 6;
|
||||||
|
} else if (!strncmp(key, "HEX:", 4)) {
|
||||||
|
return UTI_HexToBytes(key + 4, key, len);
|
||||||
|
} else {
|
||||||
|
/* assume ASCII */
|
||||||
|
return len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -97,147 +162,275 @@ compare_keys_by_id(const void *a, const void *b)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
|
||||||
#define KEYLEN 2047
|
|
||||||
#define SKEYLEN "2047"
|
|
||||||
|
|
||||||
void
|
void
|
||||||
KEY_Reload(void)
|
KEY_Reload(void)
|
||||||
{
|
{
|
||||||
int i, len1;
|
unsigned int i, line_number, key_length, cmac_key_length;
|
||||||
char *key_file;
|
|
||||||
FILE *in;
|
FILE *in;
|
||||||
unsigned long key_id;
|
char line[2048], *key_file, *key_value;
|
||||||
char line[KEYLEN+1], keyval[KEYLEN+1];
|
const char *key_type;
|
||||||
|
HSH_Algorithm hash_algorithm;
|
||||||
|
CMC_Algorithm cmac_algorithm;
|
||||||
|
int hash_id;
|
||||||
|
Key key;
|
||||||
|
|
||||||
for (i=0; i<n_keys; i++) {
|
free_keys();
|
||||||
Free(keys[i].val);
|
|
||||||
}
|
|
||||||
|
|
||||||
n_keys = 0;
|
|
||||||
|
|
||||||
key_file = CNF_GetKeysFile();
|
key_file = CNF_GetKeysFile();
|
||||||
|
line_number = 0;
|
||||||
|
|
||||||
if (key_file) {
|
if (!key_file)
|
||||||
in = fopen(key_file, "r");
|
return;
|
||||||
if (in) {
|
|
||||||
while (fgets(line, sizeof(line), in)) {
|
|
||||||
len1 = strlen(line) - 1;
|
|
||||||
|
|
||||||
/* Guard against removing last character of the line
|
in = UTI_OpenFile(NULL, key_file, NULL, 'r', 0);
|
||||||
* if the last line of the file is missing an end-of-line */
|
if (!in) {
|
||||||
if (line[len1] == '\n') {
|
LOG(LOGS_WARN, "Could not open keyfile %s", key_file);
|
||||||
line[len1] = '\0';
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (sscanf(line, "%lu%" SKEYLEN "s", &key_id, keyval) == 2) {
|
|
||||||
keys[n_keys].id = key_id;
|
|
||||||
keys[n_keys].len = strlen(keyval);
|
|
||||||
keys[n_keys].val = MallocArray(char, 1 + keys[n_keys].len);
|
|
||||||
strcpy(keys[n_keys].val, keyval);
|
|
||||||
n_keys++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(in);
|
|
||||||
|
|
||||||
/* Sort keys into order. Note, if there's a duplicate, it is
|
|
||||||
arbitrary which one we use later - the user should have been
|
|
||||||
more careful! */
|
|
||||||
qsort((void *) keys, n_keys, sizeof(Key), compare_keys_by_id);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
command_key_valid = 0;
|
while (fgets(line, sizeof (line), in)) {
|
||||||
cache_valid = 0;
|
line_number++;
|
||||||
|
|
||||||
return;
|
CPS_NormalizeLine(line);
|
||||||
|
if (!*line)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
memset(&key, 0, sizeof (key));
|
||||||
|
|
||||||
|
if (!CPS_ParseKey(line, &key.id, &key_type, &key_value)) {
|
||||||
|
LOG(LOGS_WARN, "Could not parse key at line %u in file %s", line_number, key_file);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
key_length = decode_key(key_value);
|
||||||
|
if (key_length == 0) {
|
||||||
|
LOG(LOGS_WARN, "Could not decode key %"PRIu32, key.id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
hash_algorithm = UTI_HashNameToAlgorithm(key_type);
|
||||||
|
cmac_algorithm = UTI_CmacNameToAlgorithm(key_type);
|
||||||
|
|
||||||
|
if (hash_algorithm != 0) {
|
||||||
|
hash_id = HSH_GetHashId(hash_algorithm);
|
||||||
|
if (hash_id < 0) {
|
||||||
|
LOG(LOGS_WARN, "Unsupported %s in key %"PRIu32, "hash function", key.id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
key.class = NTP_MAC;
|
||||||
|
key.type = hash_algorithm;
|
||||||
|
key.length = key_length;
|
||||||
|
key.data.ntp_mac.value = MallocArray(unsigned char, key_length);
|
||||||
|
memcpy(key.data.ntp_mac.value, key_value, key_length);
|
||||||
|
key.data.ntp_mac.hash_id = hash_id;
|
||||||
|
} else if (cmac_algorithm != 0) {
|
||||||
|
cmac_key_length = CMC_GetKeyLength(cmac_algorithm);
|
||||||
|
if (cmac_key_length == 0) {
|
||||||
|
LOG(LOGS_WARN, "Unsupported %s in key %"PRIu32, "cipher", key.id);
|
||||||
|
continue;
|
||||||
|
} else if (cmac_key_length != key_length) {
|
||||||
|
LOG(LOGS_WARN, "Invalid length of %s key %"PRIu32" (expected %u bits)",
|
||||||
|
key_type, key.id, 8 * cmac_key_length);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
key.class = CMAC;
|
||||||
|
key.type = cmac_algorithm;
|
||||||
|
key.length = key_length;
|
||||||
|
key.data.cmac = CMC_CreateInstance(cmac_algorithm, (unsigned char *)key_value,
|
||||||
|
key_length);
|
||||||
|
assert(key.data.cmac);
|
||||||
|
} else {
|
||||||
|
LOG(LOGS_WARN, "Invalid type in key %"PRIu32, key.id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ARR_AppendElement(keys, &key);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(in);
|
||||||
|
|
||||||
|
/* Sort keys into order. Note, if there's a duplicate, it is
|
||||||
|
arbitrary which one we use later - the user should have been
|
||||||
|
more careful! */
|
||||||
|
qsort(ARR_GetElements(keys), ARR_GetSize(keys), sizeof (Key), compare_keys_by_id);
|
||||||
|
|
||||||
|
/* Check for duplicates */
|
||||||
|
for (i = 1; i < ARR_GetSize(keys); i++) {
|
||||||
|
if (get_key(i - 1)->id == get_key(i)->id)
|
||||||
|
LOG(LOGS_WARN, "Detected duplicate key %"PRIu32, get_key(i - 1)->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Erase any passwords from stack */
|
||||||
|
memset(line, 0, sizeof (line));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
lookup_key(unsigned long id)
|
lookup_key(uint32_t id)
|
||||||
{
|
{
|
||||||
Key specimen, *where;
|
Key specimen, *where, *keys_ptr;
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
|
keys_ptr = ARR_GetElements(keys);
|
||||||
specimen.id = id;
|
specimen.id = id;
|
||||||
where = (Key *) bsearch((void *)&specimen, (void *)keys, n_keys, sizeof(Key), compare_keys_by_id);
|
where = (Key *)bsearch((void *)&specimen, keys_ptr, ARR_GetSize(keys),
|
||||||
|
sizeof (Key), compare_keys_by_id);
|
||||||
if (!where) {
|
if (!where) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
pos = where - keys;
|
pos = where - keys_ptr;
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
static Key *
|
||||||
KEY_CommandKey(char **key, int *len)
|
get_key_by_id(uint32_t key_id)
|
||||||
{
|
|
||||||
unsigned long command_key_id;
|
|
||||||
|
|
||||||
if (!command_key_valid) {
|
|
||||||
command_key_id = CNF_GetCommandKey();
|
|
||||||
command_key_pos = lookup_key(command_key_id);
|
|
||||||
command_key_valid = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command_key_pos >= 0) {
|
|
||||||
*key = keys[command_key_pos].val;
|
|
||||||
*len = keys[command_key_pos].len;
|
|
||||||
} else {
|
|
||||||
*key = "";
|
|
||||||
*len = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
int
|
|
||||||
KEY_GetKey(unsigned long key_id, char **key, int *len)
|
|
||||||
{
|
|
||||||
if (!cache_valid || key_id != cache_key_id) {
|
|
||||||
cache_valid = 1;
|
|
||||||
cache_key_pos = lookup_key(key_id);
|
|
||||||
cache_key_id = key_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cache_key_pos >= 0) {
|
|
||||||
*key = keys[cache_key_pos].val;
|
|
||||||
*len = keys[cache_key_pos].len;
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
*key = "";
|
|
||||||
*len = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
int
|
|
||||||
KEY_KeyKnown(unsigned long key_id)
|
|
||||||
{
|
{
|
||||||
int position;
|
int position;
|
||||||
|
|
||||||
if (cache_valid && (key_id == cache_key_id)) {
|
if (cache_valid && key_id == cache_key_id)
|
||||||
return 1;
|
return get_key(cache_key_pos);
|
||||||
} else {
|
|
||||||
|
|
||||||
position = lookup_key(key_id);
|
position = lookup_key(key_id);
|
||||||
|
|
||||||
if (position >= 0) {
|
if (position >= 0) {
|
||||||
/* Store key in cache, we will probably be using it in a
|
cache_valid = 1;
|
||||||
minute... */
|
cache_key_pos = position;
|
||||||
cache_valid = 1;
|
cache_key_id = key_id;
|
||||||
cache_key_pos = position;
|
|
||||||
cache_key_id = key_id;
|
return get_key(position);
|
||||||
return 1;
|
}
|
||||||
} else {
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
KEY_KeyKnown(uint32_t key_id)
|
||||||
|
{
|
||||||
|
return get_key_by_id(key_id) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
KEY_GetAuthLength(uint32_t key_id)
|
||||||
|
{
|
||||||
|
unsigned char buf[MAX_HASH_LENGTH];
|
||||||
|
Key *key;
|
||||||
|
|
||||||
|
key = get_key_by_id(key_id);
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (key->class) {
|
||||||
|
case NTP_MAC:
|
||||||
|
return HSH_Hash(key->data.ntp_mac.hash_id, buf, 0, buf, 0, buf, sizeof (buf));
|
||||||
|
case CMAC:
|
||||||
|
return CMC_Hash(key->data.cmac, buf, 0, buf, sizeof (buf));
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
KEY_CheckKeyLength(uint32_t key_id)
|
||||||
|
{
|
||||||
|
Key *key;
|
||||||
|
|
||||||
|
key = get_key_by_id(key_id);
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return key->length >= MIN_SECURE_KEY_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
KEY_GetKeyInfo(uint32_t key_id, int *type, int *bits)
|
||||||
|
{
|
||||||
|
Key *key;
|
||||||
|
|
||||||
|
key = get_key_by_id(key_id);
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
*type = key->type;
|
||||||
|
*bits = 8 * key->length;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
generate_auth(Key *key, const void *data, int data_len, unsigned char *auth, int auth_len)
|
||||||
|
{
|
||||||
|
switch (key->class) {
|
||||||
|
case NTP_MAC:
|
||||||
|
return HSH_Hash(key->data.ntp_mac.hash_id, key->data.ntp_mac.value,
|
||||||
|
key->length, data, data_len, auth, auth_len);
|
||||||
|
case CMAC:
|
||||||
|
return CMC_Hash(key->data.cmac, data, data_len, auth, auth_len);
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
check_auth(Key *key, const void *data, int data_len,
|
||||||
|
const unsigned char *auth, int auth_len, int trunc_len)
|
||||||
|
{
|
||||||
|
unsigned char buf[MAX_HASH_LENGTH];
|
||||||
|
int hash_len;
|
||||||
|
|
||||||
|
hash_len = generate_auth(key, data, data_len, buf, sizeof (buf));
|
||||||
|
|
||||||
|
return MIN(hash_len, trunc_len) == auth_len && !memcmp(buf, auth, auth_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
KEY_GenerateAuth(uint32_t key_id, const void *data, int data_len,
|
||||||
|
unsigned char *auth, int auth_len)
|
||||||
|
{
|
||||||
|
Key *key;
|
||||||
|
|
||||||
|
key = get_key_by_id(key_id);
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return generate_auth(key, data, data_len, auth, auth_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
KEY_CheckAuth(uint32_t key_id, const void *data, int data_len,
|
||||||
|
const unsigned char *auth, int auth_len, int trunc_len)
|
||||||
|
{
|
||||||
|
Key *key;
|
||||||
|
|
||||||
|
key = get_key_by_id(key_id);
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return check_auth(key, data, data_len, auth, auth_len, trunc_len);
|
||||||
|
}
|
||||||
|
|||||||
17
keys.h
17
keys.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/keys.h,v 1.8 2002/02/28 23:27:10 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -31,14 +27,21 @@
|
|||||||
#ifndef GOT_KEYS_H
|
#ifndef GOT_KEYS_H
|
||||||
#define GOT_KEYS_H
|
#define GOT_KEYS_H
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
extern void KEY_Initialise(void);
|
extern void KEY_Initialise(void);
|
||||||
extern void KEY_Finalise(void);
|
extern void KEY_Finalise(void);
|
||||||
|
|
||||||
extern void KEY_Reload(void);
|
extern void KEY_Reload(void);
|
||||||
|
|
||||||
extern void KEY_CommandKey(char **key, int *len);
|
extern int KEY_KeyKnown(uint32_t key_id);
|
||||||
|
extern int KEY_GetAuthLength(uint32_t key_id);
|
||||||
|
extern int KEY_CheckKeyLength(uint32_t key_id);
|
||||||
|
extern int KEY_GetKeyInfo(uint32_t key_id, int *type, int *bits);
|
||||||
|
|
||||||
extern int KEY_GetKey(unsigned long key_id, char **key, int *len);
|
extern int KEY_GenerateAuth(uint32_t key_id, const void *data, int data_len,
|
||||||
extern int KEY_KeyKnown(unsigned long key_id);
|
unsigned char *auth, int auth_len);
|
||||||
|
extern int KEY_CheckAuth(uint32_t key_id, const void *data, int data_len,
|
||||||
|
const unsigned char *auth, int auth_len, int trunc_len);
|
||||||
|
|
||||||
#endif /* GOT_KEYS_H */
|
#endif /* GOT_KEYS_H */
|
||||||
|
|||||||
612
local.c
612
local.c
@@ -1,12 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/local.c,v 1.21 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
|
* Copyright (C) Miroslav Lichvar 2011, 2014-2015
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -31,12 +28,15 @@
|
|||||||
They interface with the system specific driver files in sys_*.c
|
They interface with the system specific driver files in sys_*.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include "config.h"
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
|
#include "conf.h"
|
||||||
#include "local.h"
|
#include "local.h"
|
||||||
#include "localp.h"
|
#include "localp.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "smooth.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
@@ -45,6 +45,12 @@
|
|||||||
/* Variable to store the current frequency, in ppm */
|
/* Variable to store the current frequency, in ppm */
|
||||||
static double current_freq_ppm;
|
static double current_freq_ppm;
|
||||||
|
|
||||||
|
/* Maximum allowed frequency, in ppm */
|
||||||
|
static double max_freq_ppm;
|
||||||
|
|
||||||
|
/* Temperature compensation, in ppm */
|
||||||
|
static double temp_comp_ppm;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* Store the system dependent drivers */
|
/* Store the system dependent drivers */
|
||||||
|
|
||||||
@@ -53,8 +59,8 @@ static lcl_SetFrequencyDriver drv_set_freq;
|
|||||||
static lcl_AccrueOffsetDriver drv_accrue_offset;
|
static lcl_AccrueOffsetDriver drv_accrue_offset;
|
||||||
static lcl_ApplyStepOffsetDriver drv_apply_step_offset;
|
static lcl_ApplyStepOffsetDriver drv_apply_step_offset;
|
||||||
static lcl_OffsetCorrectionDriver drv_offset_convert;
|
static lcl_OffsetCorrectionDriver drv_offset_convert;
|
||||||
static lcl_ImmediateStepDriver drv_immediate_step;
|
|
||||||
static lcl_SetLeapDriver drv_set_leap;
|
static lcl_SetLeapDriver drv_set_leap;
|
||||||
|
static lcl_SetSyncStatusDriver drv_set_sync_status;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
@@ -89,6 +95,8 @@ static DispersionNotifyListEntry dispersion_notify_list;
|
|||||||
static int precision_log;
|
static int precision_log;
|
||||||
static double precision_quantum;
|
static double precision_quantum;
|
||||||
|
|
||||||
|
static double max_clock_error;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
/* Define the number of increments of the system clock that we want
|
/* Define the number of increments of the system clock that we want
|
||||||
@@ -98,41 +106,36 @@ static double precision_quantum;
|
|||||||
under 1s of busy waiting. */
|
under 1s of busy waiting. */
|
||||||
#define NITERS 100
|
#define NITERS 100
|
||||||
|
|
||||||
static void
|
#define NSEC_PER_SEC 1000000000
|
||||||
calculate_sys_precision(void)
|
|
||||||
{
|
|
||||||
struct timeval tv, old_tv, first_tv;
|
|
||||||
struct timezone tz;
|
|
||||||
int dusec, best_dusec;
|
|
||||||
int iters;
|
|
||||||
|
|
||||||
gettimeofday(&old_tv, &tz);
|
static double
|
||||||
first_tv = old_tv;
|
measure_clock_precision(void)
|
||||||
best_dusec = 1000000; /* Assume we must be better than a second */
|
{
|
||||||
|
struct timespec ts, old_ts;
|
||||||
|
int iters, diff, best;
|
||||||
|
|
||||||
|
LCL_ReadRawTime(&old_ts);
|
||||||
|
|
||||||
|
/* Assume we must be better than a second */
|
||||||
|
best = NSEC_PER_SEC;
|
||||||
iters = 0;
|
iters = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
gettimeofday(&tv, &tz);
|
LCL_ReadRawTime(&ts);
|
||||||
dusec = 1000000*(tv.tv_sec - old_tv.tv_sec) + (tv.tv_usec - old_tv.tv_usec);
|
|
||||||
old_tv = tv;
|
diff = NSEC_PER_SEC * (ts.tv_sec - old_ts.tv_sec) + (ts.tv_nsec - old_ts.tv_nsec);
|
||||||
if (dusec > 0) {
|
|
||||||
if (dusec < best_dusec) {
|
old_ts = ts;
|
||||||
best_dusec = dusec;
|
if (diff > 0) {
|
||||||
}
|
if (diff < best)
|
||||||
|
best = diff;
|
||||||
iters++;
|
iters++;
|
||||||
}
|
}
|
||||||
} while (iters < NITERS);
|
} while (iters < NITERS);
|
||||||
if (!(best_dusec > 0)) {
|
|
||||||
CROAK("best_dusec should be positive");
|
|
||||||
}
|
|
||||||
precision_log = 0;
|
|
||||||
while (best_dusec < 500000) {
|
|
||||||
precision_log--;
|
|
||||||
best_dusec *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
precision_quantum = 1.0 / (double)(1<<(-precision_log));
|
assert(best > 0);
|
||||||
|
|
||||||
return;
|
return 1.0e-9 * best;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -154,8 +157,25 @@ LCL_Initialise(void)
|
|||||||
|
|
||||||
/* This ought to be set from the system driver layer */
|
/* This ought to be set from the system driver layer */
|
||||||
current_freq_ppm = 0.0;
|
current_freq_ppm = 0.0;
|
||||||
|
temp_comp_ppm = 0.0;
|
||||||
|
|
||||||
calculate_sys_precision();
|
precision_quantum = CNF_GetClockPrecision();
|
||||||
|
if (precision_quantum <= 0.0)
|
||||||
|
precision_quantum = measure_clock_precision();
|
||||||
|
|
||||||
|
precision_quantum = CLAMP(1.0e-9, precision_quantum, 1.0);
|
||||||
|
precision_log = round(log(precision_quantum) / log(2.0));
|
||||||
|
/* NTP code doesn't support smaller log than -30 */
|
||||||
|
assert(precision_log >= -30);
|
||||||
|
|
||||||
|
DEBUG_LOG("Clock precision %.9f (%d)", precision_quantum, precision_log);
|
||||||
|
|
||||||
|
/* This is the maximum allowed frequency offset in ppm, the time must
|
||||||
|
never stop or run backwards */
|
||||||
|
max_freq_ppm = CNF_GetMaxDrift();
|
||||||
|
max_freq_ppm = CLAMP(0.0, max_freq_ppm, 500000.0);
|
||||||
|
|
||||||
|
max_clock_error = CNF_GetMaxClockError() * 1e-6;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -163,7 +183,11 @@ LCL_Initialise(void)
|
|||||||
void
|
void
|
||||||
LCL_Finalise(void)
|
LCL_Finalise(void)
|
||||||
{
|
{
|
||||||
return;
|
/* Make sure all handlers have been removed */
|
||||||
|
if (change_list.next != &change_list)
|
||||||
|
assert(0);
|
||||||
|
if (dispersion_notify_list.next != &dispersion_notify_list)
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -186,6 +210,14 @@ LCL_GetSysPrecisionAsQuantum(void)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
double
|
||||||
|
LCL_GetMaxClockError(void)
|
||||||
|
{
|
||||||
|
return max_clock_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
LCL_AddParameterChangeHandler(LCL_ParameterChangeHandler handler, void *anything)
|
LCL_AddParameterChangeHandler(LCL_ParameterChangeHandler handler, void *anything)
|
||||||
{
|
{
|
||||||
@@ -194,7 +226,7 @@ LCL_AddParameterChangeHandler(LCL_ParameterChangeHandler handler, void *anything
|
|||||||
/* Check that the handler is not already registered */
|
/* Check that the handler is not already registered */
|
||||||
for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
|
for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
|
||||||
if (!(ptr->handler != handler || ptr->anything != anything)) {
|
if (!(ptr->handler != handler || ptr->anything != anything)) {
|
||||||
CROAK("a handler is already registered");
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,14 +240,11 @@ LCL_AddParameterChangeHandler(LCL_ParameterChangeHandler handler, void *anything
|
|||||||
new_entry->prev = change_list.prev;
|
new_entry->prev = change_list.prev;
|
||||||
change_list.prev->next = new_entry;
|
change_list.prev->next = new_entry;
|
||||||
change_list.prev = new_entry;
|
change_list.prev = new_entry;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
/* Remove a handler */
|
/* Remove a handler */
|
||||||
extern
|
|
||||||
void LCL_RemoveParameterChangeHandler(LCL_ParameterChangeHandler handler, void *anything)
|
void LCL_RemoveParameterChangeHandler(LCL_ParameterChangeHandler handler, void *anything)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -232,17 +261,35 @@ void LCL_RemoveParameterChangeHandler(LCL_ParameterChangeHandler handler, void *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ok) {
|
assert(ok);
|
||||||
CROAK("did not find a matching handler");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unlink entry from the list */
|
/* Unlink entry from the list */
|
||||||
ptr->next->prev = ptr->prev;
|
ptr->next->prev = ptr->prev;
|
||||||
ptr->prev->next = ptr->next;
|
ptr->prev->next = ptr->next;
|
||||||
|
|
||||||
free(ptr);
|
Free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
LCL_IsFirstParameterChangeHandler(LCL_ParameterChangeHandler handler)
|
||||||
|
{
|
||||||
|
return change_list.next->handler == handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
invoke_parameter_change_handlers(struct timespec *raw, struct timespec *cooked,
|
||||||
|
double dfreq, double doffset,
|
||||||
|
LCL_ChangeType change_type)
|
||||||
|
{
|
||||||
|
ChangeListEntry *ptr;
|
||||||
|
|
||||||
|
for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
|
||||||
|
(ptr->handler)(raw, cooked, dfreq, doffset, change_type, ptr->anything);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -255,7 +302,7 @@ LCL_AddDispersionNotifyHandler(LCL_DispersionNotifyHandler handler, void *anythi
|
|||||||
/* Check that the handler is not already registered */
|
/* Check that the handler is not already registered */
|
||||||
for (ptr = dispersion_notify_list.next; ptr != &dispersion_notify_list; ptr = ptr->next) {
|
for (ptr = dispersion_notify_list.next; ptr != &dispersion_notify_list; ptr = ptr->next) {
|
||||||
if (!(ptr->handler != handler || ptr->anything != anything)) {
|
if (!(ptr->handler != handler || ptr->anything != anything)) {
|
||||||
CROAK("a handler is already registered");
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,8 +316,6 @@ LCL_AddDispersionNotifyHandler(LCL_DispersionNotifyHandler handler, void *anythi
|
|||||||
new_entry->prev = dispersion_notify_list.prev;
|
new_entry->prev = dispersion_notify_list.prev;
|
||||||
dispersion_notify_list.prev->next = new_entry;
|
dispersion_notify_list.prev->next = new_entry;
|
||||||
dispersion_notify_list.prev = new_entry;
|
dispersion_notify_list.prev = new_entry;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -293,102 +338,137 @@ void LCL_RemoveDispersionNotifyHandler(LCL_DispersionNotifyHandler handler, void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ok) {
|
assert(ok);
|
||||||
CROAK("no matching handler found");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unlink entry from the list */
|
/* Unlink entry from the list */
|
||||||
ptr->next->prev = ptr->prev;
|
ptr->next->prev = ptr->prev;
|
||||||
ptr->prev->next = ptr->next;
|
ptr->prev->next = ptr->next;
|
||||||
|
|
||||||
free(ptr);
|
Free(ptr);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
/* At the moment, this is just gettimeofday(), because
|
|
||||||
I can't think of a Unix system where it would not be */
|
|
||||||
|
|
||||||
void
|
|
||||||
LCL_ReadRawTime(struct timeval *result)
|
|
||||||
{
|
|
||||||
struct timezone tz;
|
|
||||||
|
|
||||||
if (!(gettimeofday(result, &tz) >= 0)) {
|
|
||||||
CROAK("Could not get time of day");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
LCL_ReadCookedTime(struct timeval *result, double *err)
|
LCL_ReadRawTime(struct timespec *ts)
|
||||||
{
|
{
|
||||||
struct timeval raw;
|
#if HAVE_CLOCK_GETTIME
|
||||||
double correction;
|
if (clock_gettime(CLOCK_REALTIME, ts) < 0)
|
||||||
|
LOG_FATAL("clock_gettime() failed : %s", strerror(errno));
|
||||||
|
#else
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
if (gettimeofday(&tv, NULL) < 0)
|
||||||
|
LOG_FATAL("gettimeofday() failed : %s", strerror(errno));
|
||||||
|
|
||||||
|
UTI_TimevalToTimespec(&tv, ts);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LCL_ReadCookedTime(struct timespec *result, double *err)
|
||||||
|
{
|
||||||
|
struct timespec raw;
|
||||||
|
|
||||||
LCL_ReadRawTime(&raw);
|
LCL_ReadRawTime(&raw);
|
||||||
|
LCL_CookTime(&raw, result, err);
|
||||||
/* For now, cheat and set the error to zero in all cases.
|
|
||||||
*/
|
|
||||||
|
|
||||||
*err = 0.0;
|
|
||||||
|
|
||||||
/* Call system specific driver to get correction */
|
|
||||||
(*drv_offset_convert)(&raw, &correction);
|
|
||||||
UTI_AddDoubleToTimeval(&raw, correction, result);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
double
|
void
|
||||||
LCL_GetOffsetCorrection(struct timeval *raw)
|
LCL_CookTime(struct timespec *raw, struct timespec *cooked, double *err)
|
||||||
{
|
{
|
||||||
double correction;
|
double correction;
|
||||||
(*drv_offset_convert)(raw, &correction);
|
|
||||||
return correction;
|
LCL_GetOffsetCorrection(raw, &correction, err);
|
||||||
|
UTI_AddDoubleToTimespec(raw, correction, cooked);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* This is just a simple passthrough of the system specific routine */
|
|
||||||
|
void
|
||||||
|
LCL_GetOffsetCorrection(struct timespec *raw, double *correction, double *err)
|
||||||
|
{
|
||||||
|
/* Call system specific driver to get correction */
|
||||||
|
(*drv_offset_convert)(raw, correction, err);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
/* Return current frequency */
|
||||||
|
|
||||||
double
|
double
|
||||||
LCL_ReadAbsoluteFrequency(void)
|
LCL_ReadAbsoluteFrequency(void)
|
||||||
{
|
{
|
||||||
return (*drv_read_freq)();
|
double freq;
|
||||||
|
|
||||||
|
freq = current_freq_ppm;
|
||||||
|
|
||||||
|
/* Undo temperature compensation */
|
||||||
|
if (temp_comp_ppm != 0.0) {
|
||||||
|
freq = (freq + temp_comp_ppm) / (1.0 - 1.0e-6 * temp_comp_ppm);
|
||||||
|
}
|
||||||
|
|
||||||
|
return freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
static double
|
||||||
|
clamp_freq(double freq)
|
||||||
|
{
|
||||||
|
if (freq <= max_freq_ppm && freq >= -max_freq_ppm)
|
||||||
|
return freq;
|
||||||
|
|
||||||
|
LOG(LOGS_WARN, "Frequency %.1f ppm exceeds allowed maximum", freq);
|
||||||
|
|
||||||
|
return CLAMP(-max_freq_ppm, freq, max_freq_ppm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
check_offset(struct timespec *now, double offset)
|
||||||
|
{
|
||||||
|
/* Check if the time will be still sane with accumulated offset */
|
||||||
|
if (UTI_IsTimeOffsetSane(now, -offset))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
LOG(LOGS_WARN, "Adjustment of %.1f seconds is invalid", -offset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
/* This involves both setting the absolute frequency with the
|
/* This involves both setting the absolute frequency with the
|
||||||
system-specific driver, as well as calling all notify handlers */
|
system-specific driver, as well as calling all notify handlers */
|
||||||
|
|
||||||
void
|
void
|
||||||
LCL_SetAbsoluteFrequency(double afreq_ppm)
|
LCL_SetAbsoluteFrequency(double afreq_ppm)
|
||||||
{
|
{
|
||||||
ChangeListEntry *ptr;
|
struct timespec raw, cooked;
|
||||||
struct timeval raw, cooked;
|
|
||||||
double correction;
|
|
||||||
double dfreq;
|
double dfreq;
|
||||||
|
|
||||||
|
afreq_ppm = clamp_freq(afreq_ppm);
|
||||||
|
|
||||||
|
/* Apply temperature compensation */
|
||||||
|
if (temp_comp_ppm != 0.0) {
|
||||||
|
afreq_ppm = afreq_ppm * (1.0 - 1.0e-6 * temp_comp_ppm) - temp_comp_ppm;
|
||||||
|
}
|
||||||
|
|
||||||
/* Call the system-specific driver for setting the frequency */
|
/* Call the system-specific driver for setting the frequency */
|
||||||
|
|
||||||
(*drv_set_freq)(afreq_ppm);
|
afreq_ppm = (*drv_set_freq)(afreq_ppm);
|
||||||
|
|
||||||
dfreq = 1.0e-6 * (afreq_ppm - current_freq_ppm) / (1.0 - 1.0e-6 * current_freq_ppm);
|
dfreq = (afreq_ppm - current_freq_ppm) / (1.0e6 - current_freq_ppm);
|
||||||
|
|
||||||
LCL_ReadRawTime(&raw);
|
LCL_ReadRawTime(&raw);
|
||||||
(drv_offset_convert)(&raw, &correction);
|
LCL_CookTime(&raw, &cooked, NULL);
|
||||||
UTI_AddDoubleToTimeval(&raw, correction, &cooked);
|
|
||||||
|
|
||||||
/* Dispatch to all handlers */
|
/* Dispatch to all handlers */
|
||||||
for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
|
invoke_parameter_change_handlers(&raw, &cooked, dfreq, 0.0, LCL_ChangeAdjust);
|
||||||
(ptr->handler)(&raw, &cooked, dfreq, afreq_ppm, 0.0, 0, ptr->anything);
|
|
||||||
}
|
|
||||||
|
|
||||||
current_freq_ppm = afreq_ppm;
|
current_freq_ppm = afreq_ppm;
|
||||||
|
|
||||||
@@ -399,120 +479,151 @@ LCL_SetAbsoluteFrequency(double afreq_ppm)
|
|||||||
void
|
void
|
||||||
LCL_AccumulateDeltaFrequency(double dfreq)
|
LCL_AccumulateDeltaFrequency(double dfreq)
|
||||||
{
|
{
|
||||||
ChangeListEntry *ptr;
|
struct timespec raw, cooked;
|
||||||
struct timeval raw, cooked;
|
|
||||||
double correction;
|
|
||||||
|
|
||||||
/* Work out new absolute frequency. Note that absolute frequencies
|
|
||||||
are handled in units of ppm, whereas the 'dfreq' argument is in
|
|
||||||
terms of the gradient of the (offset) v (local time) function. */
|
|
||||||
|
|
||||||
current_freq_ppm = (1.0 - dfreq) * current_freq_ppm +
|
|
||||||
(1.0e6 * dfreq);
|
|
||||||
|
|
||||||
/* Call the system-specific driver for setting the frequency */
|
|
||||||
(*drv_set_freq)(current_freq_ppm);
|
|
||||||
|
|
||||||
LCL_ReadRawTime(&raw);
|
|
||||||
(drv_offset_convert)(&raw, &correction);
|
|
||||||
UTI_AddDoubleToTimeval(&raw, correction, &cooked);
|
|
||||||
|
|
||||||
/* Dispatch to all handlers */
|
|
||||||
for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
|
|
||||||
(ptr->handler)(&raw, &cooked, dfreq, current_freq_ppm, 0.0, 0, ptr->anything);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
void
|
|
||||||
LCL_AccumulateOffset(double offset)
|
|
||||||
{
|
|
||||||
ChangeListEntry *ptr;
|
|
||||||
struct timeval raw, cooked;
|
|
||||||
double correction;
|
|
||||||
|
|
||||||
/* In this case, the cooked time to be passed to the notify clients
|
|
||||||
has to be the cooked time BEFORE the change was made */
|
|
||||||
|
|
||||||
LCL_ReadRawTime(&raw);
|
|
||||||
(drv_offset_convert)(&raw, &correction);
|
|
||||||
UTI_AddDoubleToTimeval(&raw, correction, &cooked);
|
|
||||||
|
|
||||||
(*drv_accrue_offset)(offset);
|
|
||||||
|
|
||||||
/* Dispatch to all handlers */
|
|
||||||
for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
|
|
||||||
(ptr->handler)(&raw, &cooked, 0.0, current_freq_ppm, offset, 0, ptr->anything);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
void
|
|
||||||
LCL_ApplyStepOffset(double offset)
|
|
||||||
{
|
|
||||||
ChangeListEntry *ptr;
|
|
||||||
struct timeval raw, cooked;
|
|
||||||
double correction;
|
|
||||||
|
|
||||||
/* In this case, the cooked time to be passed to the notify clients
|
|
||||||
has to be the cooked time BEFORE the change was made */
|
|
||||||
|
|
||||||
LCL_ReadRawTime(&raw);
|
|
||||||
(drv_offset_convert)(&raw, &correction);
|
|
||||||
UTI_AddDoubleToTimeval(&raw, correction, &cooked);
|
|
||||||
|
|
||||||
(*drv_apply_step_offset)(offset);
|
|
||||||
|
|
||||||
/* Dispatch to all handlers */
|
|
||||||
for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
|
|
||||||
(ptr->handler)(&raw, &cooked, 0.0, current_freq_ppm, offset, 1, ptr->anything);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
void
|
|
||||||
LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset)
|
|
||||||
{
|
|
||||||
ChangeListEntry *ptr;
|
|
||||||
struct timeval raw, cooked;
|
|
||||||
double correction;
|
|
||||||
double old_freq_ppm;
|
double old_freq_ppm;
|
||||||
|
|
||||||
LCL_ReadRawTime(&raw);
|
|
||||||
(drv_offset_convert)(&raw, &correction);
|
|
||||||
/* Due to modifying the offset, this has to be the cooked time prior
|
|
||||||
to the change we are about to make */
|
|
||||||
UTI_AddDoubleToTimeval(&raw, correction, &cooked);
|
|
||||||
|
|
||||||
old_freq_ppm = current_freq_ppm;
|
old_freq_ppm = current_freq_ppm;
|
||||||
|
|
||||||
/* Work out new absolute frequency. Note that absolute frequencies
|
/* Work out new absolute frequency. Note that absolute frequencies
|
||||||
are handled in units of ppm, whereas the 'dfreq' argument is in
|
are handled in units of ppm, whereas the 'dfreq' argument is in
|
||||||
terms of the gradient of the (offset) v (local time) function. */
|
terms of the gradient of the (offset) v (local time) function. */
|
||||||
current_freq_ppm = (1.0 - dfreq) * old_freq_ppm +
|
|
||||||
(1.0e6 * dfreq);
|
|
||||||
|
|
||||||
#ifdef TRACEON
|
current_freq_ppm += dfreq * (1.0e6 - current_freq_ppm);
|
||||||
LOG(LOGS_INFO, LOGF_Local, "old_freq=%.3fppm new_freq=%.3fppm offset=%.6fsec",
|
|
||||||
old_freq_ppm, current_freq_ppm, doffset);
|
current_freq_ppm = clamp_freq(current_freq_ppm);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Call the system-specific driver for setting the frequency */
|
/* Call the system-specific driver for setting the frequency */
|
||||||
(*drv_set_freq)(current_freq_ppm);
|
current_freq_ppm = (*drv_set_freq)(current_freq_ppm);
|
||||||
(*drv_accrue_offset)(doffset);
|
dfreq = (current_freq_ppm - old_freq_ppm) / (1.0e6 - old_freq_ppm);
|
||||||
|
|
||||||
|
LCL_ReadRawTime(&raw);
|
||||||
|
LCL_CookTime(&raw, &cooked, NULL);
|
||||||
|
|
||||||
/* Dispatch to all handlers */
|
/* Dispatch to all handlers */
|
||||||
for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
|
invoke_parameter_change_handlers(&raw, &cooked, dfreq, 0.0, LCL_ChangeAdjust);
|
||||||
(ptr->handler)(&raw, &cooked, dfreq, current_freq_ppm, doffset, 0, ptr->anything);
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
LCL_AccumulateOffset(double offset, double corr_rate)
|
||||||
|
{
|
||||||
|
struct timespec raw, cooked;
|
||||||
|
|
||||||
|
/* In this case, the cooked time to be passed to the notify clients
|
||||||
|
has to be the cooked time BEFORE the change was made */
|
||||||
|
|
||||||
|
LCL_ReadRawTime(&raw);
|
||||||
|
LCL_CookTime(&raw, &cooked, NULL);
|
||||||
|
|
||||||
|
if (!check_offset(&cooked, offset))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
(*drv_accrue_offset)(offset, corr_rate);
|
||||||
|
|
||||||
|
/* Dispatch to all handlers */
|
||||||
|
invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, LCL_ChangeAdjust);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
LCL_ApplyStepOffset(double offset)
|
||||||
|
{
|
||||||
|
struct timespec raw, cooked;
|
||||||
|
|
||||||
|
/* In this case, the cooked time to be passed to the notify clients
|
||||||
|
has to be the cooked time BEFORE the change was made */
|
||||||
|
|
||||||
|
LCL_ReadRawTime(&raw);
|
||||||
|
LCL_CookTime(&raw, &cooked, NULL);
|
||||||
|
|
||||||
|
if (!check_offset(&raw, offset))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!(*drv_apply_step_offset)(offset)) {
|
||||||
|
LOG(LOGS_ERR, "Could not step system clock");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reset smoothing on all clock steps */
|
||||||
|
SMT_Reset(&cooked);
|
||||||
|
|
||||||
|
/* Dispatch to all handlers */
|
||||||
|
invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, LCL_ChangeStep);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LCL_NotifyExternalTimeStep(struct timespec *raw, struct timespec *cooked,
|
||||||
|
double offset, double dispersion)
|
||||||
|
{
|
||||||
|
/* Dispatch to all handlers */
|
||||||
|
invoke_parameter_change_handlers(raw, cooked, 0.0, offset, LCL_ChangeUnknownStep);
|
||||||
|
|
||||||
|
lcl_InvokeDispersionNotifyHandlers(dispersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LCL_NotifyLeap(int leap)
|
||||||
|
{
|
||||||
|
struct timespec raw, cooked;
|
||||||
|
|
||||||
|
LCL_ReadRawTime(&raw);
|
||||||
|
LCL_CookTime(&raw, &cooked, NULL);
|
||||||
|
|
||||||
|
/* Smooth the leap second out */
|
||||||
|
SMT_Leap(&cooked, leap);
|
||||||
|
|
||||||
|
/* Dispatch to all handlers as if the clock was stepped */
|
||||||
|
invoke_parameter_change_handlers(&raw, &cooked, 0.0, -leap, LCL_ChangeStep);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset, double corr_rate)
|
||||||
|
{
|
||||||
|
struct timespec raw, cooked;
|
||||||
|
double old_freq_ppm;
|
||||||
|
|
||||||
|
LCL_ReadRawTime(&raw);
|
||||||
|
/* Due to modifying the offset, this has to be the cooked time prior
|
||||||
|
to the change we are about to make */
|
||||||
|
LCL_CookTime(&raw, &cooked, NULL);
|
||||||
|
|
||||||
|
if (!check_offset(&cooked, doffset))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
old_freq_ppm = current_freq_ppm;
|
||||||
|
|
||||||
|
/* Work out new absolute frequency. Note that absolute frequencies
|
||||||
|
are handled in units of ppm, whereas the 'dfreq' argument is in
|
||||||
|
terms of the gradient of the (offset) v (local time) function. */
|
||||||
|
current_freq_ppm += dfreq * (1.0e6 - current_freq_ppm);
|
||||||
|
|
||||||
|
current_freq_ppm = clamp_freq(current_freq_ppm);
|
||||||
|
|
||||||
|
DEBUG_LOG("old_freq=%.3fppm new_freq=%.3fppm offset=%.6fsec",
|
||||||
|
old_freq_ppm, current_freq_ppm, doffset);
|
||||||
|
|
||||||
|
/* Call the system-specific driver for setting the frequency */
|
||||||
|
current_freq_ppm = (*drv_set_freq)(current_freq_ppm);
|
||||||
|
dfreq = (current_freq_ppm - old_freq_ppm) / (1.0e6 - old_freq_ppm);
|
||||||
|
|
||||||
|
(*drv_accrue_offset)(doffset, corr_rate);
|
||||||
|
|
||||||
|
/* Dispatch to all handlers */
|
||||||
|
invoke_parameter_change_handlers(&raw, &cooked, dfreq, doffset, LCL_ChangeAdjust);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -536,24 +647,20 @@ lcl_RegisterSystemDrivers(lcl_ReadFrequencyDriver read_freq,
|
|||||||
lcl_AccrueOffsetDriver accrue_offset,
|
lcl_AccrueOffsetDriver accrue_offset,
|
||||||
lcl_ApplyStepOffsetDriver apply_step_offset,
|
lcl_ApplyStepOffsetDriver apply_step_offset,
|
||||||
lcl_OffsetCorrectionDriver offset_convert,
|
lcl_OffsetCorrectionDriver offset_convert,
|
||||||
lcl_ImmediateStepDriver immediate_step,
|
lcl_SetLeapDriver set_leap,
|
||||||
lcl_SetLeapDriver set_leap)
|
lcl_SetSyncStatusDriver set_sync_status)
|
||||||
{
|
{
|
||||||
drv_read_freq = read_freq;
|
drv_read_freq = read_freq;
|
||||||
drv_set_freq = set_freq;
|
drv_set_freq = set_freq;
|
||||||
drv_accrue_offset = accrue_offset;
|
drv_accrue_offset = accrue_offset;
|
||||||
drv_apply_step_offset = apply_step_offset;
|
drv_apply_step_offset = apply_step_offset;
|
||||||
drv_offset_convert = offset_convert;
|
drv_offset_convert = offset_convert;
|
||||||
drv_immediate_step = immediate_step;
|
|
||||||
drv_set_leap = set_leap;
|
drv_set_leap = set_leap;
|
||||||
|
drv_set_sync_status = set_sync_status;
|
||||||
|
|
||||||
current_freq_ppm = (*drv_read_freq)();
|
current_freq_ppm = (*drv_read_freq)();
|
||||||
|
|
||||||
#ifdef TRACEON
|
DEBUG_LOG("Local freq=%.3fppm", current_freq_ppm);
|
||||||
LOG(LOGS_INFO, LOGF_Local, "Local freq=%.3fppm", current_freq_ppm);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -563,27 +670,92 @@ lcl_RegisterSystemDrivers(lcl_ReadFrequencyDriver read_freq,
|
|||||||
int
|
int
|
||||||
LCL_MakeStep(void)
|
LCL_MakeStep(void)
|
||||||
{
|
{
|
||||||
if (drv_immediate_step) {
|
struct timespec raw;
|
||||||
(drv_immediate_step)();
|
double correction;
|
||||||
#ifdef TRACEON
|
|
||||||
LOG(LOGS_INFO, LOGF_Local, "Made step to system time to apply remaining slew");
|
|
||||||
#endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
LCL_ReadRawTime(&raw);
|
||||||
|
LCL_GetOffsetCorrection(&raw, &correction, NULL);
|
||||||
|
|
||||||
|
if (!check_offset(&raw, -correction))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Cancel remaining slew and make the step */
|
||||||
|
LCL_AccumulateOffset(correction, 0.0);
|
||||||
|
if (!LCL_ApplyStepOffset(-correction))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
LOG(LOGS_WARN, "System clock was stepped by %.6f seconds", correction);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
LCL_SetLeap(int leap)
|
LCL_CancelOffsetCorrection(void)
|
||||||
{
|
{
|
||||||
if (drv_set_leap) {
|
struct timespec raw;
|
||||||
(drv_set_leap)(leap);
|
double correction;
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
LCL_ReadRawTime(&raw);
|
||||||
|
LCL_GetOffsetCorrection(&raw, &correction, NULL);
|
||||||
|
LCL_AccumulateOffset(correction, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
LCL_CanSystemLeap(void)
|
||||||
|
{
|
||||||
|
return drv_set_leap ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LCL_SetSystemLeap(int leap, int tai_offset)
|
||||||
|
{
|
||||||
|
if (drv_set_leap) {
|
||||||
|
(drv_set_leap)(leap, tai_offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
double
|
||||||
|
LCL_SetTempComp(double comp)
|
||||||
|
{
|
||||||
|
double uncomp_freq_ppm;
|
||||||
|
|
||||||
|
if (temp_comp_ppm == comp)
|
||||||
|
return comp;
|
||||||
|
|
||||||
|
/* Undo previous compensation */
|
||||||
|
current_freq_ppm = (current_freq_ppm + temp_comp_ppm) /
|
||||||
|
(1.0 - 1.0e-6 * temp_comp_ppm);
|
||||||
|
|
||||||
|
uncomp_freq_ppm = current_freq_ppm;
|
||||||
|
|
||||||
|
/* Apply new compensation */
|
||||||
|
current_freq_ppm = current_freq_ppm * (1.0 - 1.0e-6 * comp) - comp;
|
||||||
|
|
||||||
|
/* Call the system-specific driver for setting the frequency */
|
||||||
|
current_freq_ppm = (*drv_set_freq)(current_freq_ppm);
|
||||||
|
|
||||||
|
temp_comp_ppm = (uncomp_freq_ppm - current_freq_ppm) /
|
||||||
|
(1.0e-6 * uncomp_freq_ppm + 1.0);
|
||||||
|
|
||||||
|
return temp_comp_ppm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LCL_SetSyncStatus(int synchronised, double est_error, double max_error)
|
||||||
|
{
|
||||||
|
if (drv_set_sync_status) {
|
||||||
|
(drv_set_sync_status)(synchronised, est_error, max_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|||||||
91
local.h
91
local.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/local.h,v 1.16 2002/02/28 23:27:10 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -35,9 +31,8 @@
|
|||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
/* Read the system clock. This is analogous to gettimeofday(),
|
/* Read the system clock */
|
||||||
but with the timezone information ignored */
|
extern void LCL_ReadRawTime(struct timespec *ts);
|
||||||
extern void LCL_ReadRawTime(struct timeval *);
|
|
||||||
|
|
||||||
/* Read the system clock, corrected according to all accumulated
|
/* Read the system clock, corrected according to all accumulated
|
||||||
drifts and uncompensated offsets.
|
drifts and uncompensated offsets.
|
||||||
@@ -48,13 +43,15 @@ extern void LCL_ReadRawTime(struct timeval *);
|
|||||||
adjtime()-like interface to correct offsets, and to adjust the
|
adjtime()-like interface to correct offsets, and to adjust the
|
||||||
frequency), we must correct the raw time to get this value */
|
frequency), we must correct the raw time to get this value */
|
||||||
|
|
||||||
extern void LCL_ReadCookedTime(struct timeval *t, double *err);
|
extern void LCL_ReadCookedTime(struct timespec *ts, double *err);
|
||||||
|
|
||||||
|
/* Convert raw time to cooked. */
|
||||||
|
extern void LCL_CookTime(struct timespec *raw, struct timespec *cooked, double *err);
|
||||||
|
|
||||||
/* Read the current offset between the system clock and true time
|
/* Read the current offset between the system clock and true time
|
||||||
(i.e. 'cooked' - 'raw') (in seconds). Only intended for use in
|
(i.e. 'cooked' - 'raw') (in seconds). */
|
||||||
status reporting, really. */
|
|
||||||
|
|
||||||
extern double LCL_GetOffsetCorrection(struct timeval *raw);
|
extern void LCL_GetOffsetCorrection(struct timespec *raw, double *correction, double *err);
|
||||||
|
|
||||||
/* Type of routines that may be invoked as callbacks when there is a
|
/* Type of routines that may be invoked as callbacks when there is a
|
||||||
change to the frequency or offset.
|
change to the frequency or offset.
|
||||||
@@ -66,23 +63,25 @@ extern double LCL_GetOffsetCorrection(struct timeval *raw);
|
|||||||
dfreq : delta frequency relative to previous value (in terms of
|
dfreq : delta frequency relative to previous value (in terms of
|
||||||
seconds gained by system clock per unit system clock time)
|
seconds gained by system clock per unit system clock time)
|
||||||
|
|
||||||
afreq : absolute frequency relative to uncompensated system (in
|
|
||||||
terms of ppm seconds gained by system clock per unit of the
|
|
||||||
uncalibrated system clock)
|
|
||||||
|
|
||||||
doffset : delta offset applied (positive => make local system fast
|
doffset : delta offset applied (positive => make local system fast
|
||||||
by that amount, negative => make it slow by that amount)
|
by that amount, negative => make it slow by that amount)
|
||||||
|
|
||||||
is_step_change : true if change is being applied as a jump (using
|
change_type : what type of change is being applied
|
||||||
settimeofday rather than adjtime)
|
|
||||||
|
|
||||||
anything : Passthrough argument from call to registration routine */
|
anything : Passthrough argument from call to registration routine */
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
LCL_ChangeAdjust,
|
||||||
|
LCL_ChangeStep,
|
||||||
|
LCL_ChangeUnknownStep
|
||||||
|
} LCL_ChangeType;
|
||||||
|
|
||||||
typedef void (*LCL_ParameterChangeHandler)
|
typedef void (*LCL_ParameterChangeHandler)
|
||||||
(struct timeval *raw, struct timeval *cooked,
|
(struct timespec *raw, struct timespec *cooked,
|
||||||
double dfreq, double afreq_ppm,
|
double dfreq,
|
||||||
double doffset, int is_step_change,
|
double doffset,
|
||||||
|
LCL_ChangeType change_type,
|
||||||
void *anything
|
void *anything
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -92,6 +91,9 @@ extern void LCL_AddParameterChangeHandler(LCL_ParameterChangeHandler handler, vo
|
|||||||
/* Remove a handler */
|
/* Remove a handler */
|
||||||
extern void LCL_RemoveParameterChangeHandler(LCL_ParameterChangeHandler, void *anything);
|
extern void LCL_RemoveParameterChangeHandler(LCL_ParameterChangeHandler, void *anything);
|
||||||
|
|
||||||
|
/* Check if a handler is invoked first when dispatching */
|
||||||
|
extern int LCL_IsFirstParameterChangeHandler(LCL_ParameterChangeHandler handler);
|
||||||
|
|
||||||
/* Function type for handlers to be called back when an indeterminate
|
/* Function type for handlers to be called back when an indeterminate
|
||||||
offset is introduced into the local time. This situation occurs
|
offset is introduced into the local time. This situation occurs
|
||||||
when the frequency must be adjusted to effect a clock slew and
|
when the frequency must be adjusted to effect a clock slew and
|
||||||
@@ -144,9 +146,10 @@ extern void LCL_AccumulateDeltaFrequency(double dfreq);
|
|||||||
/* Routine to apply an offset (in seconds) to the local clock. The
|
/* Routine to apply an offset (in seconds) to the local clock. The
|
||||||
argument should be positive to move the clock backwards (i.e. the
|
argument should be positive to move the clock backwards (i.e. the
|
||||||
local clock is currently fast of true time), or negative to move it
|
local clock is currently fast of true time), or negative to move it
|
||||||
forwards (i.e. it is currently slow of true time). */
|
forwards (i.e. it is currently slow of true time). Provided is also
|
||||||
|
a suggested correction rate (correction time * offset). */
|
||||||
|
|
||||||
extern void LCL_AccumulateOffset(double offset);
|
extern int LCL_AccumulateOffset(double offset, double corr_rate);
|
||||||
|
|
||||||
/* Routine to apply an immediate offset by doing a sudden step if
|
/* Routine to apply an immediate offset by doing a sudden step if
|
||||||
possible. (Intended for use after an initial estimate of offset has
|
possible. (Intended for use after an initial estimate of offset has
|
||||||
@@ -155,11 +158,20 @@ extern void LCL_AccumulateOffset(double offset);
|
|||||||
the system clock is fast on true time, i.e. it needs to be stepped
|
the system clock is fast on true time, i.e. it needs to be stepped
|
||||||
backwards. (Same convention as for AccumulateOffset routine). */
|
backwards. (Same convention as for AccumulateOffset routine). */
|
||||||
|
|
||||||
extern void LCL_ApplyStepOffset(double offset);
|
extern int LCL_ApplyStepOffset(double offset);
|
||||||
|
|
||||||
|
/* Routine to invoke notify handlers on an unexpected time jump
|
||||||
|
in system clock */
|
||||||
|
extern void LCL_NotifyExternalTimeStep(struct timespec *raw, struct timespec *cooked,
|
||||||
|
double offset, double dispersion);
|
||||||
|
|
||||||
|
/* Routine to invoke notify handlers on leap second when the system clock
|
||||||
|
doesn't correct itself */
|
||||||
|
extern void LCL_NotifyLeap(int leap);
|
||||||
|
|
||||||
/* Perform the combination of modifying the frequency and applying
|
/* Perform the combination of modifying the frequency and applying
|
||||||
a slew, in one easy step */
|
a slew, in one easy step */
|
||||||
extern void LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset);
|
extern int LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset, double corr_rate);
|
||||||
|
|
||||||
/* Routine to read the system precision as a log to base 2 value. */
|
/* Routine to read the system precision as a log to base 2 value. */
|
||||||
extern int LCL_GetSysPrecisionAsLog(void);
|
extern int LCL_GetSysPrecisionAsLog(void);
|
||||||
@@ -167,6 +179,10 @@ extern int LCL_GetSysPrecisionAsLog(void);
|
|||||||
/* Routine to read the system precision in terms of the actual time step */
|
/* Routine to read the system precision in terms of the actual time step */
|
||||||
extern double LCL_GetSysPrecisionAsQuantum(void);
|
extern double LCL_GetSysPrecisionAsQuantum(void);
|
||||||
|
|
||||||
|
/* Routine to read the maximum frequency error of the local clock. This
|
||||||
|
is a frequency stability, not an absolute error. */
|
||||||
|
extern double LCL_GetMaxClockError(void);
|
||||||
|
|
||||||
/* Routine to initialise the module (to be called once at program
|
/* Routine to initialise the module (to be called once at program
|
||||||
start-up) */
|
start-up) */
|
||||||
|
|
||||||
@@ -181,9 +197,28 @@ extern void LCL_Finalise(void);
|
|||||||
to a timezone problem. */
|
to a timezone problem. */
|
||||||
extern int LCL_MakeStep(void);
|
extern int LCL_MakeStep(void);
|
||||||
|
|
||||||
/* Routine to schedule a leap second. Leap second will be inserted
|
/* Routine to cancel the outstanding system clock correction */
|
||||||
at the end of the day if argument is positive, deleted if negative,
|
extern void LCL_CancelOffsetCorrection(void);
|
||||||
and zero cancels scheduled leap second. */
|
|
||||||
extern void LCL_SetLeap(int leap);
|
/* Check if the system driver supports leap seconds, i.e. LCL_SetSystemLeap
|
||||||
|
does something */
|
||||||
|
extern int LCL_CanSystemLeap(void);
|
||||||
|
|
||||||
|
/* Routine to set the system clock to correct itself for a leap second and also
|
||||||
|
set its TAI-UTC offset. If supported, leap second will be inserted at the
|
||||||
|
end of the day if the argument is positive, deleted if negative, and zero
|
||||||
|
resets the setting. */
|
||||||
|
extern void LCL_SetSystemLeap(int leap, int tai_offset);
|
||||||
|
|
||||||
|
/* Routine to set a frequency correction (in ppm) that should be applied
|
||||||
|
to local clock to compensate for temperature changes. A positive
|
||||||
|
argument means that the clock frequency should be increased. Return the
|
||||||
|
actual compensation (may be different from the requested compensation
|
||||||
|
due to clamping or rounding). */
|
||||||
|
extern double LCL_SetTempComp(double comp);
|
||||||
|
|
||||||
|
/* Routine to update the synchronisation status in the kernel to allow other
|
||||||
|
applications to know if the system clock is synchronised and error bounds */
|
||||||
|
extern void LCL_SetSyncStatus(int synchronised, double est_error, double max_error);
|
||||||
|
|
||||||
#endif /* GOT_LOCAL_H */
|
#endif /* GOT_LOCAL_H */
|
||||||
|
|||||||
31
localp.h
31
localp.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/localp.h,v 1.9 2002/02/28 23:27:10 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -40,28 +36,29 @@ typedef double (*lcl_ReadFrequencyDriver)(void);
|
|||||||
|
|
||||||
/* System driver to set the current local frequency, in ppm relative
|
/* System driver to set the current local frequency, in ppm relative
|
||||||
to nominal. A positive value indicates that the local clock runs
|
to nominal. A positive value indicates that the local clock runs
|
||||||
fast when uncompensated. */
|
fast when uncompensated. Return actual frequency (may be different
|
||||||
typedef void (*lcl_SetFrequencyDriver)(double freq_ppm);
|
from the requested frequency due to clamping or rounding). */
|
||||||
|
typedef double (*lcl_SetFrequencyDriver)(double freq_ppm);
|
||||||
|
|
||||||
/* System driver to accrue an offset. A positive argument means slew
|
/* System driver to accrue an offset. A positive argument means slew
|
||||||
the clock forwards. */
|
the clock forwards. The suggested correction rate of time to correct the
|
||||||
typedef void (*lcl_AccrueOffsetDriver)(double offset);
|
offset is given in 'corr_rate'. */
|
||||||
|
typedef void (*lcl_AccrueOffsetDriver)(double offset, double corr_rate);
|
||||||
|
|
||||||
/* System driver to apply a step offset. A positive argument means step
|
/* System driver to apply a step offset. A positive argument means step
|
||||||
the clock forwards. */
|
the clock forwards. */
|
||||||
typedef void (*lcl_ApplyStepOffsetDriver)(double offset);
|
typedef int (*lcl_ApplyStepOffsetDriver)(double offset);
|
||||||
|
|
||||||
/* System driver to convert a raw time to an adjusted (cooked) time.
|
/* System driver to convert a raw time to an adjusted (cooked) time.
|
||||||
The number of seconds returned in 'corr' have to be added to the
|
The number of seconds returned in 'corr' have to be added to the
|
||||||
raw time to get the corrected time */
|
raw time to get the corrected time */
|
||||||
typedef void (*lcl_OffsetCorrectionDriver)(struct timeval *raw, double *corr);
|
typedef void (*lcl_OffsetCorrectionDriver)(struct timespec *raw, double *corr, double *err);
|
||||||
|
|
||||||
/* System driver to stop slewing the current offset and to apply is
|
/* System driver to schedule leap seconds and set TAI-UTC offset */
|
||||||
as an immediate step instead */
|
typedef void (*lcl_SetLeapDriver)(int leap, int tai_offset);
|
||||||
typedef void (*lcl_ImmediateStepDriver)(void);
|
|
||||||
|
|
||||||
/* System driver to schedule leap second */
|
/* System driver to set the synchronisation status */
|
||||||
typedef void (*lcl_SetLeapDriver)(int leap);
|
typedef void (*lcl_SetSyncStatusDriver)(int synchronised, double est_error, double max_error);
|
||||||
|
|
||||||
extern void lcl_InvokeDispersionNotifyHandlers(double dispersion);
|
extern void lcl_InvokeDispersionNotifyHandlers(double dispersion);
|
||||||
|
|
||||||
@@ -71,7 +68,7 @@ lcl_RegisterSystemDrivers(lcl_ReadFrequencyDriver read_freq,
|
|||||||
lcl_AccrueOffsetDriver accrue_offset,
|
lcl_AccrueOffsetDriver accrue_offset,
|
||||||
lcl_ApplyStepOffsetDriver apply_step_offset,
|
lcl_ApplyStepOffsetDriver apply_step_offset,
|
||||||
lcl_OffsetCorrectionDriver offset_convert,
|
lcl_OffsetCorrectionDriver offset_convert,
|
||||||
lcl_ImmediateStepDriver immediate_step_driver,
|
lcl_SetLeapDriver set_leap,
|
||||||
lcl_SetLeapDriver set_leap);
|
lcl_SetSyncStatusDriver set_sync_status);
|
||||||
|
|
||||||
#endif /* GOT_LOCALP_H */
|
#endif /* GOT_LOCALP_H */
|
||||||
|
|||||||
392
logging.c
392
logging.c
@@ -1,12 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/logging.c,v 1.15 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
|
* Copyright (C) Miroslav Lichvar 2011-2014, 2018-2020
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -28,21 +25,45 @@
|
|||||||
Module to handle logging of diagnostic information
|
Module to handle logging of diagnostic information
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "main.h"
|
#include <syslog.h>
|
||||||
|
|
||||||
|
#include "conf.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "version.h"
|
#include "memory.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
/* This is used by DEBUG_LOG macro */
|
||||||
|
LOG_Severity log_min_severity = LOGS_INFO;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* Flag indicating we have initialised */
|
/* Flag indicating we have initialised */
|
||||||
static int initialised = 0;
|
static int initialised = 0;
|
||||||
|
|
||||||
static int is_detached = 0;
|
static FILE *file_log = NULL;
|
||||||
|
static int system_log = 0;
|
||||||
|
|
||||||
#ifdef WINNT
|
static int parent_fd = 0;
|
||||||
static FILE *logfile;
|
|
||||||
#endif
|
struct LogFile {
|
||||||
|
const char *name;
|
||||||
|
const char *banner;
|
||||||
|
FILE *file;
|
||||||
|
unsigned long writes;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int n_filelogs = 0;
|
||||||
|
|
||||||
|
/* Increase this when adding a new logfile */
|
||||||
|
#define MAX_FILELOGS 6
|
||||||
|
|
||||||
|
static struct LogFile logfiles[MAX_FILELOGS];
|
||||||
|
|
||||||
|
/* Global prefix for debug messages */
|
||||||
|
static char *debug_prefix;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* Init function */
|
/* Init function */
|
||||||
@@ -50,13 +71,9 @@ static FILE *logfile;
|
|||||||
void
|
void
|
||||||
LOG_Initialise(void)
|
LOG_Initialise(void)
|
||||||
{
|
{
|
||||||
|
debug_prefix = Strdup("");
|
||||||
initialised = 1;
|
initialised = 1;
|
||||||
|
LOG_OpenFileLog(NULL);
|
||||||
#ifdef WINNT
|
|
||||||
logfile = fopen("./chronyd.err", "a");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -65,168 +82,271 @@ LOG_Initialise(void)
|
|||||||
void
|
void
|
||||||
LOG_Finalise(void)
|
LOG_Finalise(void)
|
||||||
{
|
{
|
||||||
#ifdef WINNT
|
if (system_log)
|
||||||
if (logfile) {
|
|
||||||
fclose(logfile);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (is_detached) {
|
|
||||||
closelog();
|
closelog();
|
||||||
}
|
|
||||||
#endif
|
if (file_log)
|
||||||
|
fclose(file_log);
|
||||||
|
|
||||||
|
LOG_CycleLogFiles();
|
||||||
|
|
||||||
|
Free(debug_prefix);
|
||||||
|
|
||||||
initialised = 0;
|
initialised = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
static void log_message(int fatal, LOG_Severity severity, const char *message)
|
||||||
LOG_Line_Function(LOG_Severity severity, LOG_Facility facility, const char *format, ...)
|
|
||||||
{
|
{
|
||||||
char buf[2048];
|
if (system_log) {
|
||||||
va_list other_args;
|
int priority;
|
||||||
va_start(other_args, format);
|
|
||||||
vsnprintf(buf, sizeof(buf), format, other_args);
|
|
||||||
va_end(other_args);
|
|
||||||
#ifdef WINNT
|
|
||||||
if (logfile) {
|
|
||||||
fprintf(logfile, "%s\n", buf);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (is_detached) {
|
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
|
case LOGS_DEBUG:
|
||||||
|
priority = LOG_DEBUG;
|
||||||
|
break;
|
||||||
case LOGS_INFO:
|
case LOGS_INFO:
|
||||||
syslog(LOG_INFO, "%s", buf);
|
priority = LOG_INFO;
|
||||||
break;
|
break;
|
||||||
case LOGS_WARN:
|
case LOGS_WARN:
|
||||||
syslog(LOG_WARNING, "%s", buf);
|
priority = LOG_WARNING;
|
||||||
break;
|
break;
|
||||||
case LOGS_ERR:
|
case LOGS_ERR:
|
||||||
default:
|
priority = LOG_ERR;
|
||||||
syslog(LOG_ERR, "%s", buf);
|
|
||||||
break;
|
break;
|
||||||
|
case LOGS_FATAL:
|
||||||
|
priority = LOG_CRIT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
} else {
|
syslog(priority, fatal ? "Fatal error : %s" : "%s", message);
|
||||||
fprintf(stderr, "%s\n", buf);
|
} else if (file_log) {
|
||||||
|
fprintf(file_log, fatal ? "Fatal error : %s\n" : "%s\n", message);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void LOG_Message(LOG_Severity severity,
|
||||||
LOG_Fatal_Function(LOG_Facility facility, const char *format, ...)
|
#if DEBUG > 0
|
||||||
|
int line_number, const char *filename, const char *function_name,
|
||||||
|
#endif
|
||||||
|
const char *format, ...)
|
||||||
{
|
{
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
va_list other_args;
|
va_list other_args;
|
||||||
|
time_t t;
|
||||||
|
struct tm *tm;
|
||||||
|
|
||||||
|
assert(initialised);
|
||||||
|
|
||||||
|
if (!system_log && file_log && severity >= log_min_severity) {
|
||||||
|
/* Don't clutter up syslog with timestamps and internal debugging info */
|
||||||
|
time(&t);
|
||||||
|
tm = gmtime(&t);
|
||||||
|
if (tm) {
|
||||||
|
strftime(buf, sizeof (buf), "%Y-%m-%dT%H:%M:%SZ", tm);
|
||||||
|
fprintf(file_log, "%s ", buf);
|
||||||
|
}
|
||||||
|
#if DEBUG > 0
|
||||||
|
if (log_min_severity <= LOGS_DEBUG)
|
||||||
|
fprintf(file_log, "%s%s:%d:(%s) ", debug_prefix, filename, line_number, function_name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
va_start(other_args, format);
|
va_start(other_args, format);
|
||||||
vsnprintf(buf, sizeof(buf), format, other_args);
|
vsnprintf(buf, sizeof(buf), format, other_args);
|
||||||
va_end(other_args);
|
va_end(other_args);
|
||||||
|
|
||||||
#ifdef WINNT
|
switch (severity) {
|
||||||
if (logfile) {
|
case LOGS_DEBUG:
|
||||||
fprintf(logfile, "Fatal error : %s\n", buf);
|
case LOGS_INFO:
|
||||||
}
|
case LOGS_WARN:
|
||||||
#else
|
case LOGS_ERR:
|
||||||
if (is_detached) {
|
if (severity >= log_min_severity)
|
||||||
syslog(LOG_CRIT, "Fatal error : %s", buf);
|
log_message(0, severity, buf);
|
||||||
} else {
|
break;
|
||||||
fprintf(stderr, "Fatal error : %s\n", buf);
|
case LOGS_FATAL:
|
||||||
}
|
if (severity >= log_min_severity)
|
||||||
#endif
|
log_message(1, severity, buf);
|
||||||
|
|
||||||
MAI_CleanupAndExit();
|
/* Send the message also to the foreground process if it is
|
||||||
|
still running, or stderr if it is still open */
|
||||||
return;
|
if (parent_fd > 0) {
|
||||||
}
|
if (write(parent_fd, buf, strlen(buf) + 1) < 0)
|
||||||
|
; /* Not much we can do here */
|
||||||
/* ================================================== */
|
} else if (system_log && parent_fd == 0) {
|
||||||
|
system_log = 0;
|
||||||
void
|
log_message(1, severity, buf);
|
||||||
LOG_Position(const char *filename, int line_number, const char *function_name)
|
|
||||||
{
|
|
||||||
#ifdef WINNT
|
|
||||||
#else
|
|
||||||
time_t t;
|
|
||||||
struct tm stm;
|
|
||||||
char buf[64];
|
|
||||||
if (!is_detached) {
|
|
||||||
/* Don't clutter up syslog with internal debugging info */
|
|
||||||
time(&t);
|
|
||||||
stm = *gmtime(&t);
|
|
||||||
strftime(buf, sizeof(buf), "%d-%H:%M:%S", &stm);
|
|
||||||
fprintf(stderr, "%s:%d:(%s)[%s] ", filename, line_number, function_name, buf);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
void
|
|
||||||
LOG_GoDaemon(void)
|
|
||||||
{
|
|
||||||
#ifdef WINNT
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int pid, fd;
|
|
||||||
|
|
||||||
/* Does this preserve existing signal handlers? */
|
|
||||||
pid = fork();
|
|
||||||
|
|
||||||
if (pid < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_Logging, "Could not detach, fork failed : %s", strerror(errno));
|
|
||||||
} else if (pid > 0) {
|
|
||||||
exit(0); /* In the 'grandparent' */
|
|
||||||
} else {
|
|
||||||
|
|
||||||
setsid();
|
|
||||||
|
|
||||||
/* Do 2nd fork, as-per recommended practice for launching daemons. */
|
|
||||||
pid = fork();
|
|
||||||
|
|
||||||
if (pid < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_Logging, "Could not detach, fork failed : %s", strerror(errno));
|
|
||||||
} else if (pid > 0) {
|
|
||||||
exit(0); /* In the 'parent' */
|
|
||||||
} else {
|
|
||||||
/* In the child we want to leave running as the daemon */
|
|
||||||
|
|
||||||
/* Don't keep stdin/out/err from before. */
|
|
||||||
for (fd=0; fd<1024; fd++) {
|
|
||||||
close(fd);
|
|
||||||
}
|
}
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is_detached = 1;
|
/* ================================================== */
|
||||||
|
|
||||||
openlog("chronyd", LOG_PID, LOG_DAEMON);
|
void
|
||||||
|
LOG_OpenFileLog(const char *log_file)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
LOG(LOGS_INFO, LOGF_Logging, "chronyd version %s starting", PROGRAM_VERSION_STRING);
|
if (log_file) {
|
||||||
|
f = UTI_OpenFile(NULL, log_file, NULL, 'A', 0640);
|
||||||
|
} else {
|
||||||
|
f = stderr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Enable line buffering */
|
||||||
|
setvbuf(f, NULL, _IOLBF, BUFSIZ);
|
||||||
|
|
||||||
|
if (file_log && file_log != stderr)
|
||||||
|
fclose(file_log);
|
||||||
|
|
||||||
|
file_log = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LOG_OpenSystemLog(void)
|
||||||
|
{
|
||||||
|
system_log = 1;
|
||||||
|
openlog("chronyd", LOG_PID, LOG_DAEMON);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void LOG_SetMinSeverity(LOG_Severity severity)
|
||||||
|
{
|
||||||
|
/* Don't print any debug messages in a non-debug build */
|
||||||
|
log_min_severity = CLAMP(DEBUG > 0 ? LOGS_DEBUG : LOGS_INFO, severity, LOGS_FATAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
LOG_Severity
|
||||||
|
LOG_GetMinSeverity(void)
|
||||||
|
{
|
||||||
|
return log_min_severity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LOG_SetDebugPrefix(const char *prefix)
|
||||||
|
{
|
||||||
|
Free(debug_prefix);
|
||||||
|
debug_prefix = Strdup(prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LOG_SetParentFd(int fd)
|
||||||
|
{
|
||||||
|
parent_fd = fd;
|
||||||
|
if (file_log == stderr)
|
||||||
|
file_log = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LOG_CloseParentFd()
|
||||||
|
{
|
||||||
|
if (parent_fd > 0)
|
||||||
|
close(parent_fd);
|
||||||
|
parent_fd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
LOG_FileID
|
||||||
|
LOG_FileOpen(const char *name, const char *banner)
|
||||||
|
{
|
||||||
|
if (n_filelogs >= MAX_FILELOGS) {
|
||||||
|
assert(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
logfiles[n_filelogs].name = name;
|
||||||
|
logfiles[n_filelogs].banner = banner;
|
||||||
|
logfiles[n_filelogs].file = NULL;
|
||||||
|
logfiles[n_filelogs].writes = 0;
|
||||||
|
|
||||||
|
return n_filelogs++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LOG_FileWrite(LOG_FileID id, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list other_args;
|
||||||
|
int banner;
|
||||||
|
|
||||||
|
if (id < 0 || id >= n_filelogs || !logfiles[id].name)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!logfiles[id].file) {
|
||||||
|
char *logdir = CNF_GetLogDir();
|
||||||
|
|
||||||
|
if (!logdir) {
|
||||||
|
LOG(LOGS_WARN, "logdir not specified");
|
||||||
|
logfiles[id].name = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logfiles[id].file = UTI_OpenFile(logdir, logfiles[id].name, ".log", 'a', 0644);
|
||||||
|
if (!logfiles[id].file) {
|
||||||
|
/* Disable the log */
|
||||||
|
logfiles[id].name = NULL;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
banner = CNF_GetLogBanner();
|
||||||
|
if (banner && logfiles[id].writes++ % banner == 0) {
|
||||||
|
char bannerline[256];
|
||||||
|
int i, bannerlen;
|
||||||
|
|
||||||
|
bannerlen = MIN(strlen(logfiles[id].banner), sizeof (bannerline) - 1);
|
||||||
|
|
||||||
|
for (i = 0; i < bannerlen; i++)
|
||||||
|
bannerline[i] = '=';
|
||||||
|
bannerline[i] = '\0';
|
||||||
|
|
||||||
|
fprintf(logfiles[id].file, "%s\n", bannerline);
|
||||||
|
fprintf(logfiles[id].file, "%s\n", logfiles[id].banner);
|
||||||
|
fprintf(logfiles[id].file, "%s\n", bannerline);
|
||||||
|
}
|
||||||
|
|
||||||
|
va_start(other_args, format);
|
||||||
|
vfprintf(logfiles[id].file, format, other_args);
|
||||||
|
va_end(other_args);
|
||||||
|
fprintf(logfiles[id].file, "\n");
|
||||||
|
|
||||||
|
fflush(logfiles[id].file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* Force a core dump and exit without doing abort() or assert(0).
|
|
||||||
These do funny things with the call stack in the core file that is
|
|
||||||
generated, which makes diagnosis difficult. */
|
|
||||||
|
|
||||||
int
|
void
|
||||||
croak(const char *file, int line, const char *msg)
|
LOG_CycleLogFiles(void)
|
||||||
{
|
{
|
||||||
int a;
|
LOG_FileID i;
|
||||||
LOG(LOGS_ERR, LOGF_Util, "Unexpected condition [%s] at %s:%d, core dumped",
|
|
||||||
msg, file, line);
|
for (i = 0; i < n_filelogs; i++) {
|
||||||
a = * (int *) 0;
|
if (logfiles[i].file)
|
||||||
return a; /* Can't happen - this stops the optimiser optimising the
|
fclose(logfiles[i].file);
|
||||||
line above */
|
logfiles[i].file = NULL;
|
||||||
|
logfiles[i].writes = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|||||||
144
logging.h
144
logging.h
@@ -1,12 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/logging.h,v 1.15 2002/02/28 23:27:10 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2002
|
* Copyright (C) Richard P. Curnow 1997-2002
|
||||||
|
* Copyright (C) Miroslav Lichvar 2013-2015
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -32,43 +29,52 @@
|
|||||||
#ifndef GOT_LOGGING_H
|
#ifndef GOT_LOGGING_H
|
||||||
#define GOT_LOGGING_H
|
#define GOT_LOGGING_H
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
|
/* Line logging macros. If the compiler is GNU C, we take advantage of
|
||||||
|
being able to get the function name also. */
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define FUNCTION_NAME __FUNCTION__
|
||||||
|
#define FORMAT_ATTRIBUTE_PRINTF(str, first) __attribute__ ((format (printf, str, first)))
|
||||||
|
#else
|
||||||
|
#define FUNCTION_NAME ""
|
||||||
|
#define FORMAT_ATTRIBUTE_PRINTF(str, first)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DEBUG > 0
|
||||||
|
#define LOG_MESSAGE(severity, ...) \
|
||||||
|
LOG_Message(severity, __LINE__, __FILE__, FUNCTION_NAME, __VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define LOG_MESSAGE(severity, ...) \
|
||||||
|
LOG_Message(severity, __VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DEBUG_LOG(...) \
|
||||||
|
do { \
|
||||||
|
if (DEBUG && log_min_severity == LOGS_DEBUG) \
|
||||||
|
LOG_MESSAGE(LOGS_DEBUG, __VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LOG_FATAL(...) \
|
||||||
|
do { \
|
||||||
|
LOG_MESSAGE(LOGS_FATAL, __VA_ARGS__); \
|
||||||
|
exit(1); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LOG(severity, ...) LOG_MESSAGE(severity, __VA_ARGS__)
|
||||||
|
|
||||||
/* Definition of severity */
|
/* Definition of severity */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LOGS_INFO,
|
LOGS_DEBUG = -1,
|
||||||
|
LOGS_INFO = 0,
|
||||||
LOGS_WARN,
|
LOGS_WARN,
|
||||||
LOGS_ERR
|
LOGS_ERR,
|
||||||
|
LOGS_FATAL,
|
||||||
} LOG_Severity;
|
} LOG_Severity;
|
||||||
|
|
||||||
/* Definition of facility. Each message is tagged with who generated
|
/* Minimum severity of messages to be logged */
|
||||||
it, so that the user can customise what level of reporting he gets
|
extern LOG_Severity log_min_severity;
|
||||||
for each area of the software */
|
|
||||||
typedef enum {
|
|
||||||
LOGF_Reference,
|
|
||||||
LOGF_NtpIO,
|
|
||||||
LOGF_NtpCore,
|
|
||||||
LOGF_NtpSources,
|
|
||||||
LOGF_Scheduler,
|
|
||||||
LOGF_SourceStats,
|
|
||||||
LOGF_Sources,
|
|
||||||
LOGF_Local,
|
|
||||||
LOGF_Util,
|
|
||||||
LOGF_Main,
|
|
||||||
LOGF_ClientLog,
|
|
||||||
LOGF_Configure,
|
|
||||||
LOGF_CmdMon,
|
|
||||||
LOGF_Acquire,
|
|
||||||
LOGF_Manual,
|
|
||||||
LOGF_Logging,
|
|
||||||
LOGF_Rtc,
|
|
||||||
LOGF_Regress,
|
|
||||||
LOGF_Sys,
|
|
||||||
LOGF_SysLinux,
|
|
||||||
LOGF_SysSolaris,
|
|
||||||
LOGF_SysSunOS,
|
|
||||||
LOGF_SysWinnt,
|
|
||||||
LOGF_RtcLinux,
|
|
||||||
LOGF_Refclock
|
|
||||||
} LOG_Facility;
|
|
||||||
|
|
||||||
/* Init function */
|
/* Init function */
|
||||||
extern void LOG_Initialise(void);
|
extern void LOG_Initialise(void);
|
||||||
@@ -77,33 +83,47 @@ extern void LOG_Initialise(void);
|
|||||||
extern void LOG_Finalise(void);
|
extern void LOG_Finalise(void);
|
||||||
|
|
||||||
/* Line logging function */
|
/* Line logging function */
|
||||||
extern void LOG_Line_Function(LOG_Severity severity, LOG_Facility facility, const char *format, ...);
|
#if DEBUG > 0
|
||||||
|
FORMAT_ATTRIBUTE_PRINTF(5, 6)
|
||||||
/* Logging function for fatal errors */
|
extern void LOG_Message(LOG_Severity severity, int line_number, const char *filename,
|
||||||
extern void LOG_Fatal_Function(LOG_Facility facility, const char *format, ...);
|
const char *function_name, const char *format, ...);
|
||||||
|
|
||||||
/* Position in code reporting function */
|
|
||||||
extern void LOG_Position(const char *filename, int line_number, const char *function_name);
|
|
||||||
|
|
||||||
extern void LOG_GoDaemon(void);
|
|
||||||
|
|
||||||
/* Line logging macro. If the compiler is GNU C, we take advantage of
|
|
||||||
being able to get the function name also. */
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
#define LOG LOG_Position(__FILE__, __LINE__, __FUNCTION__); LOG_Line_Function
|
|
||||||
#define LOG_FATAL LOG_Position(__FILE__, __LINE__, __FUNCTION__); LOG_Fatal_Function
|
|
||||||
#else
|
#else
|
||||||
#define LOG LOG_Position(__FILE__, __LINE__, ""); LOG_Line_Function
|
FORMAT_ATTRIBUTE_PRINTF(2, 3)
|
||||||
#define LOG_FATAL LOG_Position(__FILE__, __LINE__, ""); LOG_Fatal_Function
|
extern void LOG_Message(LOG_Severity severity, const char *format, ...);
|
||||||
#endif /* defined (__GNUC__) */
|
|
||||||
|
|
||||||
/* Like assert(0) */
|
|
||||||
|
|
||||||
#if defined(LINUX) && defined(__alpha__)
|
|
||||||
#define CROAK(message) assert(0) /* Added JGH Feb 24 2001 FIXME */
|
|
||||||
#else
|
|
||||||
extern int croak(const char *file, int line, const char *msg);
|
|
||||||
#define CROAK(message) croak(__FILE__, __LINE__, message);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Set the minimum severity of a message to be logged or printed to terminal.
|
||||||
|
If the severity is LOGS_DEBUG and DEBUG is enabled, all messages will be
|
||||||
|
prefixed with the filename, line number, and function name. */
|
||||||
|
extern void LOG_SetMinSeverity(LOG_Severity severity);
|
||||||
|
|
||||||
|
/* Get the minimum severity */
|
||||||
|
extern LOG_Severity LOG_GetMinSeverity(void);
|
||||||
|
|
||||||
|
/* Set a prefix for debug messages */
|
||||||
|
extern void LOG_SetDebugPrefix(const char *prefix);
|
||||||
|
|
||||||
|
/* Log messages to a file instead of stderr, or stderr again if NULL */
|
||||||
|
extern void LOG_OpenFileLog(const char *log_file);
|
||||||
|
|
||||||
|
/* Log messages to syslog instead of stderr */
|
||||||
|
extern void LOG_OpenSystemLog(void);
|
||||||
|
|
||||||
|
/* Stop using stderr and send fatal message to the foreground process */
|
||||||
|
extern void LOG_SetParentFd(int fd);
|
||||||
|
|
||||||
|
/* Close the pipe to the foreground process so it can exit */
|
||||||
|
extern void LOG_CloseParentFd(void);
|
||||||
|
|
||||||
|
/* File logging functions */
|
||||||
|
|
||||||
|
typedef int LOG_FileID;
|
||||||
|
|
||||||
|
extern LOG_FileID LOG_FileOpen(const char *name, const char *banner);
|
||||||
|
|
||||||
|
FORMAT_ATTRIBUTE_PRINTF(2, 3)
|
||||||
|
extern void LOG_FileWrite(LOG_FileID id, const char *format, ...);
|
||||||
|
|
||||||
|
extern void LOG_CycleLogFiles(void);
|
||||||
|
|
||||||
#endif /* GOT_LOGGING_H */
|
#endif /* GOT_LOGGING_H */
|
||||||
|
|||||||
644
main.c
644
main.c
@@ -1,13 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/main.c,v 1.31 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
* Copyright (C) John G. Hasler 2009
|
* Copyright (C) John G. Hasler 2009
|
||||||
|
* Copyright (C) Miroslav Lichvar 2012-2020
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -29,6 +26,8 @@
|
|||||||
The main program
|
The main program
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@@ -36,8 +35,12 @@
|
|||||||
#include "local.h"
|
#include "local.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "ntp_io.h"
|
#include "ntp_io.h"
|
||||||
|
#include "ntp_signd.h"
|
||||||
#include "ntp_sources.h"
|
#include "ntp_sources.h"
|
||||||
#include "ntp_core.h"
|
#include "ntp_core.h"
|
||||||
|
#include "nts_ke_server.h"
|
||||||
|
#include "nts_ntp_server.h"
|
||||||
|
#include "socket.h"
|
||||||
#include "sources.h"
|
#include "sources.h"
|
||||||
#include "sourcestats.h"
|
#include "sourcestats.h"
|
||||||
#include "reference.h"
|
#include "reference.h"
|
||||||
@@ -45,14 +48,15 @@
|
|||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "cmdmon.h"
|
#include "cmdmon.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "acquire.h"
|
|
||||||
#include "manual.h"
|
#include "manual.h"
|
||||||
#include "version.h"
|
|
||||||
#include "rtc.h"
|
#include "rtc.h"
|
||||||
#include "refclock.h"
|
#include "refclock.h"
|
||||||
#include "clientlog.h"
|
#include "clientlog.h"
|
||||||
#include "broadcast.h"
|
|
||||||
#include "nameserv.h"
|
#include "nameserv.h"
|
||||||
|
#include "privops.h"
|
||||||
|
#include "smooth.h"
|
||||||
|
#include "tempcomp.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
@@ -61,18 +65,36 @@
|
|||||||
|
|
||||||
static int initialised = 0;
|
static int initialised = 0;
|
||||||
|
|
||||||
/* ================================================== */
|
static int exit_status = 0;
|
||||||
|
|
||||||
static int reload = 0;
|
static int reload = 0;
|
||||||
|
|
||||||
|
static REF_Mode ref_mode = REF_ModeNormal;
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_platform_checks(void)
|
||||||
|
{
|
||||||
|
/* Require at least 32-bit integers, two's complement representation and
|
||||||
|
the usual implementation of conversion of unsigned integers */
|
||||||
|
assert(sizeof (int) >= 4);
|
||||||
|
assert(-1 == ~0);
|
||||||
|
assert((int32_t)4294967295U == (int32_t)-1);
|
||||||
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
delete_pidfile(void)
|
delete_pidfile(void)
|
||||||
{
|
{
|
||||||
const char *pidfile = CNF_GetPidFile();
|
const char *pidfile = CNF_GetPidFile();
|
||||||
/* Don't care if this fails, there's not a lot we can do */
|
|
||||||
unlink(pidfile);
|
if (!pidfile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!UTI_RemoveFile(NULL, pidfile, NULL))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -80,35 +102,46 @@ delete_pidfile(void)
|
|||||||
void
|
void
|
||||||
MAI_CleanupAndExit(void)
|
MAI_CleanupAndExit(void)
|
||||||
{
|
{
|
||||||
if (!initialised) exit(0);
|
if (!initialised) exit(exit_status);
|
||||||
|
|
||||||
if (CNF_GetDumpOnExit()) {
|
LCL_CancelOffsetCorrection();
|
||||||
SRC_DumpSources();
|
SRC_DumpSources();
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Don't update clock when removing sources */
|
||||||
|
REF_SetMode(REF_ModeIgnore);
|
||||||
|
|
||||||
|
SMT_Finalise();
|
||||||
|
TMC_Finalise();
|
||||||
MNL_Finalise();
|
MNL_Finalise();
|
||||||
ACQ_Finalise();
|
|
||||||
KEY_Finalise();
|
|
||||||
CLG_Finalise();
|
CLG_Finalise();
|
||||||
|
NKS_Finalise();
|
||||||
|
NNS_Finalise();
|
||||||
|
NSD_Finalise();
|
||||||
NSR_Finalise();
|
NSR_Finalise();
|
||||||
NCR_Finalise();
|
|
||||||
BRD_Finalise();
|
|
||||||
SRC_Finalise();
|
|
||||||
SST_Finalise();
|
SST_Finalise();
|
||||||
REF_Finalise();
|
NCR_Finalise();
|
||||||
RCL_Finalise();
|
|
||||||
RTC_Finalise();
|
|
||||||
CAM_Finalise();
|
|
||||||
NIO_Finalise();
|
NIO_Finalise();
|
||||||
|
CAM_Finalise();
|
||||||
|
|
||||||
|
KEY_Finalise();
|
||||||
|
RCL_Finalise();
|
||||||
|
SRC_Finalise();
|
||||||
|
REF_Finalise();
|
||||||
|
RTC_Finalise();
|
||||||
SYS_Finalise();
|
SYS_Finalise();
|
||||||
|
|
||||||
|
SCK_Finalise();
|
||||||
SCH_Finalise();
|
SCH_Finalise();
|
||||||
LCL_Finalise();
|
LCL_Finalise();
|
||||||
|
PRV_Finalise();
|
||||||
|
|
||||||
delete_pidfile();
|
delete_pidfile();
|
||||||
|
|
||||||
|
CNF_Finalise();
|
||||||
|
HSH_Finalise();
|
||||||
LOG_Finalise();
|
LOG_Finalise();
|
||||||
|
|
||||||
exit(0);
|
exit(exit_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -116,19 +149,26 @@ MAI_CleanupAndExit(void)
|
|||||||
static void
|
static void
|
||||||
signal_cleanup(int x)
|
signal_cleanup(int x)
|
||||||
{
|
{
|
||||||
LOG(LOGS_WARN, LOGF_Main, "chronyd exiting on signal");
|
|
||||||
if (!initialised) exit(0);
|
|
||||||
SCH_QuitProgram();
|
SCH_QuitProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
post_acquire_hook(void *anything)
|
quit_timeout(void *arg)
|
||||||
{
|
{
|
||||||
|
/* Return with non-zero status if the clock is not synchronised */
|
||||||
|
exit_status = REF_GetOurStratum() >= NTP_MAX_STRATUM;
|
||||||
|
SCH_QuitProgram();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
ntp_source_resolving_end(void)
|
||||||
|
{
|
||||||
|
NSR_SetSourceResolvingEndHandler(NULL);
|
||||||
|
|
||||||
CNF_AddSources();
|
|
||||||
CNF_AddBroadcasts();
|
|
||||||
if (reload) {
|
if (reload) {
|
||||||
/* Note, we want reload to come well after the initialisation from
|
/* Note, we want reload to come well after the initialisation from
|
||||||
the real time clock - this gives us a fighting chance that the
|
the real time clock - this gives us a fighting chance that the
|
||||||
@@ -136,10 +176,63 @@ post_acquire_hook(void *anything)
|
|||||||
semblence of validity about it. */
|
semblence of validity about it. */
|
||||||
SRC_ReloadSources();
|
SRC_ReloadSources();
|
||||||
}
|
}
|
||||||
CNF_SetupAccessRestrictions();
|
|
||||||
|
|
||||||
|
SRC_RemoveDumpFiles();
|
||||||
RTC_StartMeasurements();
|
RTC_StartMeasurements();
|
||||||
RCL_StartRefclocks();
|
RCL_StartRefclocks();
|
||||||
|
NSR_StartSources();
|
||||||
|
NSR_AutoStartSources();
|
||||||
|
|
||||||
|
/* Special modes can end only when sources update their reachability.
|
||||||
|
Give up immediately if there are no active sources. */
|
||||||
|
if (ref_mode != REF_ModeNormal && !SRC_ActiveSources()) {
|
||||||
|
REF_SetUnsynchronised();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
post_init_ntp_hook(void *anything)
|
||||||
|
{
|
||||||
|
if (ref_mode == REF_ModeInitStepSlew) {
|
||||||
|
/* Remove the initstepslew sources and set normal mode */
|
||||||
|
NSR_RemoveAllSources();
|
||||||
|
ref_mode = REF_ModeNormal;
|
||||||
|
REF_SetMode(ref_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the pipe to the foreground process so it can exit */
|
||||||
|
LOG_CloseParentFd();
|
||||||
|
|
||||||
|
CNF_AddSources();
|
||||||
|
CNF_AddBroadcasts();
|
||||||
|
|
||||||
|
NSR_SetSourceResolvingEndHandler(ntp_source_resolving_end);
|
||||||
|
NSR_ResolveSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
reference_mode_end(int result)
|
||||||
|
{
|
||||||
|
switch (ref_mode) {
|
||||||
|
case REF_ModeNormal:
|
||||||
|
case REF_ModeUpdateOnce:
|
||||||
|
case REF_ModePrintOnce:
|
||||||
|
exit_status = !result;
|
||||||
|
SCH_QuitProgram();
|
||||||
|
break;
|
||||||
|
case REF_ModeInitStepSlew:
|
||||||
|
/* Switch to the normal mode, the delay is used to prevent polling
|
||||||
|
interval shorter than the burst interval if some configured servers
|
||||||
|
were used also for initstepslew */
|
||||||
|
SCH_AddTimeoutByDelay(2.0, post_init_ntp_hook, NULL);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -147,63 +240,189 @@ post_acquire_hook(void *anything)
|
|||||||
static void
|
static void
|
||||||
post_init_rtc_hook(void *anything)
|
post_init_rtc_hook(void *anything)
|
||||||
{
|
{
|
||||||
CNF_ProcessInitStepSlew(post_acquire_hook, NULL);
|
if (CNF_GetInitSources() > 0) {
|
||||||
}
|
CNF_AddInitSources();
|
||||||
|
NSR_StartSources();
|
||||||
/* ================================================== */
|
assert(REF_GetMode() != REF_ModeNormal);
|
||||||
/* Return 1 if the process exists on the system. */
|
/* Wait for mode end notification */
|
||||||
|
|
||||||
static int
|
|
||||||
does_process_exist(int pid)
|
|
||||||
{
|
|
||||||
int status;
|
|
||||||
status = getsid(pid);
|
|
||||||
if (status >= 0) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
(post_init_ntp_hook)(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
static int
|
|
||||||
maybe_another_chronyd_running(int *other_pid)
|
|
||||||
{
|
|
||||||
const char *pidfile = CNF_GetPidFile();
|
|
||||||
FILE *in;
|
|
||||||
int pid, count;
|
|
||||||
|
|
||||||
*other_pid = 0;
|
|
||||||
|
|
||||||
in = fopen(pidfile, "r");
|
|
||||||
if (!in) return 0;
|
|
||||||
|
|
||||||
count = fscanf(in, "%d", &pid);
|
|
||||||
fclose(in);
|
|
||||||
|
|
||||||
if (count != 1) return 0;
|
|
||||||
|
|
||||||
*other_pid = pid;
|
|
||||||
return does_process_exist(pid);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_lockfile(void)
|
check_pidfile(void)
|
||||||
|
{
|
||||||
|
const char *pidfile = CNF_GetPidFile();
|
||||||
|
FILE *in;
|
||||||
|
int pid, count;
|
||||||
|
|
||||||
|
if (!pidfile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
in = UTI_OpenFile(NULL, pidfile, NULL, 'r', 0);
|
||||||
|
if (!in)
|
||||||
|
return;
|
||||||
|
|
||||||
|
count = fscanf(in, "%d", &pid);
|
||||||
|
fclose(in);
|
||||||
|
|
||||||
|
if (count != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (getsid(pid) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
LOG_FATAL("Another chronyd may already be running (pid=%d), check %s",
|
||||||
|
pid, pidfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
write_pidfile(void)
|
||||||
{
|
{
|
||||||
const char *pidfile = CNF_GetPidFile();
|
const char *pidfile = CNF_GetPidFile();
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
|
||||||
out = fopen(pidfile, "w");
|
if (!pidfile)
|
||||||
if (!out) {
|
return;
|
||||||
LOG(LOGS_ERR, LOGF_Main, "could not open lockfile %s for writing", pidfile);
|
|
||||||
} else {
|
out = UTI_OpenFile(NULL, pidfile, NULL, 'W', 0644);
|
||||||
fprintf(out, "%d\n", getpid());
|
fprintf(out, "%d\n", (int)getpid());
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
#define DEV_NULL "/dev/null"
|
||||||
|
|
||||||
|
static void
|
||||||
|
go_daemon(void)
|
||||||
|
{
|
||||||
|
int pid, fd, pipefd[2];
|
||||||
|
|
||||||
|
/* Create pipe which will the daemon use to notify the grandparent
|
||||||
|
when it's initialised or send an error message */
|
||||||
|
if (pipe(pipefd)) {
|
||||||
|
LOG_FATAL("pipe() failed : %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Does this preserve existing signal handlers? */
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid < 0) {
|
||||||
|
LOG_FATAL("fork() failed : %s", strerror(errno));
|
||||||
|
} else if (pid > 0) {
|
||||||
|
/* In the 'grandparent' */
|
||||||
|
char message[1024];
|
||||||
|
int r;
|
||||||
|
|
||||||
|
close(pipefd[1]);
|
||||||
|
r = read(pipefd[0], message, sizeof (message));
|
||||||
|
if (r) {
|
||||||
|
if (r > 0) {
|
||||||
|
/* Print the error message from the child */
|
||||||
|
message[sizeof (message) - 1] = '\0';
|
||||||
|
fprintf(stderr, "%s\n", message);
|
||||||
|
}
|
||||||
|
exit(1);
|
||||||
|
} else
|
||||||
|
exit(0);
|
||||||
|
} else {
|
||||||
|
close(pipefd[0]);
|
||||||
|
|
||||||
|
setsid();
|
||||||
|
|
||||||
|
/* Do 2nd fork, as-per recommended practice for launching daemons. */
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid < 0) {
|
||||||
|
LOG_FATAL("fork() failed : %s", strerror(errno));
|
||||||
|
} else if (pid > 0) {
|
||||||
|
exit(0); /* In the 'parent' */
|
||||||
|
} else {
|
||||||
|
/* In the child we want to leave running as the daemon */
|
||||||
|
|
||||||
|
/* Change current directory to / */
|
||||||
|
if (chdir("/") < 0) {
|
||||||
|
LOG_FATAL("chdir() failed : %s", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Don't keep stdin/out/err from before. But don't close
|
||||||
|
the parent pipe yet. */
|
||||||
|
for (fd=0; fd<1024; fd++) {
|
||||||
|
if (fd != pipefd[1])
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_SetParentFd(pipefd[1]);
|
||||||
|
|
||||||
|
/* Open /dev/null as new stdin/out/err */
|
||||||
|
errno = 0;
|
||||||
|
if (open(DEV_NULL, O_RDONLY) != STDIN_FILENO ||
|
||||||
|
open(DEV_NULL, O_WRONLY) != STDOUT_FILENO ||
|
||||||
|
open(DEV_NULL, O_RDWR) != STDERR_FILENO)
|
||||||
|
LOG_FATAL("Could not open %s : %s", DEV_NULL, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_help(const char *progname)
|
||||||
|
{
|
||||||
|
printf("Usage: %s [OPTION]... [DIRECTIVE]...\n\n"
|
||||||
|
"Options:\n"
|
||||||
|
" -4\t\tUse IPv4 addresses only\n"
|
||||||
|
" -6\t\tUse IPv6 addresses only\n"
|
||||||
|
" -f FILE\tSpecify configuration file (%s)\n"
|
||||||
|
" -n\t\tDon't run as daemon\n"
|
||||||
|
" -d\t\tDon't run as daemon and log to stderr\n"
|
||||||
|
#if DEBUG > 0
|
||||||
|
" -d -d\t\tEnable debug messages\n"
|
||||||
|
#endif
|
||||||
|
" -l FILE\tLog to file\n"
|
||||||
|
" -L LEVEL\tSet logging threshold (0)\n"
|
||||||
|
" -p\t\tPrint configuration and exit\n"
|
||||||
|
" -q\t\tSet clock and exit\n"
|
||||||
|
" -Q\t\tLog offset and exit\n"
|
||||||
|
" -r\t\tReload dump files\n"
|
||||||
|
" -R\t\tAdapt configuration for restart\n"
|
||||||
|
" -s\t\tSet clock from RTC\n"
|
||||||
|
" -t SECONDS\tExit after elapsed time\n"
|
||||||
|
" -u USER\tSpecify user (%s)\n"
|
||||||
|
" -U\t\tDon't check for root\n"
|
||||||
|
" -F LEVEL\tSet system call filter level (0)\n"
|
||||||
|
" -P PRIORITY\tSet process priority (0)\n"
|
||||||
|
" -m\t\tLock memory\n"
|
||||||
|
" -x\t\tDon't control clock\n"
|
||||||
|
" -v, --version\tPrint version and exit\n"
|
||||||
|
" -h, --help\tPrint usage and exit\n",
|
||||||
|
progname, DEFAULT_CONF_FILE, DEFAULT_USER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_version(void)
|
||||||
|
{
|
||||||
|
printf("chronyd (chrony) version %s (%s)\n", CHRONY_VERSION, CHRONYD_FEATURES);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
parse_int_arg(const char *arg)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (sscanf(arg, "%d", &i) != 1)
|
||||||
|
LOG_FATAL("Invalid argument %s", arg);
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -211,94 +430,188 @@ write_lockfile(void)
|
|||||||
int main
|
int main
|
||||||
(int argc, char **argv)
|
(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *conf_file = NULL;
|
const char *conf_file = DEFAULT_CONF_FILE;
|
||||||
char *user = NULL;
|
const char *progname = argv[0];
|
||||||
int debug = 0;
|
char *user = NULL, *log_file = NULL;
|
||||||
int do_init_rtc = 0;
|
struct passwd *pw;
|
||||||
int other_pid;
|
int opt, debug = 0, nofork = 0, address_family = IPADDR_UNSPEC;
|
||||||
int lock_memory = 0, sched_priority = 0;
|
int do_init_rtc = 0, restarted = 0, client_only = 0, timeout = -1;
|
||||||
|
int scfilter_level = 0, lock_memory = 0, sched_priority = 0;
|
||||||
|
int clock_control = 1, system_log = 1, log_severity = LOGS_INFO;
|
||||||
|
int user_check = 1, config_args = 0, print_config = 0;
|
||||||
|
|
||||||
|
do_platform_checks();
|
||||||
|
|
||||||
LOG_Initialise();
|
LOG_Initialise();
|
||||||
|
|
||||||
/* Parse command line options */
|
/* Parse long command-line options */
|
||||||
while (++argv, (--argc)>0) {
|
for (optind = 1; optind < argc; optind++) {
|
||||||
|
if (!strcmp("--help", argv[optind])) {
|
||||||
if (!strcmp("-f", *argv)) {
|
print_help(progname);
|
||||||
++argv, --argc;
|
return 0;
|
||||||
conf_file = *argv;
|
} else if (!strcmp("--version", argv[optind])) {
|
||||||
} else if (!strcmp("-P", *argv)) {
|
print_version();
|
||||||
++argv, --argc;
|
return 0;
|
||||||
if (argc == 0 || sscanf(*argv, "%d", &sched_priority) != 1) {
|
|
||||||
LOG_FATAL(LOGF_Main, "Bad scheduler priority");
|
|
||||||
}
|
|
||||||
} else if (!strcmp("-m", *argv)) {
|
|
||||||
lock_memory = 1;
|
|
||||||
} else if (!strcmp("-r", *argv)) {
|
|
||||||
reload = 1;
|
|
||||||
} else if (!strcmp("-u", *argv)) {
|
|
||||||
++argv, --argc;
|
|
||||||
if (argc == 0) {
|
|
||||||
LOG_FATAL(LOGF_Main, "Missing user name");
|
|
||||||
} else {
|
|
||||||
user = *argv;
|
|
||||||
}
|
|
||||||
} else if (!strcmp("-s", *argv)) {
|
|
||||||
do_init_rtc = 1;
|
|
||||||
} else if (!strcmp("-v", *argv) || !strcmp("--version",*argv)) {
|
|
||||||
/* This write to the terminal is OK, it comes before we turn into a daemon */
|
|
||||||
printf("chronyd (chrony) version %s\n", PROGRAM_VERSION_STRING);
|
|
||||||
exit(0);
|
|
||||||
} else if (!strcmp("-d", *argv)) {
|
|
||||||
debug = 1;
|
|
||||||
} else if (!strcmp("-4", *argv)) {
|
|
||||||
DNS_SetAddressFamily(IPADDR_INET4);
|
|
||||||
} else if (!strcmp("-6", *argv)) {
|
|
||||||
DNS_SetAddressFamily(IPADDR_INET6);
|
|
||||||
} else {
|
|
||||||
LOG(LOGS_WARN, LOGF_Main, "Unrecognized command line option [%s]", *argv);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SYS_WINNT
|
optind = 1;
|
||||||
if (getuid() != 0) {
|
|
||||||
/* This write to the terminal is OK, it comes before we turn into a daemon */
|
/* Parse short command-line options */
|
||||||
fprintf(stderr,"Not superuser\n");
|
while ((opt = getopt(argc, argv, "46df:F:hl:L:mnpP:qQrRst:u:Uvx")) != -1) {
|
||||||
exit(1);
|
switch (opt) {
|
||||||
|
case '4':
|
||||||
|
case '6':
|
||||||
|
address_family = opt == '4' ? IPADDR_INET4 : IPADDR_INET6;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
debug++;
|
||||||
|
nofork = 1;
|
||||||
|
system_log = 0;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
conf_file = optarg;
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
scfilter_level = parse_int_arg(optarg);
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
log_file = optarg;
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
log_severity = parse_int_arg(optarg);
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
lock_memory = 1;
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
nofork = 1;
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
print_config = 1;
|
||||||
|
user_check = 0;
|
||||||
|
nofork = 1;
|
||||||
|
system_log = 0;
|
||||||
|
log_severity = LOGS_WARN;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
sched_priority = parse_int_arg(optarg);
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
ref_mode = REF_ModeUpdateOnce;
|
||||||
|
nofork = 1;
|
||||||
|
client_only = 0;
|
||||||
|
system_log = 0;
|
||||||
|
break;
|
||||||
|
case 'Q':
|
||||||
|
ref_mode = REF_ModePrintOnce;
|
||||||
|
nofork = 1;
|
||||||
|
client_only = 1;
|
||||||
|
user_check = 0;
|
||||||
|
clock_control = 0;
|
||||||
|
system_log = 0;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
reload = 1;
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
restarted = 1;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
do_init_rtc = 1;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
timeout = parse_int_arg(optarg);
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
user = optarg;
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
user_check = 0;
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
print_version();
|
||||||
|
return 0;
|
||||||
|
case 'x':
|
||||||
|
clock_control = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print_help(progname);
|
||||||
|
return opt != 'h';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user_check && getuid() != 0)
|
||||||
|
LOG_FATAL("Not superuser");
|
||||||
|
|
||||||
/* Turn into a daemon */
|
/* Turn into a daemon */
|
||||||
if (!debug) {
|
if (!nofork) {
|
||||||
LOG_GoDaemon();
|
go_daemon();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log_file) {
|
||||||
|
LOG_OpenFileLog(log_file);
|
||||||
|
} else if (system_log) {
|
||||||
|
LOG_OpenSystemLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether another chronyd may already be running. Do this after
|
LOG_SetMinSeverity(debug >= 2 ? LOGS_DEBUG : log_severity);
|
||||||
* forking, so that message logging goes to the right place (i.e. syslog), in
|
|
||||||
* case this chronyd is being run from a boot script. */
|
LOG(LOGS_INFO, "chronyd version %s starting (%s)", CHRONY_VERSION, CHRONYD_FEATURES);
|
||||||
if (maybe_another_chronyd_running(&other_pid)) {
|
|
||||||
LOG_FATAL(LOGF_Main, "Another chronyd may already be running (pid=%d), check lockfile (%s)",
|
DNS_SetAddressFamily(address_family);
|
||||||
other_pid, CNF_GetPidFile());
|
|
||||||
exit(1);
|
CNF_Initialise(restarted, client_only);
|
||||||
|
if (print_config)
|
||||||
|
CNF_EnablePrint();
|
||||||
|
|
||||||
|
/* Parse the config file or the remaining command line arguments */
|
||||||
|
config_args = argc - optind;
|
||||||
|
if (!config_args) {
|
||||||
|
CNF_ReadFile(conf_file);
|
||||||
|
} else {
|
||||||
|
for (; optind < argc; optind++)
|
||||||
|
CNF_ParseLine(NULL, config_args + optind - argc + 1, argv[optind]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write our lockfile to prevent other chronyds running. This has *GOT* to
|
if (print_config)
|
||||||
* be done *AFTER* the daemon-creation fork() */
|
return 0;
|
||||||
write_lockfile();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CNF_ReadFile(conf_file);
|
/* Check whether another chronyd may already be running */
|
||||||
|
check_pidfile();
|
||||||
|
|
||||||
if (do_init_rtc) {
|
if (!user)
|
||||||
RTC_TimePreInit();
|
user = CNF_GetUser();
|
||||||
}
|
|
||||||
|
|
||||||
|
pw = getpwnam(user);
|
||||||
|
if (!pw)
|
||||||
|
LOG_FATAL("Could not get user/group ID of %s", user);
|
||||||
|
|
||||||
|
/* Create directories for sockets, log files, and dump files */
|
||||||
|
CNF_CreateDirs(pw->pw_uid, pw->pw_gid);
|
||||||
|
|
||||||
|
/* Write our pidfile to prevent other instances from running */
|
||||||
|
write_pidfile();
|
||||||
|
|
||||||
|
PRV_Initialise();
|
||||||
LCL_Initialise();
|
LCL_Initialise();
|
||||||
SCH_Initialise();
|
SCH_Initialise();
|
||||||
SYS_Initialise();
|
SCK_Initialise(address_family);
|
||||||
NIO_Initialise();
|
|
||||||
CAM_Initialise();
|
/* Start helper processes if needed */
|
||||||
RTC_Initialise();
|
NKS_PreInitialise(pw->pw_uid, pw->pw_gid, scfilter_level);
|
||||||
|
|
||||||
|
SYS_Initialise(clock_control);
|
||||||
|
RTC_Initialise(do_init_rtc);
|
||||||
|
SRC_Initialise();
|
||||||
RCL_Initialise();
|
RCL_Initialise();
|
||||||
|
KEY_Initialise();
|
||||||
|
|
||||||
|
/* Open privileged ports before dropping root */
|
||||||
|
CAM_Initialise();
|
||||||
|
NIO_Initialise();
|
||||||
|
NCR_Initialise();
|
||||||
|
CNF_SetupAccessRestrictions();
|
||||||
|
|
||||||
/* Command-line switch must have priority */
|
/* Command-line switch must have priority */
|
||||||
if (!sched_priority) {
|
if (!sched_priority) {
|
||||||
@@ -312,41 +625,56 @@ int main
|
|||||||
SYS_LockMemory();
|
SYS_LockMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user) {
|
/* Drop root privileges if the specified user has a non-zero UID */
|
||||||
SYS_DropRoot(user);
|
if (!geteuid() && (pw->pw_uid || pw->pw_gid))
|
||||||
}
|
SYS_DropRoot(pw->pw_uid, pw->pw_gid, SYS_MAIN_PROCESS);
|
||||||
|
|
||||||
|
if (!geteuid())
|
||||||
|
LOG(LOGS_WARN, "Running with root privileges");
|
||||||
|
|
||||||
REF_Initialise();
|
REF_Initialise();
|
||||||
SST_Initialise();
|
SST_Initialise();
|
||||||
SRC_Initialise();
|
|
||||||
BRD_Initialise();
|
|
||||||
NCR_Initialise();
|
|
||||||
NSR_Initialise();
|
NSR_Initialise();
|
||||||
|
NSD_Initialise();
|
||||||
|
NNS_Initialise();
|
||||||
|
NKS_Initialise();
|
||||||
CLG_Initialise();
|
CLG_Initialise();
|
||||||
KEY_Initialise();
|
|
||||||
ACQ_Initialise();
|
|
||||||
MNL_Initialise();
|
MNL_Initialise();
|
||||||
|
TMC_Initialise();
|
||||||
|
SMT_Initialise();
|
||||||
|
|
||||||
/* From now on, it is safe to do finalisation on exit */
|
/* From now on, it is safe to do finalisation on exit */
|
||||||
initialised = 1;
|
initialised = 1;
|
||||||
|
|
||||||
|
UTI_SetQuitSignalsHandler(signal_cleanup, 1);
|
||||||
|
|
||||||
|
CAM_OpenUnixSocket();
|
||||||
|
|
||||||
|
if (scfilter_level)
|
||||||
|
SYS_EnableSystemCallFilter(scfilter_level, SYS_MAIN_PROCESS);
|
||||||
|
|
||||||
|
if (ref_mode == REF_ModeNormal && CNF_GetInitSources() > 0) {
|
||||||
|
ref_mode = REF_ModeInitStepSlew;
|
||||||
|
}
|
||||||
|
|
||||||
|
REF_SetModeEndHandler(reference_mode_end);
|
||||||
|
REF_SetMode(ref_mode);
|
||||||
|
|
||||||
|
if (timeout >= 0)
|
||||||
|
SCH_AddTimeoutByDelay(timeout, quit_timeout, NULL);
|
||||||
|
|
||||||
if (do_init_rtc) {
|
if (do_init_rtc) {
|
||||||
RTC_TimeInit(post_init_rtc_hook, NULL);
|
RTC_TimeInit(post_init_rtc_hook, NULL);
|
||||||
} else {
|
} else {
|
||||||
post_init_rtc_hook(NULL);
|
post_init_rtc_hook(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
signal(SIGINT, signal_cleanup);
|
|
||||||
signal(SIGTERM, signal_cleanup);
|
|
||||||
#if !defined(WINNT)
|
|
||||||
signal(SIGQUIT, signal_cleanup);
|
|
||||||
signal(SIGHUP, signal_cleanup);
|
|
||||||
#endif /* WINNT */
|
|
||||||
|
|
||||||
/* The program normally runs under control of the main loop in
|
/* The program normally runs under control of the main loop in
|
||||||
the scheduler. */
|
the scheduler. */
|
||||||
SCH_MainLoop();
|
SCH_MainLoop();
|
||||||
|
|
||||||
|
LOG(LOGS_INFO, "chronyd exiting");
|
||||||
|
|
||||||
MAI_CleanupAndExit();
|
MAI_CleanupAndExit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
4
main.h
4
main.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/main.h,v 1.8 2002/02/28 23:27:10 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|||||||
77
make_release
77
make_release
@@ -1,52 +1,51 @@
|
|||||||
#!/usr/bin/env perl
|
#!/bin/sh
|
||||||
|
|
||||||
$tool = "chrony";
|
LANG=C.UTF-8
|
||||||
|
export LANG
|
||||||
|
|
||||||
$version = shift || die "Usage : $0 <version>\n";
|
if [ $# -ne 1 ]; then
|
||||||
$subdir = "${tool}-${version}";
|
echo "Usage : $0 <version>"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
unless (-d ".git") {
|
version=$1
|
||||||
die "No .git subdirectory?"
|
tag=$version
|
||||||
}
|
subdir=chrony-${version}
|
||||||
|
|
||||||
unless (-d "RELEASES") {
|
umask 022
|
||||||
mkdir "RELEASES", 0755;
|
|
||||||
}
|
|
||||||
|
|
||||||
system ("git tag -s $version");
|
if [ ! -d .git ]; then
|
||||||
die "git-tag failed" if ($? != 0);
|
echo "No .git subdirectory?"
|
||||||
if (-d "RELEASES/$subdir") {
|
exit 3
|
||||||
system ("rm -rf RELEASES/$subdir");
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
system ("git archive --format=tar --prefix=RELEASES/${subdir}/ $version | tar xf -");
|
[ -d RELEASES ] || mkdir RELEASES
|
||||||
die "git-tar-tree failed" if ($? != 0);
|
|
||||||
|
|
||||||
chdir "RELEASES";
|
rm -rf RELEASES/$subdir
|
||||||
$here = qx/pwd/;
|
|
||||||
chomp $here;
|
|
||||||
chdir $subdir;
|
|
||||||
|
|
||||||
open (OUT, ">version.txt");
|
if [ $version != test ]; then
|
||||||
print OUT $version."\n";
|
git tag -s $tag || exit 1
|
||||||
close OUT;
|
else
|
||||||
|
tag=HEAD
|
||||||
|
fi
|
||||||
|
|
||||||
open (IN, "<${tool}.spec.sample");
|
git archive --format=tar --prefix=RELEASES/${subdir}/ $tag | \
|
||||||
open (OUT, ">${tool}.spec");
|
tar xf - || exit 1
|
||||||
while (<IN>) {
|
|
||||||
s/\@\@VERSION\@\@/$version/;
|
|
||||||
print OUT;
|
|
||||||
}
|
|
||||||
close (IN);
|
|
||||||
close (OUT);
|
|
||||||
|
|
||||||
system("makeinfo --no-headers --number-sections -o chrony.txt chrony.texi");
|
cd RELEASES/$subdir || exit 1
|
||||||
unlink "make_release";
|
|
||||||
unlink "${tool}.spec.sample";
|
|
||||||
unlink ".gitignore";
|
|
||||||
|
|
||||||
chdir $here;
|
echo $version > version.txt
|
||||||
system ("tar cvf - $subdir | gzip -9 > ${subdir}.tar.gz");
|
|
||||||
system ("gpg -b -a -o ${subdir}-tar-gz-asc.txt ${subdir}.tar.gz");
|
|
||||||
|
|
||||||
|
./configure && make -C doc man txt || exit 1
|
||||||
|
|
||||||
|
iconv -f utf-8 -t ascii//TRANSLIT < doc/installation.txt > INSTALL
|
||||||
|
iconv -f utf-8 -t ascii//TRANSLIT < doc/faq.txt > FAQ
|
||||||
|
|
||||||
|
make distclean
|
||||||
|
rm -f make_release .gitignore
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
tar cv --owner root --group root $subdir | gzip -9 > ${subdir}.tar.gz
|
||||||
|
|
||||||
|
[ $version != test ] && \
|
||||||
|
gpg -b -a -o ${subdir}-tar-gz-asc.txt ${subdir}.tar.gz
|
||||||
|
|||||||
137
manual.c
137
manual.c
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/manual.c,v 1.21 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -34,7 +30,9 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stddef.h>
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "manual.h"
|
#include "manual.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
@@ -49,34 +47,28 @@ static int enabled = 0;
|
|||||||
|
|
||||||
/* More recent samples at highest indices */
|
/* More recent samples at highest indices */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct timeval when; /* This is our 'cooked' time */
|
struct timespec when; /* This is our 'cooked' time */
|
||||||
double orig_offset; /*+ Not modified by slew samples */
|
double orig_offset; /*+ Not modified by slew samples */
|
||||||
double offset; /*+ if we are fast of the supplied reference */
|
double offset; /*+ if we are fast of the supplied reference */
|
||||||
double residual; /*+ regression residual (sign convention given by
|
double residual; /*+ regression residual (sign convention given by
|
||||||
(measured-predicted)) */
|
(measured-predicted)) */
|
||||||
} Sample;
|
} Sample;
|
||||||
|
|
||||||
|
#define MIN_SAMPLE_SEPARATION 1.0
|
||||||
|
|
||||||
#define MAX_SAMPLES 16
|
#define MAX_SAMPLES 16
|
||||||
|
|
||||||
static Sample samples[16];
|
static Sample samples[16];
|
||||||
static int n_samples;
|
static int n_samples;
|
||||||
|
|
||||||
static int replace_margin;
|
|
||||||
static int error;
|
|
||||||
|
|
||||||
/* Eventually these constants need to be user-defined in conf file */
|
|
||||||
#define REPLACE_MARGIN 300
|
|
||||||
#define ERROR_MARGIN 0.2
|
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
slew_samples(struct timeval *raw,
|
slew_samples(struct timespec *raw,
|
||||||
struct timeval *cooked,
|
struct timespec *cooked,
|
||||||
double dfreq,
|
double dfreq,
|
||||||
double afreq,
|
|
||||||
double doffset,
|
double doffset,
|
||||||
int is_step_change,
|
LCL_ChangeType change_type,
|
||||||
void *not_used);
|
void *not_used);
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -92,12 +84,7 @@ MNL_Initialise(void)
|
|||||||
|
|
||||||
n_samples = 0;
|
n_samples = 0;
|
||||||
|
|
||||||
replace_margin = REPLACE_MARGIN;
|
|
||||||
error = ERROR_MARGIN;
|
|
||||||
|
|
||||||
LCL_AddParameterChangeHandler(slew_samples, NULL);
|
LCL_AddParameterChangeHandler(slew_samples, NULL);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -105,13 +92,14 @@ MNL_Initialise(void)
|
|||||||
void
|
void
|
||||||
MNL_Finalise(void)
|
MNL_Finalise(void)
|
||||||
{
|
{
|
||||||
return;
|
LCL_RemoveParameterChangeHandler(slew_samples, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
estimate_and_set_system(struct timeval *now, int offset_provided, double offset, long *offset_cs, double *dfreq_ppm, double *new_afreq_ppm)
|
estimate_and_set_system(struct timespec *now, int offset_provided, double offset,
|
||||||
|
double *reg_offset, double *dfreq_ppm, double *new_afreq_ppm)
|
||||||
{
|
{
|
||||||
double agos[MAX_SAMPLES], offsets[MAX_SAMPLES];
|
double agos[MAX_SAMPLES], offsets[MAX_SAMPLES];
|
||||||
double b0, b1;
|
double b0, b1;
|
||||||
@@ -122,32 +110,28 @@ estimate_and_set_system(struct timeval *now, int offset_provided, double offset,
|
|||||||
int found_freq;
|
int found_freq;
|
||||||
double slew_by;
|
double slew_by;
|
||||||
|
|
||||||
|
b0 = offset_provided ? offset : 0.0;
|
||||||
|
b1 = freq = 0.0;
|
||||||
|
found_freq = 0;
|
||||||
|
|
||||||
if (n_samples > 1) {
|
if (n_samples > 1) {
|
||||||
for (i=0; i<n_samples; i++) {
|
for (i=0; i<n_samples; i++) {
|
||||||
UTI_DiffTimevalsToDouble(&agos[i], &samples[n_samples-1].when, &samples[i].when);
|
agos[i] = UTI_DiffTimespecsToDouble(&samples[n_samples - 1].when, &samples[i].when);
|
||||||
offsets[i] = samples[i].offset;
|
offsets[i] = samples[i].offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
RGR_FindBestRobustRegression(agos, offsets, n_samples,
|
if (RGR_FindBestRobustRegression(agos, offsets, n_samples, 1.0e-8,
|
||||||
1.0e-8, /* 0.01ppm easily good enough for this! */
|
&b0, &b1, &n_runs, &best_start)) {
|
||||||
&b0, &b1, &n_runs, &best_start);
|
/* Ignore b0 from regression; treat offset as being the most
|
||||||
|
recently entered value. (If the administrator knows he's put
|
||||||
|
an outlier in, he will rerun the settime operation.) However,
|
||||||
/* Ignore b0 from regression; treat offset as being the most
|
the frequency estimate comes from the regression. */
|
||||||
recently entered value. (If the administrator knows he's put
|
freq = -b1;
|
||||||
an outlier in, he will rerun the settime operation.) However,
|
found_freq = 1;
|
||||||
the frequency estimate comes from the regression. */
|
|
||||||
|
|
||||||
freq = -b1;
|
|
||||||
found_freq = 1;
|
|
||||||
} else {
|
|
||||||
if (offset_provided) {
|
|
||||||
b0 = offset;
|
|
||||||
} else {
|
|
||||||
b0 = 0.0;
|
|
||||||
}
|
}
|
||||||
b1 = freq = 0.0;
|
} else {
|
||||||
found_freq = 0;
|
agos[0] = 0.0;
|
||||||
|
offsets[0] = b0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset_provided) {
|
if (offset_provided) {
|
||||||
@@ -157,21 +141,20 @@ estimate_and_set_system(struct timeval *now, int offset_provided, double offset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (found_freq) {
|
if (found_freq) {
|
||||||
LOG(LOGS_INFO, LOGF_Manual,
|
LOG(LOGS_INFO, "Making a frequency change of %.3f ppm and a slew of %.6f",
|
||||||
"Making a frequency change of %.3fppm and a slew of %.6f\n",
|
|
||||||
1.0e6 * freq, slew_by);
|
1.0e6 * freq, slew_by);
|
||||||
|
|
||||||
REF_SetManualReference(now,
|
REF_SetManualReference(now,
|
||||||
slew_by,
|
slew_by,
|
||||||
freq, skew);
|
freq, skew);
|
||||||
} else {
|
} else {
|
||||||
LOG(LOGS_INFO, LOGF_Manual, "Making a slew of %.6f", slew_by);
|
LOG(LOGS_INFO, "Making a slew of %.6f", slew_by);
|
||||||
REF_SetManualReference(now,
|
REF_SetManualReference(now,
|
||||||
slew_by,
|
slew_by,
|
||||||
0.0, skew);
|
0.0, skew);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset_cs) *offset_cs = (long)(0.5 + 100.0 * b0);
|
if (reg_offset) *reg_offset = b0;
|
||||||
if (dfreq_ppm) *dfreq_ppm = 1.0e6 * freq;
|
if (dfreq_ppm) *dfreq_ppm = 1.0e6 * freq;
|
||||||
if (new_afreq_ppm) *new_afreq_ppm = LCL_ReadAbsoluteFrequency();
|
if (new_afreq_ppm) *new_afreq_ppm = LCL_ReadAbsoluteFrequency();
|
||||||
|
|
||||||
@@ -185,19 +168,28 @@ estimate_and_set_system(struct timeval *now, int offset_provided, double offset,
|
|||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
int
|
int
|
||||||
MNL_AcceptTimestamp(struct timeval *ts, long *offset_cs, double *dfreq_ppm, double *new_afreq_ppm)
|
MNL_AcceptTimestamp(struct timespec *ts, double *reg_offset, double *dfreq_ppm, double *new_afreq_ppm)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timespec now;
|
||||||
double local_clock_err;
|
double offset, diff;
|
||||||
double offset;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
LCL_ReadCookedTime(&now, NULL);
|
||||||
|
|
||||||
/* Check whether timestamp is within margin of old one */
|
/* Make sure the provided timestamp is sane and the sample
|
||||||
LCL_ReadCookedTime(&now, &local_clock_err);
|
is not too close to the last one */
|
||||||
|
|
||||||
UTI_DiffTimevalsToDouble(&offset, &now, ts);
|
if (!UTI_IsTimeOffsetSane(ts, 0.0))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (n_samples) {
|
||||||
|
diff = UTI_DiffTimespecsToDouble(&now, &samples[n_samples - 1].when);
|
||||||
|
if (diff < MIN_SAMPLE_SEPARATION)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = UTI_DiffTimespecsToDouble(&now, ts);
|
||||||
|
|
||||||
/* Check if buffer full up */
|
/* Check if buffer full up */
|
||||||
if (n_samples == MAX_SAMPLES) {
|
if (n_samples == MAX_SAMPLES) {
|
||||||
@@ -213,7 +205,7 @@ MNL_AcceptTimestamp(struct timeval *ts, long *offset_cs, double *dfreq_ppm, doub
|
|||||||
samples[n_samples].orig_offset = offset;
|
samples[n_samples].orig_offset = offset;
|
||||||
++n_samples;
|
++n_samples;
|
||||||
|
|
||||||
estimate_and_set_system(&now, 1, offset, offset_cs, dfreq_ppm, new_afreq_ppm);
|
estimate_and_set_system(&now, 1, offset, reg_offset, dfreq_ppm, new_afreq_ppm);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -227,23 +219,25 @@ MNL_AcceptTimestamp(struct timeval *ts, long *offset_cs, double *dfreq_ppm, doub
|
|||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
slew_samples(struct timeval *raw,
|
slew_samples(struct timespec *raw,
|
||||||
struct timeval *cooked,
|
struct timespec *cooked,
|
||||||
double dfreq,
|
double dfreq,
|
||||||
double afreq,
|
|
||||||
double doffset,
|
double doffset,
|
||||||
int is_step_change,
|
LCL_ChangeType change_type,
|
||||||
void *not_used)
|
void *not_used)
|
||||||
{
|
{
|
||||||
double elapsed, delta_time;
|
double delta_time;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (change_type == LCL_ChangeUnknownStep) {
|
||||||
|
MNL_Reset();
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0; i<n_samples; i++) {
|
for (i=0; i<n_samples; i++) {
|
||||||
UTI_DiffTimevalsToDouble(&elapsed, cooked, &samples[i].when);
|
UTI_AdjustTimespec(&samples[i].when, cooked, &samples[i].when, &delta_time,
|
||||||
delta_time = elapsed * dfreq - doffset;
|
dfreq, doffset);
|
||||||
UTI_AddDoubleToTimeval(&samples[i].when, delta_time, &samples[i].when);
|
|
||||||
samples[i].offset += delta_time;
|
samples[i].offset += delta_time;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -271,6 +265,14 @@ MNL_Reset(void)
|
|||||||
n_samples = 0;
|
n_samples = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
MNL_IsEnabled(void)
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* Generate report data for the REQ_MANUAL_LIST command/monitoring
|
/* Generate report data for the REQ_MANUAL_LIST command/monitoring
|
||||||
protocol */
|
protocol */
|
||||||
@@ -302,8 +304,7 @@ int
|
|||||||
MNL_DeleteSample(int index)
|
MNL_DeleteSample(int index)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct timeval now;
|
struct timespec now;
|
||||||
double local_clock_err;
|
|
||||||
|
|
||||||
if ((index < 0) || (index >= n_samples)) {
|
if ((index < 0) || (index >= n_samples)) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -319,7 +320,7 @@ MNL_DeleteSample(int index)
|
|||||||
|
|
||||||
/* Now re-estimate. NULLs because we don't want the parameters back
|
/* Now re-estimate. NULLs because we don't want the parameters back
|
||||||
in this case. */
|
in this case. */
|
||||||
LCL_ReadCookedTime(&now, &local_clock_err);
|
LCL_ReadCookedTime(&now, NULL);
|
||||||
estimate_and_set_system(&now, 0, 0.0, NULL, NULL, NULL);
|
estimate_and_set_system(&now, 0, 0.0, NULL, NULL, NULL);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
7
manual.h
7
manual.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/manual.h,v 1.12 2002/02/28 23:27:11 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -37,11 +33,12 @@
|
|||||||
|
|
||||||
extern void MNL_Initialise(void);
|
extern void MNL_Initialise(void);
|
||||||
extern void MNL_Finalise(void);
|
extern void MNL_Finalise(void);
|
||||||
extern int MNL_AcceptTimestamp(struct timeval *ts, long *offset_cs, double *dfreq_ppm, double *new_afreq_ppm);
|
extern int MNL_AcceptTimestamp(struct timespec *ts, double *reg_offset, double *dfreq_ppm, double *new_afreq_ppm);
|
||||||
|
|
||||||
extern void MNL_Enable(void);
|
extern void MNL_Enable(void);
|
||||||
extern void MNL_Disable(void);
|
extern void MNL_Disable(void);
|
||||||
extern void MNL_Reset(void);
|
extern void MNL_Reset(void);
|
||||||
|
extern int MNL_IsEnabled(void);
|
||||||
|
|
||||||
extern void MNL_ReportSamples(RPT_ManualSamplesReport *report, int max, int *n);
|
extern void MNL_ReportSamples(RPT_ManualSamplesReport *report, int max, int *n);
|
||||||
extern int MNL_DeleteSample(int index);
|
extern int MNL_DeleteSample(int index);
|
||||||
|
|||||||
6
md5.h
6
md5.h
@@ -32,11 +32,7 @@
|
|||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAS_STDINT_H
|
#include "sysincl.h"
|
||||||
#include <stdint.h>
|
|
||||||
#elif defined(HAS_INTTYPES_H)
|
|
||||||
#include <inttypes.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* typedef a 32-bit type */
|
/* typedef a 32-bit type */
|
||||||
typedef uint32_t UINT4;
|
typedef uint32_t UINT4;
|
||||||
|
|||||||
93
memory.c
Normal file
93
memory.c
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2014, 2017
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Utility functions for memory allocation.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "logging.h"
|
||||||
|
#include "memory.h"
|
||||||
|
|
||||||
|
void *
|
||||||
|
Malloc(size_t size)
|
||||||
|
{
|
||||||
|
void *r;
|
||||||
|
|
||||||
|
r = malloc(size);
|
||||||
|
if (!r && size)
|
||||||
|
LOG_FATAL("Could not allocate memory");
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
Realloc(void *ptr, size_t size)
|
||||||
|
{
|
||||||
|
void *r;
|
||||||
|
|
||||||
|
r = realloc(ptr, size);
|
||||||
|
if (!r && size)
|
||||||
|
LOG_FATAL("Could not allocate memory");
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
get_array_size(size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
size_t array_size;
|
||||||
|
|
||||||
|
array_size = nmemb * size;
|
||||||
|
|
||||||
|
/* Check for overflow */
|
||||||
|
if (nmemb > 0 && array_size / nmemb != size)
|
||||||
|
LOG_FATAL("Could not allocate memory");
|
||||||
|
|
||||||
|
return array_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
Malloc2(size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
return Malloc(get_array_size(nmemb, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
Realloc2(void *ptr, size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
return Realloc(ptr, get_array_size(nmemb, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
Strdup(const char *s)
|
||||||
|
{
|
||||||
|
void *r;
|
||||||
|
|
||||||
|
r = strdup(s);
|
||||||
|
if (!r)
|
||||||
|
LOG_FATAL("Could not allocate memory");
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
22
memory.h
22
memory.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/memory.h,v 1.7 2002/02/28 23:27:11 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -31,13 +27,19 @@
|
|||||||
#ifndef GOT_MEMORY_H
|
#ifndef GOT_MEMORY_H
|
||||||
#define GOT_MEMORY_H
|
#define GOT_MEMORY_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include "sysincl.h"
|
||||||
|
|
||||||
#define Malloc(x) malloc(x)
|
/* Wrappers checking for errors */
|
||||||
#define MallocNew(T) ((T *) malloc(sizeof(T)))
|
extern void *Malloc(size_t size);
|
||||||
#define MallocArray(T, n) ((T *) malloc((n) * sizeof(T)))
|
extern void *Realloc(void *ptr, size_t size);
|
||||||
#define Realloc(x,y) realloc(x,y)
|
extern void *Malloc2(size_t nmemb, size_t size);
|
||||||
#define ReallocArray(T,n,x) ((T *) realloc((void *)(x), (n)*sizeof(T)))
|
extern void *Realloc2(void *ptr, size_t nmemb, size_t size);
|
||||||
|
extern char *Strdup(const char *s);
|
||||||
|
|
||||||
|
/* Convenient macros */
|
||||||
|
#define MallocNew(T) ((T *) Malloc(sizeof(T)))
|
||||||
|
#define MallocArray(T, n) ((T *) Malloc2(n, sizeof(T)))
|
||||||
|
#define ReallocArray(T, n, x) ((T *) Realloc2((void *)(x), n, sizeof(T)))
|
||||||
#define Free(x) free(x)
|
#define Free(x) free(x)
|
||||||
|
|
||||||
#endif /* GOT_MEMORY_H */
|
#endif /* GOT_MEMORY_H */
|
||||||
|
|||||||
135
mkdirpp.c
135
mkdirpp.c
@@ -1,135 +0,0 @@
|
|||||||
/*
|
|
||||||
$Header: /cvs/src/chrony/mkdirpp.c,v 1.10 2002/11/03 22:49:17 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
|
||||||
|
|
||||||
**********************************************************************
|
|
||||||
* Copyright (C) Richard P. Curnow 1997-2002
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
**********************************************************************
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
A function for creating a directory and any parent directories that
|
|
||||||
don't exist.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sysincl.h"
|
|
||||||
|
|
||||||
#include "mkdirpp.h"
|
|
||||||
|
|
||||||
static int
|
|
||||||
do_dir(char *p)
|
|
||||||
{
|
|
||||||
int status;
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
#if defined(TEST)
|
|
||||||
fprintf(stderr, "do_dir(%s)\n", p);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* See if directory exists */
|
|
||||||
status = stat(p, &buf);
|
|
||||||
|
|
||||||
if (status < 0) {
|
|
||||||
if (errno == ENOENT) {
|
|
||||||
/* Try to create directory */
|
|
||||||
status = mkdir(p, 0755);
|
|
||||||
return status;
|
|
||||||
} else {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!S_ISDIR(buf.st_mode)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
/* Return 0 if the directory couldn't be created, 1 if it could (or
|
|
||||||
already existed) */
|
|
||||||
|
|
||||||
int
|
|
||||||
mkdir_and_parents(const char *path)
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
int len;
|
|
||||||
int i, j, k, last;
|
|
||||||
len = strlen(path);
|
|
||||||
|
|
||||||
p = (char *) malloc(1 + len);
|
|
||||||
|
|
||||||
i = k = 0;
|
|
||||||
while (1) {
|
|
||||||
p[i++] = path[k++];
|
|
||||||
|
|
||||||
if (path[k] == '/' || !path[k]) {
|
|
||||||
p[i] = 0;
|
|
||||||
|
|
||||||
if (do_dir(p) < 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!path[k]) {
|
|
||||||
/* End of the string */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check whether its a trailing / or group of / */
|
|
||||||
last = 1;
|
|
||||||
j = k+1;
|
|
||||||
while (path[j]) {
|
|
||||||
if (path[j] != '/') {
|
|
||||||
k = j - 1; /* Pick up a / into p[] thru the assignment at the top of the loop */
|
|
||||||
last = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (last) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!path[k]) break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
free(p);
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
#if defined(TEST)
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
if (argc > 1) {
|
|
||||||
/* Invert sense of result */
|
|
||||||
return mkdir_and_parents(argv[1]) ? 0 : 1;
|
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
15
mkversion
15
mkversion
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
rm -f version.h
|
|
||||||
echo "#ifndef VERSION_H" > version.h
|
|
||||||
echo "#define VERSION_H 1" >> version.h
|
|
||||||
|
|
||||||
if [ -f version.txt ]; then
|
|
||||||
ver=`cat version.txt`
|
|
||||||
echo "#define PROGRAM_VERSION_STRING \"$ver\"" >> version.h
|
|
||||||
else
|
|
||||||
echo "#define PROGRAM_VERSION_STRING \"DEVELOPMENT\"" >> version.h
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "#endif /* VERSION_H */" >> version.h
|
|
||||||
|
|
||||||
203
nameserv.c
203
nameserv.c
@@ -1,13 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/nameserv.c,v 1.15 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
* Copyright (C) Miroslav Lichvar 2009
|
* Copyright (C) Miroslav Lichvar 2009-2011
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -30,16 +26,18 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "nameserv.h"
|
#include <netdb.h>
|
||||||
#include "util.h"
|
|
||||||
#include <resolv.h>
|
#include <resolv.h>
|
||||||
|
|
||||||
/* ================================================== */
|
#include "nameserv.h"
|
||||||
|
#include "socket.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#define MAXRETRIES 10
|
/* ================================================== */
|
||||||
static unsigned int retries = 0;
|
|
||||||
|
|
||||||
static int address_family = IPADDR_UNSPEC;
|
static int address_family = IPADDR_UNSPEC;
|
||||||
|
|
||||||
@@ -49,130 +47,119 @@ DNS_SetAddressFamily(int family)
|
|||||||
address_family = family;
|
address_family = family;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
DNS_Status
|
||||||
DNS_Name2IPAddress(const char *name, IPAddr *addr, int retry)
|
DNS_Name2IPAddress(const char *name, IPAddr *ip_addrs, int max_addrs)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
struct addrinfo hints, *res, *ai;
|
struct addrinfo hints, *res, *ai;
|
||||||
int result;
|
int i, result;
|
||||||
|
IPAddr ip;
|
||||||
memset(&hints, 0, sizeof (hints));
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
max_addrs = MIN(max_addrs, DNS_MAX_ADDRESSES);
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
|
||||||
#ifdef AI_ADDRCONFIG
|
for (i = 0; i < max_addrs; i++)
|
||||||
hints.ai_flags = AI_ADDRCONFIG;
|
ip_addrs[i].family = IPADDR_UNSPEC;
|
||||||
#endif
|
|
||||||
|
/* Avoid calling getaddrinfo() if the name is an IP address */
|
||||||
|
if (UTI_StringToIP(name, &ip)) {
|
||||||
|
if (address_family != IPADDR_UNSPEC && ip.family != address_family)
|
||||||
|
return DNS_Failure;
|
||||||
|
if (max_addrs >= 1)
|
||||||
|
ip_addrs[0] = ip;
|
||||||
|
return DNS_Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&hints, 0, sizeof (hints));
|
||||||
|
|
||||||
|
switch (address_family) {
|
||||||
|
case IPADDR_INET4:
|
||||||
|
hints.ai_family = AF_INET;
|
||||||
|
break;
|
||||||
|
#ifdef FEAT_IPV6
|
||||||
|
case IPADDR_INET6:
|
||||||
|
hints.ai_family = AF_INET6;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
}
|
||||||
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
|
|
||||||
try_again:
|
|
||||||
result = getaddrinfo(name, NULL, &hints, &res);
|
result = getaddrinfo(name, NULL, &hints, &res);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
if (retry && result == EAI_AGAIN && retries < MAXRETRIES) {
|
#ifdef FORCE_DNSRETRY
|
||||||
sleep(2 << retries);
|
return DNS_TryAgain;
|
||||||
retries++;
|
#else
|
||||||
res_init();
|
return result == EAI_AGAIN ? DNS_TryAgain : DNS_Failure;
|
||||||
goto try_again;
|
#endif
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ai = res; !result && ai != NULL; ai = ai->ai_next) {
|
for (ai = res, i = 0; i < max_addrs && ai != NULL; ai = ai->ai_next) {
|
||||||
switch (ai->ai_family) {
|
switch (ai->ai_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
addr->family = IPADDR_INET4;
|
if (address_family != IPADDR_UNSPEC && address_family != IPADDR_INET4)
|
||||||
addr->addr.in4 = ntohl(((struct sockaddr_in *)ai->ai_addr)->sin_addr.s_addr);
|
continue;
|
||||||
result = 1;
|
ip_addrs[i].family = IPADDR_INET4;
|
||||||
|
ip_addrs[i].addr.in4 = ntohl(((struct sockaddr_in *)ai->ai_addr)->sin_addr.s_addr);
|
||||||
|
i++;
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_IPV6
|
#ifdef FEAT_IPV6
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
addr->family = IPADDR_INET6;
|
if (address_family != IPADDR_UNSPEC && address_family != IPADDR_INET6)
|
||||||
memcpy(&addr->addr.in6, &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr.s6_addr, sizeof (addr->addr.in6));
|
continue;
|
||||||
result = 1;
|
/* Don't return an address that would lose a scope ID */
|
||||||
|
if (((struct sockaddr_in6 *)ai->ai_addr)->sin6_scope_id != 0)
|
||||||
|
continue;
|
||||||
|
ip_addrs[i].family = IPADDR_INET6;
|
||||||
|
memcpy(&ip_addrs[i].addr.in6, &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr.s6_addr,
|
||||||
|
sizeof (ip_addrs->addr.in6));
|
||||||
|
i++;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (result && address_family != IPADDR_UNSPEC && address_family != addr->family)
|
|
||||||
result = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
return result;
|
|
||||||
|
return !max_addrs || ip_addrs[0].family != IPADDR_UNSPEC ? DNS_Success : DNS_Failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
DNS_IPAddress2Name(IPAddr *ip_addr, char *name, int len)
|
||||||
|
{
|
||||||
|
char *result = NULL;
|
||||||
|
#ifdef FEAT_IPV6
|
||||||
|
struct sockaddr_in6 saddr;
|
||||||
#else
|
#else
|
||||||
struct hostent *host;
|
struct sockaddr_in saddr;
|
||||||
char *address0;
|
|
||||||
|
|
||||||
try_again:
|
|
||||||
host = gethostbyname(name);
|
|
||||||
|
|
||||||
if (host == NULL) {
|
|
||||||
if (retry && h_errno == TRY_AGAIN && retries < MAXRETRIES) {
|
|
||||||
sleep(2 << retries);
|
|
||||||
retries++;
|
|
||||||
res_init();
|
|
||||||
goto try_again;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
addr->family = IPADDR_INET4;
|
|
||||||
address0 = host->h_addr_list[0];
|
|
||||||
addr->addr.in4 = ((((unsigned long)address0[0])<<24) |
|
|
||||||
(((unsigned long)address0[1])<<16) |
|
|
||||||
(((unsigned long)address0[2])<<8) |
|
|
||||||
(((unsigned long)address0[3])));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
IPSockAddr ip_saddr;
|
||||||
|
socklen_t slen;
|
||||||
|
char hbuf[NI_MAXHOST];
|
||||||
|
|
||||||
|
ip_saddr.ip_addr = *ip_addr;
|
||||||
|
ip_saddr.port = 0;
|
||||||
|
|
||||||
|
slen = SCK_IPSockAddrToSockaddr(&ip_saddr, (struct sockaddr *)&saddr, sizeof (saddr));
|
||||||
|
if (!getnameinfo((struct sockaddr *)&saddr, slen, hbuf, sizeof (hbuf), NULL, 0, 0))
|
||||||
|
result = hbuf;
|
||||||
|
|
||||||
|
if (result == NULL)
|
||||||
|
result = UTI_IPToString(ip_addr);
|
||||||
|
if (snprintf(name, len, "%s", result) >= len)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
DNS_IPAddress2Name(IPAddr *ip_addr, char *name, int len)
|
DNS_Reload(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
res_init();
|
||||||
int result;
|
|
||||||
struct sockaddr_in in4;
|
|
||||||
struct sockaddr_in6 in6;
|
|
||||||
|
|
||||||
switch (ip_addr->family) {
|
|
||||||
case IPADDR_INET4:
|
|
||||||
memset(&in4, 0, sizeof (in4));
|
|
||||||
in4.sin_family = AF_INET;
|
|
||||||
in4.sin_addr.s_addr = htonl(ip_addr->addr.in4);
|
|
||||||
result = getnameinfo((const struct sockaddr *)&in4, sizeof (in4), name, len, NULL, 0, 0);
|
|
||||||
break;
|
|
||||||
case IPADDR_INET6:
|
|
||||||
memset(&in6, 0, sizeof (in6));
|
|
||||||
in6.sin6_family = AF_INET6;
|
|
||||||
memcpy(&in6.sin6_addr.s6_addr, ip_addr->addr.in6, sizeof (in6.sin6_addr.s6_addr));
|
|
||||||
result = getnameinfo((const struct sockaddr *)&in6, sizeof (in6), name, len, NULL, 0, 0);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
result = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result)
|
|
||||||
snprintf(name, len, "%s", UTI_IPToString(ip_addr));
|
|
||||||
#else
|
|
||||||
struct hostent *host;
|
|
||||||
uint32_t addr;
|
|
||||||
|
|
||||||
switch (ip_addr->family) {
|
|
||||||
case IPADDR_INET4:
|
|
||||||
addr = htonl(ip_addr->addr.in4);
|
|
||||||
host = gethostbyaddr((const char *) &addr, sizeof (ip_addr), AF_INET);
|
|
||||||
break;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case IPADDR_INET6:
|
|
||||||
host = gethostbyaddr((const void *) ip_addr->addr.in6, sizeof (ip_addr->addr.in6), AF_INET6);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
host = NULL;
|
|
||||||
}
|
|
||||||
snprintf(name, len, "%s", host ? host->h_name : UTI_IPToString(ip_addr));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|||||||
19
nameserv.h
19
nameserv.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/nameserv.h,v 1.8 2002/02/28 23:27:11 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -34,12 +30,23 @@
|
|||||||
|
|
||||||
#include "addressing.h"
|
#include "addressing.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
DNS_Success,
|
||||||
|
DNS_TryAgain,
|
||||||
|
DNS_Failure
|
||||||
|
} DNS_Status;
|
||||||
|
|
||||||
/* Resolve names only to selected address family */
|
/* Resolve names only to selected address family */
|
||||||
extern void DNS_SetAddressFamily(int family);
|
extern void DNS_SetAddressFamily(int family);
|
||||||
|
|
||||||
extern int DNS_Name2IPAddress(const char *name, IPAddr *addr, int retry);
|
/* Maximum number of addresses returned by DNS_Name2IPAddress */
|
||||||
|
#define DNS_MAX_ADDRESSES 16
|
||||||
|
|
||||||
extern void DNS_IPAddress2Name(IPAddr *ip_addr, char *name, int len);
|
extern DNS_Status DNS_Name2IPAddress(const char *name, IPAddr *ip_addrs, int max_addrs);
|
||||||
|
|
||||||
|
extern int DNS_IPAddress2Name(IPAddr *ip_addr, char *name, int len);
|
||||||
|
|
||||||
|
extern void DNS_Reload(void);
|
||||||
|
|
||||||
#endif /* GOT_NAMESERV_H */
|
#endif /* GOT_NAMESERV_H */
|
||||||
|
|
||||||
|
|||||||
130
nameserv_async.c
Normal file
130
nameserv_async.c
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2014
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Functions to asynchronously convert name to IP address
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
|
#include "nameserv_async.h"
|
||||||
|
#include "logging.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "privops.h"
|
||||||
|
#include "sched.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#ifdef USE_PTHREAD_ASYNCDNS
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
struct DNS_Async_Instance {
|
||||||
|
const char *name;
|
||||||
|
DNS_Status status;
|
||||||
|
IPAddr addresses[DNS_MAX_ADDRESSES];
|
||||||
|
DNS_NameResolveHandler handler;
|
||||||
|
void *arg;
|
||||||
|
|
||||||
|
pthread_t thread;
|
||||||
|
int pipe[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
static pthread_mutex_t privops_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void *
|
||||||
|
start_resolving(void *anything)
|
||||||
|
{
|
||||||
|
struct DNS_Async_Instance *inst = (struct DNS_Async_Instance *)anything;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&privops_lock);
|
||||||
|
inst->status = PRV_Name2IPAddress(inst->name, inst->addresses, DNS_MAX_ADDRESSES);
|
||||||
|
pthread_mutex_unlock(&privops_lock);
|
||||||
|
|
||||||
|
/* Notify the main thread that the result is ready */
|
||||||
|
if (write(inst->pipe[1], "", 1) < 0)
|
||||||
|
;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
end_resolving(int fd, int event, void *anything)
|
||||||
|
{
|
||||||
|
struct DNS_Async_Instance *inst = (struct DNS_Async_Instance *)anything;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (pthread_join(inst->thread, NULL)) {
|
||||||
|
LOG_FATAL("pthread_join() failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
SCH_RemoveFileHandler(inst->pipe[0]);
|
||||||
|
close(inst->pipe[0]);
|
||||||
|
close(inst->pipe[1]);
|
||||||
|
|
||||||
|
for (i = 0; inst->status == DNS_Success && i < DNS_MAX_ADDRESSES &&
|
||||||
|
inst->addresses[i].family != IPADDR_UNSPEC; i++)
|
||||||
|
;
|
||||||
|
|
||||||
|
(inst->handler)(inst->status, i, inst->addresses, inst->arg);
|
||||||
|
|
||||||
|
Free(inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
DNS_Name2IPAddressAsync(const char *name, DNS_NameResolveHandler handler, void *anything)
|
||||||
|
{
|
||||||
|
struct DNS_Async_Instance *inst;
|
||||||
|
|
||||||
|
inst = MallocNew(struct DNS_Async_Instance);
|
||||||
|
inst->name = name;
|
||||||
|
inst->handler = handler;
|
||||||
|
inst->arg = anything;
|
||||||
|
inst->status = DNS_Failure;
|
||||||
|
|
||||||
|
if (pipe(inst->pipe)) {
|
||||||
|
LOG_FATAL("pipe() failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
UTI_FdSetCloexec(inst->pipe[0]);
|
||||||
|
UTI_FdSetCloexec(inst->pipe[1]);
|
||||||
|
|
||||||
|
if (pthread_create(&inst->thread, NULL, start_resolving, inst)) {
|
||||||
|
LOG_FATAL("pthread_create() failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
SCH_AddFileHandler(inst->pipe[0], SCH_FILE_INPUT, end_resolving, inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
40
nameserv_async.h
Normal file
40
nameserv_async.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2014
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Header for asynchronous nameserver functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GOT_NAMESERV_ASYNC_H
|
||||||
|
#define GOT_NAMESERV_ASYNC_H
|
||||||
|
|
||||||
|
#include "nameserv.h"
|
||||||
|
|
||||||
|
/* Function type for callback to process the result */
|
||||||
|
typedef void (*DNS_NameResolveHandler)(DNS_Status status, int n_addrs, IPAddr *ip_addrs, void *anything);
|
||||||
|
|
||||||
|
/* Request resolving of a name to IP address. The handler will be
|
||||||
|
called when the result is available. */
|
||||||
|
extern void DNS_Name2IPAddressAsync(const char *name, DNS_NameResolveHandler handler, void *anything);
|
||||||
|
|
||||||
|
#endif
|
||||||
117
ntp.h
117
ntp.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/ntp.h,v 1.12 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -31,11 +27,9 @@
|
|||||||
#ifndef GOT_NTP_H
|
#ifndef GOT_NTP_H
|
||||||
#define GOT_NTP_H
|
#define GOT_NTP_H
|
||||||
|
|
||||||
#ifdef HAS_STDINT_H
|
#include "sysincl.h"
|
||||||
#include <stdint.h>
|
|
||||||
#elif defined(HAS_INTTYPES_H)
|
#include "hash.h"
|
||||||
#include <inttypes.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t hi;
|
uint32_t hi;
|
||||||
@@ -44,7 +38,33 @@ typedef struct {
|
|||||||
|
|
||||||
typedef uint32_t NTP_int32;
|
typedef uint32_t NTP_int32;
|
||||||
|
|
||||||
#define AUTH_DATA_LEN 16
|
/* The UDP port number used by NTP */
|
||||||
|
#define NTP_PORT 123
|
||||||
|
|
||||||
|
/* The NTP protocol version that we support */
|
||||||
|
#define NTP_VERSION 4
|
||||||
|
|
||||||
|
/* Maximum stratum number (infinity) */
|
||||||
|
#define NTP_MAX_STRATUM 16
|
||||||
|
|
||||||
|
/* Invalid stratum number */
|
||||||
|
#define NTP_INVALID_STRATUM 0
|
||||||
|
|
||||||
|
/* The minimum and maximum supported length of MAC */
|
||||||
|
#define NTP_MIN_MAC_LENGTH (4 + 16)
|
||||||
|
#define NTP_MAX_MAC_LENGTH (4 + MAX_HASH_LENGTH)
|
||||||
|
|
||||||
|
/* The minimum valid length of an extension field */
|
||||||
|
#define NTP_MIN_EF_LENGTH 16
|
||||||
|
|
||||||
|
/* The maximum assumed length of all extension fields in an NTP packet,
|
||||||
|
including a MAC (RFC 5905 doesn't specify a limit on length or number of
|
||||||
|
extension fields in one packet) */
|
||||||
|
#define NTP_MAX_EXTENSIONS_LENGTH (1024 + NTP_MAX_MAC_LENGTH)
|
||||||
|
|
||||||
|
/* The maximum length of MAC in NTPv4 packets which allows deterministic
|
||||||
|
parsing of extension fields (RFC 7822) */
|
||||||
|
#define NTP_MAX_V4_MAC_LENGTH (4 + 20)
|
||||||
|
|
||||||
/* Type definition for leap bits */
|
/* Type definition for leap bits */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -75,42 +95,63 @@ typedef struct {
|
|||||||
NTP_int64 originate_ts;
|
NTP_int64 originate_ts;
|
||||||
NTP_int64 receive_ts;
|
NTP_int64 receive_ts;
|
||||||
NTP_int64 transmit_ts;
|
NTP_int64 transmit_ts;
|
||||||
NTP_int32 auth_keyid;
|
|
||||||
uint8_t auth_data[AUTH_DATA_LEN];
|
uint8_t extensions[NTP_MAX_EXTENSIONS_LENGTH];
|
||||||
} NTP_Packet;
|
} NTP_Packet;
|
||||||
|
|
||||||
/* We have to declare a buffer type to hold a datagram read from the
|
#define NTP_HEADER_LENGTH (int)offsetof(NTP_Packet, extensions)
|
||||||
network. Even though we won't be using them (yet?!), this must be
|
|
||||||
large enough to hold NTP control messages. */
|
|
||||||
|
|
||||||
/* Define the maximum number of bytes that can be read in a single
|
/* Macros to work with the lvm field */
|
||||||
message. (This is cribbed from ntp.h in the xntpd source code). */
|
#define NTP_LVM_TO_LEAP(lvm) (((lvm) >> 6) & 0x3)
|
||||||
|
#define NTP_LVM_TO_VERSION(lvm) (((lvm) >> 3) & 0x7)
|
||||||
|
#define NTP_LVM_TO_MODE(lvm) ((lvm) & 0x7)
|
||||||
|
#define NTP_LVM(leap, version, mode) \
|
||||||
|
((((leap) << 6) & 0xc0) | (((version) << 3) & 0x38) | ((mode) & 0x07))
|
||||||
|
|
||||||
#define MAX_NTP_MESSAGE_SIZE (468+12+16+4)
|
/* Special NTP reference IDs */
|
||||||
|
#define NTP_REFID_UNSYNC 0x0UL
|
||||||
|
#define NTP_REFID_LOCAL 0x7F7F0101UL /* 127.127.1.1 */
|
||||||
|
#define NTP_REFID_SMOOTH 0x7F7F01FFUL /* 127.127.1.255 */
|
||||||
|
|
||||||
typedef union {
|
/* Enumeration for authentication modes of NTP packets */
|
||||||
NTP_Packet ntp_pkt;
|
typedef enum {
|
||||||
uint8_t arbitrary[MAX_NTP_MESSAGE_SIZE];
|
NTP_AUTH_NONE = 0, /* No authentication */
|
||||||
} ReceiveBuffer;
|
NTP_AUTH_SYMMETRIC, /* NTP MAC or CMAC using a symmetric key
|
||||||
|
(RFC 1305, RFC 5905, RFC 8573) */
|
||||||
|
NTP_AUTH_MSSNTP, /* MS-SNTP authenticator field */
|
||||||
|
NTP_AUTH_MSSNTP_EXT, /* MS-SNTP extended authenticator field */
|
||||||
|
NTP_AUTH_NTS, /* Network Time Security (RFC 8915) */
|
||||||
|
} NTP_AuthMode;
|
||||||
|
|
||||||
#define NTP_NORMAL_PACKET_SIZE (sizeof(NTP_Packet) - (sizeof(NTP_int32) + AUTH_DATA_LEN))
|
/* Structure describing an NTP packet */
|
||||||
|
typedef struct {
|
||||||
|
int length;
|
||||||
|
int version;
|
||||||
|
NTP_Mode mode;
|
||||||
|
|
||||||
/* ================================================== */
|
int ext_fields;
|
||||||
|
|
||||||
inline static double
|
struct {
|
||||||
int32_to_double(NTP_int32 x)
|
NTP_AuthMode mode;
|
||||||
{
|
struct {
|
||||||
return (double) ntohl(x) / 65536.0;
|
int start;
|
||||||
}
|
int length;
|
||||||
|
uint32_t key_id;
|
||||||
|
} mac;
|
||||||
|
} auth;
|
||||||
|
} NTP_PacketInfo;
|
||||||
|
|
||||||
/* ================================================== */
|
/* Structure used to save NTP measurements. time is the local time at which
|
||||||
|
the sample is to be considered to have been made and offset is the offset at
|
||||||
inline static NTP_int32
|
the time (positive indicates that the local clock is slow relative to the
|
||||||
double_to_int32(double x)
|
source). root_delay/root_dispersion include peer_delay/peer_dispersion. */
|
||||||
{
|
typedef struct {
|
||||||
return htonl((NTP_int32)(0.5 + 65536.0 * x));
|
struct timespec time;
|
||||||
}
|
double offset;
|
||||||
|
double peer_delay;
|
||||||
/* ================================================== */
|
double peer_dispersion;
|
||||||
|
double root_delay;
|
||||||
|
double root_dispersion;
|
||||||
|
} NTP_Sample;
|
||||||
|
|
||||||
#endif /* GOT_NTP_H */
|
#endif /* GOT_NTP_H */
|
||||||
|
|||||||
495
ntp_auth.c
Normal file
495
ntp_auth.c
Normal file
@@ -0,0 +1,495 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2019-2020
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
NTP authentication
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
|
#include "keys.h"
|
||||||
|
#include "logging.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "ntp_auth.h"
|
||||||
|
#include "ntp_ext.h"
|
||||||
|
#include "ntp_signd.h"
|
||||||
|
#include "nts_ntp.h"
|
||||||
|
#include "nts_ntp_client.h"
|
||||||
|
#include "nts_ntp_server.h"
|
||||||
|
#include "srcparams.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
/* Structure to hold authentication configuration and state */
|
||||||
|
|
||||||
|
struct NAU_Instance_Record {
|
||||||
|
NTP_AuthMode mode; /* Authentication mode of NTP packets */
|
||||||
|
uint32_t key_id; /* Identifier of a symmetric key */
|
||||||
|
NNC_Instance nts; /* Client NTS state */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
generate_symmetric_auth(uint32_t key_id, NTP_Packet *packet, NTP_PacketInfo *info)
|
||||||
|
{
|
||||||
|
int auth_len, max_auth_len;
|
||||||
|
|
||||||
|
if (info->length + NTP_MIN_MAC_LENGTH > sizeof (*packet)) {
|
||||||
|
DEBUG_LOG("Packet too long");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Truncate long MACs in NTPv4 packets to allow deterministic parsing
|
||||||
|
of extension fields (RFC 7822) */
|
||||||
|
max_auth_len = (info->version == 4 ? NTP_MAX_V4_MAC_LENGTH : NTP_MAX_MAC_LENGTH) - 4;
|
||||||
|
max_auth_len = MIN(max_auth_len, sizeof (*packet) - info->length - 4);
|
||||||
|
|
||||||
|
auth_len = KEY_GenerateAuth(key_id, packet, info->length,
|
||||||
|
(unsigned char *)packet + info->length + 4, max_auth_len);
|
||||||
|
if (auth_len < NTP_MIN_MAC_LENGTH - 4) {
|
||||||
|
DEBUG_LOG("Could not generate auth data with key %"PRIu32, key_id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(uint32_t *)((unsigned char *)packet + info->length) = htonl(key_id);
|
||||||
|
|
||||||
|
info->auth.mac.start = info->length;
|
||||||
|
info->auth.mac.length = 4 + auth_len;
|
||||||
|
info->auth.mac.key_id = key_id;
|
||||||
|
info->length += info->auth.mac.length;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
check_symmetric_auth(NTP_Packet *packet, NTP_PacketInfo *info)
|
||||||
|
{
|
||||||
|
int trunc_len;
|
||||||
|
|
||||||
|
if (info->auth.mac.length < NTP_MIN_MAC_LENGTH)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
trunc_len = info->version == 4 && info->auth.mac.length <= NTP_MAX_V4_MAC_LENGTH ?
|
||||||
|
NTP_MAX_V4_MAC_LENGTH : NTP_MAX_MAC_LENGTH;
|
||||||
|
|
||||||
|
if (!KEY_CheckAuth(info->auth.mac.key_id, packet, info->auth.mac.start,
|
||||||
|
(unsigned char *)packet + info->auth.mac.start + 4,
|
||||||
|
info->auth.mac.length - 4, trunc_len - 4))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
is_zero_data(unsigned char *data, int length)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < length; i++)
|
||||||
|
if (data[i] != 0)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static NAU_Instance
|
||||||
|
create_instance(NTP_AuthMode mode)
|
||||||
|
{
|
||||||
|
NAU_Instance instance;
|
||||||
|
|
||||||
|
instance = MallocNew(struct NAU_Instance_Record);
|
||||||
|
instance->mode = mode;
|
||||||
|
instance->key_id = INACTIVE_AUTHKEY;
|
||||||
|
instance->nts = NULL;
|
||||||
|
|
||||||
|
assert(sizeof (instance->key_id) == 4);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
NAU_Instance
|
||||||
|
NAU_CreateNoneInstance(void)
|
||||||
|
{
|
||||||
|
return create_instance(NTP_AUTH_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
NAU_Instance
|
||||||
|
NAU_CreateSymmetricInstance(uint32_t key_id)
|
||||||
|
{
|
||||||
|
NAU_Instance instance = create_instance(NTP_AUTH_SYMMETRIC);
|
||||||
|
|
||||||
|
instance->key_id = key_id;
|
||||||
|
|
||||||
|
if (!KEY_KeyKnown(key_id))
|
||||||
|
LOG(LOGS_WARN, "Key %"PRIu32" is %s", key_id, "missing");
|
||||||
|
else if (!KEY_CheckKeyLength(key_id))
|
||||||
|
LOG(LOGS_WARN, "Key %"PRIu32" is %s", key_id, "too short");
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
NAU_Instance
|
||||||
|
NAU_CreateNtsInstance(IPSockAddr *nts_address, const char *name, uint32_t cert_set,
|
||||||
|
uint16_t ntp_port)
|
||||||
|
{
|
||||||
|
NAU_Instance instance = create_instance(NTP_AUTH_NTS);
|
||||||
|
|
||||||
|
instance->nts = NNC_CreateInstance(nts_address, name, cert_set, ntp_port);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
NAU_DestroyInstance(NAU_Instance instance)
|
||||||
|
{
|
||||||
|
if (instance->mode == NTP_AUTH_NTS)
|
||||||
|
NNC_DestroyInstance(instance->nts);
|
||||||
|
Free(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NAU_IsAuthEnabled(NAU_Instance instance)
|
||||||
|
{
|
||||||
|
return instance->mode != NTP_AUTH_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NAU_GetSuggestedNtpVersion(NAU_Instance instance)
|
||||||
|
{
|
||||||
|
/* If the MAC in NTPv4 packets would be truncated, prefer NTPv3 for
|
||||||
|
compatibility with older chronyd servers */
|
||||||
|
if (instance->mode == NTP_AUTH_SYMMETRIC &&
|
||||||
|
KEY_GetAuthLength(instance->key_id) + sizeof (instance->key_id) > NTP_MAX_V4_MAC_LENGTH)
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
return NTP_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NAU_PrepareRequestAuth(NAU_Instance instance)
|
||||||
|
{
|
||||||
|
switch (instance->mode) {
|
||||||
|
case NTP_AUTH_NTS:
|
||||||
|
if (!NNC_PrepareForAuth(instance->nts))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NAU_GenerateRequestAuth(NAU_Instance instance, NTP_Packet *request, NTP_PacketInfo *info)
|
||||||
|
{
|
||||||
|
switch (instance->mode) {
|
||||||
|
case NTP_AUTH_NONE:
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_SYMMETRIC:
|
||||||
|
if (!generate_symmetric_auth(instance->key_id, request, info))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_NTS:
|
||||||
|
if (!NNC_GenerateRequestAuth(instance->nts, request, info))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
info->auth.mode = instance->mode;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NAU_ParsePacket(NTP_Packet *packet, NTP_PacketInfo *info)
|
||||||
|
{
|
||||||
|
int parsed, remainder, ef_length, ef_type;
|
||||||
|
unsigned char *data;
|
||||||
|
|
||||||
|
data = (void *)packet;
|
||||||
|
parsed = NTP_HEADER_LENGTH;
|
||||||
|
remainder = info->length - parsed;
|
||||||
|
|
||||||
|
info->ext_fields = 0;
|
||||||
|
|
||||||
|
/* Check if this is a plain NTP packet with no extension fields or MAC */
|
||||||
|
if (remainder <= 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
assert(remainder % 4 == 0);
|
||||||
|
|
||||||
|
/* In NTPv3 and older packets don't have extension fields. Anything after
|
||||||
|
the header is assumed to be a MAC. */
|
||||||
|
if (info->version <= 3) {
|
||||||
|
info->auth.mode = NTP_AUTH_SYMMETRIC;
|
||||||
|
info->auth.mac.start = parsed;
|
||||||
|
info->auth.mac.length = remainder;
|
||||||
|
info->auth.mac.key_id = ntohl(*(uint32_t *)(data + parsed));
|
||||||
|
|
||||||
|
/* Check if it is an MS-SNTP authenticator field or extended authenticator
|
||||||
|
field with zeroes as digest */
|
||||||
|
if (info->version == 3 && info->auth.mac.key_id != 0) {
|
||||||
|
if (remainder == 20 && is_zero_data(data + parsed + 4, remainder - 4))
|
||||||
|
info->auth.mode = NTP_AUTH_MSSNTP;
|
||||||
|
else if (remainder == 72 && is_zero_data(data + parsed + 8, remainder - 8))
|
||||||
|
info->auth.mode = NTP_AUTH_MSSNTP_EXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check for a crypto NAK */
|
||||||
|
if (remainder == 4 && ntohl(*(uint32_t *)(data + parsed)) == 0) {
|
||||||
|
info->auth.mode = NTP_AUTH_SYMMETRIC;
|
||||||
|
info->auth.mac.start = parsed;
|
||||||
|
info->auth.mac.length = remainder;
|
||||||
|
info->auth.mac.key_id = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse the rest of the NTPv4 packet */
|
||||||
|
|
||||||
|
while (remainder > 0) {
|
||||||
|
/* Check if the remaining data is a MAC */
|
||||||
|
if (remainder >= NTP_MIN_MAC_LENGTH && remainder <= NTP_MAX_V4_MAC_LENGTH)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Check if this is a valid NTPv4 extension field and skip it */
|
||||||
|
if (!NEF_ParseField(packet, info->length, parsed, &ef_length, &ef_type, NULL, NULL)) {
|
||||||
|
DEBUG_LOG("Invalid format");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(ef_length > 0 && ef_length % 4 == 0);
|
||||||
|
|
||||||
|
switch (ef_type) {
|
||||||
|
case NTP_EF_NTS_UNIQUE_IDENTIFIER:
|
||||||
|
case NTP_EF_NTS_COOKIE:
|
||||||
|
case NTP_EF_NTS_COOKIE_PLACEHOLDER:
|
||||||
|
case NTP_EF_NTS_AUTH_AND_EEF:
|
||||||
|
info->auth.mode = NTP_AUTH_NTS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DEBUG_LOG("Unknown extension field type=%x", (unsigned int)ef_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
info->ext_fields++;
|
||||||
|
parsed += ef_length;
|
||||||
|
remainder = info->length - parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remainder == 0) {
|
||||||
|
/* No MAC */
|
||||||
|
return 1;
|
||||||
|
} else if (remainder >= NTP_MIN_MAC_LENGTH) {
|
||||||
|
info->auth.mode = NTP_AUTH_SYMMETRIC;
|
||||||
|
info->auth.mac.start = parsed;
|
||||||
|
info->auth.mac.length = remainder;
|
||||||
|
info->auth.mac.key_id = ntohl(*(uint32_t *)(data + parsed));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_LOG("Invalid format");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NAU_CheckRequestAuth(NTP_Packet *request, NTP_PacketInfo *info, uint32_t *kod)
|
||||||
|
{
|
||||||
|
*kod = 0;
|
||||||
|
|
||||||
|
switch (info->auth.mode) {
|
||||||
|
case NTP_AUTH_NONE:
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_SYMMETRIC:
|
||||||
|
if (!check_symmetric_auth(request, info))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_MSSNTP:
|
||||||
|
/* MS-SNTP requests are not authenticated */
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_MSSNTP_EXT:
|
||||||
|
/* Not supported yet */
|
||||||
|
return 0;
|
||||||
|
case NTP_AUTH_NTS:
|
||||||
|
if (!NNS_CheckRequestAuth(request, info, kod))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NAU_GenerateResponseAuth(NTP_Packet *request, NTP_PacketInfo *request_info,
|
||||||
|
NTP_Packet *response, NTP_PacketInfo *response_info,
|
||||||
|
NTP_Remote_Address *remote_addr, NTP_Local_Address *local_addr,
|
||||||
|
uint32_t kod)
|
||||||
|
{
|
||||||
|
switch (request_info->auth.mode) {
|
||||||
|
case NTP_AUTH_NONE:
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_SYMMETRIC:
|
||||||
|
if (!generate_symmetric_auth(request_info->auth.mac.key_id, response, response_info))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_MSSNTP:
|
||||||
|
/* Sign the packet asynchronously by ntp_signd */
|
||||||
|
if (!NSD_SignAndSendPacket(request_info->auth.mac.key_id, response, response_info,
|
||||||
|
remote_addr, local_addr))
|
||||||
|
return 0;
|
||||||
|
/* Don't send the original packet */
|
||||||
|
return 0;
|
||||||
|
case NTP_AUTH_NTS:
|
||||||
|
if (!NNS_GenerateResponseAuth(request, request_info, response, response_info, kod))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DEBUG_LOG("Could not authenticate response auth_mode=%d", (int)request_info->auth.mode);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
response_info->auth.mode = request_info->auth.mode;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NAU_CheckResponseAuth(NAU_Instance instance, NTP_Packet *response, NTP_PacketInfo *info)
|
||||||
|
{
|
||||||
|
/* The authentication must match the expected mode */
|
||||||
|
if (info->auth.mode != instance->mode)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (info->auth.mode) {
|
||||||
|
case NTP_AUTH_NONE:
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_SYMMETRIC:
|
||||||
|
/* Check if it is authenticated with the specified key */
|
||||||
|
if (info->auth.mac.key_id != instance->key_id)
|
||||||
|
return 0;
|
||||||
|
/* and that the MAC is valid */
|
||||||
|
if (!check_symmetric_auth(response, info))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_NTS:
|
||||||
|
if (!NNC_CheckResponseAuth(instance->nts, response, info))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
NAU_ChangeAddress(NAU_Instance instance, IPAddr *address)
|
||||||
|
{
|
||||||
|
switch (instance->mode) {
|
||||||
|
case NTP_AUTH_NONE:
|
||||||
|
case NTP_AUTH_SYMMETRIC:
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_NTS:
|
||||||
|
NNC_ChangeAddress(instance->nts, address);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
NAU_DumpData(NAU_Instance instance)
|
||||||
|
{
|
||||||
|
switch (instance->mode) {
|
||||||
|
case NTP_AUTH_NTS:
|
||||||
|
NNC_DumpData(instance->nts);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
NAU_GetReport(NAU_Instance instance, RPT_AuthReport *report)
|
||||||
|
{
|
||||||
|
memset(report, 0, sizeof (*report));
|
||||||
|
|
||||||
|
report->mode = instance->mode;
|
||||||
|
report->last_ke_ago = -1;
|
||||||
|
|
||||||
|
switch (instance->mode) {
|
||||||
|
case NTP_AUTH_NONE:
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_SYMMETRIC:
|
||||||
|
report->key_id = instance->key_id;
|
||||||
|
KEY_GetKeyInfo(instance->key_id, &report->key_type, &report->key_length);
|
||||||
|
break;
|
||||||
|
case NTP_AUTH_NTS:
|
||||||
|
NNC_GetReport(instance->nts, report);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
87
ntp_auth.h
Normal file
87
ntp_auth.h
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2019
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Header file for NTP authentication
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GOT_NTP_AUTH_H
|
||||||
|
#define GOT_NTP_AUTH_H
|
||||||
|
|
||||||
|
#include "addressing.h"
|
||||||
|
#include "ntp.h"
|
||||||
|
#include "reports.h"
|
||||||
|
|
||||||
|
typedef struct NAU_Instance_Record *NAU_Instance;
|
||||||
|
|
||||||
|
/* Create an authenticator instance in a specific mode */
|
||||||
|
extern NAU_Instance NAU_CreateNoneInstance(void);
|
||||||
|
extern NAU_Instance NAU_CreateSymmetricInstance(uint32_t key_id);
|
||||||
|
extern NAU_Instance NAU_CreateNtsInstance(IPSockAddr *nts_address, const char *name,
|
||||||
|
uint32_t cert_set, uint16_t ntp_port);
|
||||||
|
|
||||||
|
/* Destroy an instance */
|
||||||
|
extern void NAU_DestroyInstance(NAU_Instance instance);
|
||||||
|
|
||||||
|
/* Check if an instance is not in the None mode */
|
||||||
|
extern int NAU_IsAuthEnabled(NAU_Instance instance);
|
||||||
|
|
||||||
|
/* Get NTP version recommended for better compatibility */
|
||||||
|
extern int NAU_GetSuggestedNtpVersion(NAU_Instance instance);
|
||||||
|
|
||||||
|
/* Perform operations necessary for NAU_GenerateRequestAuth() */
|
||||||
|
extern int NAU_PrepareRequestAuth(NAU_Instance instance);
|
||||||
|
|
||||||
|
/* Extend a request with data required by the authentication mode */
|
||||||
|
extern int NAU_GenerateRequestAuth(NAU_Instance instance, NTP_Packet *request,
|
||||||
|
NTP_PacketInfo *info);
|
||||||
|
|
||||||
|
/* Parse a request or response to detect the authentication mode */
|
||||||
|
extern int NAU_ParsePacket(NTP_Packet *packet, NTP_PacketInfo *info);
|
||||||
|
|
||||||
|
/* Verify that a request is authentic. If it is not authentic and a non-zero
|
||||||
|
kod code is returned, a KoD response should be sent back. */
|
||||||
|
extern int NAU_CheckRequestAuth(NTP_Packet *request, NTP_PacketInfo *info, uint32_t *kod);
|
||||||
|
|
||||||
|
/* Extend a response with data required by the authentication mode. This
|
||||||
|
function can be called only if the previous call of NAU_CheckRequestAuth()
|
||||||
|
was on the same request. */
|
||||||
|
extern int NAU_GenerateResponseAuth(NTP_Packet *request, NTP_PacketInfo *request_info,
|
||||||
|
NTP_Packet *response, NTP_PacketInfo *response_info,
|
||||||
|
NTP_Remote_Address *remote_addr,
|
||||||
|
NTP_Local_Address *local_addr,
|
||||||
|
uint32_t kod);
|
||||||
|
|
||||||
|
/* Verify that a response is authentic */
|
||||||
|
extern int NAU_CheckResponseAuth(NAU_Instance instance, NTP_Packet *response,
|
||||||
|
NTP_PacketInfo *info);
|
||||||
|
|
||||||
|
/* Change an authentication-specific address (e.g. after replacing a source) */
|
||||||
|
extern void NAU_ChangeAddress(NAU_Instance instance, IPAddr *address);
|
||||||
|
|
||||||
|
/* Save authentication-specific data to speed up the next start */
|
||||||
|
extern void NAU_DumpData(NAU_Instance instance);
|
||||||
|
|
||||||
|
/* Provide a report about the current authentication state */
|
||||||
|
extern void NAU_GetReport(NAU_Instance instance, RPT_AuthReport *report);
|
||||||
|
|
||||||
|
#endif
|
||||||
3507
ntp_core.c
3507
ntp_core.c
File diff suppressed because it is too large
Load Diff
93
ntp_core.h
93
ntp_core.h
@@ -1,8 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/ntp_core.h,v 1.16 2002/02/28 23:27:12 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -38,6 +34,22 @@
|
|||||||
#include "ntp.h"
|
#include "ntp.h"
|
||||||
#include "reports.h"
|
#include "reports.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NTP_SERVER, NTP_PEER
|
||||||
|
} NTP_Source_Type;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NTP_TS_DAEMON = 0,
|
||||||
|
NTP_TS_KERNEL,
|
||||||
|
NTP_TS_HARDWARE
|
||||||
|
} NTP_Timestamp_Source;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
struct timespec ts;
|
||||||
|
double err;
|
||||||
|
NTP_Timestamp_Source source;
|
||||||
|
} NTP_Local_Timestamp;
|
||||||
|
|
||||||
/* This is a private data type used for storing the instance record for
|
/* This is a private data type used for storing the instance record for
|
||||||
each source that we are chiming with */
|
each source that we are chiming with */
|
||||||
typedef struct NCR_Instance_Record *NCR_Instance;
|
typedef struct NCR_Instance_Record *NCR_Instance;
|
||||||
@@ -46,41 +58,52 @@ typedef struct NCR_Instance_Record *NCR_Instance;
|
|||||||
extern void NCR_Initialise(void);
|
extern void NCR_Initialise(void);
|
||||||
extern void NCR_Finalise(void);
|
extern void NCR_Finalise(void);
|
||||||
|
|
||||||
/* Get a new instance for a server */
|
/* Get a new instance for a server or peer */
|
||||||
extern NCR_Instance NCR_GetServerInstance(NTP_Remote_Address *remote_addr, SourceParameters *params);
|
extern NCR_Instance NCR_CreateInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type,
|
||||||
|
SourceParameters *params, const char *name);
|
||||||
/* Get a new instance for a peer */
|
|
||||||
extern NCR_Instance NCR_GetPeerInstance(NTP_Remote_Address *remote_addr, SourceParameters *params);
|
|
||||||
|
|
||||||
/* Destroy an instance */
|
/* Destroy an instance */
|
||||||
extern void NCR_DestroyInstance(NCR_Instance instance);
|
extern void NCR_DestroyInstance(NCR_Instance instance);
|
||||||
|
|
||||||
|
/* Start an instance */
|
||||||
|
extern void NCR_StartInstance(NCR_Instance instance);
|
||||||
|
|
||||||
|
/* Reset an instance */
|
||||||
|
extern void NCR_ResetInstance(NCR_Instance inst);
|
||||||
|
|
||||||
|
/* Reset polling interval of an instance */
|
||||||
|
extern void NCR_ResetPoll(NCR_Instance instance);
|
||||||
|
|
||||||
|
/* Change the remote address of an instance */
|
||||||
|
extern void NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr,
|
||||||
|
int ntp_only);
|
||||||
|
|
||||||
/* This routine is called when a new packet arrives off the network,
|
/* This routine is called when a new packet arrives off the network,
|
||||||
and it relates to a source we have an ongoing protocol exchange with */
|
and it relates to a source we have an ongoing protocol exchange with */
|
||||||
extern void NCR_ProcessNoauthKnown(NTP_Packet *message, struct timeval *now, NCR_Instance data);
|
extern int NCR_ProcessRxKnown(NCR_Instance inst, NTP_Local_Address *local_addr,
|
||||||
|
NTP_Local_Timestamp *rx_ts, NTP_Packet *message, int length);
|
||||||
|
|
||||||
/* This routine is called when a new packet arrives off the network,
|
/* This routine is called when a new packet arrives off the network,
|
||||||
and we do not recognize its source */
|
and we do not recognize its source */
|
||||||
extern void NCR_ProcessNoauthUnknown(NTP_Packet *message, struct timeval *now, NTP_Remote_Address *remote_addr);
|
extern void NCR_ProcessRxUnknown(NTP_Remote_Address *remote_addr, NTP_Local_Address *local_addr,
|
||||||
|
NTP_Local_Timestamp *rx_ts, NTP_Packet *message, int length);
|
||||||
|
|
||||||
/* This routine is called when a new authenticated packet arrives off
|
/* This routine is called when a packet is sent to a source we have
|
||||||
the network, and it relates to a source we have an ongoing protocol
|
an ongoing protocol exchange with */
|
||||||
exchange with */
|
extern void NCR_ProcessTxKnown(NCR_Instance inst, NTP_Local_Address *local_addr,
|
||||||
extern void NCR_ProcessAuthKnown(NTP_Packet *message, struct timeval *now, NCR_Instance data);
|
NTP_Local_Timestamp *tx_ts, NTP_Packet *message, int length);
|
||||||
|
|
||||||
/* This routine is called when a new authenticated packet arrives off
|
/* This routine is called when a packet is sent to a destination we
|
||||||
the network, and we do not recognize its source */
|
do not recognize */
|
||||||
extern void NCR_ProcessAuthUnknown(NTP_Packet *message, struct timeval *now, NTP_Remote_Address *remote_addr);
|
extern void NCR_ProcessTxUnknown(NTP_Remote_Address *remote_addr, NTP_Local_Address *local_addr,
|
||||||
|
NTP_Local_Timestamp *tx_ts, NTP_Packet *message, int length);
|
||||||
|
|
||||||
/* Slew receive and transmit times in instance records */
|
/* Slew receive and transmit times in instance records */
|
||||||
extern void NCR_SlewTimes(NCR_Instance inst, struct timeval *when, double dfreq, double doffset);
|
extern void NCR_SlewTimes(NCR_Instance inst, struct timespec *when, double dfreq, double doffset);
|
||||||
|
|
||||||
/* Take a particular source online (i.e. start sampling it) */
|
/* Take a particular source online (i.e. start sampling it) or offline
|
||||||
extern void NCR_TakeSourceOnline(NCR_Instance inst);
|
(i.e. stop sampling it) */
|
||||||
|
extern void NCR_SetConnectivity(NCR_Instance inst, SRC_Connectivity connectivity);
|
||||||
/* Take a particular source offline (i.e. stop sampling it, without
|
|
||||||
marking it unreachable in the source selection stuff) */
|
|
||||||
extern void NCR_TakeSourceOffline(NCR_Instance inst);
|
|
||||||
|
|
||||||
extern void NCR_ModifyMinpoll(NCR_Instance inst, int new_minpoll);
|
extern void NCR_ModifyMinpoll(NCR_Instance inst, int new_minpoll);
|
||||||
|
|
||||||
@@ -90,18 +113,32 @@ extern void NCR_ModifyMaxdelay(NCR_Instance inst, double new_max_delay);
|
|||||||
|
|
||||||
extern void NCR_ModifyMaxdelayratio(NCR_Instance inst, double new_max_delay_ratio);
|
extern void NCR_ModifyMaxdelayratio(NCR_Instance inst, double new_max_delay_ratio);
|
||||||
|
|
||||||
|
extern void NCR_ModifyMaxdelaydevratio(NCR_Instance inst, double new_max_delay_dev_ratio);
|
||||||
|
|
||||||
|
extern void NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum);
|
||||||
|
|
||||||
|
extern void NCR_ModifyPolltarget(NCR_Instance inst, int new_poll_target);
|
||||||
|
|
||||||
extern void NCR_InitiateSampleBurst(NCR_Instance inst, int n_good_samples, int n_total_samples);
|
extern void NCR_InitiateSampleBurst(NCR_Instance inst, int n_good_samples, int n_total_samples);
|
||||||
|
|
||||||
extern void NCR_ReportSource(NCR_Instance inst, RPT_SourceReport *report, struct timeval *now);
|
extern void NCR_ReportSource(NCR_Instance inst, RPT_SourceReport *report, struct timespec *now);
|
||||||
|
extern void NCR_GetAuthReport(NCR_Instance inst, RPT_AuthReport *report);
|
||||||
|
extern void NCR_GetNTPReport(NCR_Instance inst, RPT_NTPReport *report);
|
||||||
|
|
||||||
extern int NCR_AddAccessRestriction(IPAddr *ip_addr, int subnet_bits, int allow, int all);
|
extern int NCR_AddAccessRestriction(IPAddr *ip_addr, int subnet_bits, int allow, int all);
|
||||||
extern int NCR_CheckAccessRestriction(IPAddr *ip_addr);
|
extern int NCR_CheckAccessRestriction(IPAddr *ip_addr);
|
||||||
|
|
||||||
extern void NCR_CycleLogFile(void);
|
|
||||||
|
|
||||||
extern void NCR_IncrementActivityCounters(NCR_Instance inst, int *online, int *offline,
|
extern void NCR_IncrementActivityCounters(NCR_Instance inst, int *online, int *offline,
|
||||||
int *burst_online, int *burst_offline);
|
int *burst_online, int *burst_offline);
|
||||||
|
|
||||||
extern NTP_Remote_Address *NCR_GetRemoteAddress(NCR_Instance instance);
|
extern NTP_Remote_Address *NCR_GetRemoteAddress(NCR_Instance instance);
|
||||||
|
|
||||||
|
extern uint32_t NCR_GetLocalRefid(NCR_Instance inst);
|
||||||
|
|
||||||
|
extern int NCR_IsSyncPeer(NCR_Instance instance);
|
||||||
|
|
||||||
|
extern void NCR_DumpAuthData(NCR_Instance inst);
|
||||||
|
|
||||||
|
extern void NCR_AddBroadcastDestination(NTP_Remote_Address *addr, int interval);
|
||||||
|
|
||||||
#endif /* GOT_NTP_CORE_H */
|
#endif /* GOT_NTP_CORE_H */
|
||||||
|
|||||||
192
ntp_ext.c
Normal file
192
ntp_ext.c
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2019-2020
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Functions for adding and parsing NTPv4 extension fields
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "sysincl.h"
|
||||||
|
|
||||||
|
#include "ntp_ext.h"
|
||||||
|
|
||||||
|
struct ExtFieldHeader {
|
||||||
|
uint16_t type;
|
||||||
|
uint16_t length;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
format_field(unsigned char *buffer, int buffer_length, int start,
|
||||||
|
int type, int body_length, int *length, void **body)
|
||||||
|
{
|
||||||
|
struct ExtFieldHeader *header;
|
||||||
|
|
||||||
|
if (buffer_length < 0 || start < 0 || buffer_length <= start ||
|
||||||
|
buffer_length - start < sizeof (*header) || start % 4 != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
header = (struct ExtFieldHeader *)(buffer + start);
|
||||||
|
|
||||||
|
if (body_length < 0 || sizeof (*header) + body_length > 0xffff ||
|
||||||
|
start + sizeof (*header) + body_length > buffer_length || body_length % 4 != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
header->type = htons(type);
|
||||||
|
header->length = htons(sizeof (*header) + body_length);
|
||||||
|
*length = sizeof (*header) + body_length;
|
||||||
|
*body = header + 1;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NEF_SetField(unsigned char *buffer, int buffer_length, int start,
|
||||||
|
int type, void *body, int body_length, int *length)
|
||||||
|
{
|
||||||
|
void *ef_body;
|
||||||
|
|
||||||
|
if (!format_field(buffer, buffer_length, start, type, body_length, length, &ef_body))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
memcpy(ef_body, body, body_length);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NEF_AddBlankField(NTP_Packet *packet, NTP_PacketInfo *info, int type, int body_length, void **body)
|
||||||
|
{
|
||||||
|
int ef_length, length = info->length;
|
||||||
|
|
||||||
|
if (length < NTP_HEADER_LENGTH || length >= sizeof (*packet) || length % 4 != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Only NTPv4 packets can have extension fields */
|
||||||
|
if (info->version != 4)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!format_field((unsigned char *)packet, sizeof (*packet), length,
|
||||||
|
type, body_length, &ef_length, body))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (ef_length < NTP_MIN_EF_LENGTH)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
info->length += ef_length;
|
||||||
|
info->ext_fields++;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NEF_AddField(NTP_Packet *packet, NTP_PacketInfo *info,
|
||||||
|
int type, void *body, int body_length)
|
||||||
|
{
|
||||||
|
void *ef_body;
|
||||||
|
|
||||||
|
if (!NEF_AddBlankField(packet, info, type, body_length, &ef_body))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
memcpy(ef_body, body, body_length);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NEF_ParseSingleField(unsigned char *buffer, int buffer_length, int start,
|
||||||
|
int *length, int *type, void **body, int *body_length)
|
||||||
|
{
|
||||||
|
struct ExtFieldHeader *header;
|
||||||
|
int ef_length;
|
||||||
|
|
||||||
|
if (buffer_length < 0 || start < 0 || buffer_length <= start ||
|
||||||
|
buffer_length - start < sizeof (*header))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
header = (struct ExtFieldHeader *)(buffer + start);
|
||||||
|
|
||||||
|
assert(sizeof (*header) == 4);
|
||||||
|
|
||||||
|
ef_length = ntohs(header->length);
|
||||||
|
|
||||||
|
if (ef_length < (int)(sizeof (*header)) || start + ef_length > buffer_length ||
|
||||||
|
ef_length % 4 != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (length)
|
||||||
|
*length = ef_length;
|
||||||
|
if (type)
|
||||||
|
*type = ntohs(header->type);
|
||||||
|
if (body)
|
||||||
|
*body = header + 1;
|
||||||
|
if (body_length)
|
||||||
|
*body_length = ef_length - sizeof (*header);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NEF_ParseField(NTP_Packet *packet, int packet_length, int start,
|
||||||
|
int *length, int *type, void **body, int *body_length)
|
||||||
|
{
|
||||||
|
int ef_length;
|
||||||
|
|
||||||
|
if (packet_length <= NTP_HEADER_LENGTH || packet_length > sizeof (*packet) ||
|
||||||
|
packet_length <= start || packet_length % 4 != 0 ||
|
||||||
|
start < NTP_HEADER_LENGTH || start % 4 != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Only NTPv4 packets have extension fields */
|
||||||
|
if (NTP_LVM_TO_VERSION(packet->lvm) != 4)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Check if the remaining data is a MAC. RFC 7822 specifies the maximum
|
||||||
|
length of a MAC in NTPv4 packets in order to enable deterministic
|
||||||
|
parsing. */
|
||||||
|
if (packet_length - start <= NTP_MAX_V4_MAC_LENGTH)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!NEF_ParseSingleField((unsigned char *)packet, packet_length, start,
|
||||||
|
&ef_length, type, body, body_length))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (ef_length < NTP_MIN_EF_LENGTH)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (length)
|
||||||
|
*length = ef_length;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
43
ntp_ext.h
Normal file
43
ntp_ext.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Copyright (C) Miroslav Lichvar 2019
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Header file for NTP extension fields
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GOT_NTP_EXT_H
|
||||||
|
#define GOT_NTP_EXT_H
|
||||||
|
|
||||||
|
#include "ntp.h"
|
||||||
|
|
||||||
|
extern int NEF_SetField(unsigned char *buffer, int buffer_length, int start,
|
||||||
|
int type, void *body, int body_length, int *length);
|
||||||
|
extern int NEF_AddBlankField(NTP_Packet *packet, NTP_PacketInfo *info, int type,
|
||||||
|
int body_length, void **body);
|
||||||
|
extern int NEF_AddField(NTP_Packet *packet, NTP_PacketInfo *info,
|
||||||
|
int type, void *body, int body_length);
|
||||||
|
extern int NEF_ParseSingleField(unsigned char *buffer, int buffer_length, int start,
|
||||||
|
int *length, int *type, void **body, int *body_length);
|
||||||
|
extern int NEF_ParseField(NTP_Packet *packet, int packet_length, int start,
|
||||||
|
int *length, int *type, void **body, int *body_length);
|
||||||
|
|
||||||
|
#endif
|
||||||
745
ntp_io.c
745
ntp_io.c
@@ -1,14 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
$Header: /cvs/src/chrony/ntp_io.c,v 1.24 2003/09/22 21:22:30 richard Exp $
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
* Copyright (C) Timo Teras 2009
|
* Copyright (C) Timo Teras 2009
|
||||||
* Copyright (C) Miroslav Lichvar 2009
|
* Copyright (C) Miroslav Lichvar 2009, 2013-2016, 2018-2020
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -30,32 +26,49 @@
|
|||||||
This file deals with the IO aspects of reading and writing NTP packets
|
This file deals with the IO aspects of reading and writing NTP packets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "ntp_io.h"
|
#include "ntp_io.h"
|
||||||
#include "ntp_core.h"
|
#include "ntp_core.h"
|
||||||
#include "ntp_sources.h"
|
#include "ntp_sources.h"
|
||||||
#include "sched.h"
|
#include "sched.h"
|
||||||
|
#include "socket.h"
|
||||||
#include "local.h"
|
#include "local.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
#include "privops.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
|
#include "ntp_io_linux.h"
|
||||||
union sockaddr_in46 {
|
|
||||||
struct sockaddr_in in4;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
struct sockaddr_in6 in6;
|
|
||||||
#endif
|
#endif
|
||||||
struct sockaddr u;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The file descriptors for the IPv4 and IPv6 sockets */
|
#define INVALID_SOCK_FD -1
|
||||||
static int sock_fd4;
|
|
||||||
#ifdef HAVE_IPV6
|
/* The server/peer and client sockets for IPv4 and IPv6 */
|
||||||
static int sock_fd6;
|
static int server_sock_fd4;
|
||||||
#endif
|
static int server_sock_fd6;
|
||||||
|
static int client_sock_fd4;
|
||||||
|
static int client_sock_fd6;
|
||||||
|
|
||||||
|
/* Reference counters for server sockets to keep them open only when needed */
|
||||||
|
static int server_sock_ref4;
|
||||||
|
static int server_sock_ref6;
|
||||||
|
|
||||||
|
/* Flag indicating we create a new connected client socket for each
|
||||||
|
server instead of sharing client_sock_fd4 and client_sock_fd6 */
|
||||||
|
static int separate_client_sockets;
|
||||||
|
|
||||||
|
/* Flag indicating the server sockets are not created dynamically when needed,
|
||||||
|
either to have a socket for client requests when separate client sockets
|
||||||
|
are disabled and client port is equal to server port, or the server port is
|
||||||
|
disabled */
|
||||||
|
static int permanent_server_sockets;
|
||||||
|
|
||||||
|
/* Flag indicating the server IPv4 socket is bound to an address */
|
||||||
|
static int bound_server_sock_fd4;
|
||||||
|
|
||||||
/* Flag indicating that we have been initialised */
|
/* Flag indicating that we have been initialised */
|
||||||
static int initialised=0;
|
static int initialised=0;
|
||||||
@@ -63,185 +76,151 @@ static int initialised=0;
|
|||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
/* Forward prototypes */
|
/* Forward prototypes */
|
||||||
static int prepare_socket(int family);
|
static void read_from_socket(int sock_fd, int event, void *anything);
|
||||||
static void read_from_socket(void *anything);
|
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
static void
|
static int
|
||||||
do_size_checks(void)
|
open_socket(int family, int local_port, int client_only, IPSockAddr *remote_addr)
|
||||||
{
|
{
|
||||||
/* Assertions to check the sizes of certain data types
|
int sock_fd, sock_flags, dscp, events = SCH_FILE_INPUT;
|
||||||
and the positions of certain record fields */
|
IPSockAddr local_addr;
|
||||||
|
char *iface;
|
||||||
|
|
||||||
/* Check that certain invariants are true */
|
if (!SCK_IsIpFamilyEnabled(family))
|
||||||
assert(sizeof(NTP_int32) == 4);
|
return INVALID_SOCK_FD;
|
||||||
assert(sizeof(NTP_int64) == 8);
|
|
||||||
|
|
||||||
/* Check offsets of all fields in the NTP packet format */
|
if (!client_only) {
|
||||||
assert(offsetof(NTP_Packet, lvm) == 0);
|
CNF_GetBindAddress(family, &local_addr.ip_addr);
|
||||||
assert(offsetof(NTP_Packet, stratum) == 1);
|
iface = CNF_GetBindNtpInterface();
|
||||||
assert(offsetof(NTP_Packet, poll) == 2);
|
} else {
|
||||||
assert(offsetof(NTP_Packet, precision) == 3);
|
CNF_GetBindAcquisitionAddress(family, &local_addr.ip_addr);
|
||||||
assert(offsetof(NTP_Packet, root_delay) == 4);
|
iface = CNF_GetBindAcquisitionInterface();
|
||||||
assert(offsetof(NTP_Packet, root_dispersion) == 8);
|
}
|
||||||
assert(offsetof(NTP_Packet, reference_id) == 12);
|
|
||||||
assert(offsetof(NTP_Packet, reference_ts) == 16);
|
|
||||||
assert(offsetof(NTP_Packet, originate_ts) == 24);
|
|
||||||
assert(offsetof(NTP_Packet, receive_ts) == 32);
|
|
||||||
assert(offsetof(NTP_Packet, transmit_ts) == 40);
|
|
||||||
|
|
||||||
|
local_addr.port = local_port;
|
||||||
|
|
||||||
|
sock_flags = SCK_FLAG_RX_DEST_ADDR | SCK_FLAG_PRIV_BIND;
|
||||||
|
if (!client_only)
|
||||||
|
sock_flags |= SCK_FLAG_BROADCAST;
|
||||||
|
|
||||||
|
sock_fd = SCK_OpenUdpSocket(remote_addr, &local_addr, iface, sock_flags);
|
||||||
|
if (sock_fd < 0) {
|
||||||
|
if (!client_only)
|
||||||
|
LOG(LOGS_ERR, "Could not open NTP socket on %s", UTI_IPSockAddrToString(&local_addr));
|
||||||
|
return INVALID_SOCK_FD;
|
||||||
|
}
|
||||||
|
|
||||||
|
dscp = CNF_GetNtpDscp();
|
||||||
|
if (dscp > 0 && dscp < 64) {
|
||||||
|
#ifdef IP_TOS
|
||||||
|
if (!SCK_SetIntOption(sock_fd, IPPROTO_IP, IP_TOS, dscp << 2))
|
||||||
|
;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!client_only && family == IPADDR_INET4 && local_addr.port > 0)
|
||||||
|
bound_server_sock_fd4 = local_addr.ip_addr.addr.in4 != INADDR_ANY;
|
||||||
|
|
||||||
|
/* Enable kernel/HW timestamping of packets */
|
||||||
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
|
if (!NIO_Linux_SetTimestampSocketOptions(sock_fd, client_only, &events))
|
||||||
|
#endif
|
||||||
|
if (!SCK_EnableKernelRxTimestamping(sock_fd))
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Register handler for read and possibly exception events on the socket */
|
||||||
|
SCH_AddFileHandler(sock_fd, events, read_from_socket, NULL);
|
||||||
|
|
||||||
|
return sock_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
prepare_socket(int family)
|
open_separate_client_socket(IPSockAddr *remote_addr)
|
||||||
{
|
{
|
||||||
union sockaddr_in46 my_addr;
|
return open_socket(remote_addr->ip_addr.family, 0, 1, remote_addr);
|
||||||
socklen_t my_addr_len;
|
|
||||||
int sock_fd;
|
|
||||||
unsigned short port_number;
|
|
||||||
IPAddr bind_address;
|
|
||||||
int on_off = 1;
|
|
||||||
|
|
||||||
port_number = CNF_GetNTPPort();
|
|
||||||
|
|
||||||
/* Open Internet domain UDP socket for NTP message transmissions */
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
sock_fd = socket(family, SOCK_DGRAM, IPPROTO_UDP);
|
|
||||||
#else
|
|
||||||
sock_fd = socket(family, SOCK_DGRAM, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sock_fd < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not open %s NTP socket : %s",
|
|
||||||
family == AF_INET ? "IPv4" : "IPv6", strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make the socket capable of re-using an old address */
|
|
||||||
if (setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&on_off, sizeof(on_off)) < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not set reuseaddr socket options");
|
|
||||||
/* Don't quit - we might survive anyway */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make the socket capable of sending broadcast pkts - needed for NTP broadcast mode */
|
|
||||||
if (setsockopt(sock_fd, SOL_SOCKET, SO_BROADCAST, (char *)&on_off, sizeof(on_off)) < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not set broadcast socket options");
|
|
||||||
/* Don't quit - we might survive anyway */
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SO_TIMESTAMP
|
|
||||||
/* Enable receiving of timestamp control messages */
|
|
||||||
if (setsockopt(sock_fd, SOL_SOCKET, SO_TIMESTAMP, (char *)&on_off, sizeof(on_off)) < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not set timestamp socket options");
|
|
||||||
/* Don't quit - we might survive anyway */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (family == AF_INET) {
|
|
||||||
#ifdef IP_PKTINFO
|
|
||||||
/* We want the local IP info too */
|
|
||||||
if (setsockopt(sock_fd, IPPROTO_IP, IP_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not request packet info using socket option");
|
|
||||||
/* Don't quit - we might survive anyway */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
else if (family == AF_INET6) {
|
|
||||||
#ifdef IPV6_V6ONLY
|
|
||||||
/* Receive IPv6 packets only */
|
|
||||||
if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&on_off, sizeof(on_off)) < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not request IPV6_V6ONLY socket option");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Bind the port */
|
|
||||||
memset(&my_addr, 0, sizeof (my_addr));
|
|
||||||
|
|
||||||
switch (family) {
|
|
||||||
case AF_INET:
|
|
||||||
my_addr_len = sizeof (my_addr.in4);
|
|
||||||
my_addr.in4.sin_family = family;
|
|
||||||
my_addr.in4.sin_port = htons(port_number);
|
|
||||||
|
|
||||||
CNF_GetBindAddress(IPADDR_INET4, &bind_address);
|
|
||||||
|
|
||||||
if (bind_address.family == IPADDR_INET4)
|
|
||||||
my_addr.in4.sin_addr.s_addr = htonl(bind_address.addr.in4);
|
|
||||||
else
|
|
||||||
my_addr.in4.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
||||||
break;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case AF_INET6:
|
|
||||||
my_addr_len = sizeof (my_addr.in6);
|
|
||||||
my_addr.in6.sin6_family = family;
|
|
||||||
my_addr.in6.sin6_port = htons(port_number);
|
|
||||||
|
|
||||||
CNF_GetBindAddress(IPADDR_INET6, &bind_address);
|
|
||||||
|
|
||||||
if (bind_address.family == IPADDR_INET6)
|
|
||||||
memcpy(my_addr.in6.sin6_addr.s6_addr, bind_address.addr.in6,
|
|
||||||
sizeof (my_addr.in6.sin6_addr.s6_addr));
|
|
||||||
else
|
|
||||||
my_addr.in6.sin6_addr = in6addr_any;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
LOG(LOGS_INFO, LOGF_NtpIO, "Initialising, socket fd=%d", sock_fd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (bind(sock_fd, &my_addr.u, my_addr_len) < 0) {
|
|
||||||
LOG_FATAL(LOGF_NtpIO, "Could not bind %s NTP socket : %s",
|
|
||||||
family == AF_INET ? "IPv4" : "IPv6", strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Register handler for read events on the socket */
|
|
||||||
SCH_AddInputFileHandler(sock_fd, read_from_socket, (void *)(long)sock_fd);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (fcntl(sock_fd, F_SETFL, O_NONBLOCK | O_NDELAY) < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not make socket non-blocking");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ioctl(sock_fd, I_SETSIG, S_INPUT) < 0) {
|
|
||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not enable signal");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return sock_fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
close_socket(int sock_fd)
|
||||||
|
{
|
||||||
|
if (sock_fd == INVALID_SOCK_FD)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
|
NIO_Linux_NotifySocketClosing(sock_fd);
|
||||||
|
#endif
|
||||||
|
SCH_RemoveFileHandler(sock_fd);
|
||||||
|
SCK_CloseSocket(sock_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
NIO_Initialise(void)
|
NIO_Initialise(void)
|
||||||
{
|
{
|
||||||
|
int server_port, client_port;
|
||||||
|
|
||||||
assert(!initialised);
|
assert(!initialised);
|
||||||
initialised = 1;
|
initialised = 1;
|
||||||
|
|
||||||
do_size_checks();
|
#ifdef PRIVOPS_BINDSOCKET
|
||||||
|
SCK_SetPrivBind(PRV_BindSocket);
|
||||||
sock_fd4 = prepare_socket(AF_INET);
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
sock_fd6 = prepare_socket(AF_INET6);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (sock_fd4 < 0
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
#ifdef HAVE_IPV6
|
NIO_Linux_Initialise();
|
||||||
&& sock_fd6 < 0
|
#else
|
||||||
|
if (1) {
|
||||||
|
CNF_HwTsInterface *conf_iface;
|
||||||
|
if (CNF_GetHwTsInterface(0, &conf_iface))
|
||||||
|
LOG_FATAL("HW timestamping not supported");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
) {
|
|
||||||
LOG_FATAL(LOGF_NtpIO, "Could not open any NTP socket");
|
server_port = CNF_GetNTPPort();
|
||||||
|
client_port = CNF_GetAcquisitionPort();
|
||||||
|
|
||||||
|
/* Use separate connected sockets if client port is negative */
|
||||||
|
separate_client_sockets = client_port < 0;
|
||||||
|
if (client_port < 0)
|
||||||
|
client_port = 0;
|
||||||
|
|
||||||
|
permanent_server_sockets = !server_port || (!separate_client_sockets &&
|
||||||
|
client_port == server_port);
|
||||||
|
|
||||||
|
server_sock_fd4 = INVALID_SOCK_FD;
|
||||||
|
server_sock_fd6 = INVALID_SOCK_FD;
|
||||||
|
client_sock_fd4 = INVALID_SOCK_FD;
|
||||||
|
client_sock_fd6 = INVALID_SOCK_FD;
|
||||||
|
server_sock_ref4 = 0;
|
||||||
|
server_sock_ref6 = 0;
|
||||||
|
|
||||||
|
if (permanent_server_sockets && server_port) {
|
||||||
|
server_sock_fd4 = open_socket(IPADDR_INET4, server_port, 0, NULL);
|
||||||
|
server_sock_fd6 = open_socket(IPADDR_INET6, server_port, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
if (!separate_client_sockets) {
|
||||||
|
if (client_port != server_port || !server_port) {
|
||||||
|
client_sock_fd4 = open_socket(IPADDR_INET4, client_port, 1, NULL);
|
||||||
|
client_sock_fd6 = open_socket(IPADDR_INET6, client_port, 1, NULL);
|
||||||
|
} else {
|
||||||
|
client_sock_fd4 = server_sock_fd4;
|
||||||
|
client_sock_fd6 = server_sock_fd6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((server_port && permanent_server_sockets &&
|
||||||
|
server_sock_fd4 == INVALID_SOCK_FD && server_sock_fd6 == INVALID_SOCK_FD) ||
|
||||||
|
(!separate_client_sockets &&
|
||||||
|
client_sock_fd4 == INVALID_SOCK_FD && client_sock_fd6 == INVALID_SOCK_FD)) {
|
||||||
|
LOG_FATAL("Could not open NTP sockets");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -249,256 +228,256 @@ NIO_Initialise(void)
|
|||||||
void
|
void
|
||||||
NIO_Finalise(void)
|
NIO_Finalise(void)
|
||||||
{
|
{
|
||||||
if (sock_fd4 >= 0) {
|
if (server_sock_fd4 != client_sock_fd4)
|
||||||
SCH_RemoveInputFileHandler(sock_fd4);
|
close_socket(client_sock_fd4);
|
||||||
close(sock_fd4);
|
close_socket(server_sock_fd4);
|
||||||
}
|
server_sock_fd4 = client_sock_fd4 = INVALID_SOCK_FD;
|
||||||
sock_fd4 = -1;
|
|
||||||
#ifdef HAVE_IPV6
|
if (server_sock_fd6 != client_sock_fd6)
|
||||||
if (sock_fd6 >= 0) {
|
close_socket(client_sock_fd6);
|
||||||
SCH_RemoveInputFileHandler(sock_fd6);
|
close_socket(server_sock_fd6);
|
||||||
close(sock_fd6);
|
server_sock_fd6 = client_sock_fd6 = INVALID_SOCK_FD;
|
||||||
}
|
|
||||||
sock_fd6 = -1;
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
|
NIO_Linux_Finalise();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
initialised = 0;
|
initialised = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
/* ================================================== */
|
NIO_OpenClientSocket(NTP_Remote_Address *remote_addr)
|
||||||
|
|
||||||
static void
|
|
||||||
read_from_socket(void *anything)
|
|
||||||
{
|
{
|
||||||
/* This should only be called when there is something
|
if (separate_client_sockets) {
|
||||||
to read, otherwise it will block. */
|
return open_separate_client_socket(remote_addr);
|
||||||
|
} else {
|
||||||
int status, sock_fd;
|
switch (remote_addr->ip_addr.family) {
|
||||||
ReceiveBuffer message;
|
case IPADDR_INET4:
|
||||||
union sockaddr_in46 where_from;
|
return client_sock_fd4;
|
||||||
unsigned int flags = 0;
|
case IPADDR_INET6:
|
||||||
struct timeval now;
|
return client_sock_fd6;
|
||||||
NTP_Remote_Address remote_addr;
|
|
||||||
char cmsgbuf[256];
|
|
||||||
struct msghdr msg;
|
|
||||||
struct iovec iov;
|
|
||||||
struct cmsghdr *cmsg;
|
|
||||||
|
|
||||||
assert(initialised);
|
|
||||||
|
|
||||||
SCH_GetFileReadyTime(&now);
|
|
||||||
|
|
||||||
iov.iov_base = message.arbitrary;
|
|
||||||
iov.iov_len = sizeof(message);
|
|
||||||
msg.msg_name = &where_from;
|
|
||||||
msg.msg_namelen = sizeof(where_from);
|
|
||||||
msg.msg_iov = &iov;
|
|
||||||
msg.msg_iovlen = 1;
|
|
||||||
msg.msg_control = (void *) cmsgbuf;
|
|
||||||
msg.msg_controllen = sizeof(cmsgbuf);
|
|
||||||
msg.msg_flags = 0;
|
|
||||||
|
|
||||||
sock_fd = (long)anything;
|
|
||||||
status = recvmsg(sock_fd, &msg, flags);
|
|
||||||
|
|
||||||
/* Don't bother checking if read failed or why if it did. More
|
|
||||||
likely than not, it will be connection refused, resulting from a
|
|
||||||
previous sendto() directing a datagram at a port that is not
|
|
||||||
listening (which appears to generate an ICMP response, and on
|
|
||||||
some architectures e.g. Linux this is translated into an error
|
|
||||||
reponse on a subsequent recvfrom). */
|
|
||||||
|
|
||||||
if (status > 0) {
|
|
||||||
memset(&remote_addr, 0, sizeof (remote_addr));
|
|
||||||
|
|
||||||
switch (where_from.u.sa_family) {
|
|
||||||
case AF_INET:
|
|
||||||
remote_addr.ip_addr.family = IPADDR_INET4;
|
|
||||||
remote_addr.ip_addr.addr.in4 = ntohl(where_from.in4.sin_addr.s_addr);
|
|
||||||
remote_addr.port = ntohs(where_from.in4.sin_port);
|
|
||||||
break;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case AF_INET6:
|
|
||||||
remote_addr.ip_addr.family = IPADDR_INET6;
|
|
||||||
memcpy(&remote_addr.ip_addr.addr.in6, where_from.in6.sin6_addr.s6_addr,
|
|
||||||
sizeof (remote_addr.ip_addr.addr.in6));
|
|
||||||
remote_addr.port = ntohs(where_from.in6.sin6_port);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
assert(0);
|
return INVALID_SOCK_FD;
|
||||||
}
|
|
||||||
|
|
||||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
|
||||||
#ifdef IP_PKTINFO
|
|
||||||
if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO) {
|
|
||||||
struct in_pktinfo ipi;
|
|
||||||
|
|
||||||
memcpy(&ipi, CMSG_DATA(cmsg), sizeof(ipi));
|
|
||||||
remote_addr.local_ip_addr.addr.in4 = ntohl(ipi.ipi_spec_dst.s_addr);
|
|
||||||
remote_addr.local_ip_addr.family = IPADDR_INET4;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SO_TIMESTAMP
|
|
||||||
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SO_TIMESTAMP) {
|
|
||||||
struct timeval tv;
|
|
||||||
double correction;
|
|
||||||
|
|
||||||
memcpy(&tv, CMSG_DATA(cmsg), sizeof(tv));
|
|
||||||
correction = LCL_GetOffsetCorrection(&tv);
|
|
||||||
UTI_AddDoubleToTimeval(&tv, correction, &tv);
|
|
||||||
#if 0
|
|
||||||
UTI_DiffTimevalsToDouble(&correction, &now, &tv);
|
|
||||||
LOG(LOGS_INFO, LOGF_NtpIO, "timestamp diff: %f", correction);
|
|
||||||
#endif
|
|
||||||
now = tv;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == NTP_NORMAL_PACKET_SIZE) {
|
|
||||||
|
|
||||||
NSR_ProcessReceive((NTP_Packet *) &message.ntp_pkt, &now, &remote_addr);
|
|
||||||
|
|
||||||
} else if (status == sizeof(NTP_Packet)) {
|
|
||||||
|
|
||||||
NSR_ProcessAuthenticatedReceive((NTP_Packet *) &message.ntp_pkt, &now, &remote_addr);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* Just ignore the packet if it's not of a recognized length */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* Send a packet to given address */
|
|
||||||
|
|
||||||
static void
|
int
|
||||||
send_packet(void *packet, int packetlen, NTP_Remote_Address *remote_addr)
|
NIO_OpenServerSocket(NTP_Remote_Address *remote_addr)
|
||||||
{
|
{
|
||||||
union sockaddr_in46 remote;
|
|
||||||
struct msghdr msg;
|
|
||||||
struct iovec iov;
|
|
||||||
char cmsgbuf[256];
|
|
||||||
int cmsglen;
|
|
||||||
int sock_fd;
|
|
||||||
socklen_t addrlen;
|
|
||||||
|
|
||||||
assert(initialised);
|
|
||||||
|
|
||||||
switch (remote_addr->ip_addr.family) {
|
switch (remote_addr->ip_addr.family) {
|
||||||
case IPADDR_INET4:
|
case IPADDR_INET4:
|
||||||
memset(&remote.in4, 0, sizeof (remote.in4));
|
if (permanent_server_sockets)
|
||||||
addrlen = sizeof (remote.in4);
|
return server_sock_fd4;
|
||||||
remote.in4.sin_family = AF_INET;
|
if (server_sock_fd4 == INVALID_SOCK_FD)
|
||||||
remote.in4.sin_port = htons(remote_addr->port);
|
server_sock_fd4 = open_socket(IPADDR_INET4, CNF_GetNTPPort(), 0, NULL);
|
||||||
remote.in4.sin_addr.s_addr = htonl(remote_addr->ip_addr.addr.in4);
|
if (server_sock_fd4 != INVALID_SOCK_FD)
|
||||||
sock_fd = sock_fd4;
|
server_sock_ref4++;
|
||||||
break;
|
return server_sock_fd4;
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case IPADDR_INET6:
|
case IPADDR_INET6:
|
||||||
memset(&remote.in6, 0, sizeof (remote.in6));
|
if (permanent_server_sockets)
|
||||||
addrlen = sizeof (remote.in6);
|
return server_sock_fd6;
|
||||||
remote.in6.sin6_family = AF_INET6;
|
if (server_sock_fd6 == INVALID_SOCK_FD)
|
||||||
remote.in6.sin6_port = htons(remote_addr->port);
|
server_sock_fd6 = open_socket(IPADDR_INET6, CNF_GetNTPPort(), 0, NULL);
|
||||||
memcpy(&remote.in6.sin6_addr.s6_addr, &remote_addr->ip_addr.addr.in6,
|
if (server_sock_fd6 != INVALID_SOCK_FD)
|
||||||
sizeof (remote.in6.sin6_addr.s6_addr));
|
server_sock_ref6++;
|
||||||
sock_fd = sock_fd6;
|
return server_sock_fd6;
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
return;
|
return INVALID_SOCK_FD;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sock_fd < 0)
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
NIO_CloseClientSocket(int sock_fd)
|
||||||
|
{
|
||||||
|
if (separate_client_sockets)
|
||||||
|
close_socket(sock_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
NIO_CloseServerSocket(int sock_fd)
|
||||||
|
{
|
||||||
|
if (permanent_server_sockets || sock_fd == INVALID_SOCK_FD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
iov.iov_base = packet;
|
if (sock_fd == server_sock_fd4) {
|
||||||
iov.iov_len = packetlen;
|
if (--server_sock_ref4 <= 0) {
|
||||||
msg.msg_name = &remote.u;
|
close_socket(server_sock_fd4);
|
||||||
msg.msg_namelen = addrlen;
|
server_sock_fd4 = INVALID_SOCK_FD;
|
||||||
msg.msg_iov = &iov;
|
}
|
||||||
msg.msg_iovlen = 1;
|
} else if (sock_fd == server_sock_fd6) {
|
||||||
msg.msg_control = cmsgbuf;
|
if (--server_sock_ref6 <= 0) {
|
||||||
msg.msg_controllen = sizeof(cmsgbuf);
|
close_socket(server_sock_fd6);
|
||||||
msg.msg_flags = 0;
|
server_sock_fd6 = INVALID_SOCK_FD;
|
||||||
cmsglen = 0;
|
}
|
||||||
|
} else {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef IP_PKTINFO
|
/* ================================================== */
|
||||||
if (remote_addr->local_ip_addr.family == IPADDR_INET4) {
|
|
||||||
struct cmsghdr *cmsg;
|
|
||||||
struct in_pktinfo *ipi;
|
|
||||||
|
|
||||||
cmsg = CMSG_FIRSTHDR(&msg);
|
int
|
||||||
memset(cmsg, 0, CMSG_SPACE(sizeof(struct in_pktinfo)));
|
NIO_IsServerSocket(int sock_fd)
|
||||||
cmsglen += CMSG_SPACE(sizeof(struct in_pktinfo));
|
{
|
||||||
|
return sock_fd != INVALID_SOCK_FD &&
|
||||||
|
(sock_fd == server_sock_fd4 || sock_fd == server_sock_fd6);
|
||||||
|
}
|
||||||
|
|
||||||
cmsg->cmsg_level = IPPROTO_IP;
|
/* ================================================== */
|
||||||
cmsg->cmsg_type = IP_PKTINFO;
|
|
||||||
cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
|
|
||||||
|
|
||||||
ipi = (struct in_pktinfo *) CMSG_DATA(cmsg);
|
int
|
||||||
ipi->ipi_spec_dst.s_addr = htonl(remote_addr->local_ip_addr.addr.in4);
|
NIO_IsServerSocketOpen(void)
|
||||||
|
{
|
||||||
|
return server_sock_fd4 != INVALID_SOCK_FD || server_sock_fd6 != INVALID_SOCK_FD;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NIO_IsServerConnectable(NTP_Remote_Address *remote_addr)
|
||||||
|
{
|
||||||
|
int sock_fd;
|
||||||
|
|
||||||
|
sock_fd = open_separate_client_socket(remote_addr);
|
||||||
|
if (sock_fd == INVALID_SOCK_FD)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
close_socket(sock_fd);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
process_message(SCK_Message *message, int sock_fd, int event)
|
||||||
|
{
|
||||||
|
NTP_Local_Address local_addr;
|
||||||
|
NTP_Local_Timestamp local_ts;
|
||||||
|
struct timespec sched_ts;
|
||||||
|
|
||||||
|
SCH_GetLastEventTime(&local_ts.ts, &local_ts.err, NULL);
|
||||||
|
local_ts.source = NTP_TS_DAEMON;
|
||||||
|
sched_ts = local_ts.ts;
|
||||||
|
|
||||||
|
if (message->addr_type != SCK_ADDR_IP) {
|
||||||
|
DEBUG_LOG("Unexpected address type");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
local_addr.ip_addr = message->local_addr.ip;
|
||||||
|
local_addr.if_index = message->if_index;;
|
||||||
|
local_addr.sock_fd = sock_fd;
|
||||||
|
|
||||||
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
|
if (NIO_Linux_ProcessMessage(message, &local_addr, &local_ts, event))
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
if (!UTI_IsZeroTimespec(&message->timestamp.kernel)) {
|
||||||
|
LCL_CookTime(&message->timestamp.kernel, &local_ts.ts, &local_ts.err);
|
||||||
|
local_ts.source = NTP_TS_KERNEL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
if (local_ts.source != NTP_TS_DAEMON)
|
||||||
LOG(LOGS_INFO, LOGF_NtpIO, "sending to %s:%d from %s",
|
DEBUG_LOG("Updated RX timestamp delay=%.9f tss=%u",
|
||||||
UTI_IPToString(&remote_addr->ip_addr), remote_addr->port, UTI_IPToString(&remote_addr->local_ip_addr));
|
UTI_DiffTimespecsToDouble(&sched_ts, &local_ts.ts), local_ts.source);
|
||||||
#endif
|
|
||||||
|
|
||||||
msg.msg_controllen = cmsglen;
|
/* Just ignore the packet if it's not of a recognized length */
|
||||||
/* This is apparently required on some systems */
|
if (message->length < NTP_HEADER_LENGTH || message->length > sizeof (NTP_Packet)) {
|
||||||
if (!cmsglen)
|
DEBUG_LOG("Unexpected length");
|
||||||
msg.msg_control = NULL;
|
return;
|
||||||
|
|
||||||
if (sendmsg(sock_fd, &msg, 0) < 0) {
|
|
||||||
LOG(LOGS_WARN, LOGF_NtpIO, "Could not send to %s:%d : %s",
|
|
||||||
UTI_IPToString(&remote_addr->ip_addr), remote_addr->port, strerror(errno));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
NSR_ProcessRx(&message->remote_addr.ip, &local_addr, &local_ts, message->data, message->length);
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
/* Send an unauthenticated packet to a given address */
|
|
||||||
|
|
||||||
void
|
|
||||||
NIO_SendNormalPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr)
|
|
||||||
{
|
|
||||||
send_packet((void *) packet, NTP_NORMAL_PACKET_SIZE, remote_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
/* Send an authenticated packet to a given address */
|
|
||||||
|
|
||||||
void
|
|
||||||
NIO_SendAuthenticatedPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr)
|
|
||||||
{
|
|
||||||
send_packet((void *) packet, sizeof(NTP_Packet), remote_addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
/* We ought to use getservbyname, but I can't really see this changing */
|
static void
|
||||||
#define ECHO_PORT 7
|
read_from_socket(int sock_fd, int event, void *anything)
|
||||||
|
|
||||||
void
|
|
||||||
NIO_SendEcho(NTP_Remote_Address *remote_addr)
|
|
||||||
{
|
{
|
||||||
unsigned long magic_message = 0xbe7ab1e7UL;
|
SCK_Message *messages;
|
||||||
NTP_Remote_Address addr;
|
int i, received, flags = 0;
|
||||||
|
|
||||||
addr = *remote_addr;
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
addr.port = ECHO_PORT;
|
if (NIO_Linux_ProcessEvent(sock_fd, event))
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
send_packet((void *) &magic_message, sizeof(unsigned long), &addr);
|
if (event == SCH_FILE_EXCEPTION) {
|
||||||
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
|
flags |= SCK_FLAG_MSG_ERRQUEUE;
|
||||||
|
#else
|
||||||
|
assert(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
messages = SCK_ReceiveMessages(sock_fd, flags, &received);
|
||||||
|
if (!messages)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < received; i++)
|
||||||
|
process_message(&messages[i], sock_fd, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
/* Send a packet to remote address from local address */
|
||||||
|
|
||||||
|
int
|
||||||
|
NIO_SendPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr,
|
||||||
|
NTP_Local_Address *local_addr, int length, int process_tx)
|
||||||
|
{
|
||||||
|
SCK_Message message;
|
||||||
|
|
||||||
|
assert(initialised);
|
||||||
|
|
||||||
|
if (local_addr->sock_fd == INVALID_SOCK_FD) {
|
||||||
|
DEBUG_LOG("No socket to send to %s", UTI_IPSockAddrToString(remote_addr));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCK_InitMessage(&message, SCK_ADDR_IP);
|
||||||
|
|
||||||
|
message.data = packet;
|
||||||
|
message.length = length;
|
||||||
|
|
||||||
|
/* Specify remote address if the socket is not connected */
|
||||||
|
if (NIO_IsServerSocket(local_addr->sock_fd) || !separate_client_sockets) {
|
||||||
|
message.remote_addr.ip.ip_addr = remote_addr->ip_addr;
|
||||||
|
message.remote_addr.ip.port = remote_addr->port;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.local_addr.ip = local_addr->ip_addr;
|
||||||
|
|
||||||
|
/* Don't require responses to non-link-local addresses to use the same
|
||||||
|
interface */
|
||||||
|
message.if_index = SCK_IsLinkLocalIPAddress(&message.remote_addr.ip.ip_addr) ?
|
||||||
|
local_addr->if_index : INVALID_IF_INDEX;
|
||||||
|
|
||||||
|
#if !defined(HAVE_IN_PKTINFO) && defined(IP_SENDSRCADDR)
|
||||||
|
/* On FreeBSD a local IPv4 address cannot be specified on bound socket */
|
||||||
|
if (message.local_addr.ip.family == IPADDR_INET4 &&
|
||||||
|
(local_addr->sock_fd != server_sock_fd4 || bound_server_sock_fd4))
|
||||||
|
message.local_addr.ip.family = IPADDR_UNSPEC;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
|
if (process_tx)
|
||||||
|
NIO_Linux_RequestTxTimestamp(&message, local_addr->sock_fd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!SCK_SendMessage(local_addr->sock_fd, &message, 0))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user