]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
4 years agotest-cpu-set-util: fix allocation size check on i386 v239-21 v239-22
Zbigniew Jędrzejewski-Szmek [Tue, 4 Jun 2019 07:40:38 +0000 (09:40 +0200)] 
test-cpu-set-util: fix allocation size check on i386

We get just 28 bytes not 32 as on 64-bit architectures (__cpu_set_t is 4 bytes,
we need at least 26, so 28 satisfies the constraints).

(cherry picked from commit 64412970ac0d4b6f5c4bbd8816edc9bff9eab2de)

Related: #1734787

4 years agotest-cpu-set-util: fix comparison for allocation size
Zbigniew Jędrzejewski-Szmek [Tue, 4 Jun 2019 07:19:04 +0000 (09:19 +0200)] 
test-cpu-set-util: fix comparison for allocation size

On i386, __cpu_mask is 4 bytes, so we'd check if c.allocated >= 0, and
gcc would warn about a bogus comparison. Let's round up.

Fixes #12726.

(cherry picked from commit a299ce058b41b21c87f36e77e2c563b0ddd1be0d)

Related: #1734787

4 years agodebug-generator: enable custom systemd.debug_shell tty v239-20
Jan Synacek [Thu, 25 Apr 2019 10:19:16 +0000 (12:19 +0200)] 
debug-generator: enable custom systemd.debug_shell tty

(cherry picked from commit 93912e872fb14e9c372e090409e429084a6450f5)

Resolves: #1723722

4 years agocore, job: fix breakage of ordering dependencies by systemctl reload command
HATAYAMA Daisuke [Mon, 28 Oct 2019 10:35:24 +0000 (19:35 +0900)] 
core, job: fix breakage of ordering dependencies by systemctl reload command

Currently, systemctl reload command breaks ordering dependencies if it's
executed when its target service unit is in activating state.

For example, prepare A.service, B.service and C.target as follows:

    # systemctl cat A.service B.service C.target
    # /etc/systemd/system/A.service
    [Unit]
    Description=A

    [Service]
    Type=oneshot
    ExecStart=/usr/bin/echo A1
    ExecStart=/usr/bin/sleep 60
    ExecStart=/usr/bin/echo A2
    ExecReload=/usr/bin/echo A reloaded
    RemainAfterExit=yes

    # /etc/systemd/system/B.service
    [Unit]
    Description=B
    After=A.service

    [Service]
    Type=oneshot
    ExecStart=/usr/bin/echo B
    RemainAfterExit=yes

    # /etc/systemd/system/C.target
    [Unit]
    Description=C
    Wants=A.service B.service

Start them.

    # systemctl daemon-reload
    # systemctl start C.target

Then, we have:

    # LANG=C journalctl --no-pager -u A.service -u B.service -u C.target -b
    -- Logs begin at Mon 2019-09-09 00:25:06 EDT, end at Thu 2019-10-24 22:28:47 EDT. --
    Oct 24 22:27:47 localhost.localdomain systemd[1]: Starting A...
    Oct 24 22:27:47 localhost.localdomain systemd[1]: A.service: Child 967 belongs to A.service.
    Oct 24 22:27:47 localhost.localdomain systemd[1]: A.service: Main process exited, code=exited, status=0/SUCCESS
    Oct 24 22:27:47 localhost.localdomain systemd[1]: A.service: Running next main command for state start.
    Oct 24 22:27:47 localhost.localdomain systemd[1]: A.service: Passing 0 fds to service
    Oct 24 22:27:47 localhost.localdomain systemd[1]: A.service: About to execute: /usr/bin/sleep 60
    Oct 24 22:27:47 localhost.localdomain systemd[1]: A.service: Forked /usr/bin/sleep as 968
    Oct 24 22:27:47 localhost.localdomain systemd[968]: A.service: Executing: /usr/bin/sleep 60
    Oct 24 22:27:52 localhost.localdomain systemd[1]: A.service: Trying to enqueue job A.service/reload/replace
    Oct 24 22:27:52 localhost.localdomain systemd[1]: A.service: Merged into running job, re-running: A.service/reload as 1288
    Oct 24 22:27:52 localhost.localdomain systemd[1]: A.service: Enqueued job A.service/reload as 1288
    Oct 24 22:27:52 localhost.localdomain systemd[1]: A.service: Unit cannot be reloaded because it is inactive.
    Oct 24 22:27:52 localhost.localdomain systemd[1]: A.service: Job 1288 A.service/reload finished, result=invalid
    Oct 24 22:27:52 localhost.localdomain systemd[1]: B.service: Passing 0 fds to service
    Oct 24 22:27:52 localhost.localdomain systemd[1]: B.service: About to execute: /usr/bin/echo B
    Oct 24 22:27:52 localhost.localdomain systemd[1]: B.service: Forked /usr/bin/echo as 970
    Oct 24 22:27:52 localhost.localdomain systemd[970]: B.service: Executing: /usr/bin/echo B
    Oct 24 22:27:52 localhost.localdomain systemd[1]: B.service: Failed to send unit change signal for B.service: Connection reset by peer
    Oct 24 22:27:52 localhost.localdomain systemd[1]: B.service: Changed dead -> start
    Oct 24 22:27:52 localhost.localdomain systemd[1]: Starting B...
    Oct 24 22:27:52 localhost.localdomain echo[970]: B
    Oct 24 22:27:52 localhost.localdomain systemd[1]: B.service: Child 970 belongs to B.service.
    Oct 24 22:27:52 localhost.localdomain systemd[1]: B.service: Main process exited, code=exited, status=0/SUCCESS
    Oct 24 22:27:52 localhost.localdomain systemd[1]: B.service: Changed start -> exited
    Oct 24 22:27:52 localhost.localdomain systemd[1]: B.service: Job 1371 B.service/start finished, result=done
    Oct 24 22:27:52 localhost.localdomain systemd[1]: Started B.
    Oct 24 22:27:52 localhost.localdomain systemd[1]: C.target: Job 1287 C.target/start finished, result=done
    Oct 24 22:27:52 localhost.localdomain systemd[1]: Reached target C.
    Oct 24 22:27:52 localhost.localdomain systemd[1]: C.target: Failed to send unit change signal for C.target: Connection reset by peer
    Oct 24 22:28:47 localhost.localdomain systemd[1]: A.service: Child 968 belongs to A.service.
    Oct 24 22:28:47 localhost.localdomain systemd[1]: A.service: Main process exited, code=exited, status=0/SUCCESS
    Oct 24 22:28:47 localhost.localdomain systemd[1]: A.service: Running next main command for state start.
    Oct 24 22:28:47 localhost.localdomain systemd[1]: A.service: Passing 0 fds to service
    Oct 24 22:28:47 localhost.localdomain systemd[1]: A.service: About to execute: /usr/bin/echo A2
    Oct 24 22:28:47 localhost.localdomain systemd[1]: A.service: Forked /usr/bin/echo as 972
    Oct 24 22:28:47 localhost.localdomain systemd[972]: A.service: Executing: /usr/bin/echo A2
    Oct 24 22:28:47 localhost.localdomain echo[972]: A2
    Oct 24 22:28:47 localhost.localdomain systemd[1]: A.service: Child 972 belongs to A.service.
    Oct 24 22:28:47 localhost.localdomain systemd[1]: A.service: Main process exited, code=exited, status=0/SUCCESS
    Oct 24 22:28:47 localhost.localdomain systemd[1]: A.service: Changed start -> exited

The issue occurs not only in reload command, i.e.:

  - reload
  - try-restart
  - reload-or-restart
  - reload-or-try-restart commands

The cause of this issue is that job_type_collapse() doesn't take care of the
activating state.

Fixes: #10464
(cherry picked from commit d1559793df555212271e490a4a72f55826caf5b4)

Resolves: #1766417

4 years agocryptsetup: reduce the chance that we will be OOM killed
Michal Sekletár [Wed, 27 Nov 2019 13:27:58 +0000 (14:27 +0100)] 
cryptsetup: reduce the chance that we will be OOM killed

cryptsetup introduced optional locking scheme that should serialize
unlocking keyslots which use memory hard key derivation
function (argon2). Using the serialization should prevent OOM situation
in early boot while unlocking encrypted volumes.

(cherry picked from commit 408c81f62454684dfbff1c95ce3210d06f256e58)

Resolves: #1696602

4 years agoset kptr_restrict=1
David Tardon [Tue, 3 Dec 2019 13:04:00 +0000 (14:04 +0100)] 
set kptr_restrict=1

Resolves: #1689346

4 years agocore: disable CPUAccounting by default
Michal Sekletár [Thu, 28 Nov 2019 14:47:43 +0000 (15:47 +0100)] 
core: disable CPUAccounting by default

Related: #1734787

[RHEL-only]

4 years agocore: introduce NUMAPolicy and NUMAMask options
Michal Sekletár [Mon, 18 Nov 2019 11:50:11 +0000 (12:50 +0100)] 
core: introduce NUMAPolicy and NUMAMask options

Make possible to set NUMA allocation policy for manager. Manager's
policy is by default inherited to all forked off processes. However, it
is possible to override the policy on per-service basis. Currently we
support, these policies: default, prefer, bind, interleave, local.
See man 2 set_mempolicy for details on each policy.

Overall NUMA policy actually consists of two parts. Policy itself and
bitmask representing NUMA nodes where is policy effective. Node mask can
be specified using related option, NUMAMask. Default mask can be
overwritten on per-service level.

(cherry-picked from commit fe9c54b2188e6cd23262a319f96b13215f2c5e9c)

Resolves: #1734787

4 years agocpu-set-util: use %d-%d format in cpu_set_to_range_string() only for actual ranges
Michal Sekletar [Mon, 3 Jun 2019 08:12:35 +0000 (10:12 +0200)] 
cpu-set-util: use %d-%d format in  cpu_set_to_range_string() only for actual ranges

(cherry picked from commit 71923237b18df35401626993d8a285cd998be78d)

Related: #1734787

4 years agoexecute: dump CPUAffinity as a range string instead of a list of CPUs
Michal Sekletar [Fri, 31 May 2019 16:02:20 +0000 (18:02 +0200)] 
execute: dump CPUAffinity as a range string instead of a list of CPUs

We do this already when printing the property in systemctl so be
consistent and do the same for systemd-analyze dump.

(cherry picked from commit e7fca352ba43988682a927de6b1f629b3f10a415)

Related: #1734787

4 years agoshared/cpu-set-util: only force range printing one time
Zbigniew Jędrzejewski-Szmek [Wed, 29 May 2019 08:17:43 +0000 (10:17 +0200)] 
shared/cpu-set-util: only force range printing one time

The idea is to have at least one range to make the new format clearly
distinguishable from the old. But it is enough to just do it once.
In particular, in case the affinity would be specified like 0, 2, 4, 6…,
this gives much shorter output.

(cherry picked from commit 1f57a176af5152d05719bf43740e87a47e37af50)

Related: #1734787

4 years agosystemctl: present CPUAffinity mask as a list of CPU index ranges
Michal Sekletar [Wed, 22 May 2019 15:14:21 +0000 (17:14 +0200)] 
systemctl: present CPUAffinity mask as a list of CPU index ranges

(cherry picked from commit a047f4f10ed2f922d6079c033d24a443b0e95f38)

Related: #1734787

4 years agoshared/cpu-set-util: introduce cpu_set_to_range()
Michal Sekletar [Thu, 23 May 2019 12:27:18 +0000 (14:27 +0200)] 
shared/cpu-set-util: introduce cpu_set_to_range()

(cherry picked from commit 71b28519b55b496237146f9bcb5a627455f15f7e)

Related: #1734787

4 years agotest-cpu-set-util: add test for dbus conversions
Zbigniew Jędrzejewski-Szmek [Wed, 29 May 2019 07:44:16 +0000 (09:44 +0200)] 
test-cpu-set-util: add test for dbus conversions

(cherry picked from commit 1bf0d6c28f8c884e187c7dacc1a969c0763ff4e3)

Related: #1734787

4 years agoshared/cpu-set-util: make transfer of cpu_set_t over bus endian safe
Michal Sekletar [Wed, 22 May 2019 11:55:49 +0000 (13:55 +0200)] 
shared/cpu-set-util: make transfer of cpu_set_t over bus endian safe

(cherry picked from commit c367f996f5f091a63f812f0140b304c649be77fc)

Related: #1734787

4 years agoshared/cpu-set-util: drop now-unused cleanup function
Zbigniew Jędrzejewski-Szmek [Tue, 28 May 2019 19:40:10 +0000 (21:40 +0200)] 
shared/cpu-set-util: drop now-unused cleanup function

(cherry picked from commit cb0d3acf55ef335001cac5dd9c335ec5e75e9b56)

Related: #1734787

4 years agotest-execute: use CPUSet too
Zbigniew Jędrzejewski-Szmek [Tue, 28 May 2019 19:38:41 +0000 (21:38 +0200)] 
test-execute: use CPUSet too

cpu_set_malloc() was the last user. It doesn't seem useful to keep
it just to save the allocation of a few hundred bytes in a test, so
it is dropped and a fixed maximum is allocated (1024 bytes).

(cherry picked from commit 167a776dbe9d033523bd6881e5a695f2155dc321)

Related: #1734787

4 years agopid1: when reloading configuration, forget old settings
Zbigniew Jędrzejewski-Szmek [Fri, 24 May 2019 07:41:44 +0000 (09:41 +0200)] 
pid1: when reloading configuration, forget old settings

If we had a configuration setting from a configuration file, and it was
removed, we'd still remember the old value, because there's was no mechanism to
"reset" everything, just to assign new values.

Note that the effect of this is limited. For settings that have an "ongoing" effect,
like systemd.confirm_spawn, the new value is simply used. But some settings can only
be set at start.

In particular, CPUAffinity= will be updated if set to a new value, but if
CPUAffinity= is fully removed, it will not be reset, simply because we don't
know what to reset it to. We might have inherited a setting, or we might have
set it ourselves. In principle we could remember the "original" value that was
set when we were executed, but propagate this over reloads and reexecs, but
that would be a lot of work for little gain. So this corner case of removal of
CPUAffinity= is not handled fully, and a reboot is needed to execute the
change. As a work-around, a full mask of CPUAffinity=0-8191 can be specified.

(cherry picked from commit fb39af4ce42d7ef9af63009f271f404038703704)

Related: #1734787

4 years agopid1: don't reset setting from /proc/cmdline upon restart
Zbigniew Jędrzejewski-Szmek [Fri, 24 May 2019 06:59:23 +0000 (08:59 +0200)] 
pid1: don't reset setting from /proc/cmdline upon restart

We have settings which may be set on the kernel command line, and also
in /proc/cmdline (for pid1). The settings in /proc/cmdline have higher priority
of course. When a reload was done, we'd reload just the configuration file,
losing the overrides.

So read /proc/cmdline again during reload.

Also, when initially reading the configuration file when program starts,
don't treat any errors as fatal. The configuration done in there doesn't
seem important enough to refuse boot.

(cherry picked from commit 470a5e6dcec4637439ae953002127af214d396ac)

Related: #1734787

4 years agopid1: parse CPUAffinity= in incremental fashion
Zbigniew Jędrzejewski-Szmek [Fri, 24 May 2019 06:35:51 +0000 (08:35 +0200)] 
pid1: parse CPUAffinity= in incremental fashion

This makes the handling of this option match what we do in unit files. I think
consistency is important here. (As it happens, it is the only option in
system.conf that is "non-atomic", i.e. where there's a list of things which can
be split over multiple assignments. All other options are single-valued, so
there's no issue of how to handle multiple assignments.)

(cherry picked from commit 61fbbac1d517a0b3498a689c736c6ca918497904)

Related: #1734787

4 years agotest-cpu-set-util: add a smoke test for test_parse_cpu_set_extend()
Zbigniew Jędrzejewski-Szmek [Fri, 24 May 2019 06:50:41 +0000 (08:50 +0200)] 
test-cpu-set-util: add a smoke test for test_parse_cpu_set_extend()

(cherry picked from commit b54d7241f25b859c6c008e516c2131c39902e6e4)

Related: #1734787

4 years agotest-cpu-set-util: add simple test for cpus_in_affinity_mask()
Zbigniew Jędrzejewski-Szmek [Tue, 21 May 2019 07:01:34 +0000 (09:01 +0200)] 
test-cpu-set-util: add simple test for cpus_in_affinity_mask()

(cherry picked from commit 9d1345f0657c707df89b41b2738776efb40aec8e)

Related: #1734787

4 years agoMove cpus_in_affinity_mask() to cpu-set-util.[ch]
Zbigniew Jędrzejewski-Szmek [Tue, 28 May 2019 19:28:31 +0000 (21:28 +0200)] 
Move cpus_in_affinity_mask() to cpu-set-util.[ch]

It just seems to fit better there and it's always better to have things
in shared/ rather than basic/.

(cherry picked from commit f44b3035d4a698aa0ce08a552199b54d43de3d85)

Related: #1734787

4 years agoRework cpu affinity parsing
Zbigniew Jędrzejewski-Szmek [Tue, 21 May 2019 06:45:19 +0000 (08:45 +0200)] 
Rework cpu affinity parsing

The CPU_SET_S api is pretty bad. In particular, it has a parameter for the size
of the array, but operations which take two (CPU_EQUAL_S) or even three arrays
(CPU_{AND,OR,XOR}_S) still take just one size. This means that all arrays must
be of the same size, or buffer overruns will occur. This is exactly what our
code would do, if it received an array of unexpected size over the network.
("Unexpected" here means anything different from what cpu_set_malloc() detects
as the "right" size.)

Let's rework this, and store the size in bytes of the allocated storage area.

The code will now parse any number up to 8191, independently of what the current
kernel supports. This matches the kernel maximum setting for any architecture,
to make things more portable.

Fixes #12605.

(cherry picked from commit 0985c7c4e22c8dbbea4398cf3453da45ebf63800)

Related: #1734787

4 years agoshared/cpu-set-util: remove now-unused CPU_SIZE_TO_NUM()
Zbigniew Jędrzejewski-Szmek [Sun, 19 May 2019 16:08:39 +0000 (18:08 +0200)] 
shared/cpu-set-util: remove now-unused CPU_SIZE_TO_NUM()

(cherry picked from commit b12ef7141648be40fd8c4b0209a742f2151736d9)

Related: #1734787

4 years agoshared/cpu-set-util: move the part to print cpu-set into a separate function
Zbigniew Jędrzejewski-Szmek [Sun, 19 May 2019 16:02:38 +0000 (18:02 +0200)] 
shared/cpu-set-util: move the part to print cpu-set into a separate function

Also avoid unnecessary asprintf() when we can write to the output area
directly.

(cherry picked from commit a832893f9c4f0a0329768e90f67e2fa24bb0008e)

Related: #1734787

4 years agocore/dbus-execute: remove unnecessary initialization
Zbigniew Jędrzejewski-Szmek [Sun, 19 May 2019 14:05:02 +0000 (16:05 +0200)] 
core/dbus-execute: remove unnecessary initialization

(cherry picked from commit bd0abfaea1514bdd7cb60228d7a3f94c17ba916d)

Related: #1734787

4 years agocore: change ownership/mode of the execution directories also for static users
Lennart Poettering [Thu, 14 Mar 2019 16:19:30 +0000 (17:19 +0100)] 
core: change ownership/mode of the execution directories also for static users

It's probably unexpected if we do a recursive chown() when dynamic users
are used but not on static users.

hence, let's tweak the logic slightly, and recursively chown in both
cases, except when operating on the configuration directory.

Fixes: #11842
(cherry picked from commit 206e9864de460dd79d9edd7bedb47dee168765e1)

Resolves: #1778384

4 years agoexecute: remove one redundant comparison check
Lennart Poettering [Thu, 14 Mar 2019 16:01:46 +0000 (17:01 +0100)] 
execute: remove one redundant comparison check

(cherry picked from commit d484580ca6f0e79abe6f3f5c677323a22d9e22d7)

Related: #1778384

4 years agoAdd a warning about the difference in permissions between existing directories and...
Taro Yamada [Sun, 27 Jan 2019 04:50:04 +0000 (13:50 +0900)] 
Add a warning about the difference in permissions between existing directories and unit settings.

To follows the intent of 30c81ce, this change does not execute chmod() and just add warnings.

(cherry picked from commit 6cff72eb0a18d8547f005a481cd0622d3bc78483)

Related: #1778384

4 years agojournald: take leading spaces into account in syslog_parse_identifier
Evgeny Vereshchagin [Fri, 10 Aug 2018 12:55:09 +0000 (12:55 +0000)] 
journald: take leading spaces into account in syslog_parse_identifier

This is a kind of follow-up to e88baee88fad8bc59d3 which should finally fix
the issue which that commit was supposed to fix.

(cherry picked from commit 937b1171378bc1000a34fcdfe9534d898227e35f)

Resolves: #1764560

4 years agofuzz-journal-stream: avoid assertion failure on samples which don't fit in pipe
Zbigniew Jędrzejewski-Szmek [Tue, 26 Feb 2019 12:00:35 +0000 (13:00 +0100)] 
fuzz-journal-stream: avoid assertion failure on samples which don't fit in pipe

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11587.
We had a sample which was large enough that write(2) failed to push all the
data into the pipe, and an assert failed. The code could be changed to use
a loop, but then we'd need to interleave writes and sd_event_run (to process
the journal). I don't think the complexity is worth it — fuzzing works best
if the sample is not too huge anyway. So let's just reject samples above 64k,
and tell oss-fuzz about this limit.

(cherry picked from commit eafadd069c4e30ed62173123326a7237448615d1)

Resolves: #1764560

4 years agotests: add a fuzzer for server_process_native_file
Evgeny Vereshchagin [Thu, 22 Nov 2018 23:27:19 +0000 (00:27 +0100)] 
tests: add a fuzzer for server_process_native_file

(cherry picked from commit a4aa59bae206eebb4703b291147144def5d4bb3e)

Resolves: #1764560

4 years agotests: add a fuzzer for journald streams
Evgeny Vereshchagin [Tue, 20 Nov 2018 00:20:32 +0000 (01:20 +0100)] 
tests: add a fuzzer for journald streams

(cherry picked from commit 9541f5ff5c637bb1b3e3c69706cb73e68ff06813)

Resolves: #1764560

4 years agotests: introduce dummy_server_init and use it in all journald fuzzers
Evgeny Vereshchagin [Sat, 17 Nov 2018 12:01:09 +0000 (13:01 +0100)] 
tests: introduce dummy_server_init and use it in all journald fuzzers

(cherry picked from commit ed62712dc6fb236845c489a7f386c7aff0ec31d6)

Resolves: #1764560

4 years agojournald: check whether sscanf has changed the value corresponding to %n
Evgeny Vereshchagin [Fri, 16 Nov 2018 22:32:31 +0000 (23:32 +0100)] 
journald: check whether sscanf has changed the value corresponding to %n

It's possible for sscanf to receive strings containing all three fields
and not matching the template at the same time. When this happens the
value of k doesn't change, which basically means that process_audit_string
tries to access memory randomly. Sometimes it works and sometimes it doesn't :-)

See also https://bugzilla.redhat.com/show_bug.cgi?id=1059314.

(cherry picked from commit 1dab14aba749b9c5ab8176c5730107b70834240b)

Resolves: #1764560

4 years agotests: add a fuzzer for process_audit_string
Evgeny Vereshchagin [Fri, 16 Nov 2018 20:23:56 +0000 (21:23 +0100)] 
tests: add a fuzzer for process_audit_string

(cherry picked from commit 090a20cfaf3d5439fa39c5d8df473b0cfef181dd)

Resolves: #1764560

4 years agotest: initialize syslog_fd in fuzz-journald-kmsg too
Evgeny Vereshchagin [Fri, 16 Nov 2018 08:23:53 +0000 (09:23 +0100)] 
test: initialize syslog_fd in fuzz-journald-kmsg too

This is a follow-up to 8857fb9beb9dcb that prevents the fuzzer from crashing with
```
==220==ERROR: AddressSanitizer: ABRT on unknown address 0x0000000000dc (pc 0x7ff4953c8428 bp 0x7ffcf66ec290 sp 0x7ffcf66ec128 T0)
SCARINESS: 10 (signal)
    #0 0x7ff4953c8427 in gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35427)
    #1 0x7ff4953ca029 in abort (/lib/x86_64-linux-gnu/libc.so.6+0x37029)
    #2 0x7ff49666503a in log_assert_failed_realm /work/build/../../src/systemd/src/basic/log.c:805:9
    #3 0x7ff496614ecf in safe_close /work/build/../../src/systemd/src/basic/fd-util.c:66:17
    #4 0x548806 in server_done /work/build/../../src/systemd/src/journal/journald-server.c:2064:9
    #5 0x5349fa in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-journald-kmsg.c:26:9
    #6 0x592755 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:571:15
    #7 0x590627 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:480:3
    #8 0x594432 in fuzzer::Fuzzer::MutateAndTestOne() /src/libfuzzer/FuzzerLoop.cpp:708:19
    #9 0x5973c6 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:839:5
    #10 0x574541 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:764:6
    #11 0x5675fc in main /src/libfuzzer/FuzzerMain.cpp:20:10
    #12 0x7ff4953b382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #13 0x420f58 in _start (/out/fuzz-journald-kmsg+0x420f58)
```

(cherry picked from commit cc55ac0171a2493768c021faa356513642797e7f)

Resolves: #1764560

4 years agotests: add a reproducer for a heap-buffer-overflow fixed in 937b1171378bc1000a
Evgeny Vereshchagin [Fri, 16 Nov 2018 06:33:02 +0000 (07:33 +0100)] 
tests: add a reproducer for a heap-buffer-overflow fixed in 937b1171378bc1000a

(cherry picked from commit f7a6b40187a98751a9ab6867e8b52e4e6f1dad5c)

Resolves: #1764560

4 years agotests: add a reproducer for a memory leak fixed in 30eddcd51b8a472e05d3b8d1 in August
Evgeny Vereshchagin [Fri, 16 Nov 2018 06:20:44 +0000 (07:20 +0100)] 
tests: add a reproducer for a memory leak fixed in 30eddcd51b8a472e05d3b8d1 in August

(cherry picked from commit 1dd485b700fe9ad94d7a780f14fcf18a4738ace4)

Resolves: #1764560

4 years agojournal: fix an off-by-one error in dev_kmsg_record
Evgeny Vereshchagin [Fri, 16 Nov 2018 06:11:06 +0000 (07:11 +0100)] 
journal: fix an off-by-one error in dev_kmsg_record

(cherry picked from commit 080d112caa0dc948555a69a008c1caf4d5d41ed6)

Resolves: #1764560

4 years agobasic: remove an assertion from cunescape_one
Evgeny Vereshchagin [Fri, 16 Nov 2018 06:05:29 +0000 (07:05 +0100)] 
basic: remove an assertion from cunescape_one

The function takes a pointer to a random block of memory and
the length of that block. It shouldn't crash every time it sees
a zero byte at the beginning there.

This should help the dev-kmsg fuzzer to keep going.

(cherry picked from commit 8dc4de966ce6d32470aaff30ed054f6a2688d6d7)

Resolves: #1764560

4 years agotests: add a fuzzer for dev_kmsg_record
Evgeny Vereshchagin [Thu, 15 Nov 2018 16:52:57 +0000 (17:52 +0100)] 
tests: add a fuzzer for dev_kmsg_record

(cherry picked from commit 8857fb9beb9dcb95a6ce1be14dc94c4dc4cd3ea3)

Resolves: #1764560

4 years agotests: put fuzz_journald_processing_function in a .c file
Evgeny Vereshchagin [Fri, 7 Sep 2018 06:13:17 +0000 (06:13 +0000)] 
tests: put fuzz_journald_processing_function in a .c file

(cherry picked from commit 231dca5579cfba6175d19eee5347d693893fb5aa)

Resolves: #1764560

4 years agosd-bus: bump message queue size again
Jan Synacek [Fri, 8 Nov 2019 13:54:30 +0000 (14:54 +0100)] 
sd-bus: bump message queue size again

Simliarly to issue #4068, the current limit turns out to be too small for a
big storage setup that uses many small disks. Let's bump it further.

(cherry picked from commit 83a32ea7b03d6707b8e5bb90a0b3a6eb868ef633)
Resolves: #1770189

4 years agobasic/user-util: allow dots in user names
Jan Synacek [Wed, 2 Oct 2019 09:59:41 +0000 (11:59 +0200)] 
basic/user-util: allow dots in user names

(based on commit 1a29610f5fa1bcb2eeb37d2c6b79d8d1a6dbb865)

Resolves: #1717603

4 years agojournal: rely on _cleanup_free_ to free a temporary string used in client_context_rea...
Evgeny Vereshchagin [Sun, 23 Dec 2018 23:29:56 +0000 (00:29 +0100)] 
journal: rely on _cleanup_free_ to free a temporary string used in client_context_read_cgroup

Closes https://github.com/systemd/systemd/issues/11253.

(cherry picked from commit ef30f7cac18a810814ada7e6a68a31d48cc9fccd)

Resolves: #1764560

4 years agoresolved: query polkit only after parsing the data v239-19
Zbigniew Jędrzejewski-Szmek [Tue, 27 Aug 2019 17:28:19 +0000 (19:28 +0200)] 
resolved: query polkit only after parsing the data

That's what we do everywhere else because it leads to nicer user experience.

Related: #1746857

4 years agoresolved: allow access to Set*Link and Revert methods through polkit
Zbigniew Jędrzejewski-Szmek [Tue, 27 Aug 2019 17:25:05 +0000 (19:25 +0200)] 
resolved: allow access to Set*Link and Revert methods through polkit

This matches what is done in networkd very closely. In fact even the
policy descriptions are all identical (with s/network/resolve), except
for the last one:
resolved has org.freedesktop.resolve1.revert while
networkd has org.freedesktop.network1.revert-ntp and
org.freedesktop.network1.revert-dns so the description is a bit different.

Conflicts:
src/resolve/resolved-bus.c
src/resolve/resolved-link-bus.c

Related: #1746857

4 years agoresolved: do not run loop twice
Zbigniew Jędrzejewski-Szmek [Tue, 27 Aug 2019 17:02:53 +0000 (19:02 +0200)] 
resolved: do not run loop twice

This doesn't matter much, but let's just do the loop once and allocate
the populate the result set on the fly. If we find an error, it'll get
cleaned up automatically.

Related: #1746857

4 years agosd-bus: adjust indentation of comments
Zbigniew Jędrzejewski-Szmek [Tue, 27 Aug 2019 17:00:50 +0000 (19:00 +0200)] 
sd-bus: adjust indentation of comments

Related: #1746857

4 years agoshared/but-util: drop trusted annotation from bus_open_system_watch_bind_with_descrip...
Zbigniew Jędrzejewski-Szmek [Tue, 27 Aug 2019 17:00:34 +0000 (19:00 +0200)] 
shared/but-util: drop trusted annotation from bus_open_system_watch_bind_with_description()

https://bugzilla.redhat.com/show_bug.cgi?id=1746057

This only affects systemd-resolved. bus_open_system_watch_bind_with_description()
is also used in timesyncd, but it has no methods, only read-only properties, and
in networkd, but it annotates all methods with SD_BUS_VTABLE_UNPRIVILEGED and does
polkit checks.

Resolves: #1746857

4 years agoudev: Add id program and rule for FIDO security tokens
Fabian Henneke [Wed, 21 Aug 2019 09:17:59 +0000 (11:17 +0200)] 
udev: Add id program and rule for FIDO security tokens

Add a fido_id program meant to be run for devices in the hidraw
subsystem via an IMPORT directive. The program parses the HID report
descriptor and assigns the ID_SECURITY_TOKEN environment variable if a
declared usage matches the FIDO_CTAPHID_USAGE declared in the FIDO CTAP
specification. This replaces the previous approach of whitelisting all
known security token models manually.

This commit is accompanied by a test suite and a fuzzer target for the
descriptor parsing routine.

Fixes: #11996.
(cherry picked from commit d45ee2f31a8358db0accde2e7c81777cedadc3c2)

Resolves: #1753369

4 years agosd-device: introduce log_device_*() macros
Yu Watanabe [Mon, 22 Oct 2018 03:04:13 +0000 (12:04 +0900)] 
sd-device: introduce log_device_*() macros

(cherry picked from commit b0cba0ca526ed2d86e283a0fcfebdf0a4d4bea9b)

Related: #1753369

4 years agoselinux: don't log SELINUX_INFO and SELINUX_WARNING messages to audit
Michal Sekletar [Tue, 26 Feb 2019 16:33:27 +0000 (17:33 +0100)] 
selinux: don't log SELINUX_INFO and SELINUX_WARNING messages to audit

Previously we logged even info message from libselinux as USER_AVC's to
audit. For example, setting SELinux to permissive mode generated
following audit message,

time->Tue Feb 26 11:29:29 2019
type=USER_AVC msg=audit(1551198569.423:334): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:  received setenforce notice (enforcing=0)  exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'

This is unnecessary and wrong at the same time. First, kernel already
records audit event that SELinux was switched to permissive mode, also
the type of the message really shouldn't be USER_AVC.

Let's ignore SELINUX_WARNING and SELINUX_INFO and forward to audit only
USER_AVC's and errors as these two libselinux message types have clear
mapping to audit message types.

(cherry picked from commit 6227fc14c48c4c17daed4b91f61cdd4aa375790a)

Resolves: #1763612

4 years agoshared/sleep-config: exclude zram devices from hibernation candidates
Andrew Jorgensen [Wed, 25 Jul 2018 15:06:57 +0000 (08:06 -0700)] 
shared/sleep-config: exclude zram devices from hibernation candidates

On a host with sufficiently large zram but with no actual swap, logind will
respond to CanHibernate() with yes. With this patch, it will correctly respond
no, unless there are other swap devices to consider.

(cherry picked from commit 411ae92b407bd7b4549b205ad754bcd0e3dfd81f)

Resolves: #1763617

4 years agotest: bump the second partition's size to 50M
Frantisek Sumsal [Mon, 21 Oct 2019 16:39:39 +0000 (18:39 +0200)] 
test: bump the second partition's size to 50M

The former size (10M) caused systemd-journald to crash with SIGABRT when
used on a LUKS2 partition, as the LUKS2 metadata consume a significant
part of the 10M partition, thus leaving no space for the journal file
itself (relevant for TEST-02-CRYPTSETUP). This change has been present
in upstream for a while anyway.

Related: #1761519
rhel-only

4 years agotest: mask several unnecessary services
Yu Watanabe [Thu, 1 Nov 2018 08:26:36 +0000 (17:26 +0900)] 
test: mask several unnecessary services

This may make CIs run faster.

(cherry picked from commit 056ae88152a722bdbea54ff33db815d585c8b9c6)

Related: #1761519

4 years agotest: use PBKDF2 instead of Argon2 in cryptsetup...
Frantisek Sumsal [Fri, 15 Mar 2019 09:05:33 +0000 (10:05 +0100)] 
test: use PBKDF2 instead of Argon2 in cryptsetup...

to reduce memory requirements for volume manipulation. Also,
to further improve the test performance, reduce number of PBKDF
iterations to 1000 (allowed minimum).

(cherry picked from commit 5b69d297c153478f6f5e74ba66e1f4e5b6422baf)

Related: #1761519

4 years agojournald: fixed assertion failure when system journal rotation fails (#9893)
Renaud Métrich [Mon, 3 Sep 2018 03:42:39 +0000 (05:42 +0200)] 
journald: fixed assertion failure when system journal rotation fails (#9893)

(cherry picked from commit fd790d6f09b10a87b007b71403cb018f18ff91c9)

Resolves: #1763619

4 years agopath: stop watching path specs once we triggered the target unit
Michal Sekletar [Mon, 9 Sep 2019 12:38:35 +0000 (14:38 +0200)] 
path: stop watching path specs once we triggered the target unit

We start watching them again once we get a notification that triggered
unit entered inactive or failed state.

Fixes: #10503
(cherry picked from commit 8fca6944c2ee20c63d62154c8badddc77170b176)

Resolves: #1763161

4 years agocore: implement per unit journal rate limiting
Anita Zhang [Mon, 8 Oct 2018 03:28:36 +0000 (20:28 -0700)] 
core: implement per unit journal rate limiting

Add LogRateLimitIntervalSec= and LogRateLimitBurst= options for
services. If provided, these values get passed to the journald
client context, and those values are used in the rate limiting
function in the journal over the the journald.conf values.

Part of #10230

(cherry picked from commit 90fc172e191f44979005a524521112f2bd1ff21b)

Resolves: #1719577

4 years agocore: only watch processes when it's really necessary
Franck Bui [Tue, 19 Mar 2019 09:59:26 +0000 (10:59 +0100)] 
core: only watch processes when it's really necessary

If we know that main pid is our child then it's unnecessary to watch all
other processes of a unit since in this case we will get SIGCHLD when the main
process will exit and will act upon accordingly.

So let's watch all processes only if the main process is not our child since in
this case we need to detect when the cgroup will become empty in order to
figure out when the service becomes dead. This is only needed by cgroupv1.

Thanks Renaud Métrich for backporting this to RHEL.
Resolves: #1744972

4 years agocore: reduce the number of stalled PIDs from the watched processes list when possible
Franck Bui [Mon, 18 Mar 2019 19:59:36 +0000 (20:59 +0100)] 
core: reduce the number of stalled PIDs from the watched processes list when possible

Some PIDs can remain in the watched list even though their processes have
exited since a long time. It can easily happen if the main process of a forking
service manages to spawn a child before the control process exits for example.

However when a pid is about to be mapped to a unit by calling unit_watch_pid(),
the caller usually knows if the pid should belong to this unit exclusively: if
we just forked() off a child, then we can be sure that its PID is otherwise
unused. In this case we take this opportunity to remove any stalled PIDs from
the watched process list.

If we learnt about a PID in any other form (for example via PID file, via
searching, MAINPID= and so on), then we can't assume anything.

Thanks Renaud Métrich for backporting this to RHEL.
Resolves: #1744972

4 years agoprocess-util: introduce pid_is_my_child() helper
Franck Bui [Mon, 18 Mar 2019 10:48:34 +0000 (11:48 +0100)] 
process-util: introduce pid_is_my_child() helper

No functional changes.

Thanks Renaud Métrich for backporting this to RHEL.
Resolves: #1744972

4 years agoConsider smb3 as remote filesystem
Jan Synacek [Tue, 1 Oct 2019 06:45:08 +0000 (08:45 +0200)] 
Consider smb3 as remote filesystem

Currently systemd will treat smb3 as local filesystem and cause
can't boot failures. Add smb3 to the list of remote filesystems
to fix this issue.

Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
(cherry picked from commit ff7d6a740b0c6fa3be63d3908a0858730a0837c5)

Resolves: #1757257

4 years agoCall getgroups() to know size of supplementary groups array to allocate
Renaud Métrich [Fri, 13 Sep 2019 09:18:18 +0000 (11:18 +0200)] 
Call getgroups() to know size of supplementary groups array to allocate

Resolves RHBZ #1743230 - journalctl dumps core when stack limit is reduced to 256 KB

(cherry picked from commit f5e0b942af1e86993c21f4e5c84342bb10403dac)

Resolves: #1743235

4 years agoudev: introduce CONST key name
Jan Synacek [Thu, 17 Oct 2019 07:37:35 +0000 (09:37 +0200)] 
udev: introduce CONST key name

Currently, there is no way to match against system-wide constants, such
as architecture or virtualization type, without forking helper binaries.
That potentially results in a huge number of spawned processes which
output always the same answer.

This patch introduces a special CONST keyword which takes a hard-coded
string as its key and returns a value assigned to that key. Currently
implemented are CONST{arch} and CONST{virt}, which can be used to match
against the system's architecture and virtualization type.

(based on commit 4801d8afe2ff1c1c075c9f0bc5631612172e0bb7)

Resolves: #1762679

4 years agobuildsys: don't garbage collect sections while linking
Michal Sekletar [Tue, 3 Sep 2019 08:05:42 +0000 (10:05 +0200)] 
buildsys: don't garbage collect sections while linking

gc-sections is actually very aggressive and garbage collects ELF
sections used by annobin gcc plugin and annocheck then reports gaps in
coverage. Let's drop that linker flag.

RHEL-only

Resolves: #1748258

4 years agocore: try to reopen /dev/kmsg again right after mounting /dev
Lennart Poettering [Fri, 19 Jul 2019 16:29:11 +0000 (18:29 +0200)] 
core: try to reopen /dev/kmsg again right after mounting /dev

I was debugging stuff during early boot, and was confused that I never
found the logs for it in kmsg. The reason for that was that /proc is
generally not mounted the first time we do log_open() and hence
log_set_target(LOG_TARGET_KMSG) we do when running as PID 1 had not
effect. A lot later during start-up we call log_open() again where this
is fixed (after the point where we close all remaining fds still open),
but in the meantime no logs every got written to kmsg. This patch fixes
that.

(cherry picked from commit 0a2eef1ee1fef74be9d12f7dc4d0006b645b579c)

Resolves: #1749212

4 years agoask-password: prevent buffer overrow when reading from keyring
Thadeu Lima de Souza Cascardo [Mon, 13 May 2019 19:58:01 +0000 (16:58 -0300)] 
ask-password: prevent buffer overrow when reading from keyring

When we read from keyring, a temporary buffer is allocated in order to
determine the size needed for the entire data. However, when zeroing that area,
we use the data size returned by the read instead of the lesser size allocate
for the buffer.

That will cause memory corruption that causes systemd-cryptsetup to crash
either when a single large password is used or when multiple passwords have
already been pushed to the keyring.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
(cherry picked from commit 59c55e73eaee345e1ee67c23eace8895ed499693)

Resolves: #1752050

4 years agokernel-install: do not require non-empty kernel cmdline
Zbigniew Jędrzejewski-Szmek [Fri, 23 Aug 2019 09:34:45 +0000 (11:34 +0200)] 
kernel-install: do not require non-empty kernel cmdline

When booting with Fedora-Server-dvd-x86_64-30-20190411.n.0.iso,
/proc/cmdline is empty (libvirt, qemu host with bios, not sure if that
matters), after installation to disk, anaconda would "crash" in kernel-core
%posttrans, after calling kernel-install, because dracut would fail
with

> Could not determine the kernel command line parameters.
> Please specify the kernel command line in /etc/kernel/cmdline!

I guess it's legitimate, even if unusual, to have no cmdline parameters.
Two changes are done in this patch:

1. do not fail if the cmdline is empty.
2. if /usr/lib/kernel/cmdline or /etc/kernel/cmdline are present, but
   empty, ignore /proc/cmdline. If there's explicit configuration to
   have empty cmdline, don't ignore it.

The same change was done in dracut:
https://github.com/dracutdevs/dracut/pull/561.

(cherry picked from commit 88e1306af6380794842fb31108ba67895799fab4)

Resolves: #1701454

4 years agotravis: don't run slow tests under ASan/UBSan
Frantisek Sumsal [Mon, 14 Oct 2019 15:14:35 +0000 (17:14 +0200)] 
travis: don't run slow tests under ASan/UBSan

Resolves: #1761519

4 years agosd-bus: make strict asan shut up
Lennart Poettering [Fri, 16 Nov 2018 12:00:40 +0000 (13:00 +0100)] 
sd-bus: make strict asan shut up

asan doesn't like it if we use strndup() (i.e. a string function) on a
non-NULL terminated buffer (i.e. something that isn't really a string).

Let's hence use memdup_suffix0() instead of strndup(), which is more
appropriate for binary data that is to become a string.

Fixes: #10385
(cherry picked from commit ac0a94f7438b49a0890d9806db1fa211a5bca10a)

Resolves: #1761519

4 years agosyslog: fix segfault in syslog_parse_priority()
Yu Watanabe [Wed, 8 Aug 2018 09:27:15 +0000 (18:27 +0900)] 
syslog: fix segfault in syslog_parse_priority()

(cherry picked from commit a5ee33b951cfa22db53d0274c9c6c0d9d4dae39d)

Resolves: #1761519

4 years agotravis: drop SCL remains
Frantisek Sumsal [Mon, 14 Oct 2019 14:22:51 +0000 (16:22 +0200)] 
travis: drop SCL remains

The `bash -ic` wrapper existed solely to make SCL work as expected

Resolves: #1761519

4 years agotravis: move to CentOS 8 docker images
Frantisek Sumsal [Mon, 14 Oct 2019 13:26:48 +0000 (15:26 +0200)] 
travis: move to CentOS 8 docker images

As the CentOS 8 Docker images is finally out, we can use it and drop the
plethora of workarounds we had to implement to compile RHEL8 systemd on
CentOS 7.

Resolves: #1761519

4 years agoman: reorder and add examples to systemd-analyze(1)
Zbigniew Jędrzejewski-Szmek [Fri, 15 Mar 2019 09:13:55 +0000 (10:13 +0100)] 
man: reorder and add examples to systemd-analyze(1)

The number of verbs supported by systemd-analyze has grown quite a bit, and the
man page has become an unreadable wall of text. Let's put each verb in a
separate subsection, grouping similar verbs together, and add a lot of examples
to guide the user.

(cherry picked from commit d323a99001c1f7625e8ac902e18deb514a4ca18d)

Related: #1750343

4 years agoman: document systemd-analyze security
Jan Synacek [Fri, 13 Sep 2019 07:23:32 +0000 (09:23 +0200)] 
man: document systemd-analyze security

(cherry-picked from commit ee93c1e664a7bbc59f1578e285c871999507b14d)

Resolves: #1750343

4 years agocore: never propagate reload failure to service result
Lennart Poettering [Wed, 17 Jul 2019 17:16:33 +0000 (19:16 +0200)] 
core: never propagate reload failure to service result

Fixes: #11238
(cherry picked from commit d611cfa748aaf600832160132774074e808c82c7)

Resolves: #1735787

4 years agoanalyze-security: fix potential division by zero v239-17 v239-18
Jan Synacek [Wed, 31 Jul 2019 07:13:41 +0000 (09:13 +0200)] 
analyze-security: fix potential division by zero

Upstream PR: https://github.com/systemd/systemd/pull/13238

Resolves: #1734400

4 years agoswap: scan /proc/swaps before processing waitid() results
Lennart Poettering [Wed, 17 Jul 2019 16:58:44 +0000 (18:58 +0200)] 
swap: scan /proc/swaps before processing waitid() results

Similar to the previous commit, but for /proc/swaps, where the same
logic and rationale applies.

(cherry picked from commit bcce581d65de68cca01c73e1c890e261e72d20af)

Related: #1696178

4 years agomount: rescan /proc/self/mountinfo before processing waitid() results
Lennart Poettering [Wed, 17 Jul 2019 16:57:13 +0000 (18:57 +0200)] 
mount: rescan /proc/self/mountinfo before processing waitid() results

(The interesting bits about the what and why are in a comment in the
patch, please have a look there instead of looking here in the commit
msg).

Fixes: #10872
(cherry picked from commit 350804867dbcc9b7ccabae1187d730d37e2d8a21)

Conflicts:
src/core/mount.c

Resolves: #1696178

4 years agomount: simplify /proc/self/mountinfo handler
Lennart Poettering [Wed, 17 Jul 2019 12:53:07 +0000 (14:53 +0200)] 
mount: simplify /proc/self/mountinfo handler

Our IO handler is only installed for one fd, hence there's no reason to
conditionalize on it again.

Also, split out the draining into a helper function of its own.

(cherry picked from commit fcd8e119c28be19ffbc5227089cf4d3b8ba60238)

Conflicts:
src/core/mount.c

Related: #1696178

4 years agorules: skip memory hotplug on ppc64 v239-16
Jan Synacek [Thu, 6 Jun 2019 07:35:27 +0000 (09:35 +0200)] 
rules: skip memory hotplug on ppc64

Resolves (#1713159)

4 years agoman: note that journal does not validate syslog fields
Jan Synacek [Tue, 14 May 2019 08:45:08 +0000 (10:45 +0200)] 
man: note that journal does not validate syslog fields

(cherry picked from commit 63ea8032f28052f7cda860e5324c0a83dee7ed23)

Resolves: #1707175

4 years agobash-completion: analyze: support 'security'
Yu Watanabe [Thu, 6 Dec 2018 17:51:56 +0000 (18:51 +0100)] 
bash-completion: analyze: support 'security'

(cherry picked from commit 83da42c3bf86e8787cfec2c7fb6ca379dfec3632)

Resolves: #1733395

4 years agoChange job mode of manager triggered restarts to JOB_REPLACE
Jonathon Kowalski [Thu, 17 Jan 2019 17:08:00 +0000 (17:08 +0000)] 
Change job mode of manager triggered restarts to JOB_REPLACE

Fixes: #11305
Fixes: #3260
Related: #11456

So, here's what happens in the described scenario in #11305. A unit goes
down, and that triggeres stop jobs for the other two units as they were
bound to it. Now, the timer for manager triggered restarts kicks in and
schedules a restart job with the JOB_FAIL job mode. This means there is
a stop job installed on those units, and now due to them being bound to
us they also get a restart job enqueued. This however is a conflicts, as
neither stop can merge into restart, nor restart into stop. However,
restart should be able to replace stop in any case. If the stop
procedure is ongoing, it can cancel the stop job, install itself, and
then after reaching dead finish and convert itself to a start job.
However, if we increase the timer, then it can always take those units
from inactive -> auto-restart.

We change the job mode to JOB_REPLACE so the restart job cancels the
stop job and installs itself.

Also, the original bug could be worked around by bumping RestartSec= to
avoid the conflicting.

This doesn't seem to be something that is going to break uses. That is
because for those who already had it working, there must have never been
conflicting jobs, as that would result in a desctructive transaction by
virtue of the job mode used.

After this change, the test case is able to work nicely without issues.

(cherry picked from commit 03ff2dc71ecb09272d728d458498b44f7f132f51)

Resolves: #1712524

4 years agoudev/scsi_id: fix incorrect page length when get device identification VPD page
Zhang Xianwei [Mon, 13 May 2019 10:41:55 +0000 (18:41 +0800)] 
udev/scsi_id: fix incorrect page length when get device identification VPD page

The length of device identification VPD page is filled with two bytes,
but scsi_id only gets the low byte. Fix it.

Signed-off-by: Zhang Xianwei <zhang.xianwei8@zte.com.cn>
(cherry picked from commit 1f7b6872dbe8ccae1f3bda9aa6aeb87c9b42e01e)

Resolves: #1713227

4 years agocryptsetup: Add LUKS2 token support.
Milan Broz [Mon, 27 May 2019 07:44:14 +0000 (09:44 +0200)] 
cryptsetup: Add LUKS2 token support.

LUKS2 supports so-called tokens. The libcryptsetup internally
support keyring token (it tries to open device using specified
keyring entry).
Only if all token fails (or are not available), it uses a passphrase.

This patch aligns the functionality with the cryptsetup utility
(cryptsetup luksOpen tries tokens first) but does not replace
the systemd native ask-password function (can be used the same in
combination with this patch).

(cherry picked from commit 894bb3ca4c730cc9e9d46ef5004ba4ca5e201d8d)

Resolves: #1719153

4 years agocryptsetup: call crypt_load() for LUKS only once
Milan Broz [Mon, 27 May 2019 07:43:03 +0000 (09:43 +0200)] 
cryptsetup: call crypt_load() for LUKS only once

The crypt_load() for LUKS2 can read a quite big area of disk
(metadata area size is configurable and can increase up to megabytes).

This initialization is not needed to be repeated, just use the existing context.

(This patch is also required for the following change.)

(cherry picked from commit ea9a9d49e4af31c49e5c216e7e5e2f533e727579)

Related: #1719153

4 years agocryptsetup: Do not fallback to PLAIN mapping if LUKS data device set fails.
Milan Broz [Mon, 27 May 2019 07:27:54 +0000 (09:27 +0200)] 
cryptsetup: Do not fallback to PLAIN mapping if LUKS data device set fails.

If crypt_load() for LUKS succeeds, we know that it is a LUKS device.
Failure of data device setting should fail in this case; remapping
as a PLAIN device late could mean data corruption.

(If a user wants to map PLAIN device over a device with LUKS header,
it should be said explicitly with "plain" argument type.)

Also, if there is no explicit PLAIN type requested and crypt device
is already initialized (crypt_data_type() is set), do not run
the initialization again.

(cherry picked from commit 2e4beb875bcb24e7d7d4339cc202b0b3f2953f71)

Related: #1719153

4 years agojournal: do not remove multiple spaces after identifier in syslog message
Yu Watanabe [Fri, 10 Aug 2018 02:07:54 +0000 (11:07 +0900)] 
journal: do not remove multiple spaces after identifier in syslog message

Single space is used as separator.
C.f. discussions in #156.

Fixes #9839 introduced by a6aadf4ae0bae185dc4c414d492a4a781c80ffe5.

(cherry picked from commit 8595102d3ddde6d25c282f965573a6de34ab4421)

Resolves: #1691817

4 years agojournal-remote: do not request Content-Length if Transfer-Encoding is chunked
Yu Watanabe [Mon, 11 Mar 2019 03:27:18 +0000 (12:27 +0900)] 
journal-remote: do not request Content-Length if Transfer-Encoding is chunked

This fixes a bug introduced by 7fdb237f5473cb8fc2129e57e8a0039526dcb4fd.

Closes #11571.

(cherry picked from commit a289dfd69b3ff4bccdde93e84b67c947bafa27e1)

Resolves: #1708849

4 years agosd-bus: deal with cookie overruns
Lennart Poettering [Mon, 25 Feb 2019 10:02:46 +0000 (11:02 +0100)] 
sd-bus: deal with cookie overruns

Apparently this happens IRL. Let's carefully deal with issues like this:
when we overrun, let's not go back to zero but instead leave the highest
cookie bit set. We use that as indication that we are in "overrun
territory", and then are particularly careful with checking cookies,
i.e. that they haven't been used for still outstanding replies yet. This
should retain the quick cookie generation behaviour we used to have, but
permits dealing with overruns.

Replaces: #11804
Fixes: #11809
(cherry picked from commit 1f82f5bb4237ed5f015daf93f818e9db95e764b8)

Resolves: #1694999

5 years agojournal-gateway: use localStorage["cursor"] only when it has valid value v239-15
Yu Watanabe [Wed, 27 Jun 2018 05:50:19 +0000 (14:50 +0900)] 
journal-gateway: use localStorage["cursor"] only when it has valid value

Discovered by LGTM.

(cherry picked from commit 944072feddb73333023d0a98bf87fd2a17f894d3)

Resolves: #1705971

5 years agotools: drop unused variable
Yu Watanabe [Sat, 8 Dec 2018 10:33:37 +0000 (19:33 +0900)] 
tools: drop unused variable

(cherry picked from commit 2f6c9b6f3fb0128cee7f74985c143b4850feff6d)

Resolves: #1705971

5 years agojournal-gateway: explicitly declare local variables
Yu Watanabe [Wed, 27 Jun 2018 05:22:24 +0000 (14:22 +0900)] 
journal-gateway: explicitly declare local variables

Suggested by LGTM.

(cherry picked from commit c497e449f41774a36e01ae2cc2abade6133dffe1)

Resolves: #1705971

5 years agotest: add test for Type=exec
Lennart Poettering [Tue, 17 Jul 2018 10:35:12 +0000 (12:35 +0200)] 
test: add test for Type=exec

(cherry picked from commit 0e1f17561f5f6061ec5503de044298372ed7ca37)

Resolves: #1683334

5 years agosd-login: let's also make sd-login understand ".host"
Lennart Poettering [Tue, 17 Jul 2018 10:24:50 +0000 (12:24 +0200)] 
sd-login: let's also make sd-login understand ".host"

if sd-bus and machined grok it, then sd-login should grok it too.

(cherry picked from commit a8c9b7a0fc0aa02666042543ff9a652aae3c9499)

Resolves: #1683334