-
Notifications
You must be signed in to change notification settings - Fork 0
/
10-patch_peer-constraint-logs.patch
396 lines (371 loc) · 13.3 KB
/
10-patch_peer-constraint-logs.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
From: Pekka Helenius <[email protected]>
Date: Thu, 13 Aug 2020 18:29:24 +0300
Subject: Improve constraint & NTP peer log entries; update conf & man
--- a/src/client.c 2020-08-05 15:32:27.511659074 +0300
+++ b/src/client.c 2020-08-05 16:40:21.478329708 +0300
@@ -377,7 +377,7 @@ client_dispatch(struct ntp_peer *p, u_in
}
interval = error_interval();
set_next(p, interval);
- log_info("NTP client: reply from %-16s is not synced (%s), next query in %llds",
+ log_info("NTP client: reply from NTP peer %-16s is not synced (%s), next query in %llds",
log_sockaddr((struct sockaddr *)&p->addr->ss), s,
(long long)interval);
return (0);
@@ -405,9 +405,13 @@ client_dispatch(struct ntp_peer *p, u_in
/* Detect liars */
if (!p->trusted && conf->constraint_median != 0 &&
(constraint_check(T2) != 0 || constraint_check(T3) != 0)) {
- log_info("NTP client: reply from %-16s constraint check failed",
- log_sockaddr((struct sockaddr *)&p->addr->ss));
- set_next(p, error_interval());
+ interval = error_interval();
+ log_info("NTP client: reply from NTP peer %-16s constraint check failed, "
+ "next query in %llds",
+ log_sockaddr((struct sockaddr *)&p->addr->ss),
+ (long long)interval
+ );
+ set_next(p, interval);
return (0);
}
@@ -417,10 +421,12 @@ client_dispatch(struct ntp_peer *p, u_in
if (p->reply[p->shift].delay < 0) {
interval = error_interval();
set_next(p, interval);
- log_info("NTP client: reply from %-16s has negative delay %9fs, "
+ log_info("NTP client: reply from NTP peer %-16s has negative delay %9fs, "
"next query in %llds",
- log_sockaddr((struct sockaddr *)&p->addr->ss),
- p->reply[p->shift].delay, (long long)interval);
+ log_sockaddr((struct sockaddr *)&p->addr->ss),
+ p->reply[p->shift].delay,
+ (long long)interval
+ );
return (0);
}
p->reply[p->shift].error = (T2 - T1) - (T3 - T4);
@@ -472,7 +478,7 @@ client_dispatch(struct ntp_peer *p, u_in
p->trustlevel++;
}
- log_debug("NTP client: reply from %-16s offset: %9fs, delay: %9fs, "
+ log_debug("NTP client: reply from NTP peer %-16s offset: %9fs, delay: %9fs, "
"next query in %llds",
log_sockaddr((struct sockaddr *)&p->addr->ss),
p->reply[p->shift].offset, p->reply[p->shift].delay,
--- a/src/constraint-libressl.c 2020-08-04 00:01:30.008179382 +0300
+++ b/src/constraint-libressl.c 2020-08-05 15:56:10.558327257 +0300
@@ -42,7 +42,8 @@ httpsdate_init(const char *addr, const i
if ((httpsdate->tls_addr = strdup(addr)) == NULL ||
(httpsdate->tls_port = strdup(port_s)) == NULL ||
(httpsdate->tls_hostname = strdup(hostname)) == NULL ||
- (httpsdate->tls_path = strdup(path)) == NULL)
+ (httpsdate->tls_path = strdup(path)) == NULL
+ )
goto fail;
if (useragent)
@@ -53,13 +54,15 @@ httpsdate_init(const char *addr, const i
"HEAD %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\nConnection: close\r\n\r\n",
httpsdate->tls_path,
httpsdate->tls_hostname,
- httpsdate->tls_useragent) == -1)
+ httpsdate->tls_useragent
+ ) == -1)
goto fail;
} else {
if (asprintf(&httpsdate->tls_request,
"HEAD %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n",
httpsdate->tls_path,
- httpsdate->tls_hostname) == -1)
+ httpsdate->tls_hostname
+ ) == -1)
goto fail;
}
@@ -67,10 +70,16 @@ httpsdate_init(const char *addr, const i
goto fail;
if (ca == NULL || ca_len == 0 || conf->constraint_ca_validation == 0) {
- log_debug("constraint %s: certificate can't be verified", addr);
+ log_debug("constraint %s (%s): certificate can't be verified",
+ addr,
+ httpsdate->tls_hostname
+ );
tls_config_insecure_noverifycert(httpsdate->tls_config);
} else {
- log_debug("constraint %s: verifying certificate", addr);
+ log_debug("constraint %s (%s): verifying certificate",
+ addr,
+ httpsdate->tls_hostname
+ );
if (tls_config_set_ca_mem(httpsdate->tls_config, ca, ca_len) == -1)
goto fail;
}
@@ -124,8 +133,11 @@ httpsdate_request(struct httpsdate *http
goto fail;
if (httpsdate->tls_useragent)
- log_debug("constraint %s: user agent: %s", httpsdate->tls_addr,
- httpsdate->tls_useragent);
+ log_debug("constraint %s (%s): user agent: %s",
+ httpsdate->tls_addr,
+ httpsdate->tls_hostname,
+ httpsdate->tls_useragent
+ );
/*
* LibreSSL expects an address string, which can also be a DNS name,
@@ -133,13 +145,16 @@ httpsdate_request(struct httpsdate *http
* does not trigger any DNS operation and is safe to be called
* without the dns pledge.
*/
- log_debug("constraint %s: establishing connection", httpsdate->tls_addr);
+ log_debug("constraint %s (%s): establishing connection",
+ httpsdate->tls_addr,
+ httpsdate->tls_hostname
+ );
if (tls_connect_servername(httpsdate->tls_ctx, httpsdate->tls_addr,
httpsdate->tls_port, httpsdate->tls_hostname) == -1) {
- log_debug("constraint %s: TLS connection failed (%s): %s",
- httpsdate->tls_addr,
+ log_debug("constraint %s (%s): TLS connection failed: %s",
+ httpsdate->tls_addr,
httpsdate->tls_hostname,
- tls_error(httpsdate->tls_ctx)
+ tls_error(httpsdate->tls_ctx)
);
goto fail;
}
@@ -151,7 +166,7 @@ httpsdate_request(struct httpsdate *http
if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT)
continue;
if (ret == -1) {
- log_warnx("constraint %s: TLS write operation failed (%s): %s",
+ log_warnx("constraint %s (%s): TLS write operation failed: %s",
httpsdate->tls_addr,
httpsdate->tls_hostname,
tls_error(httpsdate->tls_ctx)
@@ -180,9 +195,10 @@ httpsdate_request(struct httpsdate *http
* the timezone which is required here.
*/
if (strptime(p, IMF_FIXDATE,
- &httpsdate->tls_tm) == NULL) {
- log_warnx("constraint %s: unsupported date format",
- httpsdate->tls_addr
+ &httpsdate->tls_tm) == NULL) {
+ log_warnx("constraint %s (%s): unsupported date format",
+ httpsdate->tls_addr,
+ httpsdate->tls_hostname
);
free(line);
return (-1);
@@ -209,11 +225,15 @@ httpsdate_request(struct httpsdate *http
if (strftime(timebuf1, sizeof(timebuf1), X509_DATE, tm) == 0)
goto fail;
if (strftime(timebuf2, sizeof(timebuf2), X509_DATE,
- &httpsdate->tls_tm) == 0)
+ &httpsdate->tls_tm) == 0)
goto fail;
- log_warnx("constraint %s: TLS certificate not yet valid (%s): "
- "not before %s, now is %s", httpsdate->tls_addr,
- httpsdate->tls_hostname, timebuf1, timebuf2);
+ log_warnx("constraint %s (%s): TLS certificate not yet valid: "
+ "not before %s, current time is %s",
+ httpsdate->tls_addr,
+ httpsdate->tls_hostname,
+ timebuf1,
+ timebuf2
+ );
goto fail;
}
if (httptime >= notafter) {
@@ -222,11 +242,15 @@ httpsdate_request(struct httpsdate *http
if (strftime(timebuf1, sizeof(timebuf1), X509_DATE, tm) == 0)
goto fail;
if (strftime(timebuf2, sizeof(timebuf2), X509_DATE,
- &httpsdate->tls_tm) == 0)
+ &httpsdate->tls_tm) == 0)
goto fail;
- log_warnx("constraint %s: TLS certificate has been expired (%s): "
- "not after %s, now is %s", httpsdate->tls_addr,
- httpsdate->tls_hostname, timebuf1, timebuf2);
+ log_warnx("constraint %s (%s): TLS certificate has been expired: "
+ "not after %s, current time is %s",
+ httpsdate->tls_addr,
+ httpsdate->tls_hostname,
+ timebuf1,
+ timebuf2
+ );
goto fail;
}
--- a/src/constraint-openssl.c 2020-08-04 00:01:16.178179367 +0300
+++ b/src/constraint-openssl.c 2020-08-05 16:33:55.571662669 +0300
@@ -122,16 +122,23 @@ o_httpsdate_request(struct o_httpsdate *
inet_ntop(AF_INET, &sa_in.sin_addr, ia_str, sizeof(ia_str));
if ((sslfd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) == -1)
- log_warnx("constraint %s: can't create OpenSSL socket (4)", ia_str);
+ log_warnx("constraint %s (%s): can't create OpenSSL socket (4)",
+ ia_str,
+ httpsdate->cstr->addr_head.name
+ );
SSL_set_fd(httpsdate->tls_conn, sslfd);
- log_debug("constraint %s: initializing HTTPS request", ia_str);
+ log_debug("constraint %s (%s): initializing HTTPS request",
+ ia_str,
+ httpsdate->cstr->addr_head.name
+ );
ret = connect(sslfd, (struct sockaddr *)&sa_in, sizeof(sa_in));
if (ret < 0) {
- log_warnx("constraint %s: TLS connection failed, socket error: %d",
- ia_str,
- errno
+ log_warnx("constraint %s (%s): TLS connection failed, socket error: %d",
+ ia_str,
+ httpsdate->cstr->addr_head.name,
+ errno
);
goto fail;
}
@@ -145,18 +152,23 @@ o_httpsdate_request(struct o_httpsdate *
inet_ntop(AF_INET6, &sa_in6->sin6_addr, ia_str, sizeof(ia_str));
if ((sslfd = socket(AF_INET6, SOCK_STREAM, 0)) == -1)
- log_warnx("constraint %s: can't create OpenSSL socket (6)",
- ia_str
+ log_warnx("constraint %s (%s): can't create OpenSSL socket (6)",
+ ia_str,
+ httpsdate->cstr->addr_head.name
);
SSL_set_fd(httpsdate->tls_conn, sslfd);
- log_debug("constraint %s: initializing HTTPS request", ia_str);
+ log_debug("constraint %s (%s): initializing HTTPS request",
+ ia_str,
+ httpsdate->cstr->addr_head.name
+ );
ret = connect(sslfd, (struct sockaddr *)&sa_in6, sizeof(sa_in6));
if (ret < 0) {
- log_warnx("constraint %s: TLS connection failed, socket error: %d",
- ia_str,
- errno
+ log_warnx("constraint %s (%s): TLS connection failed, socket error: %d",
+ ia_str,
+ httpsdate->cstr->addr_head.name,
+ errno
);
goto fail;
}
@@ -164,20 +176,26 @@ o_httpsdate_request(struct o_httpsdate *
break;
default:
- fatalx("constraint %s: invalid network address family in HTTPS request",
- ia_str
+ fatalx("constraint %s (%s): invalid network address family in HTTPS request",
+ ia_str,
+ httpsdate->cstr->addr_head.name
);
goto fail;
}
if (httpsdate->cstr->useragent)
- log_debug("constraint %s: user agent: %s", ia_str,
- httpsdate->cstr->useragent);
+ log_debug("constraint %s (%s): user agent: %s",
+ ia_str,
+ httpsdate->cstr->addr_head.name,
+ httpsdate->cstr->useragent);
- log_debug("constraint %s: establishing connection", ia_str);
+ log_debug("constraint %s (%s): establishing connection",
+ ia_str,
+ httpsdate->cstr->addr_head.name
+ );
ret = SSL_connect(httpsdate->tls_conn);
if (ret < 1) {
- log_warnx("constraint %s: TLS connection failed in accept (%s)",
+ log_warnx("constraint %s (%s): TLS connection failed in accept",
ia_str,
httpsdate->cstr->addr_head.name
);
@@ -185,7 +203,10 @@ o_httpsdate_request(struct o_httpsdate *
goto fail;
}
if (ret == 5) {
- log_warnx("constraint %s: socket error no: %d", ia_str, ret);
+ log_warnx("constraint %s (%s): socket error no: %d",
+ ia_str,
+ httpsdate->cstr->addr_head.name,
+ ret);
goto fail;
}
@@ -197,7 +218,7 @@ o_httpsdate_request(struct o_httpsdate *
if (ret == SSL_ERROR_WANT_WRITE || ret == SSL_ERROR_WANT_READ)
continue;
if (ret < 1) {
- log_warnx("constraint %s: TLS write operation failed: (%s)",
+ log_warnx("constraint %s (%s): TLS write operation failed",
ia_str,
httpsdate->cstr->addr_head.name
);
@@ -205,7 +226,10 @@ o_httpsdate_request(struct o_httpsdate *
goto fail;
}
if (ret == 6) {
- log_warnx("constraint %s: HTTPS server aborted the request", ia_str);
+ log_warnx("constraint %s (%s): HTTPS server aborted the request",
+ ia_str,
+ httpsdate->cstr->addr_head.name
+ );
openssl_lasterr();
SSL_shutdown(httpsdate->tls_conn);
}
@@ -233,8 +257,9 @@ o_httpsdate_request(struct o_httpsdate *
*/
if (strptime(p, IMF_FIXDATE,
&httpsdate->tls_tm) == NULL) {
- log_warnx("constraint %s: unsupported date format",
- ia_str
+ log_warnx("constraint %s (%s): unsupported date format",
+ ia_str,
+ httpsdate->cstr->addr_head.name
);
free(line);
return (-1);
--- a/src/constraint.c 2020-08-03 23:43:48.584926017 +0300
+++ b/src/constraint.c 2020-08-13 18:29:05.369040808 +0300
@@ -767,9 +767,10 @@ constraint_msg_result(u_int32_t id, u_in
offset = gettime_from_timeval(&tv[0]) -
gettime_from_timeval(&tv[1]);
- log_info("constraint %s: reply received: offset %fs",
- log_sockaddr((struct sockaddr *)&cstr->addr->ss),
- offset);
+ log_info("constraint %s (%s): reply received: offset %fs",
+ log_sockaddr((struct sockaddr *)&cstr->addr->ss),
+ cstr->addr_head.name,
+ offset);
cstr->state = STATE_REPLY_RECEIVED;
cstr->last = getmonotime();
--- a/ntpd.conf 2020-08-02 02:30:41.000000000 +0300
+++ b/ntpd.conf 2020-08-05 16:01:50.858327562 +0300
@@ -115,11 +115,11 @@ constraints from "https://www.duckduckgo
# ntpd(8) socket file path.
#
-# ctlsocket /var/run/ntpd.sock
+# ctlsocket "/var/run/ntpd.sock"
# ntpd(8) drift file path.
#
-# driftfile /var/db/ntpd.drift
+# driftfile "/var/db/ntpd.drift"
# Whether to reset frequency filters after
# frequency adjustment.
--- a/src/ntpd.conf.5 2020-08-04 01:38:53.878185531 +0300
+++ b/src/ntpd.conf.5 2020-08-05 16:02:55.751660907 +0300
@@ -463,7 +463,7 @@ socket file path.
.Bd -literal -offset indent
.Bl -tag -width "Default:" -compact
.It Default:
-/var/run/ntpd.sock
+"/var/run/ntpd.sock"
.El
.Ed
.It Ic driftfile Ar path-to-file
@@ -472,7 +472,7 @@ drift file path.
.Bd -literal -offset indent
.Bl -tag -width "Default:" -compact
.It Default:
-/var/db/ntpd.drift
+"/var/db/ntpd.drift"
.El
.Ed
.It Ic filter_adjfreq Ar true | false