Commit graph

22961 commits

Author SHA1 Message Date
Lennart Poettering 4edd65e4cf cgroup-util: add mask definitions for sets of controllers supported by cgroupsv1 vs. cgroupsv2 2018-10-26 18:43:34 +02:00
Lennart Poettering 604028de60 cgroup-util: disable buffering for cg_enable_everywhere() when writing to cgroup attributes
Let's better be safe than sorry.
2018-10-26 18:43:34 +02:00
Lennart Poettering 38a90d45ad cgroup-util: don't expect cg_mask_from_string()'s return value to be initialized
Also, when we fail, don't clobber the return value.

This brings the call more in-line with our usual coding style, and
removes surprises.

None of the callers seemed to care about this behaviour.
2018-10-26 18:43:34 +02:00
Lennart Poettering 0887fa711c cgroup-util: debug log if /proc/self/ns/cgroup is not available for unexpected reasons 2018-10-26 18:43:34 +02:00
Lennart Poettering 0d76d772d1
Merge pull request #10536 from keszybz/serialize-fixes
Tests for the new serialization functions
2018-10-26 17:56:43 +02:00
Lennart Poettering cb9e44db36 test: add test case for recursive chown()ing 2018-10-26 15:13:26 +02:00
Lennart Poettering cd6b7d50c3 chown-recursive: TAKE_FD() is your friend 2018-10-26 15:13:26 +02:00
Lennart Poettering f89bc84f32 chown-recursive: also drop ACLs when recursively chown()ing
Let's better be safe than sorry and also drop ACLs.
2018-10-26 15:13:26 +02:00
Lennart Poettering 5de6cce58b chown-recursive: let's rework the recursive logic to use O_PATH
That way we can pin a specific inode and analyze it and manipulate it
without it being swapped out beneath our hands.

Fixes a vulnerability originally found by Jann Horn from Google.

CVE-2018-15687
LP: #1796692
https://bugzilla.redhat.com/show_bug.cgi?id=1639076
2018-10-26 15:13:26 +02:00
Lennart Poettering 56abe1d107
Merge pull request #10508 from poettering/watchdog-original-fix
various service watchdog fixes
2018-10-26 14:50:17 +02:00
Lennart Poettering 0ea63f7a7d
Merge pull request #10534 from poettering/cmdline-fixlets
proc-cmdline.c fixlets
2018-10-26 14:49:53 +02:00
Zbigniew Jędrzejewski-Szmek 1c1d719aec Move tests for *serialize_environment into test-serialize.c
The implementation is in serialize.c.
2018-10-26 13:17:49 +02:00
Zbigniew Jędrzejewski-Szmek fa2951def7 test-serialize: allocate long_string dynamically 2018-10-26 13:17:44 +02:00
Lennart Poettering aa8c4bbf6a service: when starting a service make a copy of the watchdog timeout and use that
When we start a service process we pass the selected watchdog timeout to
it with the $WATCHDOG_USEC environment variable. If the unit file is
reconfigured later, we need to make sure to continue to honour the
original timeout, i.e. watch $WATCHDOG_USEC was set to, otherwise we'll
expect the ping at a different time as the service process is sending it
to us.

Hence, whenever we start a unit, save the watchdog timeout, and stick to
that for everything we do.

Fixes: #9467
2018-10-26 13:00:04 +02:00
Lennart Poettering 34b3f625f2 service: continue to use the overriden timeout when forking off again
Let's make sure we always use the right watchdog timeout: when a service
has overwritten it, then stick to it, also for follow-up processes of
the same service.
2018-10-26 13:00:04 +02:00
Lennart Poettering 95d0d8ed0a service: rename service_reset_watchdog_timeout() → service_override_watchdog_timeout()
This is what the function really does, hence name it that way.
2018-10-26 13:00:04 +02:00
Lennart Poettering ec35a7f6b0 service: rework service_extend_timeout()
Let's unify common code: let's extend the watchdog timeout and the
regular timeout with the same helper function.
2018-10-26 13:00:04 +02:00
Zbigniew Jędrzejewski-Szmek 40a4c4b38d test-serialize: a smoke test for the serialization functions 2018-10-26 12:56:53 +02:00
Zbigniew Jędrzejewski-Szmek 75e7d50e26 test: _cleanup_(unlink_tempfilep) in two more places 2018-10-26 12:56:53 +02:00
Zbigniew Jędrzejewski-Szmek d8351049a8 Introduce fmkostemp_safe and use it in tests
No functional change.
2018-10-26 12:56:51 +02:00
Lennart Poettering 9fb1cdb480 service: explicit stop the watchdog when we shall not use it
This is useful so that WATCHDOG_USEC=0 sent from a process does the
right thing if turning off the watchdog logic.
2018-10-26 12:53:17 +02:00
Lennart Poettering 2a1e0f2228 journalctl: in --follow mode watch stdout for POLLHUP/POLLERR and exit
Fixes: #9374
2018-10-26 12:28:38 +02:00
Lennart Poettering 7d95229ba7 proc-cmdline: teach proc_cmdline_get_key() the same flags magic as proc_cmdline_parse() 2018-10-26 12:03:32 +02:00
Lennart Poettering cb447ff5cc proc-cmdline: use FLAGS_SET() where appropriate
This was mostly prompted by seeing the expression "in_initrd() && flags
& PROC_CMDLINE_RD_STRICT", which uses & and && without any brackets.
Let's make that a bit more readable and hide all doubts about operator
precedence.
2018-10-26 12:00:37 +02:00
Lennart Poettering 9de12b2ef4 proc-cmdline: use our usual syntax for denoting bit mask enums 2018-10-26 12:00:01 +02:00
Lennart Poettering 923db66a16 fileio: drop FOREACH_LINE(), it's not used anymore 2018-10-26 10:52:41 +02:00
Lennart Poettering d68c645bd3 core: rework serialization
Let's be more careful with what we serialize: let's ensure we never
serialize strings that are longer than LONG_LINE_MAX, so that we know we
can read them back with read_line(…, LONG_LINE_MAX, …) safely.

In order to implement this all serialization functions are move to
serialize.[ch], and internally will do line size checks. We'd rather
skip a serialization line (with a loud warning) than write an overly
long line out. Of course, this is just a second level protection, after
all the data we serialize shouldn't be this long in the first place.

While we are at it also clean up logging: while serializing make sure to
always log about errors immediately. Also, (void)ify all calls we don't
expect errors in (or catch errors as part of the general
fflush_and_check() at the end.
2018-10-26 10:52:41 +02:00
Lennart Poettering cdd620e346 core: make manager_serialize() a bit easier to read by adding predicate function
The predicate function manager_timestamp_shall_serialize() simply says
whether to serialize or not serialize a timestamp, and should make
things a bit easier to read.
2018-10-26 10:40:01 +02:00
Lennart Poettering c475e57d67 core: strjoina() in a loop is never OK
Let's use plain strjoin() instead.
2018-10-26 10:40:01 +02:00
Lennart Poettering a2a444440f automount: fix deserialization of dev_t
let's prefer "unsigned long" rather than "unsigned", in case there are
archs that have 32bit int, but 64bit dev_t.

(Also one cast was wrong anyway.)
2018-10-26 10:40:01 +02:00
Lennart Poettering 3eac1bcae9 core: enforce a limit on STATUS= texts recvd from services
Let's better be safe than sorry, and put a limit on what we receive.
2018-10-26 10:40:01 +02:00
Lennart Poettering 8948b3415d core: when deserializing state always use read_line(…, LONG_LINE_MAX, …)
This should be much better than fgets(), as we can read substantially
longer lines and overly long lines result in proper errors.

Fixes a vulnerability discovered by Jann Horn at Google.

CVE-2018-15686
LP: #1796402
https://bugzilla.redhat.com/show_bug.cgi?id=1639071
2018-10-26 10:40:01 +02:00
Zbigniew Jędrzejewski-Szmek 84ac98faa8
Merge pull request #10525 from poettering/journal-vaccum-all
journald: add ability to vacuum active files too
2018-10-26 10:36:25 +02:00
Zbigniew Jędrzejewski-Szmek f4478c98fa
Merge pull request #10522 from lnykryn/initrd_debug
Let's make systemd-debug-generator usable also in initrd
2018-10-26 10:08:39 +02:00
Yu Watanabe dcdc2f61b1
sd-device: fix wrong assertion (#10530) 2018-10-26 10:16:00 +09:00
Yu Watanabe bf1d6be5b8
Merge pull request #10523 from poettering/fd-get-path-optimize
fd_get_path() optimization
2018-10-26 09:34:07 +09:00
Lennart Poettering 1d445eda4e core: reword polkit request a bit (#10524)
"killing" is very UNIX terminology, and not really what this is about.
Let's be more correct and say "send a UNIX signal" for the operation.

Otherwise things are really weird if users call "journalctl --rotate"
from the command line, which internally asks systemd to send SIGUSR2 to
to journald: when german locale is selected this asks the user — roughly
transliterated — whether they want to "eliminate" journald, which is
definitely not the intended meaning.
2018-10-26 06:01:41 +09:00
Lennart Poettering 971b52c485 journal-file: structured initialization is your friend 2018-10-25 21:44:48 +02:00
Lennart Poettering a33687b792 journald: when we are asked to rotate all files, let's also look at closed files
Before this when asked for rotation we'd only rotate files we have open
anyway. However there might be a number of other files on disk that are
active (i.e. not archived yet) but not open. Let's take care of those
too, so that rotation is always comprehensive, and the user gets the
guarantee that afterthe rotation all stored data is in archived files.

Fixes: #1017
2018-10-25 21:44:48 +02:00
Lennart Poettering e5b2d45c1d journalctl: fix error number in error message 2018-10-25 21:44:48 +02:00
Lennart Poettering 8df64fd01d journalctl: add ability to vacuum and rotate in one step
journalctl --vacuum-*= only vacuums archived files. To archive all
active files the rotate operation is used. Let's add a new switch that
combines both, so that the user a single command to first move all
running journal files into archival and then vacuum them.

See: #1017
2018-10-25 21:44:48 +02:00
Lennart Poettering d03077759e journald: log about an OOM condition 2018-10-25 21:44:48 +02:00
Lennart Poettering e859154447 journald: debug log when we cannot read the machine ID 2018-10-25 21:44:48 +02:00
Lennart Poettering 6812765891 journal-file: refactor journal_file_open_reliably()
Let's split out the part that actually renames the file in case we can't
open it into a new function journal_file_dispose().

This way we can reuse the function in other cases where we want to open
a file but can't.
2018-10-25 21:43:09 +02:00
Lennart Poettering 7a4d21ad20 journal-file: refactor journal_file_rotate()
Let's split the function in three: the part where we archive the old
file into journal_file_archive(), and the part where we initiate the
deferred closing into journal_file_initiate_close().
journal_file_rotate() then simply becomes a wrapper around these two
calls, and the opening of the new journal file.

This useful so that we can archive journal files without having to open
new ones, i.e. to do only the archival part of the rotation, without the
rotation part.
2018-10-25 21:43:09 +02:00
Lennart Poettering f760d8a858 journal: refactor out loop that processes deferred closes into its own function 2018-10-25 21:43:09 +02:00
Lennart Poettering 180e7f4e62 journal: fix some type confusion in journal_directory_vacuum()
Let's store array sizes and indexes in size_t. And let's count numbers
of files in uint64_t (simply because that is the type of the input
parameter for this of the function)
2018-10-25 21:43:09 +02:00
Lennart Poettering ab41da087d journald: use structured initialization 2018-10-25 21:42:05 +02:00
Lennart Poettering 6761e0a2fd journald: use usec_sub_unsigned() where we can 2018-10-25 21:42:05 +02:00
Lennart Poettering f267719c38 fd-util: optimize fd_get_path() a bit
journald calls fd_get_path() a lot (it probably shouldn't, there's some
room for improvement there, but I'll leave that for another time), hence
it's worth optimizing the call a bit, in particular as it's easy.

Previously we'd open the dir /proc/self/fd/ first, before reading the
symlink inside it. This means the whole function requires three system
calls: open(), readlinkat(), close(). The reason for doing it this way
is to distinguish the case when we see ENOENT because /proc is not
mounted and the case when the fd doesn't exist.

With this change we'll directly go for the readlink(), and only if that
fails do an access() to see if /proc is mounted at all.

This optimizes the common case (where the fd is valid and /proc
mounted), in favour of the uncommon case (where the fd doesn#t exist or
/proc is not mounted).
2018-10-25 21:37:14 +02:00
Lennart Poettering 8e060ec225 fs-util: increase start buffer size in readlinkat_malloc()
I noticed while profiling journald that we invoke readlinkat() a ton on
open /proc/self/fd/<fd>, and that the returned paths are more often than
not longer than the 99 chars used before, when we look at archived
journal files. This means for these cases we generally need to execute
two rather than one syscalls.

Let's increase the buffer size a tiny bit, so that we reduce the number
of syscalls executed. This is really a low-hanging fruit of
optimization.
2018-10-25 21:37:14 +02:00
Lukas Nykryn a7dd6d04b0 debug-generator: introduce rd.* version of all options 2018-10-25 17:05:50 +02:00
Zbigniew Jędrzejewski-Szmek 05f339267e
Merge pull request #10378 from poettering/json-fuzz-fix
json: a comprehensive fix for oss-fuzz#10908
2018-10-25 16:25:39 +02:00
Lukas Nykryn ed58820d76 proc-cmdline: introduce PROC_CMDLINE_RD_STRICT
Our current set of flags allows an option to be either
use just in initrd or both in initrd and normal system.
This new flag is intended to be used in the case where
you want apply some settings just in initrd or just
in normal system.
2018-10-25 16:21:26 +02:00
Lennart Poettering 5ec1fca41e
Merge pull request #10518 from poettering/dhcp6-size-fixes
dhcp6 packet size calculation fixes
2018-10-25 13:29:42 +02:00
Zbigniew Jędrzejewski-Szmek 5b8b8056eb
Merge pull request #10504 from poettering/hibernate-fallback
s2h: when hibernate fails after coming back from suspend, go back to suspend
2018-10-25 12:54:47 +02:00
Martin Wilck e1e74614aa core: don't create Requires for workdir if "missing ok"
Don't add an implicit RequiresMountsFor depenency for the
WorkingDirectory of a unit if the "-" character was used to
indicate that "a missing working directory is not considered fatal"
(see systemd.exec(5)). Otherwise systemd might fail the unit
because of missing dependencies.
2018-10-25 11:35:59 +02:00
Lennart Poettering 20b55f8538 dhcp6: prefer offsetof() over sizeof() for structs with undefined sizes
This doesn't change anything in the generated source, but I think makes
semantically more sense, as these structures have undefined size, and we
only want to know the size up to the data field in these cases.
2018-10-25 11:23:19 +02:00
Lennart Poettering 4dac5eaba4 dhcp6: make sure we have enough space for the DHCP6 option header
Fixes a vulnerability originally discovered by Felix Wilhelm from
Google.

CVE-2018-15688
LP: #1795921
https://bugzilla.redhat.com/show_bug.cgi?id=1639067
2018-10-25 11:23:19 +02:00
Lennart Poettering 990668aa4c dhcp6: reduce whitespace a bit 2018-10-25 11:23:19 +02:00
Lennart Poettering 3c290c0316 dhcp6: split assert_return() to be more debuggable when hit 2018-10-25 11:23:19 +02:00
Lennart Poettering e0a18b74a3 dhcp6: constify things where we can 2018-10-25 11:23:19 +02:00
Yu Watanabe 4e412d2684
string-util: fix prototype of explicit_bzero_safe() (#10513)
Follow-up for 87f5446311.
2018-10-25 11:41:55 +09:00
Lennart Poettering def34f63fe time-util: change parse_sec_fix_0() to accept "0s" for infinity too (#10501)
This function is about compatibility, nothing else, hence we should make
it properly compatible.

Fixes: #9556
2018-10-25 05:21:28 +09:00
Lennart Poettering d776fd08a3
Merge pull request #10510 from poettering/uacess-brackets
coverity fixes
2018-10-24 22:18:33 +02:00
Lennart Poettering 87f5446311 string-util: introduce explicit_zero_safe()
The only real difference is that this wrapper can deal with NULL
pointer arguments, but only if the length is also zero.

CID 1396277
2018-10-24 21:00:15 +02:00
Lennart Poettering 7388cea30d udev: use right error variable to make level decision 2018-10-24 20:47:52 +02:00
Lennart Poettering dc4fedd8cb udev: fix bad if {}
CID 1396318
CID 1396319
2018-10-24 20:46:41 +02:00
Lennart Poettering 5f00dc4df6 test: skip various tests if namespacing is not available
Apparently on Debian LXC/AppArmor doesn't allow namespacing to container
payloads. Deal with it.

Fixes: #9700
2018-10-24 19:40:24 +02:00
Lennart Poettering a4bc3c1d25 tests: add helper call have_namespaces() to test whether Linux namespaces are available
A slighly sloppy test call for conditionalizing several tests.
2018-10-24 19:40:24 +02:00
Lennart Poettering 795919efdf tests: as per CODING_STYLE undefine basename() right after including libgen.h 2018-10-24 17:08:12 +02:00
Lennart Poettering eca27ebbc8 tests: alloc-util.h and fs-util.h are our own headers
Hence include them with "" rather than <>. Also including them twices is
a pretty bad idea too.
2018-10-24 17:08:12 +02:00
Lennart Poettering 2194547e3b execute: if we fail to do namespacing, explain why we refuse to continue in a debug message 2018-10-24 17:08:12 +02:00
Lennart Poettering f05e1ae666 sleep: when we can't hibernate on suspend-then-hibernate, fall back to suspend again
Let's make this a bit safer, and try hard to return to sleep, if we can
at all.

Fixes: #10212
2018-10-24 14:44:14 +02:00
Lennart Poettering 14250f0942 sleep: rework what we do if a suspend fails.
First of all, let's fix logging: let's simply log the same message as we
do on success, so that there's always the same pair of these messages
around, regardless if the suspend was successful or not. To distuingish
a successful suspend from a failed one, check the ERRNO= field of the
structured message.

In most ways a failed suspend cycle is not distuingishable from a
successful one that took no time, hence let's treat it this way, and
always pair the success message with a failure message.

This also changes a more important concept: the post-suspend callouts
are now called also called on failure, following the same logic: let's
always run them in pairs: for every pre callout a post callout has to
follow.
2018-10-24 13:07:53 +02:00
Lennart Poettering c695101f47 sleep: no need to check for resume_offset twice
The W_OK check already checks for existance hence let's remove the F_OK
check.
2018-10-24 12:57:37 +02:00
Lennart Poettering eabcf200f7 sleep: let's turn off the RTC alarm time ASAP
Let's be a tiny bit more careful here.

Also, let's rearrange things to simplify them a bit, and to not use "r"
outside of its immediate scope of validity.
2018-10-24 12:52:11 +02:00
Lennart Poettering d029a3a8ca sleep: round up when calculating RTC sleep time
Paranoia: this way we know that when we wake up all timers are
definitely equal or ahead of what we expect them to be.
2018-10-24 12:48:56 +02:00
Lennart Poettering 033cea5c9d sleep: move log message generation for rtc_read_time() into the function itself
The log messages were petty borked anyway, and generated at two separate
locations. Let's fix that.
2018-10-24 12:47:46 +02:00
Lennart Poettering f780e438fa sleep: rework write_wakealarm() to take a numeric parameter
Also, let's rename it to rtc_write_wake_alarm(). Both changes together
make sure rtc_write_wake_alarm() and rtc_read_time() are more alike in
their naming and semantics.
2018-10-24 12:46:12 +02:00
Lennart Poettering c16669a309 sleep: rename read_wakealarm() → rtc_read_time()
It doesn't read wakealarm, but the current time of the RTC. Hence, let's
rename this to make it less misleading.
2018-10-24 12:44:20 +02:00
Lennart Poettering 6ce63245f6 sleep: log about the correct errors 2018-10-24 12:38:13 +02:00
Lennart Poettering 58220e6b91 sleep: don't make up errors, propagate the right ones 2018-10-24 12:38:04 +02:00
Lennart Poettering f00aff0a02 sleep: let's use write_string_file() instead of write_string_stream() if we can
Let's shorten things.
2018-10-24 12:35:49 +02:00
Lennart Poettering d1db1c438f
Merge pull request #10484 from yuwata/udev-spawn-simplify
udev-event: cleanups about udev_event_spawn()
2018-10-24 10:57:45 +02:00
Lennart Poettering e7b48c45ae
Merge pull request #10498 from yuwata/udev-builtin-log
udev-builtin: use log_device_*() macros
2018-10-24 10:53:35 +02:00
Lennart Poettering 77d28bd10f
Merge pull request #10483 from yuwata/udev-cleanup-10
tree-wide: use log_device_*()
2018-10-24 10:51:53 +02:00
Lennart Poettering 086712f99f
Merge pull request #10461 from yuwata/small-cleanups
Fixes recent defects reported by coverity
2018-10-24 10:36:20 +02:00
Jiuyang liu a2f577fca0 add ephemeral to nspawn-settings. 2018-10-24 10:22:20 +02:00
Yu Watanabe 1cb7d29d68 udevadm-info: fix memleak
Fixes CID#1396276.
2018-10-24 05:04:01 +09:00
Yu Watanabe a0570c1a82 udevadm-monitor: initialize variable
Fixes CID#1396278.
2018-10-24 05:04:01 +09:00
Yu Watanabe db8794c3a0 modules-load: return first error in the loop
Follow-up for a889e206a7.
Fixes CID#1396280.
2018-10-24 05:04:01 +09:00
Yu Watanabe fd5ad16cfb reply-password: initialize 'length' variable
Follow-up for 1fd2786161.

This fixes the following warning when built by clang:
```
../src/reply-password/reply-password.c:76:21 warning: variable 'length' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
```

Fixes CID#1396281 and CID#1396277.
2018-10-24 05:03:00 +09:00
Yu Watanabe ec9d636b37 core: use ascii_toupper() instead of everytime judging whether it is the first message 2018-10-24 04:58:08 +09:00
Yu Watanabe e81c3a4c5f udev-event: use sd_event_add_io() for reading stdout or stderr of spawned process 2018-10-24 04:46:48 +09:00
Yu Watanabe 4e57ad3578 udev-event: unify two log_*() by log_full() 2018-10-24 04:46:48 +09:00
Yu Watanabe 5ca3dbc91a udev-event: Capitalize log messages 2018-10-24 04:46:48 +09:00
Yu Watanabe 2e48548fed udev-event: fix condition to create pipe fds
The bug was introduced by feaa6db7ac.
2018-10-24 04:46:48 +09:00
Yu Watanabe f71e8ec10e udev-event: set O_CLOEXEC to pipe fds 2018-10-24 04:46:48 +09:00
Yu Watanabe 947ce772d9 udev-event: make failure in getting device properties fatal 2018-10-24 04:46:48 +09:00
Yu Watanabe 84b1ccb98b udev-event: use rearrange_stdio() and close_all_fds() 2018-10-24 04:46:48 +09:00
Yu Watanabe 6ce075a23a udev-event: set FORK_DEATHSIG flag 2018-10-24 04:46:48 +09:00
Yu Watanabe 63ec4dfaa1 udev-event: drop redundant code
We have set FORK_RESET_SIGNALS in safe_fork(). So, calling
reset_signal_mask() after safe_fork() is redundant.
2018-10-24 04:46:48 +09:00
Yu Watanabe 3ad4d482c7 udev-event: move debug logging before safe_fork()
This fixes the following journal layout issue:
```
Oct 22 15:26:02 systemd-udevd[348]: RUN '/usr/sbin/setregdomain' /usr/lib/udev/rules.d/85-regulatory.rules:5
Oct 22 15:26:02 [439]: Starting '/usr/sbin/setregdomain'
Oct 22 15:26:02 systemd-udevd[348]: Process '/usr/sbin/setregdomain' succeeded.
```
2018-10-24 04:46:48 +09:00
Yu Watanabe d9de38caa4 udev-builtin-input_id: update log messages 2018-10-24 04:33:21 +09:00
Yu Watanabe 9a6e5c24ba udev-builtin-usb_id: update log messages 2018-10-24 04:31:48 +09:00
Yu Watanabe 883658b8f1 udev-builtin-uaccess: update log messages 2018-10-24 04:31:48 +09:00
Yu Watanabe 70fbab6e48 udev-builtin-net_setup_link: update log messages 2018-10-24 04:31:48 +09:00
Yu Watanabe 2dccfe4c2d udev-builtin-keyboard: update log messages 2018-10-24 04:31:48 +09:00
Yu Watanabe f3f80f43aa sd_hwdb: update log messages 2018-10-24 04:31:48 +09:00
Yu Watanabe 5ad71e4490 udev-builtin-btrfs: add debug log messages 2018-10-24 04:31:23 +09:00
Yu Watanabe 5c614b79f4 udev-builtin-blkid: add more debug log messages 2018-10-24 04:31:23 +09:00
Yu Watanabe b0db44fe15 udev-builtin: fix return value of udev_builtin_hwdb()
This fixes a bug introduced by d354690e7d.
Also, this adds more debug logs.
2018-10-24 04:30:05 +09:00
Yu Watanabe ec2e8c3a62 sd-device: fix argument name in log_device_*() macros
Follow-up for b0cba0ca52.
2018-10-24 04:29:00 +09:00
Evgeny Vereshchagin c8758e726c journald: use the "driver" transport for logging a refused connection
Otherwise, these messages can end up in `/dev/null` when journald is run
in containers as was shown in https://github.com/systemd/systemd/pull/10444#issuecomment-430927793.
2018-10-23 19:36:52 +02:00
Evgeny Vereshchagin 9e8b1ec08e sd-journal: escape binary data in match_make_string()
Fixes: #10383
2018-10-23 19:33:01 +02:00
Yu Watanabe 61b8aa3d27 udevadm: normalize exit status
After d354690e7d, each udevadm command
returns negative errno on error. So, let's normalize the exit status
of udevadm.
2018-10-23 19:31:37 +02:00
Yu Watanabe b220632c61 link-config: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe 4d04259d41 udev-watch: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe e0ca42e383 udev-node: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe 94ad322538 rfkill: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe 3d0ac9d0ec mount-tool: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe 76386309b8 login: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe b6124e64a5 sd-device-monitor: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe 133432cc15 gpt-auto-generator: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe 7bd33dbd6e fsck: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe 71f79b56cf core/device: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe 87a9a197ed backlight: use log_device_*() 2018-10-23 22:44:07 +09:00
Yu Watanabe db4e61071d test: add tests for detecting overflow in parse_time() and parse_nsec() 2018-10-23 22:25:01 +09:00
Yu Watanabe f6a178e91d util: check overflow in parse_nsec() 2018-10-23 22:24:16 +09:00
Yu Watanabe 8079c90333 util: check overflow in parse_time() 2018-10-23 22:23:34 +09:00
Chris Down 3f1c1287a9 analyze: Add "timespan" command to dump time span in usec
This is useful for a couple of cases, I'm mostly interested in case #1:

1. Verifying "reasonable" values in a trivially scriptable way
2. Debugging unexpected time span parsing directly

Test Plan:

```
% build/systemd-analyze timespan 20
Original: 20
      μs: 20
   Human: 20us
% build/systemd-analyze timespan 20ms
Original: 20ms
      μs: 20000
   Human: 20ms
% build/systemd-analyze timespan 20z
Failed to parse time span '20z': Invalid argument
```
2018-10-23 14:26:51 +02:00
Yu Watanabe d354690e7d udev-builtin: propagate negative errno 2018-10-23 18:29:25 +09:00
Yu Watanabe 45a73f4be3 udevadm-test-builtin: use find_device()
This also fixes minor memleak.
2018-10-23 18:28:38 +09:00
Yu Watanabe b753e14ac8 udevadm: use path friendly functions 2018-10-23 18:28:38 +09:00
Yu Watanabe 269c3b67c6 udev: propagate original error from udev_builtin_add_property() 2018-10-23 18:28:38 +09:00
Yu Watanabe 63918f926a udev: logs error in udev_builtin_add_property() 2018-10-23 18:28:38 +09:00
Yu Watanabe b0cba0ca52 sd-device: introduce log_device_*() macros 2018-10-23 18:28:38 +09:00
Yu Watanabe c45b369dd1 udev-builtin: modernize code a bit
- introduce _UDEV_BUILTIN_INVALID,
- use _UDEV_BUILTIN_MAX where applicable,
- add several assertions.
2018-10-23 18:28:38 +09:00
Yu Watanabe d277e33916 udevadm-test-builtin: replace udev_device by sd_device 2018-10-23 18:28:38 +09:00
Yu Watanabe 981b8159e9 udev: drop libudev-private.h from udev-builtin-{hwdb,net_id}.c 2018-10-23 18:28:38 +09:00
Yu Watanabe 3d6194e83e udev: make udev_builtin_run take sd_device 2018-10-23 18:28:38 +09:00
Yu Watanabe 9b917abe02 udev-builtin: simplify code a bit 2018-10-23 18:28:38 +09:00
Yu Watanabe 3fc2e9a247 udev: replace udev_device by sd_device from prototype of udev builtin commands 2018-10-23 18:28:38 +09:00
Yu Watanabe 71bd61c576 udev: replace udev_device by sd_device in udev-builtin-usb_id.c 2018-10-23 18:28:38 +09:00
Yu Watanabe 4b60fe6e83 udev: replace udev_device by sd_device in udev-builtin-uaccess.c 2018-10-23 18:28:38 +09:00
Yu Watanabe de675b17c8 udev: replace udev_device by sd_device in udev-builtin-path_id.c 2018-10-23 18:28:38 +09:00
Yu Watanabe d9b3e99656 udev: replace udev_device by sd_device in udev-builtin-net_setup_link.c 2018-10-23 18:28:38 +09:00
Yu Watanabe 09d04a74c1 udev: replace udev_device by sd_device in udev-builtin-net_id.c 2018-10-23 18:28:00 +09:00
Yu Watanabe 786cc8523a udev: replace udev_device by sd_device in udev-builtin-keyboard.c 2018-10-23 17:51:34 +09:00
Yu Watanabe ff79992751 udev: replace udev_device by sd_device in udev-builtin-input_id.c 2018-10-23 17:51:34 +09:00
Yu Watanabe 29fefe2dcb udev: replace udev_device by sd_device in udev-builtin-blkid.c 2018-10-23 17:51:34 +09:00
Yu Watanabe bfc38d8fff udev: replace udev_device by sd_device in udev-builtin-hwdb.c 2018-10-23 17:51:34 +09:00
Yu Watanabe 0c9c063477 udev: make udev_builtin_add_property() take sd_device instead of udev_device 2018-10-23 17:51:34 +09:00
Lennart Poettering 15b1180945
Merge pull request #10477 from yuwata/fix-10474
network: include linux/fou.h if it exists
2018-10-22 21:33:23 +02:00
Zbigniew Jędrzejewski-Szmek 369ca6dab1 systemd-nspawn: do not crash on /var/log/journal creation if not required
When running a read-only file system, we might not be able to create
/var/log/journal. Do not fail on this, unless actually requested by the
--link-journal options.

$ systemd-nspawn --image=image.squashfs ...
2018-10-22 15:07:08 +02:00
Yu Watanabe 80df8f2518 missing: support old linux/fou.h
linux/fou.h was introduced in 3.18.
FOU_ATTR_REMCSUM_NOPARTIAL was added in 4.0.
FOU_CMD_GET was added in 4.1.

Follow-up for 53cb501a13.
Fixes #10474.
2018-10-21 22:34:28 +09:00
Lennart Poettering a2689fa5fc
Merge pull request #9437 from poettering/sd-boot-count
many sd-boot/bootctl fixes, and a new "boot counting" concept, for automatic fallback to older kernels on persistent failures
2018-10-19 23:04:22 +02:00
Tobias Jungel cbff717048 networkd: keep bond slave up if already attached
There is no need to disable an already correct enslaved interface.

relates to #10118
2018-10-19 23:00:52 +02:00
Li Song cc3981b127 sd-dhcp: remove unreachable route after rebinding return NAK 2018-10-19 22:59:20 +02:00
Lennart Poettering 41159592f8
Merge pull request #10470 from yuwata/log-message-updates
Log message updates
2018-10-19 22:58:53 +02:00
Lennart Poettering f876f53789 units: add simple boot check unit
This is might be useful in some cases, but it's primarily an example for
a boot check service that can be plugged before boot-complete.target.

It's disabled by default.

All it does is check whether the failed unit count is zero
2018-10-19 22:34:50 +02:00
Lennart Poettering bf7b6d28c3 kernel-install: teach bot loader spec entry generator to generate entries with "tries"
This makes two changes:

1. When called for "remove" any drop-ins with "+" suffix are removed
   too, so that the logic works for entries with boot counting enabled
   too and we don't lose track of configuration snippets created that
   way.

2. When called for "add" we optionally generate a "+" suffix, based on
   the data in /etc/kernel/tries if it exists.

   This basically means after "echo 5 > /etc/kernel/tries" any installed
   kernels will automatically set up for 5 boot tries before older
   kernels will be tried.
2018-10-19 22:34:50 +02:00
Lennart Poettering 8d16ed0785 add "systemd-bless-boot-generator"
This generator automatically pulls in "systemd-bless-boot.service" if
a boot with boot counting is detected.
2018-10-19 22:34:50 +02:00
Lennart Poettering 36695e880a add new systemd-bless-boot.service that marks boots as successful
This is the counterpiece to the boot counting implemented in
systemd-boot: if a boot is detected as successful we mark drop the
counter again from the booted snippet or kernel image.
2018-10-19 22:34:50 +02:00
Yu Watanabe 14cb109d45 tree-wide: replace 'unsigned int' with 'unsigned' 2018-10-19 22:19:12 +02:00
Lennart Poettering 347a19343c
Merge pull request #10462 from yuwata/test-sd-device-monitor
Add tests for sd_device_monitor and small cleanups
2018-10-19 22:05:50 +02:00
Yu Watanabe c65ac075ef nspawn: do not include '%m' in log message if errno is zero 2018-10-20 02:01:15 +09:00
Yu Watanabe 94c9ff1606 import: include error cause in log message 2018-10-20 02:01:15 +09:00
Yu Watanabe 0a1b94497a gpt-auto-generator: include error cause in log message 2018-10-20 02:00:55 +09:00
Yu Watanabe 0cab6f7db8 firstboot: include error cause in log message 2018-10-20 01:54:52 +09:00
Yu Watanabe 63cf2d75d6 dissect: include error cause in log message 2018-10-20 01:54:29 +09:00
Yu Watanabe 9d77ca39e5 coredump: include error cause in log message 2018-10-20 01:43:13 +09:00
Yu Watanabe 5e1ee764e1 core: include error cause in log message 2018-10-20 01:40:42 +09:00
Yu Watanabe 486d76bd7e cgtop: include error cause in log message 2018-10-20 01:01:31 +09:00
Yu Watanabe 3d9942de4f busctl: include error cause in log message 2018-10-20 00:57:53 +09:00
Yu Watanabe 7709ef3a70 bootctl: include error cause in log message 2018-10-20 00:52:45 +09:00
Yu Watanabe 011723a451 fs-util: include error cause in log message 2018-10-20 00:48:21 +09:00
Yu Watanabe 0c7539634f analyze: include error cause in the log message 2018-10-20 00:46:33 +09:00
Yu Watanabe e95a86c79e analyze: update log message 2018-10-20 00:43:02 +09:00
Lennart Poettering 490c5a37cb tree-wide: some automatic coccinelle fixes (#10463)
Nothing fancy, just coccinelle doing its work.
2018-10-20 00:07:46 +09:00
Yu Watanabe aaa5b4cec7 test: add tests for sd_device_monitor 2018-10-19 18:07:53 +09:00
Lennart Poettering a4544f53c4
Merge pull request #10457 from yuwata/fuzz-11019
sd-dhcp: fixes oss-fuzz#11019 and several cleanups
2018-10-19 10:48:41 +02:00
Evgeny Vereshchagin 2ac1ff68f2 core: stop ignoring errors in connect_logger_as
When journald reaches the maximum number of active streams, it,
basically, starts to decline new connections. On the client
side it can be detected by getting EPIPE and, if the writing
process isn't lucky enough, getting SIGPIPE soon afterwards.
systemd has always ignored EPIPE, which makes it very hard
to keep track of services losing logs. This patch should make
it easier to detect such services by just staring at the logs
carefully.

In case anyone is interested, the following one-liner run as any user
can be used to paralyze all the stream logging on a machine:

for i in {1..4096}; do systemd-cat -t HEY-$i & done
2018-10-19 10:32:21 +02:00
Lennart Poettering 6ab1853953
Merge pull request #10460 from yuwata/setsockopt_int-more
tree-wide: use setsockopt_int() more
2018-10-19 10:12:00 +02:00
Yu Watanabe b58d4d2d4f sd-device-monitor: include error cause in log message 2018-10-19 11:57:54 +09:00
Yu Watanabe a537eafe1d sd-device-monitor: drop unnecessary condition 2018-10-19 11:57:29 +09:00
Lennart Poettering a87b1faad3 core: beautify per-unit consumed resources log message a bit. (#10390)
Shorten message to say "no IP traffic" if there is no IP traffic, rather
than "received 0B IP traffic, sent 0B IP traffic".

Fixes: #9816
2018-10-19 09:04:12 +09:00
Yu Watanabe 84711d20b0
Merge pull request #10437 from poettering/env-util-love
some env-util.c love
2018-10-19 08:57:51 +09:00
Yu Watanabe b0b8c9a5a4
Merge pull request #10389 from poettering/nspawn-path-fix
nspawn $PATH execvpe() fix
2018-10-19 08:48:37 +09:00
Yu Watanabe 17acb7ef9a
Merge pull request #10450 from poettering/foreach-line-excorcism
FOREACH_LINE excorcism
2018-10-19 08:44:51 +09:00
Yu Watanabe 218b4609d0
Merge pull request #10447 from poettering/fgets-excorcism
let's get rid of fgets()
2018-10-19 08:36:01 +09:00
Yu Watanabe aae1fa5cc8 sd-dhcp6: drop empty 'error' label 2018-10-19 06:11:58 +09:00
Yu Watanabe 9a25416479 test-dhcp6-client: normalize logs 2018-10-19 06:11:58 +09:00
Yu Watanabe 3c72b6ed42 sd-dhcp6: make dhcp6_option_parse_domainname() not store empty domain
This improves performance of fuzzer.
C.f. oss-fuzz#11019.
2018-10-19 06:11:58 +09:00
Yu Watanabe 33d3675895 sd-dhcp6: do not update serverid when ENOMEM 2018-10-19 06:11:58 +09:00
Yu Watanabe da07cf3582 sd-dhcp6: coding style cleanups 2018-10-19 06:11:58 +09:00
Yu Watanabe 91c43f3978 sd-dhcp6: fix argument and error handling of dhcp6_option_parse_status() 2018-10-19 06:11:58 +09:00
Yu Watanabe 73c7676756 resolved-mdns: use TAKE_FD() 2018-10-19 06:03:19 +09:00
Yu Watanabe 3f548ffff4 resolved-llmnr: use TAKE_FD() 2018-10-19 05:58:03 +09:00
Yu Watanabe 9e5b649655 tree-wide: use setsockopt_int() more 2018-10-19 05:52:42 +09:00
Lennart Poettering 986c8af1b8
Merge pull request #10456 from poettering/setsockopt-int
add a setsockopt_int() helper and make use of it everywhere
2018-10-18 21:53:01 +02:00
Lennart Poettering 6d4150cb45 job: add a comment that JOB_DONE also means skipped due to condition (#10453) 2018-10-19 03:55:30 +09:00
Lennart Poettering b33fa02b2d util: drop const_int_one/const_int_zero again
There's only a single user remaining now that we have setsockopt_int(),
let's define those variables locally.

This more or less reverts 6d5e65f645.
2018-10-18 19:50:29 +02: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 0fef958361 efi: rework OFFSETOF() based on __builtin_offsetof()
Since both LLVM and gcc supported this for a long time, we are not
adding a fallback compat kludge. And even if there's some relevant
compiler that doesn't know this concept, it'll fail with a compiler
error, and we'll fix it then.

As suggested by @keszybz:

https://github.com/systemd/systemd/pull/10174#discussion_r226266540
2018-10-18 19:01:54 +02:00
Lennart Poettering 849d653a4e
Merge pull request #10239 from yuwata/sd-device-monitor
sd-device: introduce sd_device_monitor
2018-10-18 18:30:38 +02:00
Lennart Poettering c0815ca93d
Merge pull request #10407 from yuwata/netlink-slot
sd-netlink: introduce sd_netlink_slot object and relevant functions
2018-10-18 18:05:58 +02:00
Lennart Poettering 085f3d6416 json: add an assert_cc() check that validates _JSON_VARIANT_MAGIC_MAX 2018-10-18 16:44:51 +02:00
Lennart Poettering 7e61bd0f67 macro.h: include assert.h so that static_assert can be properly checked for
For the definition of assert_cc() we try to use static_assert and check
for it with "#ifdef". But that can only work if assert.h is imported
before. Hence let's do so.
2018-10-18 16:44:51 +02:00
Lennart Poettering d520d519f0 json: add support for using static const strings directly as JsonVariant objects
This is a nice little optimization when using static const strings: we
can now use them directly as JsonVariant objecs, without any additional
allocation.
2018-10-18 16:44:51 +02:00
Lennart Poettering 4fcb507a90 json: minor optimization
instead of comparing the magic JsonVariants one by one, let's simply
compare that they lie within a specific range.
2018-10-18 16:44:51 +02:00
Lennart Poettering d77e781fd0 json: when creating an object, insist that every second item is a string
After all, those are the keys, which have to be keys.
2018-10-18 16:44:51 +02:00
Lennart Poettering b2fa0d4fca json: enforce a maximum nesting depth for json variants
Simply as a safety precaution so that json objects we read are not
arbitrary amounts deep, so that code that processes json objects
recursively can't be easily exploited (by hitting stack limits).

Follow-up for oss-fuzz#10908

(Nice is that we can accomodate for this counter without increasing the
size of the JsonVariant object.)
2018-10-18 16:44:51 +02:00
Lennart Poettering a7efb03039 json: slightly reorder JsonVariant
Let's move things around a bit, so that the trailing unused whitespace
within the structure due to padding is placed together, so that it is
easier to use for new fields. (Found with pahole)
2018-10-18 16:44:51 +02:00
Lennart Poettering 4ae7e4e5d8 json: avoid stack allocation of long strings in a recursive function
Fixes: oss-fuzz#10908

https://oss-fuzz.com/v2/testcase-detail/5639441482252288
2018-10-18 16:44:51 +02:00
Lennart Poettering 92853e9bbe json: return a double when we shall return a double 2018-10-18 16:44:51 +02:00
Lennart Poettering a1559e3f53 json: use structured initialization all the way 2018-10-18 16:44:51 +02:00
Lennart Poettering 120bffada8 test: check for putenv() failures, the call might theortically fail 2018-10-18 16:40:12 +02:00
Lennart Poettering 8f7329ac27 exec-util: errors are reported by non-zero, not negative by putenv() 2018-10-18 16:40:12 +02:00
Lennart Poettering b6b180b77b nspawn: use container $PATH (not host $PATH) when searching for PID 1 binaries to execute
Fixes: #10377
2018-10-18 16:40:12 +02:00
Lennart Poettering 2a98ae4a05 tmpfiles: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering e393eff622 sysv-generator: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 050ca29963 sysusers: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 8ac3c9ab1b install: pass encountered error number to log_syntax() 2018-10-18 16:23:45 +02:00
Lennart Poettering bef77f378c install: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering d5b3c07da6 clean-ipc: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering e1b9fc23eb resolved-resolv-conf: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 7c777a7773 resolved-etc-hosts: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 0a6488b441 resolved-dns-trust-anchor: FOREACH_LINE excorcism
Also, properly ignore these read errors, and say so.
2018-10-18 16:23:45 +02:00
Lennart Poettering 271c8ec50f localectl: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 710bf2aeb2 sd-path: FOREACH_LINE exorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 8ae29228a8 bus-creds: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 7b26ea6f06 coredump: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 9fd0b02913 smack-setup: include error cause in log message 2018-10-18 16:23:45 +02:00
Lennart Poettering ea8b6526b9 smcak-setup: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering a34f0dae01 shutdown: FOREACH_LINE() excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 1fb8942284 ima-setup: prefer safe_close() over plain close() 2018-10-18 16:23:45 +02:00
Lennart Poettering b435812c64 ima-setup: include error cause in failure messages 2018-10-18 16:23:45 +02:00
Lennart Poettering 2452419b3a ima-setup: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering c66e60a838 cgroup: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 8d2b9d14c4 time-util: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering 7e7a16a00e process-util: FOREACH_LINE excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering f5af75eaec mount-util: FOREACH_LINE() excorcism 2018-10-18 16:23:45 +02:00
Lennart Poettering d2b39cb606 cgroup-util: FOREACH_LINE() excorcism 2018-10-18 16:23:45 +02:00
Zbigniew Jędrzejewski-Szmek 51a85e5ec2
Merge pull request #10174 from poettering/sd-boot-counter-efi
the EFI changes from PR #9437 (the boot counting PR)
2018-10-18 16:06:01 +02:00
Yu Watanabe 691d6f6d76 bus-unit-util: use streq() instead of STR_IN_SET()
Follow-up for 90fc172e19 (#10308).
2018-10-18 13:46:45 +02:00
Lennart Poettering fae0f8a047 udev-rules: fgets() excorcism 2018-10-18 13:41:09 +02:00
Lennart Poettering 9c6f9786c5 condition: fgets() excorcism 2018-10-18 13:40:55 +02:00
Lennart Poettering 1fd2786161 reply-password: fgets() excorcism 2018-10-18 13:40:39 +02:00