]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
4 years agontp: drop support for long NTPv4 MACs
Miroslav Lichvar [Thu, 10 Sep 2020 08:22:27 +0000 (10:22 +0200)] 
ntp: drop support for long NTPv4 MACs

Don't accept NTPv4 packets which have a MAC longer than 24 octets to
strictly follow RFC 7822, which specifies the maximum length of a MAC
and the minimum length of the last extension field to avoid an ambiguity
in parsing of the packet.

This removes an ugly hack that was needed to accept packets that
contained one or more extension fields without a MAC, before RFC 7822
was written and NTP implementations started using truncated MACs.

The long MACs were used by chrony in versions 2.x when configured to
authenticate a server or peer with a key using a 256-bit or longer hash
(e.g. SHA256). For compatibility with chrony >= 4.0, these clients/peers
will need to have "version 3" added to the server/peer line in
chrony.conf.

4 years agosiv: return error if key is not set
Miroslav Lichvar [Wed, 9 Sep 2020 12:00:32 +0000 (14:00 +0200)] 
siv: return error if key is not set

Avoid encryption or decryption using uninitialized data, or causing a
crash, if a key was not set for the SIV instance.

4 years agonts: improve NTP client code
Miroslav Lichvar [Wed, 9 Sep 2020 07:43:01 +0000 (09:43 +0200)] 
nts: improve NTP client code

Reset the client instance more thoroughly and make sure the
nonce cannot be reused.

4 years agoclient: improve help message for sources command
Miroslav Lichvar [Wed, 9 Sep 2020 06:36:59 +0000 (08:36 +0200)] 
client: improve help message for sources command

4 years agocmdmon: rename status constants
Miroslav Lichvar [Tue, 8 Sep 2020 09:17:48 +0000 (11:17 +0200)] 
cmdmon: rename status constants

Change the naming of reported selection status in the sources report to
better match the internal status.

4 years agosources: don't report untrusted sources as selectable
Miroslav Lichvar [Tue, 8 Sep 2020 08:45:24 +0000 (10:45 +0200)] 
sources: don't report untrusted sources as selectable

Show untrusted sources with the '?' symbol instead of '-' to make them
consistent with not selectable and selectable sources in the selectdata
description.

4 years agoconfigure: fix building with -NTP -CMDMON +SCFILTER
Miroslav Lichvar [Tue, 8 Sep 2020 07:45:13 +0000 (09:45 +0200)] 
configure: fix building with -NTP -CMDMON +SCFILTER

Don't enable privileged operations using the nameserv code unless
NTP is enabled.

4 years agonts: log early client NTS-KE socket errors
Miroslav Lichvar [Tue, 8 Sep 2020 07:41:12 +0000 (09:41 +0200)] 
nts: log early client NTS-KE socket errors

Log an error message when SCK_OpenTcpSocket() fails in the NTS-KE
client, e.g. when connect() fails due to the port not being allowed in
the SELinux policy.

4 years agocmdmon: remove unused test code
Miroslav Lichvar [Mon, 7 Sep 2020 08:45:03 +0000 (10:45 +0200)] 
cmdmon: remove unused test code

4 years agocmdmon: check response length before sending
Miroslav Lichvar [Mon, 7 Sep 2020 08:42:33 +0000 (10:42 +0200)] 
cmdmon: check response length before sending

Before sending a cmdmon response, make sure it is not longer than the
request to avoid amplification in case the response/padding length is
incorrectly specified for a request.

4 years agosys_linux: allow readlinkat in seccomp filter
Vincent Blut [Tue, 1 Sep 2020 12:01:10 +0000 (14:01 +0200)] 
sys_linux: allow readlinkat in seccomp filter

4 years agoexamples: improve chrony-wait service
Miroslav Lichvar [Tue, 1 Sep 2020 10:05:06 +0000 (12:05 +0200)] 
examples: improve chrony-wait service

Use the systemd TimeoutStartSec setting to report a timeout instead of
an error and reduce the timeout to 3 minutes.

4 years agoconf: add clockprecision directive
Miroslav Lichvar [Tue, 1 Sep 2020 09:21:46 +0000 (11:21 +0200)] 
conf: add clockprecision directive

Make the precision of the system clock configurable. This can be useful
on servers using hardware timestamping to reduce the amount of noise
added to the NTP timestamps and improve stability of NTP measurements.

4 years agosys_linux: allow lstat and readlink in seccomp filter
Miroslav Lichvar [Mon, 31 Aug 2020 13:13:39 +0000 (15:13 +0200)] 
sys_linux: allow lstat and readlink in seccomp filter

These syscalls seem to be needed when gnutls is loading system trusted
certificates due to p11-kit >= 0.23.21 getting the program name from
/proc/self/exe.

4 years agotest: extend frequency in ntp_adjtime() test
Bryan Christianson [Mon, 31 Aug 2020 08:09:33 +0000 (20:09 +1200)] 
test: extend frequency in ntp_adjtime() test

Extend the frequency range in the test to cover negative frequencies.

4 years agosys_timex: add workaround for broken ntp_adjtime() on macOS
Bryan Christianson [Mon, 31 Aug 2020 07:56:45 +0000 (19:56 +1200)] 
sys_timex: add workaround for broken ntp_adjtime() on macOS

On macOS 11.0 (Big Sur) beta, ntp_adjtime() incorrectly returns
timex.freq as an unsigned number. This patch is a workaround for the bug
and should be removed when Apple fix the problem (assuming they will).

4 years agodoc: update NEWS 4.0-pre3
Miroslav Lichvar [Tue, 25 Aug 2020 08:58:31 +0000 (10:58 +0200)] 
doc: update NEWS

4 years agodoc: update README
Miroslav Lichvar [Tue, 25 Aug 2020 08:55:34 +0000 (10:55 +0200)] 
doc: update README

4 years agoutil: don't open symlink when appending to file
Miroslav Lichvar [Tue, 25 Aug 2020 07:39:59 +0000 (09:39 +0200)] 
util: don't open symlink when appending to file

When opening a file for appending (i.e. a log file), use the O_NOFOLLOW
flag to get an error if the path is a symlink. Opening log files through
symlinks is no longer supported.

This is a protection against symlink attacks if chronyd is misconfigured
to write a log in a world-writable directory (e.g. /tmp). That is not
meant to become a recommended practice. Log messages will be lost, or
chronyd won't start, if a symlink exists at the location of the log
file.

4 years agotest: fix cookie length in nts_ke_client unit test
Miroslav Lichvar [Mon, 24 Aug 2020 12:03:06 +0000 (14:03 +0200)] 
test: fix cookie length in nts_ke_client unit test

4 years agonts: avoid key corruption on failed loading
Miroslav Lichvar [Thu, 20 Aug 2020 09:18:09 +0000 (11:18 +0200)] 
nts: avoid key corruption on failed loading

Don't save a loaded key to the server key slot until it is fully
decoded.

4 years agonts: explicitly disable session tickets
Miroslav Lichvar [Wed, 19 Aug 2020 11:31:48 +0000 (13:31 +0200)] 
nts: explicitly disable session tickets

Session tickets should never be enabled with the currect code on both
clients and servers. Set the GNUTLS_NO_TICKETS flag when opening a TLS
session in case this understanding is wrong, or it changes in future, to
reduce the TLS attack surface.

4 years agotest: fix 102-hwtimestamp test for new ethtool
Miroslav Lichvar [Thu, 20 Aug 2020 14:17:05 +0000 (16:17 +0200)] 
test: fix 102-hwtimestamp test for new ethtool

New ethtool using netlink messages has a different output.

4 years agotest: extend 110-chronyc test
Miroslav Lichvar [Tue, 18 Aug 2020 15:39:39 +0000 (17:39 +0200)] 
test: extend 110-chronyc test

4 years agotest: extend 007-cmdmon system test
Miroslav Lichvar [Tue, 18 Aug 2020 15:37:28 +0000 (17:37 +0200)] 
test: extend 007-cmdmon system test

4 years agotest: add 105-nts system test
Miroslav Lichvar [Wed, 19 Aug 2020 10:06:43 +0000 (12:06 +0200)] 
test: add 105-nts system test

4 years agotest: add 009-binddevice system test
Miroslav Lichvar [Wed, 19 Aug 2020 10:49:50 +0000 (12:49 +0200)] 
test: add 009-binddevice system test

4 years agotest: add 008-confload system test
Miroslav Lichvar [Tue, 18 Aug 2020 14:28:15 +0000 (16:28 +0200)] 
test: add 008-confload system test

4 years agoconf: rename confdirs and sourcedirs directives
Miroslav Lichvar [Tue, 18 Aug 2020 12:21:06 +0000 (14:21 +0200)] 
conf: rename confdirs and sourcedirs directives

Rename the directives to confdir and sourcedir to better match an
expected use case with only one specified directory.

4 years agoreference: fix assignment of frequency_sd
Miroslav Lichvar [Tue, 18 Aug 2020 11:46:29 +0000 (13:46 +0200)] 
reference: fix assignment of frequency_sd

Fixes: 8afd62d9548b ("reference: update synchronization status more frequently")
4 years agoclient: improve parsing of keygen arguments
Miroslav Lichvar [Tue, 18 Aug 2020 08:22:21 +0000 (10:22 +0200)] 
client: improve parsing of keygen arguments

Detect invalid syntax for the keygen command.

4 years agoclient: ignore case in add command
Miroslav Lichvar [Mon, 17 Aug 2020 15:18:04 +0000 (17:18 +0200)] 
client: ignore case in add command

For consistency with chronyd configuration, make the source type in the
add command case insensitive.

4 years agoclient: drop unnecessary parsing of IPv4 address
Miroslav Lichvar [Mon, 17 Aug 2020 15:06:28 +0000 (17:06 +0200)] 
client: drop unnecessary parsing of IPv4 address

4 years agocmdmon: change name fields to unsigned type
Miroslav Lichvar [Mon, 17 Aug 2020 14:27:54 +0000 (16:27 +0200)] 
cmdmon: change name fields to unsigned type

4 years agotest: fix random failures in nts_ntp_client unit test
Miroslav Lichvar [Mon, 17 Aug 2020 08:11:12 +0000 (10:11 +0200)] 
test: fix random failures in nts_ntp_client unit test

Fixes: 18d9243eb9b0 ("test: improve NTS unit tests")
4 years agotest: improve siv unit test
Miroslav Lichvar [Thu, 13 Aug 2020 14:20:46 +0000 (16:20 +0200)] 
test: improve siv unit test

4 years agotest: improve NTS unit tests
Miroslav Lichvar [Thu, 13 Aug 2020 12:27:13 +0000 (14:27 +0200)] 
test: improve NTS unit tests

4 years agotest: extend 139-nts test
Miroslav Lichvar [Thu, 13 Aug 2020 10:49:39 +0000 (12:49 +0200)] 
test: extend 139-nts test

4 years agonts: check all encrypted fields before saving cookies
Miroslav Lichvar [Thu, 13 Aug 2020 12:25:12 +0000 (14:25 +0200)] 
nts: check all encrypted fields before saving cookies

Don't save any cookies if an encrypted extension field fails parsing.

4 years agocmdmon: fix data field name in handle_ntp_source_name()
Miroslav Lichvar [Wed, 12 Aug 2020 13:59:16 +0000 (15:59 +0200)] 
cmdmon: fix data field name in handle_ntp_source_name()

Fixes: 93f6358916ca ("cmdmon: add request to get source name")
4 years agosocket: improve code
Miroslav Lichvar [Tue, 11 Aug 2020 15:07:14 +0000 (17:07 +0200)] 
socket: improve code

Add more assertions and other checks, and improve coding style a bit.

4 years agontp: fix comments
Miroslav Lichvar [Mon, 10 Aug 2020 14:22:19 +0000 (16:22 +0200)] 
ntp: fix comments

Fix typos and remove an obsolete comment.

4 years agontp: reuse pool IDs for new pools
Miroslav Lichvar [Mon, 10 Aug 2020 10:14:42 +0000 (12:14 +0200)] 
ntp: reuse pool IDs for new pools

When adding a new pool, reuse unused pool IDs to avoid increasing the
pools array.

4 years agontp: rename pool fields to pool_id
Miroslav Lichvar [Mon, 10 Aug 2020 09:54:43 +0000 (11:54 +0200)] 
ntp: rename pool fields to pool_id

Rename the pool fields holding the ID of the pool to avoid confusion
with the pool record and pool flag.

5 years agoexamples: add leapsecmode to chrony.conf examples
Miroslav Lichvar [Tue, 4 Aug 2020 13:42:59 +0000 (15:42 +0200)] 
examples: add leapsecmode to chrony.conf examples

5 years agoclient: add missing option to help message
Miroslav Lichvar [Tue, 4 Aug 2020 11:04:04 +0000 (13:04 +0200)] 
client: add missing option to help message

5 years agotest: fix compiler warning in ntp unit test
Miroslav Lichvar [Mon, 3 Aug 2020 17:10:49 +0000 (19:10 +0200)] 
test: fix compiler warning in ntp unit test

5 years agoutil: fix compiler warning
Miroslav Lichvar [Mon, 3 Aug 2020 16:56:20 +0000 (18:56 +0200)] 
util: fix compiler warning

Replace the snprintf() call with memcpy() in UTI_PathToDir() to make it
clear a truncated string is expected.

5 years agoconf: add dscp directive
Miroslav Lichvar [Mon, 3 Aug 2020 15:55:42 +0000 (17:55 +0200)] 
conf: add dscp directive

The directive sets the DSCP value in transmitted NTP packets, which can
be useful in local networks where switches/routers are configured to
prioritise packets with specific DSCP values.

5 years agosources: reset leap voting flag earlier in selection
Miroslav Lichvar [Mon, 3 Aug 2020 14:13:56 +0000 (16:13 +0200)] 
sources: reset leap voting flag earlier in selection

Remove the leap vote from sources that get the noselect option, or
have too large distance or jitter.

5 years agontp: improve auth code
Miroslav Lichvar [Mon, 3 Aug 2020 09:38:41 +0000 (11:38 +0200)] 
ntp: improve auth code

Before generating a MAC, make sure there is enough space in the packet.
This is always true with the current code, but it may change when a
non-NTS extension field is supported.

Update the packet auth info after generating a MAC in case it's needed
before the transmission.

Add more assertions and make other changes for better readability.

5 years agotest: improve nts_ntp_client unit test
Miroslav Lichvar [Mon, 27 Jul 2020 13:42:20 +0000 (15:42 +0200)] 
test: improve nts_ntp_client unit test

5 years agonts: disable TLS 1.2 on server
Miroslav Lichvar [Tue, 28 Jul 2020 10:13:17 +0000 (12:13 +0200)] 
nts: disable TLS 1.2 on server

It seems gnutls (at least in version 3.6.14) allows clients to connect
using TLS1.2 when it has a DTLS version enabled in the priority cache.

Disable all DTLS versions in order to disable TLS1.2.

5 years agonts: improve NTS-NTP server/client code
Miroslav Lichvar [Mon, 27 Jul 2020 13:38:46 +0000 (15:38 +0200)] 
nts: improve NTS-NTP server/client code

Add more comments, assertions, debug messages, and other minor
changes to make the code more robust.

5 years agonts: scale server listening backlog with number of helpers
Miroslav Lichvar [Mon, 27 Jul 2020 10:57:44 +0000 (12:57 +0200)] 
nts: scale server listening backlog with number of helpers

5 years agonts: fix destroying of NTS-KE client
Miroslav Lichvar [Mon, 27 Jul 2020 10:13:39 +0000 (12:13 +0200)] 
nts: fix destroying of NTS-KE client

Destroy the NTS-KE session of the client immediately even when the
resolver of the NTP address is running. This removes the session
local change handler and avoids an assertion failure in the local
finalization.

5 years agonts: move loading of syscall filter in NTS-KE server
Miroslav Lichvar [Mon, 27 Jul 2020 07:56:53 +0000 (09:56 +0200)] 
nts: move loading of syscall filter in NTS-KE server

Load the filter after NKS_Initialise() to avoid hitting
a fcntl syscall.

Fixes: 66e097e3e644 ("nts: improve NTS-KE server/client code")
5 years agonts: fix error response to NTS-KE request
Miroslav Lichvar [Thu, 23 Jul 2020 13:46:57 +0000 (15:46 +0200)] 
nts: fix error response to NTS-KE request

When the request has an unrecognized critical record before the
NEXT_PROTOCOL and AEAD_ALGORITHM records, respond with error 0
(unrecognized critical record) instead of 1 (bad request).

When the request has multiple NEXT_PROTOCOL or AEAD_ALGORITHM records,
respond with error 1 (bad request).

5 years agonts: reset NAK indicator with new request
Miroslav Lichvar [Mon, 20 Jul 2020 14:31:49 +0000 (16:31 +0200)] 
nts: reset NAK indicator with new request

Don't restart NTS-KE if a spoofed NAK response was received and no valid
response is received for a subsequent request.

5 years agonts: don't allow malformed encrypted extension fields
Miroslav Lichvar [Mon, 20 Jul 2020 11:38:22 +0000 (13:38 +0200)] 
nts: don't allow malformed encrypted extension fields

Require data decrypted from the NTS authenticator field to contain
correctly formatted extension fields (known or unknown).

5 years agomain: remove unneeded code in signal handler
Miroslav Lichvar [Tue, 14 Jul 2020 16:34:10 +0000 (18:34 +0200)] 
main: remove unneeded code in signal handler

The handler is set up when the main code is already initialized.

5 years agosiv: add more assertions
Miroslav Lichvar [Tue, 14 Jul 2020 15:04:30 +0000 (17:04 +0200)] 
siv: add more assertions

Make sure the returned tag and key lengths are sane.

5 years agonts: improve NTS-KE server/client code
Miroslav Lichvar [Mon, 13 Jul 2020 12:25:57 +0000 (14:25 +0200)] 
nts: improve NTS-KE server/client code

Add more assertions and comments, refactor initialization of the helper,
and make other changes to make the code more robust.

5 years agologging: extend functionality
Miroslav Lichvar [Thu, 16 Jul 2020 11:16:15 +0000 (13:16 +0200)] 
logging: extend functionality

Add a function to get the current minimum severity and a function to set
a global prefix for debug messages in order to identify messages from
helpers.

5 years agoconf: improve error message
Miroslav Lichvar [Tue, 14 Jul 2020 07:15:29 +0000 (09:15 +0200)] 
conf: improve error message

Replace "command" with "directive" for consistency with the
documentation.

5 years agoconf: adopt default bind*address values
Miroslav Lichvar [Mon, 13 Jul 2020 12:19:45 +0000 (14:19 +0200)] 
conf: adopt default bind*address values

Move the default values of the bind*address settings from the
ntp/nts/cmdmon code to conf.

5 years agonts: follow bind*device settings for NTS-KE sockets
Miroslav Lichvar [Mon, 13 Jul 2020 12:16:42 +0000 (14:16 +0200)] 
nts: follow bind*device settings for NTS-KE sockets

Bind the server and client NTS-KE sockets to the specified device.

5 years agonts: deinit gnutls when setting of credentials fails
Miroslav Lichvar [Wed, 15 Jul 2020 10:11:38 +0000 (12:11 +0200)] 
nts: deinit gnutls when setting of credentials fails

This is needed to cleanly exit when the server key/cert couldn't be
loaded.

5 years agonts: disable input when sending data in NTS-KE session
Miroslav Lichvar [Mon, 13 Jul 2020 10:21:39 +0000 (12:21 +0200)] 
nts: disable input when sending data in NTS-KE session

Ignore read events when sending data to avoid spinning with blocked
output.

5 years agodoc: fix formatting with new asciidoctor
Miroslav Lichvar [Tue, 14 Jul 2020 08:22:46 +0000 (10:22 +0200)] 
doc: fix formatting with new asciidoctor

With newer asciidoctor versions a blank character seems to be required
in an empty description used to set the indentation level in a nested
list.

https://github.com/asciidoctor/asciidoctor/issues/2766

5 years agosocket: fix debug message for unsupported binding
Miroslav Lichvar [Fri, 10 Jul 2020 07:04:20 +0000 (09:04 +0200)] 
socket: fix debug message for unsupported binding

Fixes: 4ef944b7343 ("socket: add support for binding sockets to device")
Reported-by: Bryan Christianson <bryan@whatroute.net>
5 years agodoc: mention automatic creation of directories
Miroslav Lichvar [Wed, 8 Jul 2020 15:11:15 +0000 (17:11 +0200)] 
doc: mention automatic creation of directories

5 years agoconf: create ntsdumpdir directory
Miroslav Lichvar [Wed, 8 Jul 2020 15:04:47 +0000 (17:04 +0200)] 
conf: create ntsdumpdir directory

Create the directory specified by the ntsdumpdir directive if it doesn't
exist, similarly to logdir and dumpdir.

5 years agoconf: restrict permissions of created directories
Miroslav Lichvar [Wed, 8 Jul 2020 15:02:32 +0000 (17:02 +0200)] 
conf: restrict permissions of created directories

If logdir or dumpdir doesn't exist, create the directory with no
permissions for other users (mode 0750 instead of 0755).

5 years agocmac+hash: change parameter types
Miroslav Lichvar [Wed, 8 Jul 2020 10:02:12 +0000 (12:02 +0200)] 
cmac+hash: change parameter types

For consistency and safety, change the CMC and HSH functions to accept
signed lengths and handle negative values as errors. Also, change the
input data type to void * to not require casting in the caller.

5 years agonts: don't assume field position in NNA_DecryptAuthEF()
Miroslav Lichvar [Thu, 9 Jul 2020 11:14:55 +0000 (13:14 +0200)] 
nts: don't assume field position in NNA_DecryptAuthEF()

Modify NNA_DecryptAuthEF() to not assume that the authenticator is the
last extension field in the packet as some extension fields specified in
future may need to be placed after the authenticator. The caller of the
function is supposed to verify the position.

5 years agonts: check for negative length in NNA_DecryptAuthEF()
Miroslav Lichvar [Thu, 9 Jul 2020 11:13:13 +0000 (13:13 +0200)] 
nts: check for negative length in NNA_DecryptAuthEF()

As other functions that accept a signed length, make sure it is sane in
NNA_DecryptAuthEF() too.

5 years agonts: fix comment about message handler
Miroslav Lichvar [Tue, 7 Jul 2020 15:55:07 +0000 (17:55 +0200)] 
nts: fix comment about message handler

5 years agonts: improve session code
Miroslav Lichvar [Tue, 7 Jul 2020 10:34:29 +0000 (12:34 +0200)] 
nts: improve session code

Add more comments and assertions, replace getsockopt() call with
SCK_GetIntOption(), replace strncmp() with memcmp(), move a return
statement for clarity, and remove an unused field from the instance
record.

5 years agonts: log details about failed certificate verification
Miroslav Lichvar [Tue, 7 Jul 2020 10:33:46 +0000 (12:33 +0200)] 
nts: log details about failed certificate verification

5 years agontp: drop precompensation of TX timestamp
Miroslav Lichvar [Thu, 2 Jul 2020 13:34:22 +0000 (15:34 +0200)] 
ntp: drop precompensation of TX timestamp

The daemon transmit timestamps are precompensated for the time it takes
to generate a MAC using a symmetric key (as measured on chronyd start)
and also an average round-trip time of the Samba signing of MS-SNTP
responses. This improves accuracy of the transmit timestamp, but it
has some issues.

The correction has a random error which is changing over time due to
variable CPU frequency, system load, migration to a different machine,
etc. If the measured delay is too large, the correction may cause the
transmit timestamp to be later than the actual transmission. Also, the
delay is measured for a packet of a minimal length with no extension
fields, and there is no support for NTS.

Drop the precompensation in favor of the interleaved mode, which now
avoids the authentication delay even when no kernel/hardware timestamps
are available.

5 years agontp: get TX timestamp after authentication
Miroslav Lichvar [Thu, 2 Jul 2020 13:18:23 +0000 (15:18 +0200)] 
ntp: get TX timestamp after authentication

If the daemon transmit timestamp is saved for processing of a future
response or responding in the interleaved mode, get a more accurate
timestamp right before calling NIO_SendPacket(). Avoid unnecessary
reading of the clock for the transmit timestamp in the packet (i.e.
in interleaved modes and client basic mode).

This should improve accuracy and stability when authentication is
enabled in the client and symmetric basic modes and also interleaved
modes if kernel/hardware timestamps are not available.

5 years agontp+cmdmon: fix responding to link-local addresses
Miroslav Lichvar [Tue, 30 Jun 2020 14:13:48 +0000 (16:13 +0200)] 
ntp+cmdmon: fix responding to link-local addresses

After commit e49aececceaa ("socket: don't set interface for sent
packets") the NTP and cmdmon server stopped responding to requests from
link-local addresses.

Set the interface specifically for packets sent to a link-local address.

5 years agosocket: add support for selecting interface again
Miroslav Lichvar [Tue, 30 Jun 2020 13:26:55 +0000 (15:26 +0200)] 
socket: add support for selecting interface again

Revert commit e49aececceaa ("socket: don't set interface for sent
packets") to allow the interface to be selected for outgoing packets,
but don't set it in the callers yet.

5 years agoconf: add directives to specify interfaces for binding sockets
Miroslav Lichvar [Tue, 30 Jun 2020 10:27:10 +0000 (12:27 +0200)] 
conf: add directives to specify interfaces for binding sockets

Add binddevice, bindacqdevice, and bindcmddevice directive to specify
the interface for binding the NTP server, NTP client, and command socket
respectively.

5 years agosocket: add support for binding sockets to device
Miroslav Lichvar [Tue, 30 Jun 2020 08:21:45 +0000 (10:21 +0200)] 
socket: add support for binding sockets to device

As a Linux-specific feature, allow sockets to be bound to a device using
the SO_BINDTODEVICE socket option. The CAP_NET_RAW capability is
required for setting the option.

5 years agoexamples: align onoffline with DHCP NM dispatcher
Robert Fairley [Thu, 4 Jun 2020 18:48:40 +0000 (14:48 -0400)] 
examples: align onoffline with DHCP NM dispatcher

Similar to the DHCP dispatcher, add a variable for the chronyc
executable path, which can be overwritten more easily by
downstream packages if needed.

Also give an `.onoffline` suffix to more clearly differentiate
this script from `chrony.nm-dispatcher.dhcp`.

5 years agoexamples: add dispatcher for NTP servers from DHCP
Robert Fairley [Thu, 4 Jun 2020 18:48:35 +0000 (14:48 -0400)] 
examples: add dispatcher for NTP servers from DHCP

Add new NM dispatcher script for NTP servers given by DHCP through
NetworkManager in a similar way to how distributions have done in
11-dhclient, e.g. [1]. New NTP servers are written as entries to a
file per-interface in /var/run/chrony-dhcp, which is re-read by
chronyd upon executing `chronyc reload sources`.

This provides a way for NTP server configuration to be carried over
from NetworkManager DHCP events to chrony, for DHCP clients other
than dhclient. Part of fixing integration where the NetworkManager
internal client is used, e.g [2].

Paths to the chronyc executable and sources directory are set in
variables, which may be overwritten by downstream packages, but
should work for distributions for the most part.

[1] https://src.fedoraproject.org/rpms/dhcp/blob/master/f/11-dhclient
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1800901

5 years agonameserv: don't return scoped IPv6 addresses
Miroslav Lichvar [Mon, 29 Jun 2020 14:56:09 +0000 (16:56 +0200)] 
nameserv: don't return scoped IPv6 addresses

Ignore IPv6 addresses returned by getaddrinfo() that have a non-zero
scope ID to avoid silently ignoring the ID if it was specified with the
% sign in the provided string.

This can be removed when the scope ID is returned from the function and
the callers handle it.

5 years agontp: fix comment about find_slot()
Miroslav Lichvar [Mon, 29 Jun 2020 14:46:05 +0000 (16:46 +0200)] 
ntp: fix comment about find_slot()

5 years agoconfigure: link with libnssutil3 for NSS hash support
Miroslav Lichvar [Thu, 25 Jun 2020 09:00:53 +0000 (11:00 +0200)] 
configure: link with libnssutil3 for NSS hash support

With recent NSS versions, the NSS low hash initialization seems to fail
unless the executable is linked with the libnssutil3 library.

5 years agosocket: handle negative sa_length
Miroslav Lichvar [Wed, 24 Jun 2020 10:07:55 +0000 (12:07 +0200)] 
socket: handle negative sa_length

As the type of the sa_length parameter is signed, negative values
should be handled as invalid.

5 years agologging: handle too many file logs
Miroslav Lichvar [Wed, 24 Jun 2020 09:27:41 +0000 (11:27 +0200)] 
logging: handle too many file logs

Don't rely on an assert to catch insufficient maximum number of file
logs (e.g. after introducing a new file log).

5 years agontp: rework initial burst
Miroslav Lichvar [Tue, 23 Jun 2020 11:10:02 +0000 (13:10 +0200)] 
ntp: rework initial burst

Instead of making the initial burst only once and immediately after
chronyd start (even when iburst is specified together with the offline
option), trigger the burst whenever the connectivity changes from
offline to online.

5 years agoexample: update chrony.conf examples
Miroslav Lichvar [Mon, 22 Jun 2020 12:45:42 +0000 (14:45 +0200)] 
example: update chrony.conf examples

Add some new directives, remove dumponexit (it's a no-op), remove
broadcast (to not encourage its use), fix a typo, and remove a
OS-specific limitation.

5 years agotest: update cmdmon and chronyc tests with new commands
Miroslav Lichvar [Wed, 17 Jun 2020 13:56:02 +0000 (15:56 +0200)] 
test: update cmdmon and chronyc tests with new commands

5 years agontp: reduce poll adjustment with specific failed tests
Miroslav Lichvar [Wed, 17 Jun 2020 12:18:49 +0000 (14:18 +0200)] 
ntp: reduce poll adjustment with specific failed tests

Reduce the poll increment for measurements that are rejected due to a
failed maxdelay* test in order to better track the source.

5 years agonts: warn about missing NTS support
Miroslav Lichvar [Wed, 17 Jun 2020 11:19:20 +0000 (13:19 +0200)] 
nts: warn about missing NTS support

Log a warning message if an NTP source is specified with the nts option
and the request fails due to missing NTS support.

5 years agonts: update NTS-KE port number
Miroslav Lichvar [Wed, 17 Jun 2020 10:29:20 +0000 (12:29 +0200)] 
nts: update NTS-KE port number

The port assigned by IANA for NTS-KE is 4460.

5 years agosocket: enable only specified IP families
Miroslav Lichvar [Wed, 17 Jun 2020 10:06:21 +0000 (12:06 +0200)] 
socket: enable only specified IP families

Allow an IP family to be specified in the socket initialization in order
to globally disable the other family. This replaces the ntp_io and
cmdmon code handling the -4/-6 options and fixes a case where the NTP
client could still use a disabled family if the source was specified
with an IP address.