]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agologind: style fixes
Ludwig Nussel [Mon, 7 Feb 2022 09:56:19 +0000 (10:56 +0100)] 
logind: style fixes

2 years agologind: add handle enum to struct
Ludwig Nussel [Thu, 3 Feb 2022 16:08:28 +0000 (17:08 +0100)] 
logind: add handle enum to struct

Avoid pointer arithmetic at the expense of repeating the enum value
in the struct.

2 years agoMerge pull request #22383 from yuwata/network-generator-keep-configuration
Luca Boccassi [Mon, 7 Feb 2022 18:06:24 +0000 (18:06 +0000)] 
Merge pull request #22383 from yuwata/network-generator-keep-configuration

network: enable KeepConfiguration= when running on network filesystem

2 years agologin: typo fix
Michael Biebl [Mon, 7 Feb 2022 16:49:26 +0000 (17:49 +0100)] 
login: typo fix

2 years agoman: fix typo
Michael Biebl [Mon, 7 Feb 2022 13:57:00 +0000 (14:57 +0100)] 
man: fix typo

2 years agoUpdate CODING_STYLE.md
bearhoney [Mon, 7 Feb 2022 10:41:41 +0000 (11:41 +0100)] 
Update CODING_STYLE.md

Fixed typo.

2 years agotests: also fuzz packets sent in the DHCP6_STATE_SOLICITATION state
Evgeny Vereshchagin [Fri, 4 Feb 2022 15:17:25 +0000 (15:17 +0000)] 
tests: also fuzz packets sent in the DHCP6_STATE_SOLICITATION state

With aborts enabled the fuzzer can catch issues like
https://github.com/systemd/systemd/commit/26a63b81322a3bd8b9fbd43f75897c391708de2c
Let's extend it a bit to let it cover issues like
https://github.com/systemd/systemd/pull/22406#discussion_r798932098

2 years agosd-dhcp6-client: fix sending prefix delegation request during rebind
Thomas Haller [Thu, 3 Feb 2022 17:55:18 +0000 (18:55 +0100)] 
sd-dhcp6-client: fix sending prefix delegation request during rebind

Fixes an assertion failure "pd->type == SD_DHCP6_OPTION_IA_PD" in dhcp6_option_append_pd().

Something similar was done in commit 26a63b81322a ('sd-dhcp6-client: Fix
sending prefix delegation request (#17136)'). The justification is
probably the same.

2 years agonetwork: enable KeepConfiguration= when running on network filesystem 22383/head
Yu Watanabe [Fri, 4 Feb 2022 06:33:38 +0000 (15:33 +0900)] 
network: enable KeepConfiguration= when running on network filesystem

Also, set KeepConfiguration=dhcp-on-stop by default when running in
initrd.

Fixes #21967.

2 years agoMerge pull request #22416 from fbuihuu/misc
Yu Watanabe [Sat, 5 Feb 2022 00:26:40 +0000 (09:26 +0900)] 
Merge pull request #22416 from fbuihuu/misc

Misc

2 years agoMerge pull request #22395 from benzea/benzea/oomd-dump-offenders
Anita Zhang [Fri, 4 Feb 2022 22:44:04 +0000 (14:44 -0800)] 
Merge pull request #22395 from benzea/benzea/oomd-dump-offenders

oomd: Dump top offenders after a kill action

2 years agooomd: Dump top offenders after a kill action 22395/head
Benjamin Berg [Thu, 3 Feb 2022 14:50:31 +0000 (15:50 +0100)] 
oomd: Dump top offenders after a kill action

This hopefully makes it more transparent why a specific cgroup was
killed by systemd-oomd.

2 years agoman: systemd-stdio-bridge doesn't connect "two busses"
Lennart Poettering [Thu, 3 Feb 2022 14:57:00 +0000 (15:57 +0100)] 
man: systemd-stdio-bridge doesn't connect "two busses"

In D-Bus, clients connect to a bus (the usual case), or use direct
questions to each other (the unusual case). A bus is a program one can
connect to and implemented by dbus-daemon or dbus-broker. HOwever,
busses never connect between each other, that doesn't exist. Hence don't
claim so.

This is probably confusion about the fact that sd-bus calls D-Bus
connection objects just "sd_bus" for simplicity, given they are used in
99% of the cases to connect to a bus — only in exceptional cases they
are used for direct connections between peers without involving a bus.

Follow-up for b7bb58ef70b0c876941a1c31ed4e2f5f1dc5ed0e

2 years agoMerge pull request #22378 from bluca/on_fail_follow_ups
Lennart Poettering [Fri, 4 Feb 2022 15:29:09 +0000 (16:29 +0100)] 
Merge pull request #22378 from bluca/on_fail_follow_ups

Follow-ups for #20833

2 years agoMerge pull request #22375 from michaelolbrich/watchdog
Lennart Poettering [Fri, 4 Feb 2022 15:28:41 +0000 (16:28 +0100)] 
Merge pull request #22375 from michaelolbrich/watchdog

fix watchdog handling during reboot

2 years agosystemd.netdev(5): fix acronym for DOVE extensions
Ruben Kerkhof [Fri, 4 Feb 2022 15:07:12 +0000 (16:07 +0100)] 
systemd.netdev(5): fix acronym for DOVE extensions

2 years agoshutdown: don't stop the watchdog 22375/head
Michael Olbrich [Wed, 2 Feb 2022 14:33:07 +0000 (15:33 +0100)] 
shutdown: don't stop the watchdog

This basically reverts #22079.

Stopping the watchdog is wrong. The reboot watchdog is supposed to cover
the whole time from the point when systemd start systemd-reboot until the
hardware resets.
Otherwise the system may hang in the final shutdown phase.

Add a comment, why keeping the watchdog running is correct here.

2 years agowatchdog: fix watchdog_set_device() when the default watchdog device is used
Michael Olbrich [Wed, 2 Feb 2022 14:26:53 +0000 (15:26 +0100)] 
watchdog: fix watchdog_set_device() when the default watchdog device is used

If watchdog_set_device() is not called before open_watchdog() then
'watchdog_device' remains 'NULL' while the device is open.

As a result, the "same device" check in watchdog_set_device() does not work
correctly: If no device is specified (e.g. from watchdog_free_device())
then the current fd is not closed.

Fix this by setting 'watchdog_device' to the correct device during
open_watchdog()

2 years agoudev/net_id: show the correct identifier in the debug output of dev_pci_onboard() 22416/head
Franck Bui [Thu, 27 Jan 2022 18:13:24 +0000 (19:13 +0100)] 
udev/net_id: show the correct identifier in the debug output of dev_pci_onboard()

2 years agocore: make use of VALID_CHARS_WITH_AT in unit_name_is_valid()
Franck Bui [Tue, 18 Jan 2022 14:14:12 +0000 (15:14 +0100)] 
core: make use of VALID_CHARS_WITH_AT in unit_name_is_valid()

2 years agostat-util: introduce path_is_network_fs()
Yu Watanabe [Fri, 4 Feb 2022 06:22:20 +0000 (15:22 +0900)] 
stat-util: introduce path_is_network_fs()

2 years agonetwork-generator: rename DHCP_TYPE_DHCP -> DHCP_TYPE_DHCP4
Yu Watanabe [Thu, 3 Feb 2022 03:14:19 +0000 (12:14 +0900)] 
network-generator: rename DHCP_TYPE_DHCP -> DHCP_TYPE_DHCP4

To emphasize this is DHCPv4. No behavior is changed.

2 years agohwdb: add HP calculators
Davide Cavalca [Thu, 3 Feb 2022 16:35:35 +0000 (08:35 -0800)] 
hwdb: add HP calculators

2 years agohostnamed: trivial optimization
Lennart Poettering [Thu, 3 Feb 2022 16:19:32 +0000 (17:19 +0100)] 
hostnamed: trivial optimization

2 years agoportable: reopen socket with O_RDONLY
Luca Boccassi [Thu, 3 Feb 2022 17:43:45 +0000 (17:43 +0000)] 
portable: reopen socket with O_RDONLY

Follow-up for e3f7ed944ae750a40685c52349f3cc850db0876e

2 years agoMerge pull request #22408 from mrc0mmand/test-network-cleanup
Luca Boccassi [Thu, 3 Feb 2022 22:50:38 +0000 (22:50 +0000)] 
Merge pull request #22408 from mrc0mmand/test-network-cleanup

test-network: code cleanup

2 years agoMerge pull request #22355 from yuwata/network-tunnel-external
Anita Zhang [Thu, 3 Feb 2022 22:20:43 +0000 (14:20 -0800)] 
Merge pull request #22355 from yuwata/network-tunnel-external

network: tunnel: support external mode

2 years agoboot: Fix some error messages
Jan Janssen [Thu, 3 Feb 2022 18:40:42 +0000 (19:40 +0100)] 
boot: Fix some error messages

2 years agoMerge pull request #22400 from poettering/resolved-single-invalid-list
Anita Zhang [Thu, 3 Feb 2022 19:54:00 +0000 (11:54 -0800)] 
Merge pull request #22400 from poettering/resolved-single-invalid-list

resolved: maintain only a single list of "dont-resolve" domain names

2 years agohostnamed: drop "iteractive" parameter from GetHardwareSerial()
Lennart Poettering [Thu, 3 Feb 2022 16:41:04 +0000 (17:41 +0100)] 
hostnamed: drop "iteractive" parameter from GetHardwareSerial()

Since a long time the D-Bus spec knows a special bit in its message
header for indicating that "interactive" authentication is OK. The
original hostnamed API is before that was added hence most functions
expose that boolean as explicit argument.

For new added functions let's get rid of it, the message flag is good
enough and replaces it with complete functionality.

No new APIs should carry the "interactive" boolean flag explicitly as
argument anymore.

Follow-up for: 9697662915e47a4797b05003cb1970fe2b01e530

2 years agoMerge pull request #22394 from bluca/requires_restart_doc
Anita Zhang [Thu, 3 Feb 2022 19:50:06 +0000 (11:50 -0800)] 
Merge pull request #22394 from bluca/requires_restart_doc

man: explicitly mention that Requires propagates restarts

2 years agosystemctl: use STR_IN_SET() where appropriate
Lennart Poettering [Thu, 3 Feb 2022 12:42:55 +0000 (13:42 +0100)] 
systemctl: use STR_IN_SET() where appropriate

Follow-up for: 8e98568165ee3db049160045d94ce030dc7fbb79

2 years agotest-network: disable irrelevant or one-time pylint checks 22408/head
Frantisek Sumsal [Thu, 3 Feb 2022 18:31:15 +0000 (19:31 +0100)] 
test-network: disable irrelevant or one-time pylint checks

2 years agotest-network: use specific exceptions instead of the Exception class
Frantisek Sumsal [Thu, 3 Feb 2022 18:30:11 +0000 (19:30 +0100)] 
test-network: use specific exceptions instead of the Exception class

2 years agotest-network: avoid name clashing/redefinition
Frantisek Sumsal [Thu, 3 Feb 2022 18:20:42 +0000 (19:20 +0100)] 
test-network: avoid name clashing/redefinition

2 years agotest-network: disable 'no-member' warning for the Utilities class
Frantisek Sumsal [Thu, 3 Feb 2022 18:13:06 +0000 (19:13 +0100)] 
test-network: disable 'no-member' warning for the Utilities class

The warning is correct, since we don't inherit the necessary
unittest.TestCase class, but that's on purpose, since the Utilities
class is not supposed to be instantiated on its own, but should
complement other classes' definitions which do inherit from the
unittest.TestCase class.

2 years agotest-network: use raw strings for regexes with backslashes
Frantisek Sumsal [Thu, 3 Feb 2022 17:55:12 +0000 (18:55 +0100)] 
test-network: use raw strings for regexes with backslashes

It currently works because `\(` and `\)` are not valid escape sequences,
so they're not treated differently. Using raw strings (or double
backslashes) is a more correct solution.

2 years agotest-network: explicitly set check=False for subprocess.run()
Frantisek Sumsal [Thu, 3 Feb 2022 17:49:35 +0000 (18:49 +0100)] 
test-network: explicitly set check=False for subprocess.run()

since we're checking the returned error code explicitly via the
`returncode` member.

2 years agotest-network: convert certain multiline strings to comments
Frantisek Sumsal [Thu, 3 Feb 2022 17:42:41 +0000 (18:42 +0100)] 
test-network: convert certain multiline strings to comments

Multiline comments are converted to docstrings only when they're the
first statement in a function/method. Even though they're still a no-op
otherwise, let's use "true" comments to make pylint happy.

2 years agotest-network: drop unused variables
Frantisek Sumsal [Thu, 3 Feb 2022 17:17:53 +0000 (18:17 +0100)] 
test-network: drop unused variables

2 years agotest-network: drop unnecessary else statements
Frantisek Sumsal [Thu, 3 Feb 2022 17:14:44 +0000 (18:14 +0100)] 
test-network: drop unnecessary else statements

2 years agotest-network: drop unnecessary semicolons
Frantisek Sumsal [Thu, 3 Feb 2022 17:11:26 +0000 (18:11 +0100)] 
test-network: drop unnecessary semicolons

2 years agotest-network: drop superfluous parens
Frantisek Sumsal [Thu, 3 Feb 2022 17:10:06 +0000 (18:10 +0100)] 
test-network: drop superfluous parens

2 years agoresolved: maintain only a single list of "dont-resolve" domain names 22400/head
Lennart Poettering [Thu, 3 Feb 2022 16:16:11 +0000 (17:16 +0100)] 
resolved: maintain only a single list of "dont-resolve" domain names

Follow-up for: 46b53e8035fb60c9a7f26dd32d6689ab3b7da97c

2 years agoman: explicitly mention that Requires propagates restarts 22394/head
Luca Boccassi [Thu, 3 Feb 2022 14:48:27 +0000 (14:48 +0000)] 
man: explicitly mention that Requires propagates restarts

It's implicit, but the actions are different, so let's be explicit to
avoid any confusion.

2 years agofix italian translations to display unit name
Leviticoh [Thu, 3 Feb 2022 13:23:15 +0000 (14:23 +0100)] 
fix italian translations to display unit name

2 years agoboot: fix pretty nasty typo
Lennart Poettering [Thu, 3 Feb 2022 10:41:49 +0000 (11:41 +0100)] 
boot: fix pretty nasty typo

Note to self: should I ever become a black hat hacker, this is how I'd
hide a vulnerability. ;-)

(No, this one is not a vulnerability)

Follow-up for: 163d1ea5dd69c75d889ba4c2d1b51432ed14127f

2 years agojournal: when copying journal file to undo NOCOW flag, go via fd
Lennart Poettering [Wed, 2 Feb 2022 14:21:27 +0000 (15:21 +0100)] 
journal: when copying journal file to undo NOCOW flag, go via fd

We have the journal file open already, hence reference it via the fd
insted of the file name. After all, some other tool might have
renamed/deleted it already.

Let's not actually reuse the fd though, since we want a separate file
offset for the copying, hence just make it simply and reopen via
/proc/self/fd/.

Follow-up for d71ece3f0b85c7a3decc50143b68ac07fc5831ae

2 years agotests: pass FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION to fuzzers
Evgeny Vereshchagin [Thu, 3 Feb 2022 02:22:53 +0000 (02:22 +0000)] 
tests: pass FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION to fuzzers

to let them use reproducible identifiers, which should make it possible
to really use files copied from OSS-Fuzz to reproduce issues on
GHActions and locally. Prompted by https://github.com/systemd/systemd/pull/22365

2 years agosd-boot: rename LOADER_STUB → LOADER_UNIFIED_LINUX
Lennart Poettering [Wed, 2 Feb 2022 16:28:35 +0000 (17:28 +0100)] 
sd-boot: rename LOADER_STUB → LOADER_UNIFIED_LINUX

No actual code changes, just renaming.

Rationale: the focus here should be on the fact that these are "unified"
images, whether our stub is used or not, or something else doesn't
really matter. Moreover, these are still Linux entries. Hence, emphasize
that these are *unified* images, and *Linux* images, and deemphesize
that our sd-stub is likely used.

2 years agotests: fuzz client_send_message
Evgeny Vereshchagin [Tue, 1 Feb 2022 13:11:41 +0000 (13:11 +0000)] 
tests: fuzz client_send_message

to make sure outgoing packets based on incoming packets are fine.
It's just another follow-up to
https://github.com/systemd/systemd/pull/10200.
Better late than never :-)

2 years agotest-network: add testcase for external tunnel 22355/head
Yu Watanabe [Thu, 3 Feb 2022 02:11:37 +0000 (11:11 +0900)] 
test-network: add testcase for external tunnel

2 years agonetwork: tunnel: support external mode
Yu Watanabe [Tue, 1 Feb 2022 23:56:14 +0000 (08:56 +0900)] 
network: tunnel: support external mode

Closes #22352.

2 years agonetwork: tunnel: reorder setting ip6tnl attributes
Yu Watanabe [Tue, 1 Feb 2022 23:54:52 +0000 (08:54 +0900)] 
network: tunnel: reorder setting ip6tnl attributes

Just for improving readability.

2 years agonetwork: tunnel: reduce indentation in config_parse_encap_limit()
Yu Watanabe [Tue, 1 Feb 2022 23:25:38 +0000 (08:25 +0900)] 
network: tunnel: reduce indentation in config_parse_encap_limit()

2 years agonetwork: tunnel: reduce indentation in config_parse_ipv6_flowlabel()
Yu Watanabe [Tue, 1 Feb 2022 23:25:10 +0000 (08:25 +0900)] 
network: tunnel: reduce indentation in config_parse_ipv6_flowlabel()

2 years agonetwork: tunnel: use "data" field to assign result
Yu Watanabe [Tue, 1 Feb 2022 23:23:59 +0000 (08:23 +0900)] 
network: tunnel: use "data" field to assign result

2 years agoudevadm: don't claim a sysattr was write only just because we get EPERM on read
Lennart Poettering [Wed, 2 Feb 2022 14:20:30 +0000 (15:20 +0100)] 
udevadm: don't claim a sysattr was write only just because we get EPERM on read

it might be totally inaccessible, hence weaken our language a bit and
just say "not readable", thus making not claim whether it is writable or
not.

Follow-up for 3a90bef55a5a71a03629a762470b0f9014cd8453

2 years agoMerge pull request #22373 from DaanDeMeyer/journald-file-rename
Anita Zhang [Wed, 2 Feb 2022 21:53:18 +0000 (13:53 -0800)] 
Merge pull request #22373 from DaanDeMeyer/journald-file-rename

journal: Rename JournaldFile to ManagedJournalFile

2 years agocore: simply freeing list in job_free() 22378/head
Luca Boccassi [Wed, 2 Feb 2022 15:16:06 +0000 (15:16 +0000)] 
core: simply freeing list in job_free()

Follow-up for cdebedb4d40277aad62a7734ba920b4033228197

2 years agocore: use strextend instead of strextendf when possible
Luca Boccassi [Wed, 2 Feb 2022 14:33:45 +0000 (14:33 +0000)] 
core: use strextend instead of strextendf when possible

Follow-up for cdebedb4d40277aad62a7734ba920b4033228197

2 years agoMerge pull request #22358 from yuwata/udevadm-test-support-dev-path-or-device-unit
Luca Boccassi [Wed, 2 Feb 2022 15:32:20 +0000 (15:32 +0000)] 
Merge pull request #22358 from yuwata/udevadm-test-support-dev-path-or-device-unit

udevadm: test,test-builtin: support /dev path or device unit

2 years agotest: use rm_rf_physical_and_freep cleanup function
Yu Watanabe [Wed, 2 Feb 2022 06:32:23 +0000 (15:32 +0900)] 
test: use rm_rf_physical_and_freep cleanup function

2 years agojournal: Rename JournaldFile to ManagedJournalFile 22373/head
Daan De Meyer [Wed, 2 Feb 2022 14:30:50 +0000 (14:30 +0000)] 
journal: Rename JournaldFile to ManagedJournalFile

JournalFile and JournaldFile are hard to distinguish from each other.
Let's use ManagedJournalFile instead to make the distinction more clear.

2 years agonetwork: update operational state when we remove an address
Yu Watanabe [Wed, 2 Feb 2022 07:39:38 +0000 (16:39 +0900)] 
network: update operational state when we remove an address

2 years agodhcp-identifier: always use a fixed machine-id while fuzzing
Evgeny Vereshchagin [Wed, 2 Feb 2022 08:30:19 +0000 (08:30 +0000)] 
dhcp-identifier: always use a fixed machine-id while fuzzing

It's a follow-up to https://github.com/systemd/systemd/pull/10200 where
that fuzzer was introduced. At the time it was run regularly on machines
where machine-id wasn't present so it was kind of reproducible. Now
it's run on CIFuzz and CFLite using GHActions with the public OSS-Fuzz
corpora (based on that particular machine-id) so to fully utilize
those corpora it's necessary to use it always. Other than that
it makes it possible for fuzzers targeting outgoing packets
based on incoming packets like https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1795921
to get past client_parse_message on my machine :-)

2 years agosd-device: drop device_new_from_synthetic_event() from libsystemd 22358/head
Yu Watanabe [Wed, 2 Feb 2022 03:46:29 +0000 (12:46 +0900)] 
sd-device: drop device_new_from_synthetic_event() from libsystemd

It is used by only test-udev.c.

2 years agoudevadm: trigger: drop unnecessary slash
Yu Watanabe [Wed, 2 Feb 2022 03:53:29 +0000 (12:53 +0900)] 
udevadm: trigger: drop unnecessary slash

2 years agoudevadm: make test and test-builtin command accept /dev path or device unit
Yu Watanabe [Wed, 2 Feb 2022 03:40:23 +0000 (12:40 +0900)] 
udevadm: make test and test-builtin command accept /dev path or device unit

2 years agosd-device: make device_set_action() take sd_device_action_t
Yu Watanabe [Wed, 2 Feb 2022 03:31:02 +0000 (12:31 +0900)] 
sd-device: make device_set_action() take sd_device_action_t

2 years agosd-device: move device_read_uevent_file() to device-private.h
Yu Watanabe [Wed, 2 Feb 2022 03:29:54 +0000 (12:29 +0900)] 
sd-device: move device_read_uevent_file() to device-private.h

Then, it can be used by our tools or daemons.

2 years agoudev: do not generate format dynamically
Yu Watanabe [Wed, 2 Feb 2022 03:11:26 +0000 (12:11 +0900)] 
udev: do not generate format dynamically

Prompted by LGTM.

2 years agotest: allow to set NULL to intro or outro
Yu Watanabe [Wed, 2 Feb 2022 02:06:41 +0000 (11:06 +0900)] 
test: allow to set NULL to intro or outro

Addresses https://github.com/systemd/systemd/pull/22338#discussion_r796741033.

2 years agoMerge pull request #22359 from yuwata/mkdir-fix
Luca Boccassi [Wed, 2 Feb 2022 11:03:04 +0000 (11:03 +0000)] 
Merge pull request #22359 from yuwata/mkdir-fix

mkdir: allow to create directory whose path contains symlink

2 years agotest: add a test for mkdir_p() 22359/head
Yu Watanabe [Wed, 2 Feb 2022 06:08:18 +0000 (15:08 +0900)] 
test: add a test for mkdir_p()

2 years agomkdir: allow to create directory whose path contains symlink
Yu Watanabe [Wed, 2 Feb 2022 05:20:48 +0000 (14:20 +0900)] 
mkdir: allow to create directory whose path contains symlink

Fixes a regression caused by 3008a6f21c1c42efe852d69798a2fdd63fe657ec.

Before the commit, when `mkdir_parents_internal()` is called from `mkdir_p()`,
it uses `_mkdir()` as `flag` is zero. But after the commit, `mkdir_safe_internal()`
is always used. Hence, if the path contains a symlink, it fails with -ENOTDIR.

To fix the issue, this makes `mkdir_p()` calls `mkdir_parents_internal()` with
MKDIR_FOLLOW_SYMLINK flag.

Fixes #22334.

2 years agomkdir: CHASE_NONEXISTENT cannot used in chase_symlinks_and_stat()
Yu Watanabe [Wed, 2 Feb 2022 06:06:27 +0000 (15:06 +0900)] 
mkdir: CHASE_NONEXISTENT cannot used in chase_symlinks_and_stat()

2 years agocore/mount: fail early if directory cannot be created
Yu Watanabe [Wed, 2 Feb 2022 05:05:45 +0000 (14:05 +0900)] 
core/mount: fail early if directory cannot be created

Prompted by #22334.

2 years agoMerge pull request #22350 from poettering/journal-read-object-fix
Yu Watanabe [Wed, 2 Feb 2022 04:47:32 +0000 (13:47 +0900)] 
Merge pull request #22350 from poettering/journal-read-object-fix

journal: various fixes to journal_file_read_object()

2 years agosystemctl: strings returned by sd_bus_message_read_basic() are immutable
Lennart Poettering [Tue, 1 Feb 2022 16:38:23 +0000 (17:38 +0100)] 
systemctl: strings returned by sd_bus_message_read_basic() are immutable

It's totally not OK to write to the strings returned by it, the data is
shared by all code that references the message.

While we are at it, simplify the code via
json_variant_set_field_string().

Follow-up for: 5ef599b324efbcb7af317c102b59c662df068500

2 years agojournal-file: don't use pread() when determining where to append, use mmap as before 22350/head
Lennart Poettering [Tue, 1 Feb 2022 17:45:35 +0000 (18:45 +0100)] 
journal-file: don't use pread() when determining where to append, use mmap as before

This partially undoes the effect of
ab6e257b3e4e5b95f3750ed019bed6e89989e41b.

Originally, we always used the mmap logic to determine the current end
of the file. ab6e257b3e4e5b95f3750ed019bed6e89989e41b changed this so
that we always used pread().

With this change we'll use pread() from the synchronization thread and
mmap otherwise.

2 years agotests: rework test macros to not take code as parameters
Lennart Poettering [Tue, 1 Feb 2022 11:06:59 +0000 (12:06 +0100)] 
tests: rework test macros to not take code as parameters

C macros are nasty. We use them, but we try to be conservative with
them. In particular passing literal, complex code blocks as argument is
icky, because of "," handling of C, and also because it's quite a
challange for most code highlighters and similar. Hence, let's avoid
that. Using macros for genreating functions is OK but if so, the
parameters should be simple words, not full code blocks.

hence, rework DEFINE_CUSTOM_TEST_MAIN() to take a function name instead
of code block as argument.

As side-effect this also fixes a bunch of cases where we might end up
returning a negative value from main().

Some uses of DEFINE_CUSTOM_TEST_MAIN() inserted local variables into the
main() functions, these are replaced by static variables, and their
destructors by the static destructor logic.

This doesn't fix any bugs or so, it's just supposed to make the code
easier to work with and improve it easthetically.

Or in other words: let's use macros where it really makes sense, but
let's not go overboard with it.

(And yes, FOREACH_DIRENT() is another one of those macros that take
code, and I dislike that too and regret I ever added that.)

2 years agonetwork: dhcp-server: make empty string to DNS= or friends clear previously specified...
Yu Watanabe [Tue, 1 Feb 2022 22:20:25 +0000 (07:20 +0900)] 
network: dhcp-server: make empty string to DNS= or friends clear previously specified servers

2 years agosd-dhcp-lease: store static routes and classless static routes in different arrays
Yu Watanabe [Tue, 1 Feb 2022 21:35:43 +0000 (06:35 +0900)] 
sd-dhcp-lease: store static routes and classless static routes in different arrays

When classless static routes option is provided, then static routes
option should not be used. Hence, let's not mix and store them in one
storage.

This introduce sd_dhcp_lease_get_static_routes() and
sd_dhcp_lease_get_classless_routes().

2 years agoMerge pull request #22351 from mrc0mmand/TEST-56-cgroupsv1
Yu Watanabe [Wed, 2 Feb 2022 01:02:26 +0000 (10:02 +0900)] 
Merge pull request #22351 from mrc0mmand/TEST-56-cgroupsv1

test: require unified cgroup hierarchy for TEST-56

2 years agoresolve: add missing OOM check
Lennart Poettering [Tue, 1 Feb 2022 16:38:12 +0000 (17:38 +0100)] 
resolve: add missing OOM check

2 years agocore: warn on ExitType=cgroup with legacy cgroup setup
Luca Boccassi [Tue, 1 Feb 2022 15:31:52 +0000 (15:31 +0000)] 
core: warn on ExitType=cgroup with legacy cgroup setup

'cgroup empty' notifications are not reliable on v1, so log a warning.

See: https://github.com/systemd/systemd/issues/22320

2 years agoMerge pull request #22332 from yuwata/network-dhcp-server-dns-server-address
Yu Watanabe [Tue, 1 Feb 2022 22:07:22 +0000 (07:07 +0900)] 
Merge pull request #22332 from yuwata/network-dhcp-server-dns-server-address

network: dhcp-server: allow to specify server address for DNS= or friends

2 years agoMerge pull request #22327 from joanbm/main_resolved_improvements
Yu Watanabe [Tue, 1 Feb 2022 22:06:56 +0000 (07:06 +0900)] 
Merge pull request #22327 from joanbm/main_resolved_improvements

resolved: misc. small DnsStream refactors and improvements

2 years agotest: require unified cgroup hierarchy for TEST-56 22351/head
Frantisek Sumsal [Tue, 1 Feb 2022 19:25:00 +0000 (20:25 +0100)] 
test: require unified cgroup hierarchy for TEST-56

since cgroup empty notifications are unreliable in legacy cgroups.

See: systemd/systemd#22320
Complements: systemd/systemd#22344

2 years agotest: introduce `get_cgroup_hierarchy() helper
Frantisek Sumsal [Tue, 1 Feb 2022 19:18:29 +0000 (20:18 +0100)] 
test: introduce `get_cgroup_hierarchy() helper

which returns the host's cgroup hierarchy (unified, hybrid, or legacy).

2 years agounits: we need systemd-journald.service from systemd-journal-flush.service
Lennart Poettering [Tue, 1 Feb 2022 17:11:04 +0000 (18:11 +0100)] 
units: we need systemd-journald.service from systemd-journal-flush.service

This is a follow-up for d5ee050ffc9d413253932d9340ade8c8fb111092, and
reintroduces a requirement dep from systemd-journal-flush.service onto
systemd-journald.service, but a weaker one than originally: a Wants= one
instead of a Requires= one.

Why? Simply because the service issues an IPC call to the journald,
hence it should pull it in. (Note that socket activation doesn't happen
for the Varlink socket it uses, hence we should pull in the service
itself.)

2 years agotest-network: add tests for DNS=_server_address in [DHCPServer] 22332/head
Yu Watanabe [Tue, 1 Feb 2022 07:30:45 +0000 (16:30 +0900)] 
test-network: add tests for DNS=_server_address in [DHCPServer]

2 years agonetwork: dhcp-server: introduce special value DNS=_server_address
Yu Watanabe [Tue, 1 Feb 2022 07:20:33 +0000 (16:20 +0900)] 
network: dhcp-server: introduce special value DNS=_server_address

Closes #15026.

2 years agoMerge pull request #22310 from yuwata/sd-dhcp-lease-fixes
Yu Watanabe [Tue, 1 Feb 2022 19:55:07 +0000 (04:55 +0900)] 
Merge pull request #22310 from yuwata/sd-dhcp-lease-fixes

sd-dhcp-lease: two fixes

2 years agoMerge pull request #22343 from poettering/assert-se-efi
Luca Boccassi [Tue, 1 Feb 2022 19:26:57 +0000 (19:26 +0000)] 
Merge pull request #22343 from poettering/assert-se-efi

efi: add/user assert_se()/ASSERT_SE_PTR() for OOM handling

2 years agoanalyze: correctly mention that --json= is also understood by inspect-elf
Lennart Poettering [Tue, 1 Feb 2022 16:37:19 +0000 (17:37 +0100)] 
analyze: correctly mention that --json= is also understood by inspect-elf

2 years agoresolved: Allow test-resolved-stream to run concurrently 22327/head
Joan Bruguera [Sun, 30 Jan 2022 16:56:32 +0000 (17:56 +0100)] 
resolved: Allow test-resolved-stream to run concurrently

Since test-resolved-stream brings up a simple DNS server on 127.0.0.1:12345,
only one instance could run at a time, so it would fail when run like
`meson test -C build test-resolved-stream --repeat=1000`.
Similarly, if by chance something is up on port 12345, the test would fail.

To make the test more reliable, run it in an isolated user + network namespace.
If this fails (some distributions disable user namespaces), just run as before.

2 years agoresolved: Read as much as possible per stream EPOLLIN event
Joan Bruguera [Sun, 30 Jan 2022 11:51:10 +0000 (12:51 +0100)] 
resolved: Read as much as possible per stream EPOLLIN event

In commit 2aaf6bb6e99b0f2bd73e0c49bef9e11a2844bf1a, an issue was fixed where
systemd-resolved could get stuck for multiple seconds waiting for incoming data,
since GnuTLS/OpenSSL can buffer a TLS record, so data could be available, but
no EPOLLIN event would be generated.

To fix this, a somewhat elaborate logic consisting on asking the TLS library
whether it had buffered data, then "faking" an EPOLLIN event was implemented.

However, there is a much simpler solution: Always read as much data as available
(i.e. until we get an event like EAGAIN when trying to read) from the stream
when we get an EPOLLIN event, instead of at most a single packet per event.
This approach does not require asking the TLS library whether it has buffered
data, and the logic is exactly the same for both the TCP and TLS case.

test-resolved-stream is fixed to avoid a latent double free bug.

2 years agoresolved: Avoid multiple SSL writes per DoT packet
Joan Bruguera [Mon, 31 Jan 2022 20:28:32 +0000 (21:28 +0100)] 
resolved: Avoid multiple SSL writes per DoT packet

In the DoT case, dns_stream_writev decomposed an iovec into multiple
dnstls_stream_write calls, which resulted in multiple SSL writes and multiple
TLS records. This can be checked from a network capture, e.g. using socat:
socat -v -x openssl-listen:853,reuseaddr,fork,cert=my.cert,key=my.key,verify=0 openssl:8.8.8.8:853

Instead, propagate the iovec as-is into the DoT handling code. For GnuTLS, the
library provides support for buffering ('corking') a record. OpenSSL has no
such facility, so we join the iovec into a single buffer then call SSL_write.

socat capture of `resolvectl -4 query --cache=no example.com` before the commit:

> 2022/01/30 13:35:52.194200  length=2 from=0 to=1
 00 28                                            .(
--
> 2022/01/30 13:35:52.194253  length=40 from=2 to=41
 1e b2 01 00 00 01 00 00 00 00 00 01 07 65 78 61  .............exa
 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01 00 00 29  mple.com.......)
 ff e4 00 00 00 00 00 00                          ........
--
< 2022/01/30 13:35:52.232798  length=58 from=0 to=57
 00 38 1e b2 81 80 00 01 00 01 00 00 00 01 07 65  .8.............e
 78 61 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01 c0  xample.com......
 0c 00 01 00 01 00 00 53 6f 00 04 5d b8 d8 22 00  .......So..]..".
 00 29 02 00 00 00 00 00 00 00                    .)........

socat capture of `resolvectl -4 query --cache=no example.com` after the commit:

> 2022/01/30 13:34:47.598099  length=42 from=504 to=545
 00 28 37 86 01 00 00 01 00 00 00 00 00 01 07 65  .(7............e
 78 61 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01 00  xample.com......
 00 29 ff e4 00 00 00 00 00 00                    .)........
--
< 2022/01/30 13:34:47.613203  length=58 from=756 to=813
 00 38 37 86 81 80 00 01 00 01 00 00 00 01 07 65  .87............e
 78 61 6d 70 6c 65 03 63 6f 6d 00 00 01 00 01 c0  xample.com......
 0c 00 01 00 01 00 00 52 5e 00 04 5d b8 d8 22 00  .......R^..]..".
 00 29 02 00 00 00 00 00 00 00                    .)........