Commit graph

118 commits

Author SHA1 Message Date
Mike Gilbert c9f7b4d356 build-sys: add check for gperf lookup function signature (#5055)
gperf-3.1 generates lookup functions that take a size_t length
parameter instead of unsigned int. Test for this at configure time.

Fixes: https://github.com/systemd/systemd/issues/5039
2017-01-10 08:39:05 +01:00
akochetkov 5f36e3d303 timesyncd: clear ADJ_MAXERROR to keep STA_UNSYNC cleared after jump adjust (#4626)
NTP use jump adjust if system has incorrect time read from RTC during boot.
It is desireble to update RTC time as soon as NTP set correct system time.
Sometimes kernel failed to update RTC due to STA_UNSYNC get set before RTC
update finised. In that case RTC time wouldn't be updated within long time.
The commit makes RTC updates stable.

When NTP do jump time adjust using ADJ_SETOFFSET it clears STA_UNSYNC flag.
If don't clear ADJ_MAXERROR, STA_UNSYNC will be set again by kernel within
1 second (by second_overflow() function). STA_UNSYNC flag prevent RTC updates
in kernel. Sometimes the kernel is able to update RTC withing 1 second,
but sometimes it falied.
2016-11-11 18:50:46 +01:00
Zbigniew Jędrzejewski-Szmek 70887c5f29 tree-wide: add PRI_[NU]SEC, and use time format strings more 2016-11-07 22:49:09 -05:00
Zbigniew Jędrzejewski-Szmek 6b430fdb7c tree-wide: use mfree more 2016-10-16 23:35:39 -04:00
Zbigniew Jędrzejewski-Szmek 43688c49d1 tree-wide: rename config_parse_many to …_nulstr
In preparation for adding a version which takes a strv.
2016-09-16 10:32:03 -04:00
Martin Pitt 6369641d6f clock-util: make clock_is_localtime() testable and add initial tests
Add path argument to clock_is_localtime() and default to "/etc/adjtime" if it's
NULL. This makes the function testable.

Add test-clock: initial test cases for some scenarios, using a temporary file.
This also checks the behaviour with a NULL (i. e. the system's /etc/adjtime)
file.
2016-02-26 11:28:49 +01:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Zbigniew Jędrzejewski-Szmek baa33e79e3 timesyncd: use (void) to mark ignored value
CID #1325772.
2016-01-20 18:55:56 -05:00
Thomas Hindoe Paaboel Andersen 71d35b6b55 tree-wide: sort includes in *.h
This is a continuation of the previous include sort patch, which
only sorted for .c files.
2015-11-18 23:09:02 +01:00
Lennart Poettering 75eb615480 defs: rework CONF_DIRS_NULSTR() macro
The macro is generically useful for putting together search paths, hence
let's make it truly generic, by dropping the implicit ".d" appending it
does, and leave that to the caller. Also rename it from
CONF_DIRS_NULSTR() to CONF_PATHS_NULSTR(), since it's not strictly about
dirs that way, but any kind of file system path.

Also, mark CONF_DIR_SPLIT_USR() as internal macro by renaming it to
_CONF_PATHS_SPLIT_USR() so that the leading underscore indicates that
it's internal.
2015-11-10 17:31:31 +01:00
Michal Schmidt 6ff6f4d851 timesync: return negative errno from manager_adjust_clock() on error 2015-11-05 13:44:14 +01:00
Lennart Poettering a0f29c767a util-lib: move CONF_DIRS_NULSTR definition to def.h
After all, this is not some compiler or C magic, but something very
specific to how systemd works, hence let's move it into def.h, and out
of macro.h
2015-11-03 17:45:11 +01:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 430f0182b7 src/basic: rename audit.[ch] → audit-util.[ch] and capability.[ch] → capability-util.[ch]
The files are named too generically, so that they might conflict with
the upstream project headers. Hence, let's add a "-util" suffix, to
clarify that this are just our utility headers and not any official
upstream headers.
2015-10-27 13:25:57 +01:00
Lennart Poettering f4f15635ec util-lib: move a number of fs operations into fs-util.[ch] 2015-10-27 13:25:56 +01:00
Susant Sahani 2e3c585472 timesysnd: port to extract_first_word 2015-10-27 09:12:04 +05:30
Lennart Poettering b1d4f8e154 util-lib: split out user/group/uid/gid calls into user-util.[ch] 2015-10-26 01:24:38 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Lennart Poettering ac5b0c13d8 tree-wide: add more void casts for various syscall invocations 2015-10-19 23:07:18 +02:00
Lennart Poettering 12ca818ffd tree-wide: clean up log_syntax() usage
- Rely everywhere that we use abs() on the error code passed in anyway,
  thus don't need to explicitly negate what we pass in

- Never attach synthetic error number information to log messages. Only
  log about errors we *receive* with the error number we got there,
  don't log any synthetic error, that don#t even propagate, but just eat
  up.

- Be more careful with attaching exactly the error we get, instead of
  errno or unrelated errors randomly.

- Fix one occasion where the error number and line number got swapped.

- Make sure we never tape over OOM issues, or inability to resolve
  specifiers
2015-09-30 22:26:16 +02:00
Lennart Poettering aa36007ca1 timesyncd: fix how we print a PID 2015-09-11 18:31:49 +02:00
Kay Sievers b506d3141b timesyncd: remove RLIMIT_NPROC
NSS plugins might create additional threads. Remove the limit, we cannot
really make any assumptions here.
2015-07-31 15:33:49 +02:00
Kay Sievers 2c8849add4 build-sys: add all source files and no built files to the tar ball
This fully synchronizes the content of a "make dist" and a "git archive"
tar ball.

  http://lists.freedesktop.org/archives/systemd-devel/2015-June/033214.html
2015-06-23 12:43:15 +02:00
Lennart Poettering 72c0a2c255 everywhere: port everything to sigprocmask_many() and friends
This ports a lot of manual code over to sigprocmask_many() and friends.

Also, we now consistly check for sigprocmask() failures with
assert_se(), since the call cannot realistically fail unless there's a
programming error.

Also encloses a few sd_event_add_signal() calls with (void) when we
ignore the return values for it knowingly.
2015-06-15 20:13:23 +02:00
Lennart Poettering 2a1288ff89 util: introduce CMSG_FOREACH() macro and make use of it everywhere
It's only marginally shorter then the usual for() loop, but certainly
more readable.
2015-06-10 19:29:47 +02:00
Lennart Poettering 24882e06c1 util: split out signal-util.[ch] from util.[ch]
No functional changes.
2015-05-29 20:14:11 +02:00
Lennart Poettering 481b3f9e99 timesyncd: print an INFO log message when we successfully reached a time server 2015-04-08 20:14:04 +02:00
Shawn Landden 3b1c524154 add REMOTE_ADDR and REMOTE_PORT for Accept=yes 2015-03-10 09:00:27 -04:00
Zbigniew Jędrzejewski-Szmek e93549ef29 Do not advertise .d snippets over main config file
For daemons which have a main configuration file, there's
little reason for the administrator to use configuration snippets.
They are useful for packagers which need to override settings, but
we shouldn't advertise that as the main way of configuring those
services.

https://bugs.freedesktop.org/show_bug.cgi?id=89397
2015-03-03 19:10:21 -05:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
Cristian Rodríguez 625b3b71c1 timesync: Use UINT64_C for OFFSET_1900_1970
So it matches what the comment says in both 32 and 64 bit systems.
2015-02-16 18:43:47 +01:00
Lennart Poettering a38d99451f Revert "tree-wide: Always use recvmsg with MSG_CMSG_CLOEXEC"
This reverts commit d6d810fbf8.

It's apparently not OK to pass MSG_CMSG_CLOEXEC to recvmsg() of raw
sockets.
2015-02-12 11:45:39 +01:00
Cristian Rodríguez d6d810fbf8 tree-wide: Always use recvmsg with MSG_CMSG_CLOEXEC 2015-02-10 21:20:16 +01:00
Lennart Poettering 7e3254b3ba timesyncd: downgrade more log messages from LOG_INFO to LOG_DEBUG
https://bugs.freedesktop.org/show_bug.cgi?id=87505

Let's make timesyncd less chatty.
2015-02-04 17:06:39 +01:00
Lennart Poettering 7b5b3fc3ac timesyncd: reduce log chattiness a bit
Let's downgrade the statistics output from LOG_INFO to LOG_DEBUG.

https://bugs.freedesktop.org/show_bug.cgi?id=88926
2015-02-04 14:46:40 +01:00
Lennart Poettering 7e26029ff3 timesyncd: set RLIMIT_NPROC to 2
This way timesyncd cannot be used to fork().

Note that it generally is not safe to use RLIMIT_NPROC, since it breaks
running the same daemon in multiple containers if they do not use user
namespacing. However, timesyncd is excepted from running in a container
anyway, hence it is safe in this case.
2015-01-27 02:33:46 +01:00
Topi Miettinen 43fcd650e5 timesyncd: consider too long packets as invalid
If the received NTP message from server didn't fit to our buffer, either
it is doing something nasty or we don't know the protocol. Consider the
packet as invalid.

(David: add parantheses around conditional)
2015-01-18 21:42:00 +01:00
Cristian Rodríguez fa66b606b1 timesync: remove square(), use pow instead
In any case, the compiler generates the same code inline and never
actually calls the library function.
2014-12-25 10:55:41 -05:00
Lennart Poettering f89c4e15c9 timesyncd: minor simplification 2014-11-30 22:58:55 +01:00
Josh Triplett be795898c0 timesyncd: Support timesyncd.conf.d directories in the usual search paths 2014-11-29 13:55:32 -05:00
Michal Schmidt 4a62c710b6 treewide: another round of simplifications
Using the same scripts as in f647962d64 "treewide: yet more log_*_errno
+ return simplifications".
2014-11-28 19:57:32 +01:00
Michal Schmidt 56f64d9576 treewide: use log_*_errno whenever %m is in the format string
If the format string contains %m, clearly errno must have a meaningful
value, so we might as well use log_*_errno to have ERRNO= logged.

Using:
find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/'

Plus some whitespace, linewrap, and indent adjustments.
2014-11-28 19:49:27 +01:00
Michal Schmidt f647962d64 treewide: yet more log_*_errno + return simplifications
Using:
find . -name '*.[ch]' | while read f; do perl -i.mmm -e \
 'local $/;
  local $_=<>;
  s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg;
  print;'
 $f
done

And a couple of manual whitespace fixups.
2014-11-28 18:56:16 +01:00
Michal Schmidt ff49bc3212 treewide: drop unnecessary trailing \n in log_*() calls 2014-11-28 14:26:31 +01:00
Michal Schmidt da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt 0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:

find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'

Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
2014-11-28 12:04:41 +01:00
Sean Young 7b6288914b timesyncd: do not keep listening socket open forever
This also makes the source port less predicatable.
2014-11-27 00:24:52 -05:00
Lennart Poettering 69f0081748 timesyncd: the IP_TOS sockopt is really just an optimization, we shouldn't fail if we can't set it
This partially undos 2f905e821e
2014-10-24 18:32:30 +02:00
Ronny Chevalier e4746b5738 util: avoid duplication of TIME_T_MAX 2014-10-21 00:38:30 +02:00