Commit Graph

218 Commits

Author SHA1 Message Date
Lennart Poettering 00df39a56a timesyncd: don't attempt to call IP_TOS sockopt on IPv6 sockets 2020-09-11 10:16:39 +02:00
Yu Watanabe c56566530b timesync: downgrade error level when the error will be ignored 2020-09-10 14:13:26 +09:00
Zbigniew Jędrzejewski-Szmek d06bd2e785 Merge pull request #16596 from poettering/event-time-rel
Conflict in src/libsystemd-network/test-ndisc-rs.c fixed manually.
2020-08-04 16:07:03 +02:00
Zbigniew Jędrzejewski-Szmek 5919bd3df3 timesync: increase retry interval more slowly
The new retry intervals are [15, 20, 26, 34, 45, 60, 80, 106, 141, 188, 250,
333, 360, ...]. This should allow graceful response if a transient network
failure is encountered. Growth is exponential, but with a small power and
capped to a non-too-large value so that we resynchronize within a few minutes
after network is restored. I made the minimum 15 s to make sure that we never
send packets more often than that.

Fixes #16492.
2020-07-30 15:15:11 +02:00
Lennart Poettering 39cf0351c5 tree-wide: make use of new relative time events in sd-event.h 2020-07-28 11:24:55 +02:00
Zbigniew Jędrzejewski-Szmek 272ac70a21 various daemons: emit Stopping... notification before destructing the manager object
This is mostly cosmetic, but let's reorder the destructors so that
we do the final sd_notify() call before we run the destructor for
the manager object.
2020-07-02 17:12:23 +02:00
Lennart Poettering 40af3d020f shared: split out property get helpers
No code changes, just some refactoring.
2020-06-30 15:10:17 +02:00
Lennart Poettering 4f9ff96a55 conf-parser: return mtime in config_parse() and friends
This is a follow-up for 9f83091e3c.

Instead of reading the mtime off the configuration files after reading,
let's do so before reading, but with the fd we read the data from. This
is not only cleaner (as it allows us to save one stat()), but also has
the benefit that we'll detect changes that happen while we read the
files.

This also reworks unit file drop-ins to use the common code for
determining drop-in mtime, instead of reading system clock for that.
2020-06-02 19:32:20 +02:00
Lennart Poettering fb29cdbef2 tree-wide: make sure our control buffers are properly aligned
We always need to make them unions with a "struct cmsghdr" in them, so
that things properly aligned. Otherwise we might end up at an unaligned
address and the counting goes all wrong, possibly making the kernel
refuse our buffers.

Also, let's make sure we initialize the control buffers to zero when
sending, but leave them uninitialized when reading.

Both the alignment and the initialization thing is mentioned in the
cmsg(3) man page.
2020-05-07 14:39:44 +02:00
Lennart Poettering 3691bcf3c5 tree-wide: use recvmsg_safe() at various places
Let's be extra careful whenever we return from recvmsg() and see
MSG_CTRUNC set. This generally means we ran into a programming error, as
we didn't size the control buffer large enough. It's an error condition
we should at least log about, or propagate up. Hence do that.

This is particularly important when receiving fds, since for those the
control data can be of any size. In particular on stream sockets that's
nasty, because if we miss an fd because of control data truncation we
cannot recover, we might not even realize that we are one off.

(Also, when failing early, if there's any chance the socket might be
AF_UNIX let's close all received fds, all the time. We got this right
most of the time, but there were a few cases missing. God, UNIX is hard
to use)
2020-04-23 09:41:47 +02:00
Lennart Poettering ac9f55ed40 tree-wide: implement new log control API dbus interface in all our daemons 2020-04-21 17:08:16 +02:00
Zbigniew Jędrzejewski-Szmek 105a1a36cd tree-wide: fix spelling of lookup and setup verbs
"set up" and "look up" are the verbs, "setup" and "lookup" are the nouns.
2020-03-03 15:02:53 +01:00
Lennart Poettering ce96c9cb1a timesyncd: log louder when we refuse a server due to root distance
This is something people should know about, since it's caused by
misconfiguration.

Fixes: #13912
2020-01-21 15:20:17 +01:00
Yu Watanabe 92133d2878 tree-wide: drop socket.h when socket-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe f21e58b47d tree-wide: drop time.h when time-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe f5947a5e92 tree-wide: drop missing.h 2019-10-31 17:57:03 +09:00
cbzxt 37afb0ac78 Updated log message when the timesync happens for the first time (#13624) 2019-09-26 00:02:46 +09:00
Zbigniew Jędrzejewski-Szmek 8c227e7f2b Drop RATELIMIT macros
Using plain structure initialization is both shorter _and_ more clearer.
We get type safety for free.
2019-09-20 16:05:53 +02:00
Zbigniew Jędrzejewski-Szmek e5ea741c62 timesyncd: add ntp-units.d/ entry for timesync
Priority is 80. At least in Fedora, chrony uses 50, and ntpd 60.
timesyncd has lower priority, because if people install those other packages,
it's most likely on purpose. timesyncd is always installed and provides
less functionality.
2019-07-22 15:21:23 +02:00
Lennart Poettering 0892f3f999
Merge pull request #12420 from mrc0mmand/coccinelle-tweaks
Coccinelle improvements
2019-04-30 11:37:19 +02:00
Ben Boeckel 5238e95759 codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
Frantisek Sumsal 55033662f9 tree-wide: drop !! casts to booleans
Done by coccinelle/bool-cast.cocci
2019-04-28 14:32:19 +02:00
Zbigniew Jędrzejewski-Szmek ca78ad1de9 headers: remove unneeded includes from util.h
This means we need to include many more headers in various files that simply
included util.h before, but it seems cleaner to do it this way.
2019-03-27 11:53:12 +01:00
Niklas Hambüchen 3a1e46f7ae timesyncd: Improve sync log message. Fixes #11548.
This makes it clear that the user should not expect more log messages
each time the time is synchronised.
2019-01-24 23:52:24 +01:00
Lennart Poettering 92e31da100 tree-wide: make sure to flush/close all bus connections when our daemons exit
Let's make sure everything is written out ebfore we exit, so that no
messages keep our bus connections referenced.

Fixes: #11462
2019-01-17 16:12:38 +01:00
Zbigniew Jędrzejewski-Szmek 690f02f4b8 timesyncd,resolved,machinectl: drop calls to sd_event_get_exit_code()
In all three cases, sd_event_loop() will return the exit code anyway.
If sd_event_loop() returns negative, failure is logged and results in an
immediate return. Otherwise, we don't care if sd_event_loop() returns 0
or positive, because the return value feeds into DEFINE_MAIN_FUNCTION(), which
doesn't make the distinction.
2019-01-08 23:26:07 +01:00
Lennart Poettering 1a126325eb timesync: fix serialization of IP address
Fixes: #11169
2018-12-18 00:59:14 +01:00
Yu Watanabe 7082bb05ad timesync: use typesafe resolve_getaddrinfo() 2018-12-17 10:02:36 +09:00
Yu Watanabe 82310c7981 timesync: define main through macro 2018-12-08 18:09:40 +09:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Lennart Poettering 6bf3c61c57 log: introduce new helper call log_setup_service()
Let's reduce the common boilerplate and have a single setup function
used by all service code to setup logging.
2018-11-20 11:18:22 +01:00
Yu Watanabe 14cb109d45 tree-wide: replace 'unsigned int' with 'unsigned' 2018-10-19 22:19:12 +02:00
Yu Watanabe 9e5b649655 tree-wide: use setsockopt_int() more 2018-10-19 05:52:42 +09:00
Lennart Poettering 2ff48e981e tree-wide: introduce setsockopt_int() helper and make use of it everywhere
As suggested by @heftig:

6d5e65f645 (commitcomment-30938667)
2018-10-18 19:50:29 +02:00
Lennart Poettering 6d5e65f645 tree-wide: add a single version of "static const int one = 1"
All over the place we define local variables for the various sockopts
that take a bool-like "int" value. Sometimes they are const, sometimes
static, sometimes both, sometimes neither.

Let's clean this up, introduce a common const variable "const_int_one"
(as well as one matching "const_int_zero") and use it everywhere, all
acorss the codebase.
2018-10-15 19:40:51 +02:00
Zbigniew Jędrzejewski-Szmek b8b20f5a6a timesyncd: no need to reload dbus now 2018-09-20 16:52:02 +02:00
Zbigniew Jędrzejewski-Szmek 6d7c403324 tests: use a helper function to parse environment and open logging
The advantages are that we save a few lines, and that we can override
logging using environment variables in more test executables.
2018-09-14 09:29:57 +02:00
Lennart Poettering fafff8f1ff user-util: rework get_user_creds()
Let's fold get_user_creds_clean() into get_user_creds(), and introduce a
flags argument for it to select "clean" behaviour. This flags parameter
also learns to other new flags:

- USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for
  root/nobody are only synthesized as fallback. Normally, the synthesized
  records take precedence over what is in the user database.  With this
  flag set this is reversed, and the user database takes precedence, and
  the synthesized records are only used if they are missing there. This
  flag should be set in cases where doing NSS is deemed safe, and where
  there's interest in knowing the correct shell, for example if the
  admin changed root's shell to zsh or suchlike.

- USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by
  numeric value, and there's no user/group record for it accept it
  anyway. This allows us to fix #9767

This then also ports all users to set the most appropriate flags.

Fixes: #9767

[zj: remove one isempty() call]
2018-08-20 15:58:21 +02:00
Yu Watanabe 8b7140dbd0 timesync: voidify sd_event_add_signal() and sd_event_set_watchdog() 2018-07-20 11:30:11 +09:00
Yu Watanabe afb76fdbff tree-wide: drop double newline 2018-06-29 11:02:17 +09:00
Yu Watanabe a9061d97a7 timesync: update log message
Fixes #9388.
2018-06-25 10:27:18 +02:00
Yu Watanabe 75ca1621db timesync: changes type of drift_freq to int64_t
drift_freq is used for storing timex.freq, and is a 64bit integer.
To support x32 ABI, this changes the type of drift_freq to int64_t.

Fixes #9387.
2018-06-25 10:27:18 +02:00
Zbigniew Jędrzejewski-Szmek d9b02e1697 tree-wide: drop copyright headers from frequent contributors
Fixes #9320.

for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do
  git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms'
done
2018-06-20 11:58:53 +02:00
Zbigniew Jędrzejewski-Szmek 0cd41d4dff Drop my copyright headers
perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
2018-06-14 13:03:20 +02:00
Zbigniew Jędrzejewski-Szmek b0450864f1
Merge pull request #9274 from poettering/comment-header-cleanup
drop "this file is part of systemd" and lennart's copyright from header
2018-06-14 11:26:50 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Lennart Poettering 0c69794138 tree-wide: remove Lennart's copyright lines
These lines are generally out-of-date, incomplete and unnecessary. With
SPDX and git repository much more accurate and fine grained information
about licensing and authorship is available, hence let's drop the
per-file copyright notice. Of course, removing copyright lines of others
is problematic, hence this commit only removes my own lines and leaves
all others untouched. It might be nicer if sooner or later those could
go away too, making git the only and accurate source of authorship
information.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Yu Watanabe 86aaccb020 timesync: ignore any errors related to timestamp file 2018-06-14 12:04:04 +09:00
Yu Watanabe ba0c011eee timesync: add more log messages in manager_network_read_link_servers() 2018-06-13 14:05:26 +09:00