]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
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

5 years agosocket: change SCK_Send() declaration to const buffer
Miroslav Lichvar [Tue, 19 Nov 2019 09:42:23 +0000 (10:42 +0100)] 
socket: change SCK_Send() declaration to const buffer

5 years agosocket: add support for opening socket pairs
Miroslav Lichvar [Mon, 18 Nov 2019 17:08:47 +0000 (18:08 +0100)] 
socket: add support for opening socket pairs

5 years agosocket: add support for blocking sockets
Miroslav Lichvar [Mon, 18 Nov 2019 17:07:16 +0000 (18:07 +0100)] 
socket: add support for blocking sockets

Add a flag to open a blocking socket. The default stays non-blocking.

5 years agosocket: remove unnecessary MSG_DONTWAIT flag
Miroslav Lichvar [Mon, 18 Nov 2019 17:05:17 +0000 (18:05 +0100)] 
socket: remove unnecessary MSG_DONTWAIT flag

This is not needed since sockets are non-blocking by default.

5 years agosocket: add support for sending and receiving descriptors
Miroslav Lichvar [Mon, 18 Nov 2019 17:04:43 +0000 (18:04 +0100)] 
socket: add support for sending and receiving descriptors

Add support for the SCM_RIGHTS control message used in communication
with the privops helper.

5 years agotest: accept test result if RTC can't enable RTC_UIE_ON
Christian Ehrhardt [Thu, 12 Dec 2019 11:06:39 +0000 (12:06 +0100)] 
test: accept test result if RTC can't enable RTC_UIE_ON

The test might run on different platforms. If the platform happens
to have a RTC that does exist but unable to have RTC_UIE_ON set the
test will fail, while the chrony code is actually good.

Examples of bad clocks are:
- ppc64el: rtc-generic
- arm64: rtc-efi

To avoid that extend the log message check on 101-rtc to accept
that condition as a valid test result as well.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agortc: extend check for RTCs that don't support interrupts
Christian Ehrhardt [Thu, 12 Dec 2019 11:06:40 +0000 (12:06 +0100)] 
rtc: extend check for RTCs that don't support interrupts

Several RTCs would only expose the broken behavior on enabling
interrupts. The reason for that is that the kernel only returns the
error if the state changes. Therefore the check has to probe
switch_interrupts(1) as well.

On platforms that work it will be switched on and off, while on those it
never works it will just stay off.

Clocks known to expose that behavior include, but are not limited to:
PPC64# dmesg | grep -i rtc   
[    0.241872] rtc-generic rtc-generic: registered as rtc0
[    0.270221] rtc-generic rtc-generic: setting system clock to ...
ARM64# dmesg | grep -i rtc
[    0.876198] rtc-efi rtc-efi: registered as rtc0
[    1.046869] rtc-efi rtc-efi: setting system clock to ...

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agortc: disable interrupts in finalization
Miroslav Lichvar [Tue, 10 Dec 2019 16:42:34 +0000 (17:42 +0100)] 
rtc: disable interrupts in finalization

Don't leave interrupts enabled if chronyd is stopped when making an RTC
measurement.

5 years agortc: handle RTCs that don't support interrupts
Miroslav Lichvar [Tue, 10 Dec 2019 16:33:17 +0000 (17:33 +0100)] 
rtc: handle RTCs that don't support interrupts

Some RTCs supported by the Linux kernel don't support the RTC_UIE_ON/OFF
ioctls, which causes chronyd started with the -s option to get stuck in
the initial RTC mode.

After opening the RTC device in the initialization, return error if
the ioctls are not supported to prevent the upper layer from calling the
time_init() function and expecting it to finish.

5 years agortc: don't finalize driver if initialization failed
Miroslav Lichvar [Tue, 10 Dec 2019 16:30:42 +0000 (17:30 +0100)] 
rtc: don't finalize driver if initialization failed

5 years agortc: simplify and move switch_interrupts()
Miroslav Lichvar [Tue, 10 Dec 2019 16:40:44 +0000 (17:40 +0100)] 
rtc: simplify and move switch_interrupts()

5 years agotest: update log checks in system tests
Miroslav Lichvar [Tue, 10 Dec 2019 14:54:36 +0000 (15:54 +0100)] 
test: update log checks in system tests

Measurements are no longer accepted and clock updated when polling
itself.

This fixes commit 7a88e0a87b3b2d3efbd7726451ef71b257e27673.

5 years agosys_linux: allow clock_adjtime in seccomp filter
Miroslav Lichvar [Mon, 2 Dec 2019 11:47:13 +0000 (12:47 +0100)] 
sys_linux: allow clock_adjtime in seccomp filter

The adjtimex() function in glibc was switched to the clock_adjtime
system call.

5 years agologging: enable line buffering on stderr
Miroslav Lichvar [Wed, 20 Nov 2019 09:47:16 +0000 (10:47 +0100)] 
logging: enable line buffering on stderr

This should avoid mixed lines on console or in file log when multiple
processes will be logging messages at the same time.

5 years agodoc: fix typo in chrony.conf man page
Vincent Blut [Thu, 28 Nov 2019 15:06:45 +0000 (16:06 +0100)] 
doc: fix typo in chrony.conf man page

5 years agologging: disable all debug messages in non-debug build
Miroslav Lichvar [Tue, 19 Nov 2019 13:59:21 +0000 (14:59 +0100)] 
logging: disable all debug messages in non-debug build

For consistency, don't print debug messages that are compiled in due to
using the LOG macro instead of DEBUG_LOG.

5 years agoclient: don't print log messages with lower severity
Miroslav Lichvar [Tue, 19 Nov 2019 13:21:53 +0000 (14:21 +0100)] 
client: don't print log messages with lower severity

5 years agoprivops: keep stdin/out/err open
Miroslav Lichvar [Mon, 18 Nov 2019 17:15:07 +0000 (18:15 +0100)] 
privops: keep stdin/out/err open

5 years agoprivops: remove debug message from PRV_Name2IPAddress()
Miroslav Lichvar [Mon, 11 Nov 2019 16:59:26 +0000 (17:59 +0100)] 
privops: remove debug message from PRV_Name2IPAddress()

The function may be called from a separate thread, but logging is not
considered thread safe (e.g. due to using functions which read
environment variables).

5 years agomain: don't try to open unspecified pidfile
Miroslav Lichvar [Tue, 12 Nov 2019 17:10:25 +0000 (18:10 +0100)] 
main: don't try to open unspecified pidfile

6 years agoswitch to new util file functions
Miroslav Lichvar [Tue, 22 Oct 2019 16:06:25 +0000 (18:06 +0200)] 
switch to new util file functions

Replace all fopen(), rename(), and unlink() calls with the new util
functions.

6 years agotest: extend util unit test
Miroslav Lichvar [Thu, 24 Oct 2019 08:54:37 +0000 (10:54 +0200)] 
test: extend util unit test

6 years agosys_linux: allow F_GETFL in seccomp filter
Miroslav Lichvar [Thu, 24 Oct 2019 10:42:02 +0000 (12:42 +0200)] 
sys_linux: allow F_GETFL in seccomp filter

This is needed for fdopen().

6 years agoutil: add functions for common file operations
Miroslav Lichvar [Tue, 22 Oct 2019 16:06:15 +0000 (18:06 +0200)] 
util: add functions for common file operations

Add a function to open a file for reading, writing, or appending.
In uppercase modes errors are handled as fatal, i.e. the caller doesn't
need to check for NULL. To avoid string manipulations in the callers,
the function accepts an optional directory and suffix. New files are
created with specified permissions, which will be needed for saving
keys. The O_EXCL flag is used in the writing mode to make sure a new
file is created (on filesystems that support it).

Also, add a function to rename a temporary file by changing its suffix,
and a function to remove a file.

All functions log all errors, at least as debug messages.

6 years agortc: don't clone file attributes of rtc file
Miroslav Lichvar [Tue, 22 Oct 2019 12:50:00 +0000 (14:50 +0200)] 
rtc: don't clone file attributes of rtc file

When replacing an existing rtc file with the temporary file, don't
change the ownership or permissions of the temporary file to match the
old rtc file, as if it didn't exist.

6 years agoreference: don't clone file attributes of drift file
Miroslav Lichvar [Tue, 22 Oct 2019 10:31:03 +0000 (12:31 +0200)] 
reference: don't clone file attributes of drift file

When replacing an existing drift file with the temporary file, don't
change the ownership or permissions of the temporary file to match the
old drift file, as if it didn't exist.

6 years agouse PATH_MAX
Miroslav Lichvar [Thu, 10 Oct 2019 15:53:58 +0000 (17:53 +0200)] 
use PATH_MAX

Include <limits.h> and use the PATH_MAX macro to define the length of
buffers containing paths to make it constistent. (It's not supposed to
fit all possible paths.)

6 years agologging: include <syslog.h>
Miroslav Lichvar [Wed, 23 Oct 2019 15:23:35 +0000 (17:23 +0200)] 
logging: include <syslog.h>

Move the inclusion of <syslog.h> from sysincl.h to logging.c to avoid
accidentally using the LOG_* constants from the header.

6 years agologging: make banner printing safer
Miroslav Lichvar [Tue, 22 Oct 2019 13:25:03 +0000 (15:25 +0200)] 
logging: make banner printing safer

Don't rely on the buffer filled with '=' characters to be always at
least as long as the log-specific banner string.

6 years agologging: call exit() in LOG_Message()
Miroslav Lichvar [Thu, 10 Oct 2019 13:07:10 +0000 (15:07 +0200)] 
logging: call exit() in LOG_Message()

Call exit() in LOG_Message() after printing a fatal message to allow the
LOG macro or LOG_Message() to be used directly instead of the LOG_FATAL
macro.

6 years agotest: extend 110-chronyc test
Miroslav Lichvar [Tue, 24 Sep 2019 09:29:35 +0000 (11:29 +0200)] 
test: extend 110-chronyc test

6 years agotest: extend 105-ntpauth test
Miroslav Lichvar [Thu, 19 Sep 2019 15:38:22 +0000 (17:38 +0200)] 
test: extend 105-ntpauth test

6 years agotest: extend keys unit test
Miroslav Lichvar [Thu, 19 Sep 2019 15:47:53 +0000 (17:47 +0200)] 
test: extend keys unit test

6 years agotest: add cmac unit test
Miroslav Lichvar [Mon, 23 Sep 2019 12:38:57 +0000 (14:38 +0200)] 
test: add cmac unit test