]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
9 years agosources: add support for orphan sources
Miroslav Lichvar [Wed, 30 Mar 2016 15:39:49 +0000 (17:39 +0200)] 
sources: add support for orphan sources

When the local reference is configured with the orphan option, NTP
sources that have stratum equal to the configured local stratum are
considered to be orphans (i.e. serving local time while not being
synchronised with real time) and are excluded from the normal source
selection. Sources with stratum larger than the local stratum are
considered to be directly on indirectly synchronised to an orphan and
are always ignored.

If no selectable source is available and all orphan sources have
reference IDs larger than the local ID, no source will be selected and
the local reference mode will be activated at some point, i.e. this host
will become an orphan. Otherwise, the orphan source with the smallest
reference ID will be selected. This ensures a group of servers polling
each other (with the same orphan configuration) which have no external
source can settle down to a state where only one server is serving its
local unsychronised time and others are synchronised to it.

9 years agoreference: add orphan mode to local reference
Miroslav Lichvar [Wed, 30 Mar 2016 15:39:14 +0000 (17:39 +0200)] 
reference: add orphan mode to local reference

Add orphan option to the local directive. It will enable an orphan mode
compatible with ntpd.

9 years agoreference: activate local reference with large root distance
Miroslav Lichvar [Wed, 30 Mar 2016 15:12:12 +0000 (17:12 +0200)] 
reference: activate local reference with large root distance

Since the update to NTPv4, when the clock is in the synchronised state
and the clock updates stop (e.g. sources become unreachable), it doesn't
switch to the unsynchronised state and the local reference is never
activate. This can be a problem for clients that rely on the server to
always have root distance below some value (e.g. chronyd's maxdistance).

Add a timer that will activate the local reference when the root
distance reaches a specified threshold. It can be configured with the
distance option in the local directive (by default 1.0 second).

9 years agoconf: rework local directive to have default stratum
Miroslav Lichvar [Wed, 30 Mar 2016 13:58:45 +0000 (15:58 +0200)] 
conf: rework local directive to have default stratum

Allow the local directive to be specified without the stratum field.
It's an option now, with default value 10. Also, move the parsing code
to cmdparse.c to make it available to the client.

9 years agontp: add function to get local reference ID
Miroslav Lichvar [Wed, 30 Mar 2016 09:02:04 +0000 (11:02 +0200)] 
ntp: add function to get local reference ID

When a valid NTP reply is received, save the local address (e.g. from
IP_PKTINFO), so the reference ID which would the source use for this
host can be calculated when needed.

9 years agosys_linux: include <termios.h> for TCGETS
Miroslav Lichvar [Tue, 29 Mar 2016 08:06:21 +0000 (10:06 +0200)] 
sys_linux: include <termios.h> for TCGETS

9 years agolocal: make maximum frequency offset configurable
Miroslav Lichvar [Tue, 22 Mar 2016 16:07:46 +0000 (17:07 +0100)] 
local: make maximum frequency offset configurable

Add maxdrift directive to set the maximum assumed drift of the clock,
which sets the maximum frequency offset chronyd is allowed to use to
to correct the drift.

9 years agosources: try to replace NTP sources with bad distance
Miroslav Lichvar [Tue, 22 Mar 2016 16:01:38 +0000 (17:01 +0100)] 
sources: try to replace NTP sources with bad distance

Similarly to unreachable sources and falsetickers, try to replace
sources with distance larger than the limit set by the maxdistance
directive with a newly resolved address of the hostname.

9 years agoclient: ignore -v option in csv mode
Miroslav Lichvar [Fri, 18 Mar 2016 13:28:53 +0000 (14:28 +0100)] 
client: ignore -v option in csv mode

9 years agoutil: fix UTI_FloatNetworkToHost() with very small exponents
Miroslav Lichvar [Thu, 17 Mar 2016 13:28:45 +0000 (14:28 +0100)] 
util: fix UTI_FloatNetworkToHost() with very small exponents

Fix conversion of floating point numbers from the cmdmon format with
very small exponents, as for instance could be in the smoothing report
when the smoothing process ends.

This was broken in commit 8e71a46173afe01e11620980a1c7c028d7fd048f.

9 years agoclient: add CSV output mode
Miroslav Lichvar [Wed, 16 Mar 2016 14:50:47 +0000 (15:50 +0100)] 
client: add CSV output mode

Add a new option (-c) to chronyc to enable printing of reports in a
column-separated values (CSV) format. IP addresses will not be resolved
to hostnames, time will be printed as number of seconds since the epoch
and values in seconds will not be converted to other units.

9 years agoclient: rework printing of reports
Miroslav Lichvar [Wed, 16 Mar 2016 11:05:42 +0000 (12:05 +0100)] 
client: rework printing of reports

Add a new printf-like function to allow printing of all fields at once
and rework all commands which print a report to use it. Add functions
for printing of headers and information fields, and formatting of IP
addresses and reference IDs.

9 years agoutil: randomize hashing of IP addresses
Miroslav Lichvar [Mon, 14 Mar 2016 17:06:56 +0000 (18:06 +0100)] 
util: randomize hashing of IP addresses

Include a random (constant) value in the hash in UTI_IPToHash() to
randomize the order in which NTP sources are stored in the hash table
and polled on start. This change also randomizes the order of clientlog
records.

9 years agotest: make 105-ntpauth more reliable
Miroslav Lichvar [Mon, 14 Mar 2016 16:42:49 +0000 (17:42 +0100)] 
test: make 105-ntpauth more reliable

9 years agomakefile: add distclean target to test/unit/Makefile
Miroslav Lichvar [Mon, 14 Mar 2016 14:51:53 +0000 (15:51 +0100)] 
makefile: add distclean target to test/unit/Makefile

9 years agomakefile: remove Makefile in doc/Makefile on distclean
Miroslav Lichvar [Mon, 14 Mar 2016 14:50:59 +0000 (15:50 +0100)] 
makefile: remove Makefile in doc/Makefile on distclean

9 years agontp: improve error messages for socket options
Miroslav Lichvar [Mon, 14 Mar 2016 14:41:05 +0000 (15:41 +0100)] 
ntp: improve error messages for socket options

9 years agocmdmon: extend initialization checks
Miroslav Lichvar [Mon, 14 Mar 2016 14:31:11 +0000 (15:31 +0100)] 
cmdmon: extend initialization checks

Move the message size checks to a separate function and check also
header size in the command request and reply to catch incompatible
changes.

9 years agorewrite assertions with very long messages
Miroslav Lichvar [Mon, 14 Mar 2016 14:15:51 +0000 (15:15 +0100)] 
rewrite assertions with very long messages

9 years agoclient: add reselectdist to help text
Miroslav Lichvar [Fri, 11 Mar 2016 14:17:39 +0000 (15:17 +0100)] 
client: add reselectdist to help text

9 years agogit: update .gitignore
Miroslav Lichvar [Fri, 11 Mar 2016 11:46:06 +0000 (12:46 +0100)] 
git: update .gitignore

9 years agodoc: convert manual from Texinfo to AsciiDoc
Miroslav Lichvar [Mon, 7 Mar 2016 09:43:52 +0000 (10:43 +0100)] 
doc: convert manual from Texinfo to AsciiDoc

Split and convert the manual into four AsciiDoc documents, a document
about installation and three documents in the manpage type for
chrony.conf, chronyd and chronyc. The minimal man pages that were
maintained separately from the manual are replaced by full man pages
generated from AsciiDoc. Info files will no longer be provided.

Some parts of the manual are rewritten, updated or trimmed. The
introduction chapter is partially merged with README. The chapter about
typical operating scenarios is included in the chrony.conf man page.

9 years agodoc: update installation instructions 2.3
Miroslav Lichvar [Tue, 16 Feb 2016 13:22:58 +0000 (14:22 +0100)] 
doc: update installation instructions

9 years agodoc: improve description of trust option
Miroslav Lichvar [Tue, 16 Feb 2016 11:45:07 +0000 (12:45 +0100)] 
doc: improve description of trust option

9 years agotest/unit: add sources unit test
Miroslav Lichvar [Mon, 15 Feb 2016 15:08:15 +0000 (16:08 +0100)] 
test/unit: add sources unit test

9 years agotest/unit: include microseconds in default random seed
Miroslav Lichvar [Mon, 15 Feb 2016 15:05:43 +0000 (16:05 +0100)] 
test/unit: include microseconds in default random seed

9 years agotest/unit: add more helper functions
Miroslav Lichvar [Mon, 15 Feb 2016 15:05:18 +0000 (16:05 +0100)] 
test/unit: add more helper functions

9 years agotest/unit: follow chrony function naming convention
Miroslav Lichvar [Mon, 15 Feb 2016 12:13:13 +0000 (13:13 +0100)] 
test/unit: follow chrony function naming convention

9 years agotest: add ntp_sources unit test
Miroslav Lichvar [Fri, 5 Feb 2016 13:46:03 +0000 (14:46 +0100)] 
test: add ntp_sources unit test

9 years agotest: add clientlog unit test
Miroslav Lichvar [Fri, 5 Feb 2016 10:52:27 +0000 (11:52 +0100)] 
test: add clientlog unit test

9 years agoaddrfilt: remove TEST code
Miroslav Lichvar [Fri, 5 Feb 2016 10:10:44 +0000 (11:10 +0100)] 
addrfilt: remove TEST code

A test of the address filter is now included in unit tests.

9 years agotest: add addrfilt unit test
Miroslav Lichvar [Fri, 5 Feb 2016 10:08:12 +0000 (11:08 +0100)] 
test: add addrfilt unit test

9 years agotest: specify files with path in source commands
Miroslav Lichvar [Fri, 5 Feb 2016 09:52:47 +0000 (10:52 +0100)] 
test: specify files with path in source commands

This should prevent sourcing of an unrelated file found in $PATH.

9 years agotest: don't download files in tests
Miroslav Lichvar [Fri, 5 Feb 2016 09:47:16 +0000 (10:47 +0100)] 
test: don't download files in tests

Remove automatic download and compilation of clknetsim. If clknetsim is
not found, skip all simulation tests, but don't fail "make check".
Also, respect the CLKNETSIM_PATH environment variable.

9 years agogit: update .gitignore
Miroslav Lichvar [Fri, 5 Feb 2016 08:53:43 +0000 (09:53 +0100)] 
git: update .gitignore

9 years agotest: add support for unit testing
Miroslav Lichvar [Fri, 5 Feb 2016 08:52:46 +0000 (09:52 +0100)] 
test: add support for unit testing

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.