]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
2 years agoexamples: harden systemd services
Miroslav Lichvar [Wed, 29 Sep 2021 13:25:48 +0000 (15:25 +0200)] 
examples: harden systemd services

Add various settings to the example chronyd and chrony-wait services to
decrease the exposure reported by the "systemd-analyze security"
command. The original exposure was high as the analyzer does not check
the actual process (e.g. that it dropped the root privileges or that it
has its own seccomp filter).

Limit read-write access to /run, /var/lib/chrony, and /var/spool.
Access to /run (instead of /run/chrony) is needed for the refclock
socket expected by gpsd.

The mailonchange directive is most likely to break as it executes
/usr/sbin/sendmail, which can do unexpected operations depending on the
implementation. It should work with a setuid/setgid binary, but it is
not expected to write outside of /var/spool and the private /tmp.

2 years agontp: check software timestamps on Linux
Miroslav Lichvar [Thu, 23 Sep 2021 11:00:24 +0000 (13:00 +0200)] 
ntp: check software timestamps on Linux

Apparently some routers with hardware NAT acceleration have a bug
causing the kernel timestamps to be corrupted and break NTP. Similarly
to the sanity check applied to hardware timestamps, require the
kernel/driver timestamps to be within one second of the daemon timestamp
to be accepted.

2 years agontp: print stratum 1 refid in ASCII in debug message
Miroslav Lichvar [Thu, 23 Sep 2021 10:39:54 +0000 (12:39 +0200)] 
ntp: print stratum 1 refid in ASCII in debug message

2 years agodoc: show arguments of ratelimit options
Miroslav Lichvar [Thu, 23 Sep 2021 08:08:07 +0000 (10:08 +0200)] 
doc: show arguments of ratelimit options

2 years agouse round() for rounding
Miroslav Lichvar [Thu, 23 Sep 2021 08:01:50 +0000 (10:01 +0200)] 
use round() for rounding

Replace casting of values incremented by +0.5/-0.5 with round().

2 years agotest: fix incorrect use of RAND_MAX
Miroslav Lichvar [Thu, 23 Sep 2021 07:34:47 +0000 (09:34 +0200)] 
test: fix incorrect use of RAND_MAX

On some systems (e.g. Solaris/OpenIndiana) rand() and random() have
different ranges. RAND_MAX is the maximum value returned by rand(),
but random() should always have a range of 0 through 2^31-1.

This fixes multiple failures in different tests.

2 years agoclient: replace allow/deny parser
Miroslav Lichvar [Wed, 22 Sep 2021 15:06:38 +0000 (17:06 +0200)] 
client: replace allow/deny parser

Use the new cmdparse function for parsing the (cmd)allow/deny commands
and refactor the code a bit to reduce the number of functions needed for
all the (cmd)allow/deny(all) combinations.

2 years agoconf: rework allow/deny parser
Miroslav Lichvar [Wed, 22 Sep 2021 13:54:50 +0000 (15:54 +0200)] 
conf: rework allow/deny parser

Refactor the (cmd)allow/deny parser and make it more strict in what
input it accepts. Check the scanned numbers and require whole input to
be processed.

Move the parser to cmdparse to make it available to the client.

2 years agocmdmon: move comment to make its scope clearer
Miroslav Lichvar [Wed, 22 Sep 2021 08:34:51 +0000 (10:34 +0200)] 
cmdmon: move comment to make its scope clearer

2 years agotest: extend 110-chronyc test
Miroslav Lichvar [Wed, 22 Sep 2021 07:59:03 +0000 (09:59 +0200)] 
test: extend 110-chronyc test

2 years agotest: fix chronyc test with disabled IPv6 support
Miroslav Lichvar [Tue, 21 Sep 2021 13:42:07 +0000 (15:42 +0200)] 
test: fix chronyc test with disabled IPv6 support

2 years agotest: add 143-manual test
Miroslav Lichvar [Mon, 20 Sep 2021 15:40:09 +0000 (17:40 +0200)] 
test: add 143-manual test

2 years agotest: enable chronyc to use Unix domain socket
Miroslav Lichvar [Wed, 15 Sep 2021 14:57:09 +0000 (16:57 +0200)] 
test: enable chronyc to use Unix domain socket

2 years agotest: fix 002-scanbuild test
Miroslav Lichvar [Thu, 23 Sep 2021 12:48:25 +0000 (14:48 +0200)] 
test: fix 002-scanbuild test

2 years agotest: update compilation tests
Miroslav Lichvar [Wed, 1 Sep 2021 14:33:41 +0000 (16:33 +0200)] 
test: update compilation tests

2 years agocmac: add gnutls support
Miroslav Lichvar [Thu, 2 Sep 2021 07:56:48 +0000 (09:56 +0200)] 
cmac: add gnutls support

Similarly to hashing, add support for AES-CMAC in gnutls to avoid
linking directly with nettle.

2 years agohash: allow non-security MD5 use in FIPS mode
Miroslav Lichvar [Thu, 2 Sep 2021 09:44:15 +0000 (11:44 +0200)] 
hash: allow non-security MD5 use in FIPS mode

gnutls running in the FIPS140-2 mode does not allow MD5 to be
initialized, which breaks chronyd using MD5 to calculate reference ID
of IPv6 addresses. Specify a new hash algorithm for non-security MD5 use
and temporarily switch to the lax mode when initializing the hash
function.

2 years agohash: add gnutls support
Miroslav Lichvar [Wed, 1 Sep 2021 12:46:38 +0000 (14:46 +0200)] 
hash: add gnutls support

Add support for crypto hash functions in gnutls (internally using
nettle). This can be useful to avoid directly linking with nettle to
avoid ABI breaks.

2 years agoconfigure: fix SIV detection in gnutls
Miroslav Lichvar [Thu, 2 Sep 2021 08:36:03 +0000 (10:36 +0200)] 
configure: fix SIV detection in gnutls

gnutls_aead_cipher_init() is declared in gnutls/crypto.h. If the
compiler handles implicit declarations as errors, the SIV support was
not detected. Fix the check to use the correct header.

2 years agosiv: deinit gnutls on unsupported SIV
Miroslav Lichvar [Thu, 2 Sep 2021 07:56:58 +0000 (09:56 +0200)] 
siv: deinit gnutls on unsupported SIV

2 years agoprivops: allow binding to PTP port
Miroslav Lichvar [Thu, 2 Sep 2021 11:27:23 +0000 (13:27 +0200)] 
privops: allow binding to PTP port

Fixes: be3158c4e5b2 ("ntp: add support for NTP over PTP")
2 years agodoc: improve ptpport example
Miroslav Lichvar [Wed, 1 Sep 2021 12:44:48 +0000 (14:44 +0200)] 
doc: improve ptpport example

2 years agodoc: remove obsolete comment in maxslewrate description
Miroslav Lichvar [Wed, 18 Aug 2021 12:38:16 +0000 (14:38 +0200)] 
doc: remove obsolete comment in maxslewrate description

2 years agodoc: shorten lock_all description
Miroslav Lichvar [Wed, 18 Aug 2021 12:35:00 +0000 (14:35 +0200)] 
doc: shorten lock_all description

2 years agotest: add 142-ptpport test
Miroslav Lichvar [Wed, 18 Aug 2021 10:57:40 +0000 (12:57 +0200)] 
test: add 142-ptpport test

2 years agontp: add support for NTP over PTP
Miroslav Lichvar [Wed, 18 Aug 2021 10:42:07 +0000 (12:42 +0200)] 
ntp: add support for NTP over PTP

Allow NTP messages to be exchanged as a payload of PTP messages to
enable full hardware timestamping on NICs that can timestamp PTP packets
only. Implemented is the protocol described in this draft (version 00):

https://datatracker.ietf.org/doc/draft-mlichvar-ntp-over-ptp/

This is an experimental feature. It can be changed or removed in future.
The used PTP domain is 123 and the NTP TLV type is 0x2023 from the "do
not propagate" experimental range.

The ptpport directive enables NTP-over-PTP as a server and as a client
for all sources that have the port option set to the PTP port. The port
should be the PTP event port (319) to trigger timestamping in the
hardware.

The implementation is contained to ntp_io. It is transparent to
ntp_core.

2 years agontp: add PTP rxfilter
Miroslav Lichvar [Wed, 18 Aug 2021 08:44:48 +0000 (10:44 +0200)] 
ntp: add PTP rxfilter

Setting rxfilter to ptp enables timestamping of PTPv2 packets (UDP or
all transports). It will be needed for NTP-over-PTP support.

2 years agontp: provide remote port to NIO_OpenServerSocket()
Miroslav Lichvar [Mon, 16 Aug 2021 12:51:01 +0000 (14:51 +0200)] 
ntp: provide remote port to NIO_OpenServerSocket()

This will allow selection of different protocols based on the remote
port. Zero means the default (NTP).

2 years agodoc: fix chronyd platform support for -P and -m
Stefan R. Filipek [Sat, 7 Aug 2021 14:35:15 +0000 (10:35 -0400)] 
doc: fix chronyd platform support for -P and -m

A while back, support for memory locking and real-time scheduling was
added to more platforms. The chronyd documentation wasn't updated at
that time (chronyd.conf was). This patch fixes that.

2 years agosys_linux: allow clone3 and pread64 in seccomp filter
Miroslav Lichvar [Mon, 9 Aug 2021 09:48:21 +0000 (11:48 +0200)] 
sys_linux: allow clone3 and pread64 in seccomp filter

These seem to be needed with the latest glibc.

2 years agortc: avoid printing and scanning time_t
Miroslav Lichvar [Thu, 5 Aug 2021 12:07:17 +0000 (14:07 +0200)] 
rtc: avoid printing and scanning time_t

With the latest glibc it's now possible to define _TIME_BITS=64 to get
64-bit time_t on 32-bit Linux systems. This breaks the %ld printf/scanf
modifier used with the RTC drift timestamp. Process it as a double.

2 years agodoc: improve ntsserverkey/cert description
Miroslav Lichvar [Wed, 7 Jul 2021 14:45:46 +0000 (16:45 +0200)] 
doc: improve ntsserverkey/cert description

The files are read after dropping root privileges. They need to be
readable by the chrony user. The error message "Could not set
credentials : Error while reading file." does not make this requirement
very obvious.

3 years agodoc: update NEWS 4.1
Miroslav Lichvar [Thu, 6 May 2021 14:31:33 +0000 (16:31 +0200)] 
doc: update NEWS

3 years agoupdate copyright years
Miroslav Lichvar [Mon, 10 May 2021 13:47:10 +0000 (15:47 +0200)] 
update copyright years

3 years agotest: make 007-cmdmon test more reliable
Miroslav Lichvar [Wed, 12 May 2021 11:03:45 +0000 (13:03 +0200)] 
test: make 007-cmdmon test more reliable

Reorder the local off command with respect to offline and online to
prevent the client from getting an unsynchronized response.

3 years agotest: allow inaccurate math in util unit test
Miroslav Lichvar [Mon, 10 May 2021 16:08:33 +0000 (18:08 +0200)] 
test: allow inaccurate math in util unit test

Don't require timespec/timeval-double conversion tests to produce
correctly rounded results to handle x86 and other archs with wider
intermediate results.

3 years agotest: disable privdrop in nts test
Miroslav Lichvar [Mon, 10 May 2021 13:09:38 +0000 (15:09 +0200)] 
test: disable privdrop in nts test

They are unrelated features. Not setting privdrop avoids a skip due to
the nobody user not having access to the test directory.

3 years agosys_linux: check if execveat is defined
Miroslav Lichvar [Thu, 6 May 2021 13:41:52 +0000 (15:41 +0200)] 
sys_linux: check if execveat is defined

The syscall is missing on older systems.

3 years agosys_linux: add second scfilter level
Miroslav Lichvar [Wed, 5 May 2021 09:21:39 +0000 (11:21 +0200)] 
sys_linux: add second scfilter level

Add level "2" to enable a filter which blocks only specific system calls
like fork and exec* instead of blocking everything unknown. It should
be reliable with respect to changes in libraries, but it provides only a
very limited protection.

3 years agosys_linux: allow getuid32 in seccomp filter
Miroslav Lichvar [Thu, 29 Apr 2021 14:53:40 +0000 (16:53 +0200)] 
sys_linux: allow getuid32 in seccomp filter

This was triggered on x86 in an NTS test.

3 years agosourcestats: check samples loaded from dump files
Miroslav Lichvar [Tue, 4 May 2021 12:06:33 +0000 (14:06 +0200)] 
sourcestats: check samples loaded from dump files

When loading a dump file with the -r option, check also sanity of the
sample time, offset, peer/root delay/dispersion, and the sample order to
better handle corrupted files.

3 years agosource: don't print duplicated address in selection message
Miroslav Lichvar [Tue, 4 May 2021 09:49:54 +0000 (11:49 +0200)] 
source: don't print duplicated address in selection message

Don't print the original IP address in parentheses in the "Selected
source ..." message if it is identical to the current address. That is
expected to be the usual case for sources specified by IP address.

3 years agoconf: log error when source cannot be added
Miroslav Lichvar [Tue, 4 May 2021 09:08:59 +0000 (11:08 +0200)] 
conf: log error when source cannot be added

Log an error message when adding of a source fails, e.g. due to the new
limit on number of sources, or when the same address is specified
multiple times.

3 years agonts: close file after loading cookies
Miroslav Lichvar [Mon, 3 May 2021 12:15:28 +0000 (14:15 +0200)] 
nts: close file after loading cookies

Don't forget to close the file with cookies in ntsdumpdir if
successfully loaded.

Fixes: 2fa83b541c36 ("nts: save and load cookies on client")
3 years agonts: ignore long non-critical records
Miroslav Lichvar [Mon, 3 May 2021 10:48:23 +0000 (12:48 +0200)] 
nts: ignore long non-critical records

In the NTS-KE client don't reject the response if it has non-critical
records that are too long for the processing buffer. This is not
expected to happen with the current specification, but it might be
needed with future extensions.

Fixes: 7925ed39b81f ("nts: fix handling of long server negotiation record")
3 years agotest: fix date use in 010-nts system test
Miroslav Lichvar [Thu, 29 Apr 2021 12:45:30 +0000 (14:45 +0200)] 
test: fix date use in 010-nts system test

Avoid using nonportable -d option of date.

3 years agotest: remove logs before chronyd start in system tests
Miroslav Lichvar [Thu, 29 Apr 2021 11:15:03 +0000 (13:15 +0200)] 
test: remove logs before chronyd start in system tests

3 years agotest: extend configuration in system tests
Miroslav Lichvar [Thu, 29 Apr 2021 11:14:11 +0000 (13:14 +0200)] 
test: extend configuration in system tests

3 years agotest: rework seccomp testing
Miroslav Lichvar [Thu, 29 Apr 2021 11:18:39 +0000 (13:18 +0200)] 
test: rework seccomp testing

Instead of a single test with enabled seccomp, rerun all other
non-destructive and destructive tests for each seccomp level.

3 years agosys_linux: allow BINDTODEVICE option in seccomp filter
Miroslav Lichvar [Thu, 29 Apr 2021 10:35:49 +0000 (12:35 +0200)] 
sys_linux: allow BINDTODEVICE option in seccomp filter

Fixes: 4ef944b73436 ("socket: add support for binding sockets to device")
3 years agodoc: warn about -F and mailonchange in chronyd man page
Miroslav Lichvar [Thu, 29 Apr 2021 07:18:49 +0000 (09:18 +0200)] 
doc: warn about -F and mailonchange in chronyd man page

3 years agonts: avoid assumption about cookie record
Miroslav Lichvar [Tue, 27 Apr 2021 13:39:59 +0000 (15:39 +0200)] 
nts: avoid assumption about cookie record

The cookie record is currently assumed to be the longest record that
needs to be accepted by the client, but that does not have to be always
the case. Define the processing buffer using the maximum body record
constant instead and add an assertion to make sure it's not smaller than
the maximum accepted cookie length.

3 years agonts: fix handling of long server negotiation record
Miroslav Lichvar [Tue, 27 Apr 2021 09:18:04 +0000 (11:18 +0200)] 
nts: fix handling of long server negotiation record

Recent change in handling of the NTPv4 server negotiation record (commit
754097944be2) increased the length of the instance name buffer to make
room for the trailing dot. This allowed a record with body truncated in
the processing buffer to be accepted and caused an over-read of 1 byte
in the memcpy() call saving the name to the instance buffer.

Modify the client to accept only records that fit in the processing
buffer.

Fixes: 754097944be2 ("nts: handle negotiated server as FQDN")
3 years agodoc: update NEWS 4.1-pre1
Miroslav Lichvar [Tue, 20 Apr 2021 12:16:11 +0000 (14:16 +0200)] 
doc: update NEWS

3 years agodoc: update README
Miroslav Lichvar [Tue, 20 Apr 2021 10:37:40 +0000 (12:37 +0200)] 
doc: update README

3 years agontp: fix address in error message
Miroslav Lichvar [Wed, 21 Apr 2021 13:56:51 +0000 (15:56 +0200)] 
ntp: fix address in error message

3 years agonameserv: avoid sockaddr_in6 with disabled IPv6 support
Miroslav Lichvar [Wed, 21 Apr 2021 12:40:12 +0000 (14:40 +0200)] 
nameserv: avoid sockaddr_in6 with disabled IPv6 support

Fixes: 10c760a80c15 ("nameserv: require getaddrinfo() and getnameinfo()")
3 years agotest: extend 129-reload test
Miroslav Lichvar [Wed, 21 Apr 2021 10:50:47 +0000 (12:50 +0200)] 
test: extend 129-reload test

3 years agosources: fix loading of refclock dump files
Miroslav Lichvar [Wed, 21 Apr 2021 10:52:17 +0000 (12:52 +0200)] 
sources: fix loading of refclock dump files

Allow zero stratum in loaded dump files.

Fixes: f8610d69f08f ("sources: improve handling of dump files and their format")
3 years agosources: don't print NULL string to dump file
Miroslav Lichvar [Wed, 21 Apr 2021 10:51:07 +0000 (12:51 +0200)] 
sources: don't print NULL string to dump file

For reference clocks, which don't have a name, print "." instead of
NULL.

Fixes: f8610d69f08f ("sources: improve handling of dump files and their format")
3 years agonts: handle negotiated server as FQDN
Miroslav Lichvar [Wed, 21 Apr 2021 07:37:40 +0000 (09:37 +0200)] 
nts: handle negotiated server as FQDN

The NTS RFC requires the recipient of the Server Negotiation NTS-KE
record to handle the name as a fully qualified domain name. Add a
trailing dot if not present to force the name to be resolved as one.

3 years agotest: extend 106-refclock test
Miroslav Lichvar [Tue, 20 Apr 2021 15:43:20 +0000 (17:43 +0200)] 
test: extend 106-refclock test

3 years agodoc: improve description of allow directive
Miroslav Lichvar [Tue, 20 Apr 2021 07:54:52 +0000 (09:54 +0200)] 
doc: improve description of allow directive

Prefer CIDR notation, clarify use of hostnames and order of allow/deny
directives, refer to the accheck command.

3 years agosys_timex: remove workaround for broken ntp_adjtime on macOS
Bryan Christianson [Mon, 19 Apr 2021 21:32:52 +0000 (09:32 +1200)] 
sys_timex: remove workaround for broken ntp_adjtime on macOS

Early beta releases of macOS Big Sur had a signed/unsigned error in
Apple's implementation of ntp_adjtime. Apple have since fixed this error
and the workaround is no longer required.

3 years agodoc: improve FAQ
Miroslav Lichvar [Tue, 13 Apr 2021 10:07:38 +0000 (12:07 +0200)] 
doc: improve FAQ

3 years agoconf: require sourcedir files to be terminated by newline
Miroslav Lichvar [Thu, 15 Apr 2021 07:43:01 +0000 (09:43 +0200)] 
conf: require sourcedir files to be terminated by newline

When reading a *.sources file require that each line is termined by the
newline character to avoid processing an unfinished line, e.g. due to an
unexpected call of the reload command when the file is being written in
place.

3 years agotest: make system tests more reliable
Miroslav Lichvar [Thu, 15 Apr 2021 09:26:29 +0000 (11:26 +0200)] 
test: make system tests more reliable

3 years agotest: update and extend 110-chronyc test
Miroslav Lichvar [Tue, 13 Apr 2021 14:34:34 +0000 (16:34 +0200)] 
test: update and extend 110-chronyc test

3 years agontp: add copy option
Miroslav Lichvar [Wed, 14 Apr 2021 13:58:51 +0000 (15:58 +0200)] 
ntp: add copy option

When separate client and server instances of chronyd are running on one
computer (e.g. for security or performance reasons) and are synchronized
to each other, the server instance provides a reference ID based on the
local address used for synchronization of its NTP clock, which breaks
detection of synchronization loops for its own clients.

Add a "copy" option to specify that the server and client are closely
related, no loop can form between them, and the client should assume the
reference ID and stratum of the server to fix detection of loops between
the server and clients of the client.

3 years agontp: clamp remote stratum
Miroslav Lichvar [Wed, 14 Apr 2021 10:36:28 +0000 (12:36 +0200)] 
ntp: clamp remote stratum

Don't set the remote stratum (used for polling adjustments) to values
larger than 16.

3 years agontp: don't update source status with unsynchronized data
Miroslav Lichvar [Wed, 14 Apr 2021 10:17:22 +0000 (12:17 +0200)] 
ntp: don't update source status with unsynchronized data

Don't update the leap and stratum used in source selection if they
indicate an unsynchronized source.

Fixes: 2582be8754ab ("sources: separate update of leap status")
3 years agorefclock: drop return after LOG_FATAL
Uwe Kleine-König [Fri, 9 Apr 2021 06:12:27 +0000 (08:12 +0200)] 
refclock: drop return after LOG_FATAL

The LOG_FATAL macro expands to (emitting the message and then) exit(1).
So a return after LOG_FATAL isn't reached. Drop all those to simplify
the code a bit.

3 years agontp: fix loop test for special reference modes
Miroslav Lichvar [Tue, 6 Apr 2021 16:05:54 +0000 (18:05 +0200)] 
ntp: fix loop test for special reference modes

It is not sufficient to check for disabled server sockets as they are
not open only after the special reference modes end (e.g. initstepslew).

Fixes: 004986310d2a ("ntp: skip loop test if no server socket is open")
3 years agosys_linux: allow setsockopt(SOL_IP, IP_TOS) in seccomp
Foster Snowhill [Sun, 4 Apr 2021 13:12:17 +0000 (15:12 +0200)] 
sys_linux: allow setsockopt(SOL_IP, IP_TOS) in seccomp

This system call is required by the DSCP marking feature introduced in commit
6a5665ca5877 ("conf: add dscp directive").

Before this change, enabling seccomp filtering (chronyd -F 1) and specifying a
custom DSCP value in the configuration (for example "dscp 46") caused the
process to be killed by seccomp due to IP_TOS not being allowed by the filter.

Tested before and after the change on Ubuntu 21.04, kernel 5.11.0-13-generic.
IP_TOS is available since Linux 1.0, so I didn't add any ifdefs for it.

Signed-off-by: Foster Snowhill <forst@forstwoof.ru>
3 years agodoc: improve chrony.conf man page
Miroslav Lichvar [Wed, 7 Apr 2021 14:37:11 +0000 (16:37 +0200)] 
doc: improve chrony.conf man page

3 years agodoc: improve FAQ
Miroslav Lichvar [Tue, 6 Apr 2021 14:28:56 +0000 (16:28 +0200)] 
doc: improve FAQ

Add new questions, fix typos and version-specific information.

3 years agotest: extend 103-initstepslew test
Miroslav Lichvar [Tue, 6 Apr 2021 14:38:34 +0000 (16:38 +0200)] 
test: extend 103-initstepslew test

3 years agotest: enable valgrind in more tests
Miroslav Lichvar [Wed, 24 Mar 2021 16:50:33 +0000 (17:50 +0100)] 
test: enable valgrind in more tests

3 years agotest: extend 106-refclock test
Miroslav Lichvar [Thu, 18 Mar 2021 16:37:13 +0000 (17:37 +0100)] 
test: extend 106-refclock test

3 years agorefclock: increase PPS lock limit
Miroslav Lichvar [Thu, 18 Mar 2021 10:49:08 +0000 (11:49 +0100)] 
refclock: increase PPS lock limit

Increase the maximum acceptable offset of the PPS lock reference from
20% to 40% of the PPS interval to not require the refclock offset to be
specified in configuration so accurately, or enable operation with a
highly unstable reference clock.

3 years agodeclare variables set from signal handlers as volatile
Miroslav Lichvar [Wed, 17 Mar 2021 08:21:42 +0000 (09:21 +0100)] 
declare variables set from signal handlers as volatile

Make sure variables set from signal handlers are not cached in
registers.

3 years agoconfigure: use well-known file name conftest.c
Kamil Dudka [Mon, 15 Mar 2021 09:27:40 +0000 (10:27 +0100)] 
configure: use well-known file name conftest.c

... for configuration checks.  Compiler wrappers check for this name
in order to skip any instrumentation of the build that is intended
for regular source files only.

3 years agotest: extend ntp_sources unit test
Miroslav Lichvar [Tue, 9 Mar 2021 13:10:48 +0000 (14:10 +0100)] 
test: extend ntp_sources unit test

3 years agotest: drop logging suspension
Miroslav Lichvar [Tue, 9 Mar 2021 11:34:41 +0000 (12:34 +0100)] 
test: drop logging suspension

Instead of selectively suspending logging by redirecting messages to
/dev/null, increase the default minimum log severity to FATAL. In the
debug mode, all messages are printed.

3 years agocmdmon: return error if doffset command fails
Miroslav Lichvar [Thu, 4 Mar 2021 09:06:22 +0000 (10:06 +0100)] 
cmdmon: return error if doffset command fails

3 years agocmdmon: convert doffset request to float
Miroslav Lichvar [Wed, 3 Mar 2021 17:18:54 +0000 (18:18 +0100)] 
cmdmon: convert doffset request to float

3 years agolocal: return status from offset accumulation
Miroslav Lichvar [Thu, 4 Mar 2021 08:59:25 +0000 (09:59 +0100)] 
local: return status from offset accumulation

Change the functions accumulating offset to return success or failure.

3 years agoclient: report invalid values in doffset and dfreq commands
Miroslav Lichvar [Wed, 3 Mar 2021 17:06:50 +0000 (18:06 +0100)] 
client: report invalid values in doffset and dfreq commands

3 years agotest: extend util unit test
Miroslav Lichvar [Wed, 3 Mar 2021 16:22:26 +0000 (17:22 +0100)] 
test: extend util unit test

3 years agotest: use env shebang in all bash scripts
Miroslav Lichvar [Wed, 3 Mar 2021 11:09:38 +0000 (12:09 +0100)] 
test: use env shebang in all bash scripts

This allows the scripts to be executed on systems that don't have bash
in /bin. This fixes "make check".

3 years agotest: extend 007-cmdmon system test
Miroslav Lichvar [Wed, 3 Mar 2021 10:31:53 +0000 (11:31 +0100)] 
test: extend 007-cmdmon system test

3 years agoutil: require inet_pton()
Miroslav Lichvar [Tue, 2 Mar 2021 16:28:02 +0000 (17:28 +0100)] 
util: require inet_pton()

Always use inet_pton() for converting IP addresses. It should be
available on all currently supported systems.

3 years agonameserv: avoid unnecessary getaddrinfo() calls
Miroslav Lichvar [Tue, 2 Mar 2021 16:24:09 +0000 (17:24 +0100)] 
nameserv: avoid unnecessary getaddrinfo() calls

Check if the name passed to DNS_Name2IPAddress() is an IP address
before calling getaddrinfo(), which can be much slower and work
differently on different systems.

3 years agonameserv: require getaddrinfo() and getnameinfo()
Miroslav Lichvar [Tue, 2 Mar 2021 15:55:37 +0000 (16:55 +0100)] 
nameserv: require getaddrinfo() and getnameinfo()

Remove support for the long-deprecated gethostbyname() and
gethostbyaddr() functions.

3 years agocmdmon: fix responding to IPv4 addresses on FreeBSD
Miroslav Lichvar [Tue, 2 Mar 2021 12:10:13 +0000 (13:10 +0100)] 
cmdmon: fix responding to IPv4 addresses on FreeBSD

On FreeBSD, the source address cannot be specified when sending a
message on a socket bound to a non-any IPv4 address, e.g. in default
configuration 127.0.0.1. In this case, make the address unspecified.

This is similar to commit 6af39d63aa93 ("ntp: don't use IP_SENDSRCADDR
on bound socket").

Fixes: f06c1cfa97f8 ("cmdmon: respond from same address")
3 years agomain: suppress info messages with -p option
Miroslav Lichvar [Tue, 2 Mar 2021 11:21:52 +0000 (12:21 +0100)] 
main: suppress info messages with -p option

Log (to stderr) only warnings and higher when printing the
configuration to suppress the "chronyd starting" message.

3 years agosys_linux: check if statx syscall is defined
Miroslav Lichvar [Mon, 1 Mar 2021 09:13:19 +0000 (10:13 +0100)] 
sys_linux: check if statx syscall is defined

statx seems to be missing in older kernel and libseccomp headers, still
used on some supported systems.

3 years agomain: warn if running with root privileges
Miroslav Lichvar [Thu, 25 Feb 2021 16:04:01 +0000 (17:04 +0100)] 
main: warn if running with root privileges

Log a warning message if the main process has not dropped the root
privileges, i.e. when the compiled-in user or user specified by the user
directive or -u option is root.

3 years agorefclock: warn if lock refid is invalid
Miroslav Lichvar [Thu, 25 Feb 2021 15:59:27 +0000 (16:59 +0100)] 
refclock: warn if lock refid is invalid

Log a warning message if the specified lock refid doesn't match any
existing refclock or it matches the refclock which has the lock option
itself.

3 years agorefclock: warn if maxlockage is too small
Miroslav Lichvar [Thu, 25 Feb 2021 15:51:23 +0000 (16:51 +0100)] 
refclock: warn if maxlockage is too small

Log a warning message if the interval covered by the maxlockage at the
PPS rate of a refclock is shorter than driver poll of the locked
refclock.

Reported-by: Matt Corallo <ntp-lists@mattcorallo.com>