]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
5 years agosocket: increase maximum number of received messages
Miroslav Lichvar [Tue, 24 Mar 2020 14:26:35 +0000 (15:26 +0100)] 
socket: increase maximum number of received messages

The buffers are no longer on stack. Increase their number for better
performance on heavily loaded servers.

5 years agosocket: simplify receiving messages
Miroslav Lichvar [Tue, 24 Mar 2020 14:22:31 +0000 (15:22 +0100)] 
socket: simplify receiving messages

Don't require the caller to provide a SCK_Message (on stack). Modify the
SCK_ReceiveMessage*() functions to return a pointer to static buffers,
as the message buffer which SCK_Message points to already is.

5 years agosocket: enable port sharing on Linux
Miroslav Lichvar [Mon, 23 Mar 2020 10:34:02 +0000 (11:34 +0100)] 
socket: enable port sharing on Linux

On Linux, enable the SO_REUSEPORT option on sockets bound to a port in
order to support load balancing with multiple chronyd instances
(configured to not adjust the system clock).

The IP_FREEBIND option already allowed different instances to bind to
the same address and port, but only one was actually receiving packets.

As the instances don't share their state, sharing the NTP port doesn't
work well with the interleaved mode, symmetric mode, and rate limiting.

Sharing the NTS-KE port will not work until the server keys can be
derived from a shared key.

5 years agodoc: fix typo in smoothtime description
Miroslav Lichvar [Thu, 19 Mar 2020 16:03:25 +0000 (17:03 +0100)] 
doc: fix typo in smoothtime description

5 years agosys_macosx: fix build issue on Sierra and presumably earlier
David Bohman [Tue, 17 Mar 2020 15:24:33 +0000 (08:24 -0700)] 
sys_macosx: fix build issue on Sierra and presumably earlier

5 years agotest: make 139-nts more reliable
Miroslav Lichvar [Tue, 17 Mar 2020 14:56:31 +0000 (15:56 +0100)] 
test: make 139-nts more reliable

5 years agodoc: fix typo in NEWS
Miroslav Lichvar [Mon, 16 Mar 2020 17:34:03 +0000 (18:34 +0100)] 
doc: fix typo in NEWS

5 years agodoc: update NEWS 4.0-pre1
Miroslav Lichvar [Mon, 16 Mar 2020 12:16:14 +0000 (13:16 +0100)] 
doc: update NEWS

5 years agosys_macosx: don't require clock_gettime()
Bryan Christianson [Thu, 12 Mar 2020 19:33:00 +0000 (08:33 +1300)] 
sys_macosx: don't require clock_gettime()

Earlier versions of macOS do not provide clock_gettime(). This patch
checks for clock_gettime() at run-time and falls back to gettimeofday()
if the symbol is not present.

5 years agomain: accept zero timeout
Miroslav Lichvar [Thu, 12 Mar 2020 13:25:21 +0000 (14:25 +0100)] 
main: accept zero timeout

Allow -t to specify zero timeout to exit immediately. It might be
useful for testing.

5 years agoreference: update synchronization status more frequently
Miroslav Lichvar [Thu, 12 Mar 2020 09:49:38 +0000 (10:49 +0100)] 
reference: update synchronization status more frequently

Update the local clock errors with each update of the leap status to
avoid the kernel marking the clock as unsynchronized when a large
number of NTP samples is dropped.

5 years agosources: update reference leap status early
Miroslav Lichvar [Wed, 11 Mar 2020 16:03:00 +0000 (17:03 +0100)] 
sources: update reference leap status early

When a leap second status is updated by a source, don't wait for the
next source selection and full update of the reference. Count votes from
sources that passed the previous selection and update the reference leap
status directly.

This should allow leap seconds to spread quickly even when the
samples are dropped or delayed by the filters.

5 years agosources: separate update of leap status
Miroslav Lichvar [Wed, 11 Mar 2020 14:48:00 +0000 (15:48 +0100)] 
sources: separate update of leap status

Remove leap status from the NTP sample and set it independently from
the sample accumulation in order to accept a leap second sooner when
samples are filtered.

5 years agosourcestats: move leap status to sources
Miroslav Lichvar [Wed, 11 Mar 2020 14:21:57 +0000 (15:21 +0100)] 
sourcestats: move leap status to sources

5 years agocmdmon: add reset command
Miroslav Lichvar [Wed, 11 Mar 2020 11:20:51 +0000 (12:20 +0100)] 
cmdmon: add reset command

The reset command drops all measurements and switches the reference to
the unsynchronised state. This command can help chronyd with recovery
when the measurements are known to be no longer valid or accurate, e.g.
due to moving the computer to a different network, or resuming the
computer from a low-power state (which resets the system clock).

5 years agodoc: fix tag in chronyc man page
Miroslav Lichvar [Wed, 11 Mar 2020 10:56:29 +0000 (11:56 +0100)] 
doc: fix tag in chronyc man page

5 years agoreference: don't report synchronized status after unknown step
Miroslav Lichvar [Wed, 11 Mar 2020 10:38:24 +0000 (11:38 +0100)] 
reference: don't report synchronized status after unknown step

The source handler resets SST instances on an unknown step, which
makes the sources unselectable, but SRC_SelectSource() doesn't call
REF_SetUnsynchronised() when no source is selectable.

Handle the step in the reference handler.

Fixes: 049eae661ae3 ("sources: keep synchronized status with unreachable/unselectable sources")
5 years agoreference: convert to monotonic time
Miroslav Lichvar [Wed, 11 Mar 2020 08:54:49 +0000 (09:54 +0100)] 
reference: convert to monotonic time

Calculate the update interval and drift file age from increments in the
monotonic time instead of real time.

5 years agonts: convert to monotonic time
Miroslav Lichvar [Wed, 11 Mar 2020 08:22:53 +0000 (09:22 +0100)] 
nts: convert to monotonic time

Use the monotonic timestamp provided by the scheduler for NTS-KE rate
limiting and refresh.

5 years agosched: provide low-precision monotonic time
Miroslav Lichvar [Wed, 11 Mar 2020 07:56:17 +0000 (08:56 +0100)] 
sched: provide low-precision monotonic time

Measure the interval since the start in order to provide a monotonic
time for periodical tasks not using timers like driftfile updates, key
refresh, etc. Return the interval in the double format, but keep an
integer remainder limiting the precision to 0.01 second to avoid issues
with very small increments in a long-running process.

5 years agoconfigure: improve nettle and gnutls check
Miroslav Lichvar [Tue, 10 Mar 2020 13:02:08 +0000 (14:02 +0100)] 
configure: improve nettle and gnutls check

Before enabling NTS, check for more gnutls functions (some added in
3.6.3) to avoid build failures with older gnutls versions. Also, make
sure that nettle supports the new AES interface (added in 3.0).

5 years agodoc: add missing dependencies to installation document
Miroslav Lichvar [Tue, 10 Mar 2020 10:02:59 +0000 (11:02 +0100)] 
doc: add missing dependencies to installation document

5 years agoconfigure: improve pkg-config support
Miroslav Lichvar [Tue, 10 Mar 2020 09:50:56 +0000 (10:50 +0100)] 
configure: improve pkg-config support

5 years agodoc: update description of on/offline commands
Miroslav Lichvar [Mon, 9 Mar 2020 12:00:47 +0000 (13:00 +0100)] 
doc: update description of on/offline commands

5 years agontp: ignore onoffline command for unresolved sources
Miroslav Lichvar [Mon, 9 Mar 2020 11:26:51 +0000 (12:26 +0100)] 
ntp: ignore onoffline command for unresolved sources

The onoffline command switches an unresolved source to the offline
status, even when the network is already up.

Ignore the onoffline command for unresolved sources to prevent sources
unexpectedly staying in the offline status, e.g. when the command is
issued from a network dispatcher script (and no other call is expected
later when the name is resolved).

5 years agodoc: update installation document
Miroslav Lichvar [Tue, 4 Feb 2020 13:34:47 +0000 (14:34 +0100)] 
doc: update installation document

5 years agodoc: describe NTS directives and options
Miroslav Lichvar [Wed, 19 Jun 2019 10:44:20 +0000 (12:44 +0200)] 
doc: describe NTS directives and options

5 years agotest: add nts unit tests
Miroslav Lichvar [Wed, 26 Feb 2020 13:14:49 +0000 (14:14 +0100)] 
test: add nts unit tests

5 years agotest: update compilation tests
Miroslav Lichvar [Thu, 9 Jan 2020 11:25:20 +0000 (12:25 +0100)] 
test: update compilation tests

5 years agotest: add 139-nts test
Miroslav Lichvar [Thu, 12 Sep 2019 14:42:53 +0000 (16:42 +0200)] 
test: add 139-nts test

5 years agocmdmon: add NTS support
Miroslav Lichvar [Thu, 7 Mar 2019 10:52:16 +0000 (11:52 +0100)] 
cmdmon: add NTS support

Allow the nts and ntsport options to be specified for sources added from
chronyc. This is an incompatible change in the request, but there was no
release using the new REQ_ADD_SOURCE command yet.

5 years agontp: enable NTS support
Miroslav Lichvar [Tue, 4 Feb 2020 14:27:24 +0000 (15:27 +0100)] 
ntp: enable NTS support

Add an option to enable NTS for an NTP source. Check for NTS-specific
extension fields and pass the packets to the NTS-NTP code in order to
enable the NTS client and server.

5 years agonts: add NTS-NTP server and client
Miroslav Lichvar [Tue, 4 Feb 2020 14:15:03 +0000 (15:15 +0100)] 
nts: add NTS-NTP server and client

Add support for the NTS NTP extension fields.

5 years agonts: add NTS-KE server and client
Miroslav Lichvar [Tue, 4 Feb 2020 14:10:14 +0000 (15:10 +0100)] 
nts: add NTS-KE server and client

Add a client and server implementing the Network Time Security (NTS) Key
Establishment. Use the GnuTLS library for TLS.

5 years agotest: add siv unit test
Miroslav Lichvar [Wed, 21 Aug 2019 15:51:23 +0000 (17:51 +0200)] 
test: add siv unit test

5 years agosiv: add internal implementation based on Nettle
Miroslav Lichvar [Wed, 21 Aug 2019 12:09:37 +0000 (14:09 +0200)] 
siv: add internal implementation based on Nettle

This adds an internal implementation of the AES-SIV-CMAC-256 cipher
based on GNU Nettle and the following patch (which was later reworked
and included in Nettle):

https://gitlab.com/gnutls/gnutls/uploads/1ab02c51e317264f9dba07ddfbc01d9a/0001-Added-support-for-AES_SIV_CMAC_256-and-AES_SIV_CMAC_.patch

This implementation will be dropped when the cipher is widely supported
by gnutls or Nettle.

5 years agosiv: add support for Nettle
Miroslav Lichvar [Wed, 21 Aug 2019 12:02:49 +0000 (14:02 +0200)] 
siv: add support for Nettle

5 years agosiv: introduce API for SIV
Miroslav Lichvar [Mon, 19 Aug 2019 15:33:54 +0000 (17:33 +0200)] 
siv: introduce API for SIV

Add a header file for Synthetic Initialization Vector (SIV) cipher mode,
which will be used by NTS.

5 years agosys_linux: allow getuid() in seccomp filter
Miroslav Lichvar [Mon, 10 Feb 2020 10:57:17 +0000 (11:57 +0100)] 
sys_linux: allow getuid() in seccomp filter

This will be needed by gnutls when loading certificates.

5 years agosys_linux: add syscall filter context for NTS-KE
Miroslav Lichvar [Tue, 26 Nov 2019 13:16:47 +0000 (14:16 +0100)] 
sys_linux: add syscall filter context for NTS-KE

The NTS-KE helper process will use a more restrictive filter than the
main process.

5 years agosys: specify context for syscall filter
Miroslav Lichvar [Tue, 26 Nov 2019 13:10:24 +0000 (14:10 +0100)] 
sys: specify context for syscall filter

Specify a context to enable different processes using different (more
restrictive) syscall filters.

5 years agosched: remove slew handler in finalization
Miroslav Lichvar [Tue, 4 Feb 2020 17:03:30 +0000 (18:03 +0100)] 
sched: remove slew handler in finalization

This allows repeated calls of SCH_Initialise() and SCH_Finalise().

5 years agosched: add function to remove all timers and descriptors
Miroslav Lichvar [Wed, 20 Nov 2019 11:39:32 +0000 (12:39 +0100)] 
sched: add function to remove all timers and descriptors

This allows a helper process to be started in an *_Initialise() call
and use the scheduler (unlike the privops helper, which has its own
loop).

5 years agonameserv: allow concurrent asynchronous requests
Miroslav Lichvar [Mon, 11 Nov 2019 18:02:30 +0000 (19:02 +0100)] 
nameserv: allow concurrent asynchronous requests

Allow multiple resolving threads to be running at the same time in order
to support multiple callers, but use a mutex to avoid sending multiple
requests to the privops helper. This will be needed for the NTS-KE
server negotiation.

5 years agoutil: add functions for printing and parsing hexadecimal data
Miroslav Lichvar [Thu, 31 Oct 2019 11:52:18 +0000 (12:52 +0100)] 
util: add functions for printing and parsing hexadecimal data

5 years agosources: don't reset active status
Miroslav Lichvar [Tue, 12 Nov 2019 17:04:48 +0000 (18:04 +0100)] 
sources: don't reset active status

Avoid resetting the active status when an NTP source changes its
address in NCR_ChangeRemoteAddress().

This will allow an NTP source to update its address with NTS-KE
hostname negotiation and continue in a special reference mode
(e.g. -q/-Q option).

5 years agontp: move definition of invalid stratum to ntp.h
Miroslav Lichvar [Thu, 7 Nov 2019 14:52:34 +0000 (15:52 +0100)] 
ntp: move definition of invalid stratum to ntp.h

5 years agontp: pass server name to ntp_core instances
Miroslav Lichvar [Wed, 13 Mar 2019 16:32:40 +0000 (17:32 +0100)] 
ntp: pass server name to ntp_core instances

The server name will be needed for certificate verification in NTS-KE.

5 years agotest: add ntp_ext unit test
Miroslav Lichvar [Thu, 5 Mar 2020 09:43:43 +0000 (10:43 +0100)] 
test: add ntp_ext unit test

5 years agontp: add functions for adding extension fields
Miroslav Lichvar [Mon, 3 Feb 2020 17:28:00 +0000 (18:28 +0100)] 
ntp: add functions for adding extension fields

5 years agontp: add function to change authentication-specific address
Miroslav Lichvar [Tue, 4 Feb 2020 10:50:29 +0000 (11:50 +0100)] 
ntp: add function to change authentication-specific address

When an NTS source will be replaced, the authentication-specific address
of the NTS-KE server will need to be changed too.

5 years agontp: add function to update source NTP address
Miroslav Lichvar [Sat, 23 Mar 2019 14:49:06 +0000 (15:49 +0100)] 
ntp: add function to update source NTP address

This will allow a source to have its address changed due to NTS-KE
server negotiation, which allows the NTS-KE server to have a different
address than the NTP server.

5 years agontp: allow changing port of source
Miroslav Lichvar [Thu, 13 Feb 2020 12:27:23 +0000 (13:27 +0100)] 
ntp: allow changing port of source

Modify the replace_source() function to not require a different IP
address when replacing a source with the same address but different
port. This will enable the NTS-KE port negotiation.

5 years agontp: don't accept packets with unexpected authentication
Miroslav Lichvar [Mon, 3 Feb 2020 15:04:08 +0000 (16:04 +0100)] 
ntp: don't accept packets with unexpected authentication

If authentication is not enabled in configuration, responses are not
expected to be authenticated. Handle such responses as having failed
authentication.

A case where this could happen is a misconfigured symmetric association
where only one peer has specified the other with a key. Before this
change synchronization would work in one direction and used packets
with an asymmetric length.

5 years agontp: don't allow long MACs in NTPv4 packets with extension fields
Miroslav Lichvar [Mon, 3 Feb 2020 13:03:57 +0000 (14:03 +0100)] 
ntp: don't allow long MACs in NTPv4 packets with extension fields

MAC longer than 24 octets in NTPv4 packet is supported only for
compatibility with some pre-RFC7822 chrony versions. They didn't use
any extension fields.

5 years agontp: add support for sending KoD responses
Miroslav Lichvar [Thu, 7 Nov 2019 13:57:52 +0000 (14:57 +0100)] 
ntp: add support for sending KoD responses

Enable the server to respond with a KoD when authentication fails. This
will be used by NTS to respond with a NAK when a client has expired
cookies.

5 years agontp: prefix NTP_AuthMode enums
Miroslav Lichvar [Thu, 15 Aug 2019 09:23:44 +0000 (11:23 +0200)] 
ntp: prefix NTP_AuthMode enums

5 years agontp: move auth parsing to ntp_auth
Miroslav Lichvar [Thu, 15 Aug 2019 09:20:36 +0000 (11:20 +0200)] 
ntp: move auth parsing to ntp_auth

Move the remaining authentication-specific code to the new file.

5 years agontp: refactor authentication
Miroslav Lichvar [Wed, 14 Aug 2019 16:23:45 +0000 (18:23 +0200)] 
ntp: refactor authentication

Move most of the authentication-specific code to a new file and
introduce authenticator instances in order to support other
authentication mechanisms (e.g. NTS).

5 years agontp: rework packet parsing
Miroslav Lichvar [Wed, 14 Aug 2019 13:53:17 +0000 (15:53 +0200)] 
ntp: rework packet parsing

Rework the code to detect the authentication mode and count extension
fields in the first parsing of the packet and store this information in
the new packet info structure.

5 years agontp: add functions for parsing extension fields
Miroslav Lichvar [Mon, 18 Feb 2019 12:12:49 +0000 (13:12 +0100)] 
ntp: add functions for parsing extension fields

5 years agontp: count packets with invalid format
Miroslav Lichvar [Mon, 19 Aug 2019 11:55:12 +0000 (13:55 +0200)] 
ntp: count packets with invalid format

Include packets that cannot be parsed in the total RX count.

5 years agontp: don't send response longer than request
Miroslav Lichvar [Mon, 15 Apr 2019 10:48:41 +0000 (12:48 +0200)] 
ntp: don't send response longer than request

When sending a response in the server or passive mode, make sure the
response is not longer than the request to prevent amplification
attacks when resposes may contain extension fields (e.g. NTS).

5 years agontp: provide access to request in transmit_packet()
Miroslav Lichvar [Thu, 8 Aug 2019 13:41:09 +0000 (15:41 +0200)] 
ntp: provide access to request in transmit_packet()

This will allow new authentication code (e.g. NTS) to get data from the
request when generating a response.

5 years agontp: rename receive_packet() to process_response()
Miroslav Lichvar [Thu, 15 Aug 2019 14:30:50 +0000 (16:30 +0200)] 
ntp: rename receive_packet() to process_response()

5 years agontp: add structure with packet info
Miroslav Lichvar [Wed, 14 Aug 2019 12:10:28 +0000 (14:10 +0200)] 
ntp: add structure with packet info

Add a structure for length and other information about received and
transmitted NTP packets to minimize the number of parameters and avoid
repeated parsing of the packet.

5 years agontp: refactor NTP_Packet structure for extension fields
Miroslav Lichvar [Fri, 15 Feb 2019 15:18:39 +0000 (16:18 +0100)] 
ntp: refactor NTP_Packet structure for extension fields

5 years agontp: don't replace sources with unroutable addresses
Miroslav Lichvar [Mon, 24 Feb 2020 09:42:29 +0000 (10:42 +0100)] 
ntp: don't replace sources with unroutable addresses

When changing an address of a source (both known and unknown), make sure
the new address is connectable. This should avoid useless replacements,
e.g. polling an IPv6 address on IPv4-only systems.

5 years agodoc: list unsupported options in peer directive
Miroslav Lichvar [Wed, 4 Mar 2020 08:10:54 +0000 (09:10 +0100)] 
doc: list unsupported options in peer directive

5 years agotest: make 132-logchange more reliable
Miroslav Lichvar [Thu, 27 Feb 2020 08:02:41 +0000 (09:02 +0100)] 
test: make 132-logchange more reliable

5 years agotest: extend 001-features test
Miroslav Lichvar [Thu, 27 Feb 2020 07:30:40 +0000 (08:30 +0100)] 
test: extend 001-features test

5 years agotest: fix unit tests to build with -NTP and -CMDMON
Miroslav Lichvar [Thu, 27 Feb 2020 07:29:58 +0000 (08:29 +0100)] 
test: fix unit tests to build with -NTP and -CMDMON

5 years agotest: extend 122-xleave test
Miroslav Lichvar [Mon, 24 Feb 2020 14:21:53 +0000 (15:21 +0100)] 
test: extend 122-xleave test

5 years agosources: don't save or load dumpfiles for unknown addresses
Miroslav Lichvar [Mon, 24 Feb 2020 17:05:09 +0000 (18:05 +0100)] 
sources: don't save or load dumpfiles for unknown addresses

Don't open a dumpfile for reading or writing if the NTP source doesn't
have a real address.

Fixes: d7e3ad17ff7a ("ntp: create sources for unresolved addresses")
5 years agoclient: add option to print all sources
Miroslav Lichvar [Tue, 18 Feb 2020 09:51:41 +0000 (10:51 +0100)] 
client: add option to print all sources

Add -a option to the sources and sourcestats commands to print all
sources, including those that don't have a resolved address yet. By
default, only sources that have a real address are printed for
compatibility. Remove the "210 Number of sources" messages to avoid
confusion. Also, modify the ntpdata command to always print only sources
with a resolved address.

5 years agoclient: add support for source identifiers
Miroslav Lichvar [Tue, 18 Feb 2020 09:48:10 +0000 (10:48 +0100)] 
client: add support for source identifiers

Allow the new identifiers to be specified as addresses in commands that
modify or remove NTP sources.

5 years agontp: repeat resolving until all pool sources are resolved
Miroslav Lichvar [Tue, 18 Feb 2020 12:45:13 +0000 (13:45 +0100)] 
ntp: repeat resolving until all pool sources are resolved

When resolving of a pool name succeeds, don't remove the remaining
unresolved sources, i.e. try to get all maxsources (default 4) sources,
even if it takes multiple DNS requests.

5 years agontp: stop resolving if unresolved source is removed
Miroslav Lichvar [Tue, 18 Feb 2020 10:32:22 +0000 (11:32 +0100)] 
ntp: stop resolving if unresolved source is removed

If an individual unresolved source or all unresolved sources from a pool
are removed, stop resolving their addresses on the next attempt (don't
remove them immediately as the resolver may be running).

5 years agontp: update resolving timeout ID
Miroslav Lichvar [Wed, 19 Feb 2020 12:51:47 +0000 (13:51 +0100)] 
ntp: update resolving timeout ID

This will allow unresolved sources to be removed before resolving.

5 years agontp: create sources for unresolved addresses
Miroslav Lichvar [Tue, 18 Feb 2020 09:41:37 +0000 (10:41 +0100)] 
ntp: create sources for unresolved addresses

Rework the ntp_sources code to create sources for addresses that are not
resolved yet using the new identifiers.

5 years agoaddressing: introduce identifiers for unresolved addresses
Miroslav Lichvar [Tue, 18 Feb 2020 09:35:41 +0000 (10:35 +0100)] 
addressing: introduce identifiers for unresolved addresses

Add a new type of address for NTP sources that don't have a resolved
address yet. This will allow the sources to be displayed, modified and
deleted by chronyc.

Update utility functions to support the new addresses.

5 years agoaddrfilt: explicitly handle unexpected addresses
Miroslav Lichvar [Tue, 18 Feb 2020 07:53:11 +0000 (08:53 +0100)] 
addrfilt: explicitly handle unexpected addresses

5 years agologging: restrict file log permissions
Miroslav Lichvar [Tue, 11 Feb 2020 11:37:57 +0000 (12:37 +0100)] 
logging: restrict file log permissions

With the new file utility functions permissions can be restricted for
newly created files. For the log file specified by the -l option it
is better to remove the "other" permissions (0640) to make it similar
to the system log.

5 years agoutil: don't log unlink() error if file is not accessible
Miroslav Lichvar [Wed, 29 Jan 2020 11:28:43 +0000 (12:28 +0100)] 
util: don't log unlink() error if file is not accessible

Try stat() before calling unlink() to make sure the file is accessible.

This fixes chronyc running under a non-root/chrony user printing an
error message due to missing permissions on /var/run/chrony before
trying to bind its socket.

5 years agosys_linux: allow renameat2 in seccomp filter
Vincent Blut [Thu, 16 Jan 2020 16:04:35 +0000 (17:04 +0100)] 
sys_linux: allow renameat2 in seccomp filter

This is needed for architectures that support neither rename() nor
renameat() (e.g. riscv64)

5 years agotest: fix util unit test for NTP era split
Miroslav Lichvar [Fri, 3 Jan 2020 10:25:55 +0000 (11:25 +0100)] 
test: fix util unit test for NTP era split

The current default NTP era split passed the Unix epoch (~50 years ago),
which means the epoch converted to an NTP timestamp and back ends up in
the next NTP era (year 2106).

Fix the test to take into account the era split.

5 years agostubs: add NSR_GetName()
Miroslav Lichvar [Fri, 3 Jan 2020 09:16:34 +0000 (10:16 +0100)] 
stubs: add NSR_GetName()

Fixes: 93f6358916ca ("cmdmon: add request to get source name")
5 years agostubs: update NSR_AddSourceByName()
Miroslav Lichvar [Fri, 3 Jan 2020 09:15:40 +0000 (10:15 +0100)] 
stubs: update NSR_AddSourceByName()

Fixes: 3763befd62d9 ("ntp: check name and return status from NSR_AddSourceByName()")
5 years agoclient: add missing commands to tab-completion
Miroslav Lichvar [Fri, 3 Jan 2020 08:45:33 +0000 (09:45 +0100)] 
client: add missing commands to tab-completion

Reported-by: Lonnie Abelbeck <lonnie@abelbeck.com>
5 years agosocket: add function to check supported family
Miroslav Lichvar [Fri, 3 Jan 2020 08:36:59 +0000 (09:36 +0100)] 
socket: add function to check supported family

Don't log error when an IPv6 socket cannot be opened and chronyd was
built without IPv6 support.

Reported-by: Lonnie Abelbeck <lonnie@abelbeck.com>
5 years agoclient: add sourcename command
Miroslav Lichvar [Thu, 5 Dec 2019 12:25:10 +0000 (13:25 +0100)] 
client: add sourcename command

Add a new command to print the original name of a source specified by
address. This could be useful in scripts to avoid having to run the
sources command with and without -N.

5 years agoclient: add option to print original names
Miroslav Lichvar [Thu, 5 Dec 2019 11:22:49 +0000 (12:22 +0100)] 
client: add option to print original names

Add -N option to chronyc to print the original names by which the
sources were specified instead of using reverse DNS lookup. The option
works in the sources, sourcestats and tracking commands.

5 years agocmdmon: add request to get source name
Miroslav Lichvar [Thu, 5 Dec 2019 09:34:02 +0000 (10:34 +0100)] 
cmdmon: add request to get source name

Specify a new request to get the name of the NTP source corresponding to
an address, which was originally specified in the configuration file or
chronyc add command.

5 years agocmdmon: add support for adding pool sources
Miroslav Lichvar [Wed, 4 Dec 2019 14:26:39 +0000 (15:26 +0100)] 
cmdmon: add support for adding pool sources

Specify a new type for pool sources and extend the syntax of the chronyc
"add" command to add a pool.

5 years agocmdmon: specify name instead of address in add request
Miroslav Lichvar [Wed, 4 Dec 2019 11:04:19 +0000 (12:04 +0100)] 
cmdmon: specify name instead of address in add request

Modify the request for adding a source to provide the name of the source
instead of its address (resolved in chronyc) in order to enable chronyd
to replace the source, support an "add pool" command, and enable an NTS
client to verify the server's certificate.

The name resolving does not block the response. Success is indicated
even if the name cannot be resolved, or a source with the same address
is already present.

To prevent unresolvable names from getting to chronyd, chronyc does not
send the request if it could not resolve the name itself (assuming they
are both running on the same host using the same resolver).

5 years agocmdmon: merge add server/peer requests
Miroslav Lichvar [Wed, 4 Dec 2019 10:16:26 +0000 (11:16 +0100)] 
cmdmon: merge add server/peer requests

Instead of having two separate requests in the protocol for adding a
server and peer, specify the type of the new source in the request data.

5 years agontp: check name and return status from NSR_AddSourceByName()
Miroslav Lichvar [Thu, 12 Dec 2019 10:58:18 +0000 (11:58 +0100)] 
ntp: check name and return status from NSR_AddSourceByName()

Return an error status when the name is not printable or contains a
space (don't bother with full hostname validation). If the name is an
address, return the same status as NSR_AddSource(). Otherwise, return a
"not resolved yet" status.

5 years agontp: print name of replaced source in log message
Miroslav Lichvar [Thu, 12 Dec 2019 13:12:39 +0000 (14:12 +0100)] 
ntp: print name of replaced source in log message

5 years agodoc: remove unsupported options of add commands
Miroslav Lichvar [Wed, 4 Dec 2019 14:12:31 +0000 (15:12 +0100)] 
doc: remove unsupported options of add commands

All options from the configuration file are supported in the chronyc add
commands.

This fixes commit 65fd30a5473f0a13a216e2d481236ebe54058b41.

5 years agoprivops: convert to new socket API
Miroslav Lichvar [Mon, 18 Nov 2019 17:16:21 +0000 (18:16 +0100)] 
privops: convert to new socket API