]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agofd-util: use close_many() where appropriate 29583/head
Lennart Poettering [Wed, 18 Oct 2023 12:03:47 +0000 (14:03 +0200)] 
fd-util: use close_many() where appropriate

2 years agofd-util: add new helper close_many_unset()
Lennart Poettering [Wed, 18 Oct 2023 12:03:36 +0000 (14:03 +0200)] 
fd-util: add new helper close_many_unset()

2 years agoexecute: use close_many_and_free() more
Lennart Poettering [Wed, 18 Oct 2023 10:12:30 +0000 (12:12 +0200)] 
execute: use close_many_and_free() more

2 years agoserialize: add serialize_fd_many() helper
Lennart Poettering [Mon, 16 Oct 2023 13:56:58 +0000 (15:56 +0200)] 
serialize: add serialize_fd_many() helper

2 years agoserialize: change order of deserialize_strv() parameters 29481/head
Lennart Poettering [Fri, 6 Oct 2023 15:56:30 +0000 (17:56 +0200)] 
serialize: change order of deserialize_strv() parameters

The other deserializers put value first, and return parameter second,
let's do so here too.

2 years agoserialize: modernize deserialize_{usec|dual_timestamp}() a bit
Lennart Poettering [Fri, 6 Oct 2023 15:53:13 +0000 (17:53 +0200)] 
serialize: modernize deserialize_{usec|dual_timestamp}() a bit

Rename the return parameters "ret", and use compound initialization. Add
an assert() on input.

2 years agoserialize: add new helper deserialize_fd()
Lennart Poettering [Fri, 6 Oct 2023 15:50:48 +0000 (17:50 +0200)] 
serialize: add new helper deserialize_fd()

Currently, when we deserialize an fd we do a lot of manual work. Add a
common helper that makes this more robust and uniform.

Note that this sometimes changes behaviour slightly, but in ways that
shouldn't really matter: if we fail to deserialize an fd correctly we'll
unset (i.e. set to -EBADF) the fd in the deserialized data structure.
Previously, we'd leave the old value in place.

This should not change effective result (as in either case we'll be in a
bad state afterwards, just once we mix old/invalidated state with new
state, while now we'll reset the state explicitly to invalidated state
on failure). In particular as deserialization starts from an empty
structure generally, hence the old value should be unset anyway.

Another slight change is that if we fail to deserialize some object half
way, and we already have taken out one fd from the serialized fdset
we'll now just close it instead of returning it to/leaving it in the
fdset. Given that such "orphaned" fds are blanket closed after
deserialization finishes this also shouldn't change behaviour IRL.

Also, the idle_pipe was previously incorrectly serialized: we'd
serialize invalidated fds, which would fail, but because parsing errors
on this were ignored on the deserializatin noone noticed. This is fixed.

2 years agotree-wide: fix typo
Yu Watanabe [Wed, 18 Oct 2023 03:40:25 +0000 (12:40 +0900)] 
tree-wide: fix typo

2 years agonetwork: include SSID in ipv6 stable prefix address generation
Ronan Pigott [Sat, 14 Oct 2023 03:22:49 +0000 (20:22 -0700)] 
network: include SSID in ipv6 stable prefix address generation

The SSID fills the role of the optional Network_ID input parameter
suggested by RFC7217. Including the SSID allows networkd to generate a
different pseudorandom address for different wireless networks, which
should help to obscure the host's identity when roaming between multiple
networks.

2 years agorepart: avoid use of uninitialized TPM2B_PUBLIC data
Daniel P. Berrangé [Tue, 17 Oct 2023 15:45:52 +0000 (16:45 +0100)] 
repart: avoid use of uninitialized TPM2B_PUBLIC data

The 'TPM2B public' struct is only initialized if the public key
is non-NULL, however, it is unconditionally passed to
tpm2_calculate_sealing_policy, resulting in use of uninitialized
data. If the uninitialized data is lucky enough to be all zeroes,
this results eventually results in an error message from
tpm2_calculate_name about an unsupported nameAlg field value.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoMerge pull request #29441 from evelikov/no-input-delay
Luca Boccassi [Tue, 17 Oct 2023 22:45:44 +0000 (23:45 +0100)] 
Merge pull request #29441 from evelikov/no-input-delay

sd-boot: add "menu-disabled" option to "timeout", disabling the 100ms input polling

2 years agocgroup: turn device cgroup controller "rwm" strings into proper flags
Lennart Poettering [Tue, 10 Oct 2023 14:01:16 +0000 (16:01 +0200)] 
cgroup: turn device cgroup controller "rwm" strings into proper flags

We generally prefer dealing with parsed data instead of original
strings, do so for the "rwm" strings too. We have to convert this to
flags for the primary backend implementation (BPF) anyway, hence we
can do this early to have simpler, shorter and more normalized code.

2 years agoMerge pull request #29586 from poettering/read-stripped-line
Luca Boccassi [Tue, 17 Oct 2023 18:54:14 +0000 (19:54 +0100)] 
Merge pull request #29586 from poettering/read-stripped-line

add read_stripped_line() as trivial read_line() + strstrip() combo

2 years agomeson: add build option for install path of main config files
Franck Bui [Mon, 21 Aug 2023 10:37:00 +0000 (12:37 +0200)] 
meson: add build option for install path of main config files

This allows distros to install configuration file templates in /usr/lib/systemd
for example.

Currently we install "empty" config files in /etc/systemd/. They serve two
purposes:

- The file contains commented-out values that show the default settings.
- It is easier to edit the right file if it is already there, the user doesn't
  have to type in the path correctly, and the basic file structure is already in
  place so it's easier to edit.

Things that have happened since this approach was put in place:

- We started supporting drop-ins for config files, and drop-ins are the
  recommended way to create local configuration overrides.
- We have systemd-analyze cat-config which takes care of iterating over
  all possible locations (/etc, /run, /usr, /usr/local) and figuring out
  the right file.
- Because of the first two points, systemd-analyze cat-config is much better,
  because it takes care of finding all the drop-ins and figuring out the
  precedence. Looking at files manually is still possible of course, but not
  very convenient.

The disadvantages of the current approach with "empty" files in /etc:

- We clutter up /etc so it's harder to see what the local configuration actually is.
- If a user edits the file, package updates will not override the file (e.g.
  systemd.rpm uses %config(noreplace). This means that the "documented defaults"
  will become stale over time, if the user ever edits the main config file.

Thus, I think that it's reasonable to:

- Install the main config file to /usr/lib so that it serves as reference for
  syntax and option names and default values and is properly updated on package
  upgrades.
- Recommend to users to always use drop-ins for configuration and
  systemd-analyze cat-config to view the documentation.

This setting makes this change opt-in.

Fixes #18420.

[zjs: add more text to the description]

2 years agoMerge pull request #29242 from fbuihuu/update-main-config-file-headers
Zbigniew Jędrzejewski-Szmek [Tue, 17 Oct 2023 16:56:09 +0000 (18:56 +0200)] 
Merge pull request #29242 from fbuihuu/update-main-config-file-headers

config files: update their header to reflect that they can be install…

2 years agosd-boot: add way to disable the 100ms delay when timeout=0 29441/head
Emil Velikov [Wed, 4 Oct 2023 11:55:52 +0000 (12:55 +0100)] 
sd-boot: add way to disable the 100ms delay when timeout=0

Currently we have a 100ms delay which allows for people to enter/show
the boot menu even when timeout is set to zero.

In a handful of cases, that may not be needed - both in terms of access
policy, as well as latency.

For example: the option to provide the boot menu may be hidden behind an
"expert only" UX in the OS, to avoid end users from accidentally
entering it.

In addition, the current 100ms input polling may cause unexpected
additional delays in the boot. Some example numbers from my SteamDeck:

 - boot counting/rename/flush doubles 300us -> 600us
 - seed/hash setup doubles 900us -> 1800us
 - kernel/image load gets ~40% slower 107ms -> 167ms

It's not entirely clear why the UEFI calls gets slower, nevertheless the
information in itself proves useful.

This commit introduces a new option "menu-disabled", which omits the
100ms delay. The option is documented throughout the manual pages as
well as the Boot Loader Specification.

v2:
 - use STR_IN_SET

v3:
 - drop erroneous whitespace

v4:
 - add a new LoaderFeature bit,
 - don't change ABI keep TIMEOUT_* tokens the same
 - move new token in the 64bit range, update API and storage for it
 - change inc/dec behaviour to TIMEOUT_MIN : TIMEOUT_MENU_FORCE
 - user cannot opt-in from sd-boot itself, add assert_not_reached()

v5:
 - s/Menu disablement control/Menu can be disabled/
 - rewrap comments to 109
 - use SYNTHETIC_ERRNO(EOPNOTSUPP)

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2 years agobootctl, sd-boot: cross document the menu-hidden/force ABI
Emil Velikov [Thu, 12 Oct 2023 15:24:12 +0000 (16:24 +0100)] 
bootctl, sd-boot: cross document the menu-hidden/force ABI

Document the current state and how we got here.

v2:
 - rewrap command to 109 columns

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2 years agodocs/BOOT_LOADER_INTERFACE: mention that menu-* options are strings
Emil Velikov [Wed, 4 Oct 2023 11:55:52 +0000 (12:55 +0100)] 
docs/BOOT_LOADER_INTERFACE: mention that menu-* options are strings

To be on the safe side, explicitly mention that apart from the numerical
entries we can allow string ones.

Implementation-wise, bootctl will use internal numerical values that
match sd-boot's ABI. The latter also accepts the string options.

Going forward we'd like to avoid adding more internal magic and be more
explicit.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2 years agotest: don't restart journal-upload on an expected fail
Frantisek Sumsal [Tue, 17 Oct 2023 10:49:03 +0000 (12:49 +0200)] 
test: don't restart journal-upload on an expected fail

In c08bec1587 the journal-upload unit gained Restart=on-fail, which goes
against this one particular test that expects the unit to fail, making
the test flaky. Let's disable the automatic restarts just for this test
to make it stable once again.

2 years agotree-wide: port various parsers over to read_stripped_line() 29586/head
Lennart Poettering [Mon, 16 Oct 2023 16:01:00 +0000 (18:01 +0200)] 
tree-wide: port various parsers over to read_stripped_line()

2 years agofileio: add read_stripped_line() as trivial read_line() + strstrip() combo
Lennart Poettering [Mon, 16 Oct 2023 15:55:07 +0000 (17:55 +0200)] 
fileio: add read_stripped_line() as trivial read_line() + strstrip() combo

2 years agodocs/FILE_DESCRIPTOR_STORE: NotifyAccess=cgroup -> all
Mike Yuan [Tue, 17 Oct 2023 10:54:07 +0000 (18:54 +0800)] 
docs/FILE_DESCRIPTOR_STORE: NotifyAccess=cgroup -> all

Fixes #29590

2 years agocore/mount: allow disabling stop propagation from backing device
Mike Yuan [Thu, 12 Oct 2023 10:38:15 +0000 (18:38 +0800)] 
core/mount: allow disabling stop propagation from backing device

With file systems that have volume management functionalities or
volume managers like LVM, it's fine for the backing device of a mount
to disappear after mounted. Currently, we enforce BindsTo= or
StopPropagatedFrom= on the backing device, thus prohibiting such
cases. Instead, let's make this configurable through x-systemd.device-bound.

Closes #16801
Closes #29543

2 years agoMerge pull request #29588 from keszybz/net-naming-scheme-255
Yu Watanabe [Tue, 17 Oct 2023 10:18:29 +0000 (19:18 +0900)] 
Merge pull request #29588 from keszybz/net-naming-scheme-255

Untangle the net-naming-scheme mess with SR-IOV-R "representor" information

2 years agorules: add mtd/by-name symlinks
Matthias Schiffer [Wed, 11 Oct 2023 14:33:25 +0000 (16:33 +0200)] 
rules: add mtd/by-name symlinks

Add persistent symlinks for MTD devices like SPI-NOR flash, based on the
partition names specified on the cmdline, in a Device Tree, or by other
MTD partitioning parser drivers. Using the persistent name can be
preferable to using the numbered /dev/mtdX device, as the latter can
change depending on probe order or when partitioning has changed.

2 years agoMerge pull request #28373 from DaanDeMeyer/udevadm-query
Daan De Meyer [Tue, 17 Oct 2023 08:16:43 +0000 (10:16 +0200)] 
Merge pull request #28373 from DaanDeMeyer/udevadm-query

Add --json and filtering options for --export-db to udevadm info

2 years agomeson: Fix unused format parameter warning
Jan Janssen [Mon, 16 Oct 2023 14:47:41 +0000 (16:47 +0200)] 
meson: Fix unused format parameter warning

2 years agonspawn: check if we can set CoredumpReceive= before doing so
Nick Rosbrook [Mon, 16 Oct 2023 17:13:57 +0000 (13:13 -0400)] 
nspawn: check if we can set CoredumpReceive= before doing so

If systemd-nspawn is newer than the running systemd, we might try to set
CoredumpReceive=yes when systemd doesn't know about it yet. Try and
check if the running systemd is aware of this setting, and if not, don't
try and use it.

Fixes 411d8c72ec
("nspawn: set CoredumpReceive=yes on container's scope when --boot is set").

2 years agotest: make sure that the default naming scheme name maps back to itself 29588/head
Zbigniew Jędrzejewski-Szmek [Mon, 16 Oct 2023 10:53:10 +0000 (12:53 +0200)] 
test: make sure that the default naming scheme name maps back to itself

We were testing the that C constant is defined, but we weren't actually testing
that the string name maps back to itself. This would catch the issue fixed by
the grandparent commit.

The test for the default name is moved to the test file to keep the tests
together. The define is renamed to not have "_TEST" in the name. The issue here
is complicated by the fact that we allow downstreams to inject additional
fields, so we don't know the name of the default scheme if it not set with
-Ddefault-net-naming-scheme=, so _DEFAULT_NET_NAMING_SCHEME[_TEST] is not
defined in all cases, but at least in principle it could be used in other
places. If it exists, it is fully valid.

2 years agoshared/netif-naming-scheme: align tables
Zbigniew Jędrzejewski-Szmek [Mon, 16 Oct 2023 10:35:33 +0000 (12:35 +0200)] 
shared/netif-naming-scheme: align tables

2 years agoNEWS, man: move description of SR-IOV-R net naming to v255
Zbigniew Jędrzejewski-Szmek [Mon, 16 Oct 2023 09:54:21 +0000 (11:54 +0200)] 
NEWS, man: move description of SR-IOV-R net naming to v255

https://github.com/systemd/systemd/pull/29582 adds the "v254" name. This also
changes what the default is and what "latest" refers to. Without the name, the
code could be enabled via runtime configuration. Nevertheless, it could be
enabled at compilation time. In other words:
  meson setup build -Ddefault-net-naming-scheme=v254
would work, but
  net.naming-scheme=v254
would fail.

It is possible that people were using the compile-time override, so I think
we should allow "v254" scheme to stay and clearly document that it wasn't the
default.

Unfortunately, unless people manually introduced the compile-time override, we
were never actually testing the new code too. So all the pull request testing
was not useful.

2 years agonet_id: add missing naming scheme name for v254
Antonio Alvarez Feijoo [Mon, 16 Oct 2023 08:41:51 +0000 (10:41 +0200)] 
net_id: add missing naming scheme name for v254

Follow up to 88d2bda8120dcc375a90e28b64de06b9646ab3b6

2 years agoMerge pull request #29546 from poettering/run-invoc-id
Lennart Poettering [Mon, 16 Oct 2023 17:00:18 +0000 (19:00 +0200)] 
Merge pull request #29546 from poettering/run-invoc-id

run: output invocation ID when starting service and scope units

2 years agoudev: Enable filtering the output of udevadm info --export-db 28373/head
Daan De Meyer [Thu, 12 Oct 2023 09:20:06 +0000 (11:20 +0200)] 
udev: Enable filtering the output of udevadm info --export-db

Let's support the same filtering options that we also support in
udevadm trigger in udevadm info to filter the devices produced by
--export-db.

One difference is that all properties specified by --propery-match=
have to be satisfied in udevadm info unlike udevadm trigger where just
one of them has to be satisfied.

2 years agoMerge pull request #29272 from enr0n/coredump-container
Lennart Poettering [Mon, 16 Oct 2023 14:13:16 +0000 (16:13 +0200)] 
Merge pull request #29272 from enr0n/coredump-container

coredump: support forwarding coredumps to containers

2 years agomount-util: use mount beneath to replace previous namespace mount
Luca Boccassi [Fri, 29 Sep 2023 00:50:15 +0000 (01:50 +0100)] 
mount-util: use mount beneath to replace previous namespace mount

Instead of mounting over, do an atomic swap using mount beneath, if
available. This way assets can be mounted again and again (e.g.:
updates) without leaking mounts.

2 years agoMerge pull request #29548 from poettering/sysext-varlink
Lennart Poettering [Mon, 16 Oct 2023 13:10:24 +0000 (15:10 +0200)] 
Merge pull request #29548 from poettering/sysext-varlink

sysext: add a varlink IPC interface

2 years agoMerge pull request #29562 from poettering/namespace-fuckup-fix
Lennart Poettering [Mon, 16 Oct 2023 13:10:08 +0000 (15:10 +0200)] 
Merge pull request #29562 from poettering/namespace-fuckup-fix

namespace: normalize memory management of mount list

2 years agoupdate TODO 29546/head
Lennart Poettering [Mon, 16 Oct 2023 11:48:40 +0000 (13:48 +0200)] 
update TODO

2 years agorun: pin the unit we invoke continously while we are running
Lennart Poettering [Mon, 16 Oct 2023 09:31:38 +0000 (11:31 +0200)] 
run: pin the unit we invoke continously while we are running

We read properties of the unit, hence it shouldn't be GC'ed as long as
we run. Hence, let's just set AddRef unconditionally for the units we
create.

2 years agorun: output invocation ID when starting service and scope units
Lennart Poettering [Thu, 12 Oct 2023 10:03:03 +0000 (12:03 +0200)] 
run: output invocation ID when starting service and scope units

2 years agonamespace: add // FIXME comments on some suplicate logging 29562/head
Lennart Poettering [Mon, 16 Oct 2023 11:16:55 +0000 (13:16 +0200)] 
namespace: add // FIXME comments on some suplicate logging

@bluca thinks duplicate logging as a feature, hence simply mark these
log messages as // FIXME, but don't bother.

2 years ago namespace: downgrade log messages to LOG_DEBUG
Lennart Poettering [Mon, 16 Oct 2023 11:16:40 +0000 (13:16 +0200)] 
 namespace: downgrade log messages to LOG_DEBUG

almost all code in namespace.c only logs at debug level as it is
"library-like" code. But there are some outliers. Adjust them to match
the rest of the code

(Well, there are some left)

2 years agonamespace: don't retry to a mount if we didn't actually manage to create an inode
Lennart Poettering [Mon, 16 Oct 2023 10:42:06 +0000 (12:42 +0200)] 
namespace: don't retry to a mount if we didn't actually manage to create an inode

2 years agonamespace: downgrade log message of error we ignore to LOG_WARNING
Lennart Poettering [Mon, 16 Oct 2023 10:57:16 +0000 (12:57 +0200)] 
namespace: downgrade log message of error we ignore to LOG_WARNING

frankly, the log message shouldn't be there at all, but the error path
be propagated up, with a recognizable error code. But apparently this is
important to @bluca.

2 years agonamespace: convert ProtectHostname= logic to a static table
Lennart Poettering [Mon, 16 Oct 2023 08:36:17 +0000 (10:36 +0200)] 
namespace: convert ProtectHostname= logic to a static table

Let's simplify things, and make them more alike handling more similar to
the other ProtectXYZ= settings.

2 years agoAdd --json switch to udevadm info
Daan De Meyer [Thu, 12 Oct 2023 09:02:49 +0000 (11:02 +0200)] 
Add --json switch to udevadm info

This allows getting the udevadm info --export-db and query "all" output
as JSON.

2 years agonamespace: normalize memory management of mount list
Lennart Poettering [Fri, 13 Oct 2023 16:58:13 +0000 (18:58 +0200)] 
namespace: normalize memory management of mount list

So far we calculated exactly how many mounts we will generate, which is
a bit fragile, and easy to get wrong.

Let's normalize this, and grow the array of mounts as we need.

Various other modernizations while we are at it, such as FOREACH_ARRAY
usage, or `_cleanup_` usage.

2 years agoupdate TODO 29548/head
Lennart Poettering [Thu, 12 Oct 2023 10:36:11 +0000 (12:36 +0200)] 
update TODO

2 years agosysext: make some calls available via varlink
Lennart Poettering [Mon, 9 Oct 2023 16:57:41 +0000 (18:57 +0200)] 
sysext: make some calls available via varlink

2 years agostub: NULL checks for DeviceHandle and FilePath
Lukas [Sun, 8 Oct 2023 17:45:34 +0000 (19:45 +0200)] 
stub: NULL checks for DeviceHandle and FilePath

UKIs may be loaded in a way, that there can not be a device handle to
the filesystem, that contains the image, for example when using a
bootloader to load the image from a partition with a file system that is
not supported by the firmware.

With the current systemd stub, this causes a failed assertion, because
stub gets passed a NULL DeviceHandle and FilePath. Inserting two
explicit checks enables proper boot even in this case.

Fixes: #29331
2 years agoMerge pull request #29558 from mrc0mmand/varlinkctl-tests
Daan De Meyer [Mon, 16 Oct 2023 07:49:42 +0000 (09:49 +0200)] 
Merge pull request #29558 from mrc0mmand/varlinkctl-tests

varlink: add a couple of tests + accompanying fixes

2 years agoresolve: fix no mDNS announcement after probing
Vishal Chillara Srinivas [Fri, 13 Oct 2023 09:06:06 +0000 (14:36 +0530)] 
resolve: fix no mDNS announcement after probing

According to RFC 6762 section 8, an mDNS responder is supposed to announce its
records after probing.
Currently, there is a check in dns_scope_announce which returns if there are any
pending transactions. This prevents announcements from being sent out even if there
are pending non-probe transactions.

To fix this, return only if there are active probe transactions.

2 years agofuzz: Add fuzzer for efi conf/osrel parsing
Jan Janssen [Sun, 15 Oct 2023 09:43:59 +0000 (11:43 +0200)] 
fuzz: Add fuzzer for efi conf/osrel parsing

2 years agoboot: Fix OOB reads in conf/osrel parsing
Jan Janssen [Sun, 15 Oct 2023 09:32:32 +0000 (11:32 +0200)] 
boot: Fix OOB reads in conf/osrel parsing

2 years agoboot: Move line_get_key_value to efi-string
Jan Janssen [Sun, 15 Oct 2023 08:09:55 +0000 (10:09 +0200)] 
boot: Move line_get_key_value to efi-string

No functional changes.

2 years agoboot: Move parse_boolean to efi-string
Jan Janssen [Sun, 15 Oct 2023 07:31:02 +0000 (09:31 +0200)] 
boot: Move parse_boolean to efi-string

No functional changes.

2 years agotest: Remove unnecessary test prefix
Jan Janssen [Sun, 15 Oct 2023 07:39:50 +0000 (09:39 +0200)] 
test: Remove unnecessary test prefix

2 years agocore: don't downgrade multi-state settings to boolean
Frantisek Sumsal [Sat, 14 Oct 2023 17:25:28 +0000 (19:25 +0200)] 
core: don't downgrade multi-state settings to boolean

Protect{Home,System,Proc,Subset}= are not booleans, so make sure we use
the intended value instead of just true/false.

See: https://github.com/systemd/systemd/pull/29552
Follow-up to: 79d956d

2 years agodocs: update fuzzers docs 29558/head
Frantisek Sumsal [Sat, 14 Oct 2023 15:47:10 +0000 (17:47 +0200)] 
docs: update fuzzers docs

2 years agotest: update Ubuntu CI instructions
Frantisek Sumsal [Thu, 12 Oct 2023 20:09:49 +0000 (22:09 +0200)] 
test: update Ubuntu CI instructions

2 years agovarlink: drop dead code
Frantisek Sumsal [Thu, 12 Oct 2023 15:29:23 +0000 (17:29 +0200)] 
varlink: drop dead code

'#' is never part of either allowed_chars or allowed_delimiters when we
parse structs/enums.

2 years agovarlink: use int for log level
Frantisek Sumsal [Thu, 12 Oct 2023 15:02:16 +0000 (17:02 +0200)] 
varlink: use int for log level

2 years agovarlink: don't panic on malformed method definition
Frantisek Sumsal [Thu, 12 Oct 2023 13:55:12 +0000 (15:55 +0200)] 
varlink: don't panic on malformed method definition

2 years agotest: add a fuzzer for the varlink IDL stuff
Frantisek Sumsal [Thu, 12 Oct 2023 13:44:34 +0000 (15:44 +0200)] 
test: add a fuzzer for the varlink IDL stuff

2 years agotest: add a couple of tests for varlinkctl
Frantisek Sumsal [Thu, 12 Oct 2023 12:21:40 +0000 (14:21 +0200)] 
test: add a couple of tests for varlinkctl

2 years agocore: fix deserialization copypasta
Luca Boccassi [Sat, 14 Oct 2023 09:03:33 +0000 (10:03 +0100)] 
core: fix deserialization copypasta

CID#1522788

2 years agocore/exec-invoke: rename parameters of get_fixed_{user,group}
Mike Yuan [Fri, 13 Oct 2023 21:14:40 +0000 (05:14 +0800)] 
core/exec-invoke: rename parameters of get_fixed_{user,group}

Follow-up for 1c9433559a40982785011aa187e2b34420a67e7e

The user/group passed in could be either the name or the uid/gid.

2 years agoMerge pull request #29569 from YHNdnzj/foreach-array
Luca Boccassi [Sat, 14 Oct 2023 08:08:40 +0000 (09:08 +0100)] 
Merge pull request #29569 from YHNdnzj/foreach-array

core: use FOREACH_ARRAY more and some other minor changes

2 years agoMerge pull request #29525 from poettering/confext-sysext-multimodal
Luca Boccassi [Fri, 13 Oct 2023 23:28:47 +0000 (00:28 +0100)] 
Merge pull request #29525 from poettering/confext-sysext-multimodal

dissect: make sure we can dissect and inspect DDIs that are both confext *and* sysext

2 years agocore: add MemoryKSM and SetLoginEnvironment to exec_context_dump 29569/head
Mike Yuan [Fri, 13 Oct 2023 22:21:35 +0000 (06:21 +0800)] 
core: add MemoryKSM and SetLoginEnvironment to exec_context_dump

2 years agocore/execute: correct alignment
Mike Yuan [Fri, 13 Oct 2023 22:02:17 +0000 (06:02 +0800)] 
core/execute: correct alignment

2 years agocore/execute: use FOREACH_ARRAY more
Mike Yuan [Fri, 13 Oct 2023 22:17:11 +0000 (06:17 +0800)] 
core/execute: use FOREACH_ARRAY more

2 years agocore/execute-serialize: use FOREACH_ARRAY more
Mike Yuan [Fri, 13 Oct 2023 22:01:11 +0000 (06:01 +0800)] 
core/execute-serialize: use FOREACH_ARRAY more

2 years agorun: support --scope on old service managers that lack native PIDFD support
Lennart Poettering [Thu, 12 Oct 2023 10:02:03 +0000 (12:02 +0200)] 
run: support --scope on old service managers that lack native PIDFD support

Before this we'd fail with a complaint that PIDFDs is not supported by
the service manager. Add some compat support by falling back to classic
numeric PIDs in that case.

2 years agoupdate TODO
Lennart Poettering [Fri, 13 Oct 2023 22:01:59 +0000 (00:01 +0200)] 
update TODO

2 years agoMerge pull request #27890 from bluca/executor
Luca Boccassi [Fri, 13 Oct 2023 21:01:16 +0000 (22:01 +0100)] 
Merge pull request #27890 from bluca/executor

core: add systemd-executor binary

2 years agotpm: update comment on transient handle GetCapability bug in kernel tpm resource...
Dan Streetman [Fri, 13 Oct 2023 20:07:37 +0000 (16:07 -0400)] 
tpm: update comment on transient handle GetCapability bug in kernel tpm resource manager

Add clarification and link to kernel bug.

2 years agonspawn: set CoredumpReceive=yes on container's scope when --boot is set 29272/head
Nick Rosbrook [Thu, 12 Oct 2023 17:39:56 +0000 (13:39 -0400)] 
nspawn: set CoredumpReceive=yes on container's scope when --boot is set

When --boot is set, and --keep-unit is not, set CoredumpReceive=yes on
the scope allocated for the container. When --keep-unit is set, nspawn
does not allocate the container's unit, so the existing unit needs to
configure this setting itself.

Since systemd-nspawn@.service sets --boot and --keep-unit, add
CoredumpReceives=yes to that unit.

2 years agoman: document CoredumpReceive= setting
Nick Rosbrook [Wed, 11 Oct 2023 14:46:42 +0000 (10:46 -0400)] 
man: document CoredumpReceive= setting

2 years agoman: move NFTSec= entry to "Network Accouting and Control" section
Nick Rosbrook [Tue, 3 Oct 2023 19:31:41 +0000 (15:31 -0400)] 
man: move NFTSec= entry to "Network Accouting and Control" section

Currently it is in the "Memory Pressure and Control" section, which does
not seem accurate.

2 years agotest: add a test for container support in coredump
Nick Rosbrook [Tue, 19 Sep 2023 21:09:58 +0000 (17:09 -0400)] 
test: add a test for container support in coredump

2 years agocoredump: add support for forwarding coredump to containers
Nick Rosbrook [Wed, 6 Sep 2023 15:03:41 +0000 (11:03 -0400)] 
coredump: add support for forwarding coredump to containers

If a process crashes within a container, try and forward the coredump to
that container. To do this, check if the crashing process is in a
different pidns, and if so, find the PID of the namespace leader. We
only proceed with forwarding if that PID belongs to a cgroup that is
descendant of another cgroup with user.delegate=1 and
user.coredump_receive=1 (i.e. Delegate=yes and CoredumpReceive=yes).

If we proceed, attach to the namespaces of the leader, and send the
coredump to systemd-coredump.socket in the container. Before this is
done, we need to translate the PID, UID, and GID, and also re-gather
procfs metadata. Translate the PID, UID, and GID to the perspective of
the container by sending an SCM_CREDENTIALS message over a socket pair
from the original systemd-coredump process, to the process forked in the
container.

If we cannot successfully forward the coredump, fallback to the current
behavior so that there is still a record of the crash on the host.

2 years agoprocess-util: introduce namespace_get_leader helper
Nick Rosbrook [Fri, 8 Sep 2023 21:03:56 +0000 (17:03 -0400)] 
process-util: introduce namespace_get_leader helper

For a given PID and namespace type, this helper function gives the PID
of the leader of the namespace containing the given PID. Use this in
systemd-coredump instead of using the existing get_mount_namespace_leader.

This helper will be used again in a later commit.

2 years agocoredump: store crashing process UID and GID in Context
Nick Rosbrook [Wed, 6 Sep 2023 15:01:33 +0000 (11:01 -0400)] 
coredump: store crashing process UID and GID in Context

For convenience, store the crashing process's UID and GID in Context (as
uid_t and gid_t, respectively), as is currently done for the PID. This
means we can just parse the UID/GID once in save_context(), and use
those values in other places.

This is just re-factoring, and is a preparation commit for container
support.

2 years agocore: add CoredumpReceive= setting
Nick Rosbrook [Fri, 29 Sep 2023 19:39:17 +0000 (15:39 -0400)] 
core: add CoredumpReceive= setting

This setting indicates that the given unit wants to receive coredumps
for processes that crash within the cgroup of this unit. This setting
requires that Delegate= is also true, and therefore is only available
where Delegate= is available.

This will be used by systemd-coredump to support forwarding coredumps to
containers.

2 years agocgroup-util: add cg_is_delegated helper
Nick Rosbrook [Thu, 28 Sep 2023 18:10:59 +0000 (14:10 -0400)] 
cgroup-util: add cg_is_delegated helper

Take is_delegated from cgroup-show.c, and make it a generic helper
function. This new helper will be used again in a later commit.

2 years agocore/varlink: make sure we setup non-serialized varlink sockets
Mike Yuan [Tue, 3 Oct 2023 12:20:55 +0000 (20:20 +0800)] 
core/varlink: make sure we setup non-serialized varlink sockets

Before this PR, if m->varlink_server is not yet set up during
deserialization, we call manager_setup_varlink_server rather than
manager_varlink_init, the former of which doesn't setup varlink
addresses, but only binds to methods. This results in that
newly-added varlink addresses not getting created if deserialization
takes place.

Therefore, let's switch to manager_varlink_init, and add some
sanity checks to it in order to prevent listening on the same
address twice.

Fixes #29373

Replaces #29421

2 years agosystemd-journal-upload: Increase failure tolerance (#19426, #2877)
Priit Laes [Tue, 10 Oct 2023 08:42:37 +0000 (11:42 +0300)] 
systemd-journal-upload: Increase failure tolerance (#19426, #2877)

As systemd-journal-upload deals mostly with remote servers, add
some failsafes to its unit to restart on failures.

```
[Service]
Restart=on-failure
RestartSteps=10
RestartMaxDelaySec=60
```

2 years agoMerge pull request #29551 from poettering/no-empty-structs-in-varlink
Luca Boccassi [Thu, 12 Oct 2023 22:10:20 +0000 (23:10 +0100)] 
Merge pull request #29551 from poettering/no-empty-structs-in-varlink

varlink: properly refuse empty structs/enums in varlink IDL

2 years agovarlinkctl: generate slightly more useful error messages
Lennart Poettering [Thu, 12 Oct 2023 13:07:07 +0000 (15:07 +0200)] 
varlinkctl: generate slightly more useful error messages

2 years agoMerge pull request #29502 from keszybz/sd-boot-config-tweaks
Luca Boccassi [Thu, 12 Oct 2023 22:08:56 +0000 (23:08 +0100)] 
Merge pull request #29502 from keszybz/sd-boot-config-tweaks

Tweaks to sd-boot UX

2 years agopo: Translated using Weblate (French)
Pierre GRASSER [Thu, 12 Oct 2023 16:36:11 +0000 (18:36 +0200)] 
po: Translated using Weblate (French)

Currently translated at 100.0% (227 of 227 strings)

Co-authored-by: Pierre GRASSER <pierre.grasser@proton.me>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/fr/
Translation: systemd/main

2 years agocore: move code from execute.c to exec-invoke.c 27890/head
Luca Boccassi [Fri, 1 Sep 2023 01:24:49 +0000 (02:24 +0100)] 
core: move code from execute.c to exec-invoke.c

No functional changes, only moving code that is only needed in
exec_invoke, and adding new dependencies for seccomp/selinux/apparmor/pam
in meson for the sd-executor binary.

2 years agocore: add systemd-executor binary
Luca Boccassi [Thu, 1 Jun 2023 18:51:42 +0000 (19:51 +0100)] 
core: add systemd-executor binary

Currently we spawn services by forking a child process, doing a bunch
of work, and then exec'ing the service executable.

There are some advantages to this approach:

- quick: we immediately have access to all the enourmous amount of
  state simply by virtue of sharing the memory with the parent
- easy to refactor and add features
- part of the same binary, will never be out of sync

There are however significant drawbacks:

- doing work after fork and before exec is against glibc's supported
  case for several APIs we call
- copy-on-write trap: anytime any memory is touched in either parent
  or child, a copy of that page will be triggered
- memory footprint of the child process will be memory footprint of
  PID1, but using the cgroup memory limits of the unit

The last issue is especially problematic on resource constrained
systems where hard memory caps are enforced and swap is not allowed.
As soon as PID1 is under load, with no page out due to no swap, and a
service with a low MemoryMax= tries to start, hilarity ensues.

Add a new systemd-executor binary, that is able to receive all the
required state via memfd, deserialize it, prepare the appropriate
data structures and call exec_child.

Use posix_spawn which uses CLONE_VM + CLONE_VFORK, to ensure there is
no copy-on-write (same address space will be used, and parent process
will be frozen, until exec).
The sd-executor binary is pinned by FD on startup, so that we can
guarantee there will be no incompatibilities during upgrades.

2 years agocore: add serialization/deserialization for CGroupContext
Luca Boccassi [Thu, 31 Aug 2023 23:42:35 +0000 (00:42 +0100)] 
core: add serialization/deserialization for CGroupContext

2 years agocore: add serialization/deserialization for ExecRuntime
Luca Boccassi [Thu, 31 Aug 2023 23:41:59 +0000 (00:41 +0100)] 
core: add serialization/deserialization for ExecRuntime

2 years agocore: add serialization/deserialization for ExecParameters
Luca Boccassi [Thu, 31 Aug 2023 23:40:37 +0000 (00:40 +0100)] 
core: add serialization/deserialization for ExecParameters

2 years agocore: add serialization/deserialization for ExecCommand
Luca Boccassi [Thu, 31 Aug 2023 23:38:01 +0000 (00:38 +0100)] 
core: add serialization/deserialization for ExecCommand

2 years agocore: add serialization/deserialization for ExecContext
Luca Boccassi [Thu, 31 Aug 2023 23:31:26 +0000 (00:31 +0100)] 
core: add serialization/deserialization for ExecContext