]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
9 years agoupdate NEWS 2.3-pre1
Miroslav Lichvar [Tue, 2 Feb 2016 15:49:05 +0000 (16:49 +0100)] 
update NEWS

9 years agoupdate README
Miroslav Lichvar [Tue, 2 Feb 2016 11:05:51 +0000 (12:05 +0100)] 
update README

9 years agoupdate copyright years
Miroslav Lichvar [Mon, 1 Feb 2016 14:24:37 +0000 (15:24 +0100)] 
update copyright years

9 years agontp: optimize resizing of hash table with sources
Miroslav Lichvar [Tue, 2 Feb 2016 11:00:58 +0000 (12:00 +0100)] 
ntp: optimize resizing of hash table with sources

9 years agosys_generic: use privops for settimeofday()
Miroslav Lichvar [Mon, 1 Feb 2016 15:51:46 +0000 (16:51 +0100)] 
sys_generic: use privops for settimeofday()

This is needed on FreeBSD and Solaris when running without root
privileges.

9 years agoclientlog: fix warning reported by static analyzer
Miroslav Lichvar [Mon, 1 Feb 2016 13:37:10 +0000 (14:37 +0100)] 
clientlog: fix warning reported by static analyzer

9 years agoclient: fix format specifiers in client report
Miroslav Lichvar [Mon, 1 Feb 2016 09:23:35 +0000 (10:23 +0100)] 
client: fix format specifiers in client report

This was missing in commit 861ac013bcc54fa7b3c92cc4b43a8e2071885907.

9 years agocmdmon: update protocol changelog
Miroslav Lichvar [Fri, 29 Jan 2016 15:50:43 +0000 (16:50 +0100)] 
cmdmon: update protocol changelog

9 years agocmdmon: define new types for CLIENT_ACCESSES_BY_INDEX command
Miroslav Lichvar [Fri, 29 Jan 2016 14:46:56 +0000 (15:46 +0100)] 
cmdmon: define new types for CLIENT_ACCESSES_BY_INDEX command

There was an incompatible change in the client access report. To avoid
bumping the protocol version drop support for the original request/reply
types and define new CLIENT_ACCESSES_BY_INDEX2 types as a newer version
of the command.

9 years agocmdmon: allow unhandled commands
Miroslav Lichvar [Fri, 29 Jan 2016 14:35:32 +0000 (15:35 +0100)] 
cmdmon: allow unhandled commands

Replace the assert() with a debug message to not crash if someone
forgets to implement a newly defined command.

9 years agocmdmon: reply to invalid commands
Miroslav Lichvar [Fri, 29 Jan 2016 14:32:47 +0000 (15:32 +0100)] 
cmdmon: reply to invalid commands

If an unknown command is received (e.g. from a future client), it should
get a reply and print an error code instead of timing out.

9 years agocmdmon: update debug messages
Miroslav Lichvar [Fri, 29 Jan 2016 14:06:43 +0000 (15:06 +0100)] 
cmdmon: update debug messages

9 years agocmdmon: use 32-bit fields in client access report
Miroslav Lichvar [Fri, 29 Jan 2016 12:46:38 +0000 (13:46 +0100)] 
cmdmon: use 32-bit fields in client access report

The clientlog record still uses 16-bit integers to count dropped
packets, but this will avoid an incompatible change in the command
reply if there will be a need to count more than 2^16 drops.

9 years agoclientlog: don't allow rate limiting with noclientlog
Miroslav Lichvar [Thu, 28 Jan 2016 13:52:34 +0000 (14:52 +0100)] 
clientlog: don't allow rate limiting with noclientlog

9 years agodoc: update description of clients command
Miroslav Lichvar [Fri, 29 Jan 2016 16:18:14 +0000 (17:18 +0100)] 
doc: update description of clients command

9 years agodoc: describe rate limiting directives
Miroslav Lichvar [Thu, 28 Jan 2016 13:23:26 +0000 (14:23 +0100)] 
doc: describe rate limiting directives

9 years agoexamples: update for recent changes
Miroslav Lichvar [Mon, 25 Jan 2016 16:55:20 +0000 (17:55 +0100)] 
examples: update for recent changes

9 years agodoc: update keyfile description
Miroslav Lichvar [Mon, 25 Jan 2016 16:24:08 +0000 (17:24 +0100)] 
doc: update keyfile description

9 years agoconf: set logchange to 1 second by default
Miroslav Lichvar [Tue, 26 Jan 2016 14:35:55 +0000 (15:35 +0100)] 
conf: set logchange to 1 second by default

logchange is now always enabled, with 1 second threshold by default.

9 years agoclient: generate key 1 by default in keygen command
Miroslav Lichvar [Mon, 25 Jan 2016 17:03:39 +0000 (18:03 +0100)] 
client: generate key 1 by default in keygen command

9 years agokeys: warn about short key only if used by source
Miroslav Lichvar [Mon, 25 Jan 2016 15:50:51 +0000 (16:50 +0100)] 
keys: warn about short key only if used by source

After restricting authentication of servers and peers to the specified
key, a short key in the key file is a security problem from the client's
point of view only if it's specified for a source.

9 years agopktlength: fix compiler warning on Mac OS X
Miroslav Lichvar [Mon, 25 Jan 2016 11:33:42 +0000 (12:33 +0100)] 
pktlength: fix compiler warning on Mac OS X

9 years agocmdmon: extend initialisation tests
Miroslav Lichvar [Tue, 19 Jan 2016 15:53:28 +0000 (16:53 +0100)] 
cmdmon: extend initialisation tests

9 years agopktlength: rework code to use tables
Miroslav Lichvar [Tue, 19 Jan 2016 15:52:52 +0000 (16:52 +0100)] 
pktlength: rework code to use tables

9 years agoclient: add serverstats command
Miroslav Lichvar [Mon, 18 Jan 2016 16:13:26 +0000 (17:13 +0100)] 
client: add serverstats command

9 years agocmdmon: add serverstats command
Miroslav Lichvar [Mon, 18 Jan 2016 16:09:36 +0000 (17:09 +0100)] 
cmdmon: add serverstats command

Add a new command to obtain a server report with the new clientlog
statistics.

9 years agoclientlog: count total number of hits and drops
Miroslav Lichvar [Mon, 18 Jan 2016 16:08:23 +0000 (17:08 +0100)] 
clientlog: count total number of hits and drops

Count total number of NTP and command hits. Count also number of log
records that were replaced when the hash table couldn't be resized due
to the memory limit.

9 years agoMerge branch '2.2-security'
Miroslav Lichvar [Wed, 20 Jan 2016 11:18:42 +0000 (12:18 +0100)] 
Merge branch '2.2-security'

9 years agodoc: update NEWS 2.2-security 2.2.1
Miroslav Lichvar [Mon, 11 Jan 2016 14:42:36 +0000 (15:42 +0100)] 
doc: update NEWS

9 years agotest: extend 105-ntpauth to test symmetric mode
Miroslav Lichvar [Mon, 11 Jan 2016 15:40:29 +0000 (16:40 +0100)] 
test: extend 105-ntpauth to test symmetric mode

9 years agotest: allow setting options for each peer side separately
Miroslav Lichvar [Mon, 11 Jan 2016 15:23:07 +0000 (16:23 +0100)] 
test: allow setting options for each peer side separately

9 years agontp: restrict authentication of server/peer to specified key
Miroslav Lichvar [Fri, 8 Jan 2016 14:03:09 +0000 (15:03 +0100)] 
ntp: restrict authentication of server/peer to specified key

When a server/peer was specified with a key number to enable
authentication with a symmetric key, packets received from the
server/peer were accepted if they were authenticated with any of
the keys contained in the key file and not just the specified key.

This allowed an attacker who knew one key of a client/peer to modify
packets from its servers/peers that were authenticated with other
keys in a man-in-the-middle (MITM) attack. For example, in a network
where each NTP association had a separate key and all hosts had only
keys they needed, a client of a server could not attack other clients
of the server, but it could attack the server and also attack its own
clients (i.e. modify packets from other servers).

To not allow the server/peer to be authenticated with other keys
extend the authentication test to check if the key ID in the received
packet is equal to the configured key number. As a consequence, it's
no longer possible to authenticate two peers to each other with two
different keys, both peers have to be configured to use the same key.

This issue was discovered by Matt Street of Cisco ASIG.

9 years agoprivops: reload DNS configuration
Miroslav Lichvar [Fri, 15 Jan 2016 15:58:12 +0000 (16:58 +0100)] 
privops: reload DNS configuration

The helper process needs to call res_init() before DNS_Name2IPAddress()
in order to see changes in resolv.conf.

9 years agoclient: improve waitsync help text
Miroslav Lichvar [Thu, 14 Jan 2016 13:21:34 +0000 (14:21 +0100)] 
client: improve waitsync help text

9 years agoclient: add keygen command
Miroslav Lichvar [Thu, 14 Jan 2016 13:20:54 +0000 (14:20 +0100)] 
client: add keygen command

Add a new command that will generate a random key from /dev/urandom with
given ID, hash function and length.

9 years agoutil: add UTI_GetRandomBytesUrandom()
Miroslav Lichvar [Wed, 13 Jan 2016 10:57:36 +0000 (11:57 +0100)] 
util: add UTI_GetRandomBytesUrandom()

This function always uses /dev/urandom, even if arc4random() is
available, and is intended for generating long-term keys.

9 years agokeys: warn when loaded key is shorter than 80 bits
Miroslav Lichvar [Wed, 13 Jan 2016 18:29:15 +0000 (19:29 +0100)] 
keys: warn when loaded key is shorter than 80 bits

Consider 80 bits as the absolute minimum for a secure symmetric key.  If
a loaded key is shorter, send a warning to the system log to encourage
the admin to replace it with a longer key.

9 years agosys_linux: use privops helper when running with seccomp filter
Miroslav Lichvar [Tue, 12 Jan 2016 16:52:34 +0000 (17:52 +0100)] 
sys_linux: use privops helper when running with seccomp filter

Enable the PRV_Name2IPAddress() function with seccomp support and start
the helper process before loading the seccomp filter (but after dropping
root privileges). This will move the getaddrinfo() call outside the
seccomp filter and should make it more reliable as the list of required
system calls won't depend on what glibc NSS modules are used on the
system.

9 years agoprivops: add support for privileged DNS_Name2IPAddress()
Miroslav Lichvar [Tue, 12 Jan 2016 16:50:25 +0000 (17:50 +0100)] 
privops: add support for privileged DNS_Name2IPAddress()

9 years agonameserv: return at most 16 addresses from DNS_Name2IPAddress()
Miroslav Lichvar [Tue, 12 Jan 2016 14:29:53 +0000 (15:29 +0100)] 
nameserv: return at most 16 addresses from DNS_Name2IPAddress()

This is the same limit as in the asynchronous resolver. Use common macro
for all buffers storing IP addresses.

9 years agotest: don't check packet intervals in 009-sourceselection
Miroslav Lichvar [Thu, 7 Jan 2016 16:28:41 +0000 (17:28 +0100)] 
test: don't check packet intervals in 009-sourceselection

Since commit 8b235297, which changed address hashing, the first packet
is not sent to the first server and doesn't have the extra delay. If the
last packet is sent to the first server, the mean outgoing interval will
be significantly longer than the incoming interval and the check will
fail.

9 years agotest: add 120-selectoptions
Miroslav Lichvar [Thu, 7 Jan 2016 15:19:02 +0000 (16:19 +0100)] 
test: add 120-selectoptions

9 years agosources: add require option
Miroslav Lichvar [Thu, 7 Jan 2016 15:17:17 +0000 (16:17 +0100)] 
sources: add require option

Require that at least one of the sources specified with this option is
selectable (i.e. recently reachable and not a falseticker) before
updating the clock. Together with the trust option this may be useful to
allow a trusted, but not very precise, reference clock or a trusted
authenticated NTP source to be safely combined with unauthenticated NTP
sources in order to improve the accuracy of the clock. They can be
selected and used for synchronization only if they agree with the
trusted and required source.

9 years agosources: add trust option
Miroslav Lichvar [Thu, 7 Jan 2016 10:12:55 +0000 (11:12 +0100)] 
sources: add trust option

Assume time from a source that is specified with the trust option is
always true.  It can't be rejected as falseticker in the source
selection if sources that are specified without this option don't agree
with it.

9 years agosources: turn select options into flags
Miroslav Lichvar [Fri, 18 Dec 2015 15:18:53 +0000 (16:18 +0100)] 
sources: turn select options into flags

This will allow adding new options for source selection which can be
combined with others.

9 years agosources: fix formatting of selection intervals in comment
Miroslav Lichvar [Fri, 18 Dec 2015 09:18:16 +0000 (10:18 +0100)] 
sources: fix formatting of selection intervals in comment

It was mangled in commit 6f84d2fac16cb57a1bf3accf4ea211811b0abfab.

9 years agorefclock: ignore samples with unsynchronised leap status
Miroslav Lichvar [Fri, 18 Dec 2015 14:17:06 +0000 (15:17 +0100)] 
refclock: ignore samples with unsynchronised leap status

9 years agorefclock: describe fields in SOCK sample
Miroslav Lichvar [Fri, 18 Dec 2015 11:43:28 +0000 (12:43 +0100)] 
refclock: describe fields in SOCK sample

9 years agofix undefined shift operations on signed integers
Miroslav Lichvar [Thu, 17 Dec 2015 11:08:57 +0000 (12:08 +0100)] 
fix undefined shift operations on signed integers

9 years agoconf: update default ratelimit configuration
Miroslav Lichvar [Thu, 17 Dec 2015 08:44:21 +0000 (09:44 +0100)] 
conf: update default ratelimit configuration

9 years agoclientlog: use token buckets for response rate limiting
Miroslav Lichvar [Wed, 16 Dec 2015 15:22:01 +0000 (16:22 +0100)] 
clientlog: use token buckets for response rate limiting

Replace thresholds that activated rate limiting with token buckets.
Response rate limiting is now not just active or inactive, the interval
and burst options directly control the response rate.

9 years agoclientlog: refactor updating of record data
Miroslav Lichvar [Mon, 14 Dec 2015 16:05:02 +0000 (17:05 +0100)] 
clientlog: refactor updating of record data

9 years agodoc: update description of -u option and user directive
Miroslav Lichvar [Thu, 10 Dec 2015 14:22:55 +0000 (15:22 +0100)] 
doc: update description of -u option and user directive

9 years agosys_linux: keep CAP_NET_BIND_SERVICE only if NTP port can be opened
Miroslav Lichvar [Thu, 10 Dec 2015 13:26:16 +0000 (14:26 +0100)] 
sys_linux: keep CAP_NET_BIND_SERVICE only if NTP port can be opened

If port is set to 0 in the config file, the server port cannot be opened
and there is no point in keeping the binding capability.

9 years agosys: remove unused code
Miroslav Lichvar [Thu, 10 Dec 2015 11:54:34 +0000 (12:54 +0100)] 
sys: remove unused code

9 years agosys_solaris: add support for dropping root privileges
Miroslav Lichvar [Thu, 10 Dec 2015 10:39:40 +0000 (11:39 +0100)] 
sys_solaris: add support for dropping root privileges

On Solaris, use the privops helper for the ntp_adjtime(),
settimeofday(), and bind() system calls.

9 years agosys_solaris: fix building with current timex driver
Miroslav Lichvar [Thu, 10 Dec 2015 10:58:57 +0000 (11:58 +0100)] 
sys_solaris: fix building with current timex driver

The SYS_Timex_InitialiseWithFunctions() call in the Solaris driver
wasn't updated in commit d6fdae5f1d133026f48b434dcd24ceb70dc30e63.

9 years agosys_netbsd: add support for dropping root privileges on FreeBSD
Miroslav Lichvar [Thu, 10 Dec 2015 08:33:56 +0000 (09:33 +0100)] 
sys_netbsd: add support for dropping root privileges on FreeBSD

On FreeBSD, use the privops helper for the adjtime(), ntp_adjtime(),
settimeofday(), and bind() system calls.

9 years agosys_timex: add support for ntp_adjtime() via privops
Miroslav Lichvar [Wed, 9 Dec 2015 17:15:46 +0000 (18:15 +0100)] 
sys_timex: add support for ntp_adjtime() via privops

9 years agoprivops: add support for privileged ntp_adjtime()
Miroslav Lichvar [Wed, 9 Dec 2015 17:11:09 +0000 (18:11 +0100)] 
privops: add support for privileged ntp_adjtime()

9 years agosys_timex: move inclusion of sys/timex.h to sysincl.h
Miroslav Lichvar [Thu, 10 Dec 2015 09:53:45 +0000 (10:53 +0100)] 
sys_timex: move inclusion of sys/timex.h to sysincl.h

It will be needed by privops.

9 years agoprivops: ignore signals in helper
Miroslav Lichvar [Thu, 10 Dec 2015 15:10:31 +0000 (16:10 +0100)] 
privops: ignore signals in helper

If the whole process group receives a signal (e.g. CTRL-C in terminal),
the helper process needs to keep running until it gets the QUIT request,
so the system drivers can still use it in their finalisation, e.g. to
cancel remaining slew.

9 years agoprivops: compile only required helper functions
Miroslav Lichvar [Thu, 10 Dec 2015 07:44:05 +0000 (08:44 +0100)] 
privops: compile only required helper functions

9 years agoprivops: return from PRV functions with helper response code
Miroslav Lichvar [Wed, 9 Dec 2015 16:41:48 +0000 (17:41 +0100)] 
privops: return from PRV functions with helper response code

In receive_reponse() don't interpret return codes in helper responses as
a non-zero value may not necessarily mean an error. Just copy errno if
it's not zero and let PRV_* functions deal with the return code.

9 years agoprivops: make naming of fields and functions more consistent
Miroslav Lichvar [Wed, 9 Dec 2015 14:37:47 +0000 (15:37 +0100)] 
privops: make naming of fields and functions more consistent

9 years agoutil: add function for dropping root privileges
Miroslav Lichvar [Tue, 8 Dec 2015 16:16:45 +0000 (17:16 +0100)] 
util: add function for dropping root privileges

Share the code for dropping supplementary groups and setting effective,
saved, and real user UID/GID between system drivers.

9 years agomain: initialise privops sooner
Miroslav Lichvar [Wed, 9 Dec 2015 13:59:12 +0000 (14:59 +0100)] 
main: initialise privops sooner

System drivers may need it in their initialisation.

9 years agosys_macosx: fix adjustment correction after step
Bryan Christianson [Wed, 9 Dec 2015 07:11:06 +0000 (20:11 +1300)] 
sys_macosx: fix adjustment correction after step

The desired offset was being added to the current time instead of being
subtracted.

9 years agomain: fix compiler warning
Miroslav Lichvar [Tue, 8 Dec 2015 16:37:01 +0000 (17:37 +0100)] 
main: fix compiler warning

9 years agosys_netbsd: use privileged helper for socket binding
Miroslav Lichvar [Tue, 8 Dec 2015 16:19:33 +0000 (17:19 +0100)] 
sys_netbsd: use privileged helper for socket binding

When dropping root privileges, start the helper to allow binding
of server sockets later.

9 years agoconfigure: rework setting of privops macros
Miroslav Lichvar [Tue, 8 Dec 2015 15:43:08 +0000 (16:43 +0100)] 
configure: rework setting of privops macros

Prepare a list of required privileged operations first and from that
define the PRIVOPS macros. This will reduce the amount of code that will
be needed when the privileged helper is used on other platforms.

9 years agoconfigure: fix check of date output
Miroslav Lichvar [Tue, 8 Dec 2015 11:55:05 +0000 (12:55 +0100)] 
configure: fix check of date output

9 years agoprivops: refactor initialisation/finalisation
Miroslav Lichvar [Tue, 8 Dec 2015 13:10:29 +0000 (14:10 +0100)] 
privops: refactor initialisation/finalisation

Rename PRV_Initialise() to PRV_StartHelper() and add a new
initialisation function, which just sets the helper fd to -1. Move
the initialision/finalisation calls from the system drivers to main.c.
If privops is not included in the build, define empty macros for the
function names, so their calls don't have to be wrapped in #ifdefs.

9 years agoprivops: wait for helper pid
Miroslav Lichvar [Tue, 8 Dec 2015 15:09:02 +0000 (16:09 +0100)] 
privops: wait for helper pid

Save the pid of the helper process and replace wait() with waitpid().

9 years agoprivops: stop helper on exit
Miroslav Lichvar [Tue, 8 Dec 2015 10:10:52 +0000 (11:10 +0100)] 
privops: stop helper on exit

With SOCK_DGRAM sockets, the helper doesn't stop as there is no error
received when the socket is closed on the daemon side.

Add a QUIT operation to the protocol which is requested when the daemon
is exiting. It has no response. Register the stopping function with
atexit() to stop the helper even when the daemon is not exiting cleanly,
e.g. due to a fatal error.

9 years agoprivops: split send_to_helper()
Miroslav Lichvar [Tue, 8 Dec 2015 14:54:43 +0000 (15:54 +0100)] 
privops: split send_to_helper()

Split out the sending part of the function into send_request() and
rename it to submit_request(). This will be useful to send a request
without waiting for a response.

Also, remove the fd parameter from the functions and just use helper_fd
directly.

9 years agoprivops: use SOCK_SEQPACKET sockets when supported
Miroslav Lichvar [Tue, 8 Dec 2015 09:20:20 +0000 (10:20 +0100)] 
privops: use SOCK_SEQPACKET sockets when supported

SOCK_SEQPACKET is preferred over SOCK_DGRAM for communication with the
helper as the process will get an error when the other end of the socket
is closed. It's not supported on all platforms.

If SOCK_SEQPACKET is defined, try creating the pair of sockets with this
type first and if that fails, fall back to SOCK_DGRAM.

9 years agosys_linux: allow mremap in seccomp filter
Miroslav Lichvar [Fri, 4 Dec 2015 11:51:28 +0000 (12:51 +0100)] 
sys_linux: allow mremap in seccomp filter

9 years agosys_macosx: synchronise RTC from system time
Bryan Christianson [Thu, 3 Dec 2015 11:15:49 +0000 (00:15 +1300)] 
sys_macosx: synchronise RTC from system time

When the rtcsync directive is specified in the chronyd config file,
chronyd will update the RTC via settimeofday() every 60 minutes if
the system time is synchronised to NTP.

9 years agoclient: print invalid intervals as dash
Miroslav Lichvar [Wed, 2 Dec 2015 17:21:07 +0000 (18:21 +0100)] 
client: print invalid intervals as dash

Instead of printing some large arbitrary values use dash in the LastRx
column of the sources output and the Last/Int columns in the clients
output when no sample or hit is recorded.

9 years agosourcestats: use maximum value as invalid age in source report
Miroslav Lichvar [Wed, 2 Dec 2015 17:10:22 +0000 (18:10 +0100)] 
sourcestats: use maximum value as invalid age in source report

9 years agoclientlog: fix counting of command drops
Miroslav Lichvar [Wed, 2 Dec 2015 18:14:19 +0000 (19:14 +0100)] 
clientlog: fix counting of command drops

9 years agoclientlog: save time of last hit with sub-second resolution
Miroslav Lichvar [Wed, 2 Dec 2015 16:49:40 +0000 (17:49 +0100)] 
clientlog: save time of last hit with sub-second resolution

Instead of time_t use a 32-bit fixed point representation with 4-bit
fraction to save the time of the last hit. The rate can now be measured
up to 16 packets per second. Maximum interval between hits is about 4
years.

9 years agoconf: inline one-line parse_* functions
Miroslav Lichvar [Wed, 2 Dec 2015 11:51:15 +0000 (12:51 +0100)] 
conf: inline one-line parse_* functions

9 years agomain: assert supported integer size, representation and conversion
Miroslav Lichvar [Wed, 2 Dec 2015 11:18:01 +0000 (12:18 +0100)] 
main: assert supported integer size, representation and conversion

Abort immediately on start if chronyd is compiled on a platform with int
shorter than 32 bits, using other representation than two's complement,
or unexpected conversion of large unsigned integers to signed.

9 years agofix undefined shift operations on signed integers
Miroslav Lichvar [Wed, 2 Dec 2015 11:06:01 +0000 (12:06 +0100)] 
fix undefined shift operations on signed integers

9 years agoarray: always return non-NULL pointer from ARR_GetElements()
Miroslav Lichvar [Tue, 1 Dec 2015 13:24:36 +0000 (14:24 +0100)] 
array: always return non-NULL pointer from ARR_GetElements()

Some libc calls like memcpy() expect the pointer to be valid even when
the size is zero and there is nothing to do. Instead of checking the
size before all such calls, modify ARR_GetElements() to return a pointer
to the array instance itself if data was not allocated yet.

9 years agocontrib: update chronylogrotate.sh script
Bryan Christianson [Sun, 29 Nov 2015 21:13:03 +0000 (10:13 +1300)] 
contrib: update chronylogrotate.sh script

1. Remove obsolete options when running chronyc
2. Add copyright/licence notice
3. Use logger utility to print/store error messages

9 years agocmdmon: update CLIENT_ACCESSES_BY_INDEX command
Miroslav Lichvar [Fri, 27 Nov 2015 14:25:24 +0000 (15:25 +0100)] 
cmdmon: update CLIENT_ACCESSES_BY_INDEX command

Add new fields from clientlog to the report and print them in chronyc.
Rework the code to skip empty records in the hash table. The reply no
longer has variable length, all client fields are filled even if some
are empty. Reply with RPY_NULL when the facility is disabled.

9 years agoclientlog: limit response rate
Miroslav Lichvar [Wed, 25 Nov 2015 12:23:52 +0000 (13:23 +0100)] 
clientlog: limit response rate

When the measured NTP or command request rate of a client exceeds
a threshold, reply only to a small fraction of the requests to reduce
the network traffic. Clients are allowed to send a burst of requests.
Try to detect broken clients which increase the request rate when not
getting replies and suppress the rate limiting for them.

Add ratelimit and cmdratelimit directives to configure the thresholds,
bursts and leak rates independently for NTP and command response rate
limiting. Both are disabled by default. Commands from localhost are
never limited.

9 years agoclientlog: measure request rates
Miroslav Lichvar [Wed, 25 Nov 2015 08:57:12 +0000 (09:57 +0100)] 
clientlog: measure request rates

Extend the record with estimates of the current client's NTP and command
request rates. Store them as 8-bit scaled log2 values to save memory.

9 years agoclientlog: store records in hash table instead of tree
Miroslav Lichvar [Tue, 24 Nov 2015 13:51:15 +0000 (14:51 +0100)] 
clientlog: store records in hash table instead of tree

This simplifies the code and allows older records to be reused when no
more memory can be allocated for new addresses. Each slot of the hash
table has 16 records and there is no chaining between different slots.
Reused records may be newer than records in other slots, but the search
time remains constant.

9 years agoclientlog: reduce amount of logged information
Miroslav Lichvar [Mon, 23 Nov 2015 14:53:45 +0000 (15:53 +0100)] 
clientlog: reduce amount of logged information

Don't log NTP peer access and auth/bad command access. Also, change
types for logging number of hits from long to uint32_t. This reduces the
size of the node and allows more clients to be monitored in the same
amount of memory.

9 years agoconf: don't allow disabling clientloglimit
Miroslav Lichvar [Tue, 24 Nov 2015 11:30:54 +0000 (12:30 +0100)] 
conf: don't allow disabling clientloglimit

Don't treat zero as a special value disabling clientloglimit. It's not
useful, the amount of available memory is never unlimited.

9 years agoutil: add macros for maximum, minimum and clamp
Miroslav Lichvar [Fri, 27 Nov 2015 10:03:16 +0000 (11:03 +0100)] 
util: add macros for maximum, minimum and clamp

If MAX/MIN are defined in system headers, undefine them first.

9 years agoutil: add function for IP address hashing
Miroslav Lichvar [Mon, 23 Nov 2015 14:24:33 +0000 (15:24 +0100)] 
util: add function for IP address hashing

Move the hashing function from find_slot() in ntp_sources to make it
available to clientlog and improve the hashing a bit.

9 years agocmdmon: tidy up declarations in read_from_cmd_socket()
Miroslav Lichvar [Thu, 26 Nov 2015 09:08:49 +0000 (10:08 +0100)] 
cmdmon: tidy up declarations in read_from_cmd_socket()

9 years agosys_macosx: tidy up includes
Bryan Christianson [Tue, 24 Nov 2015 09:07:58 +0000 (22:07 +1300)] 
sys_macosx: tidy up includes

Use "sysincl.h" in place of the common system include files

9 years agosys_macosx: drop root privileges
Bryan Christianson [Tue, 24 Nov 2015 08:01:59 +0000 (21:01 +1300)] 
sys_macosx: drop root privileges

Run chronyd as a non-privileged user, using the privops helper to
perform adjtime(), settimeofday() and bind() functions on its behalf.

9 years agoadd support for privilege separation
Bryan Christianson [Fri, 20 Nov 2015 10:43:19 +0000 (23:43 +1300)] 
add support for privilege separation

Privileged helper that will perform adjtime(), settimeofday(), bind() on
behalf of chronyd when running as non-root user.