]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agohibernate-util: introduce hibernation_is_safe 29382/head
Mike Yuan [Mon, 16 Oct 2023 05:10:01 +0000 (13:10 +0800)] 
hibernate-util: introduce hibernation_is_safe

After 7470b80763ac0f598ca1ef73d44763967119c18d, we refuse
to hibernate if we fail to write HibernateLocation EFI
variable and resume= is not set. Let's teach sleep_supported
to follow the practice too.

2 years agohibernate-util: rework find_hibernate_location
Mike Yuan [Thu, 28 Sep 2023 01:05:41 +0000 (09:05 +0800)] 
hibernate-util: rework find_hibernate_location

* "HibernateLocation" struct is renamed to HibernationDevice
  to avoid ambiguity with the EFI variable. Also, it no longer
  takes the reference to a SwapEntry object, since it's really
  unnecessary (only SwapEntry.path is used), but increases complexity.
* SwapEntry is no longer used externally.
* find_hibernate_location is split into read_swap_entries and
  find_suitable_hibernation_device. The former reads all swap entries
  into SwapEntries object for later use.
* Make use of btrfs_get_file_physical_offset_fd

Closes #25130

2 years agohibernate-util: read_fiemap: add missing asserts
Mike Yuan [Sat, 30 Sep 2023 15:32:08 +0000 (23:32 +0800)] 
hibernate-util: read_fiemap: add missing asserts

2 years agosleep-config: introduce sleep_supported_full that returns a reason
Mike Yuan [Mon, 16 Oct 2023 12:34:29 +0000 (20:34 +0800)] 
sleep-config: introduce sleep_supported_full that returns a reason

Preparation for later commits.

Also some other cleanups:
* Add assertions
* Use FOREACH_ARRAY

2 years agosleep-config: minor cleanup for can_sleep_{state,disk}
Mike Yuan [Wed, 27 Sep 2023 22:43:06 +0000 (06:43 +0800)] 
sleep-config: minor cleanup for can_sleep_{state,disk}

* Rename to sleep_{state,mode}_supported
* Treat unreadable/unwriable sysfs files as error

2 years agotest-btrfs-physical-offset: log correct errno
Mike Yuan [Sat, 30 Sep 2023 08:40:22 +0000 (16:40 +0800)] 
test-btrfs-physical-offset: log correct errno

2 years agostub: Ignore the boot counter when looking for .extra.d directory
Valentin David [Thu, 19 Oct 2023 21:13:45 +0000 (23:13 +0200)] 
stub: Ignore the boot counter when looking for .extra.d directory

If `foo+3-0.efi` is booted when there are some files in `foo.efi.extra.d`,
those files are ignored. But after the boot is blessed and the system rebooted,
those file are taken into account, and the boot is different from first
boot. This behavior is a bit puzzling.

Instead we now ignore the counter and always look for the extra files in
`foo.efi.extra.d` and always boot the same way.

2 years agomkfs-util: set timezone to UTC when copying files into fat partition
Malte Poll [Fri, 20 Oct 2023 12:59:41 +0000 (12:59 +0000)] 
mkfs-util: set timezone to UTC when copying files into fat partition

mcopy will set the modification time of created directories to the mtime
of the source directories but converts it to the timezone of the host.
This behavior is identical to Windows / DOS:

>  The FAT file system stores time values based on the local time of the computer.

-- https://learn.microsoft.com/en-us/windows/win32/sysinfo/file-times

To achieve reproducible builds, mcopy should be invoked with TZ=UTC.

Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
2 years agotpm2: move event tag sd-boot/sd-stub to make measurements with into src/fundamental/
Lennart Poettering [Thu, 12 Oct 2023 14:28:38 +0000 (16:28 +0200)] 
tpm2: move event tag sd-boot/sd-stub to make measurements with into src/fundamental/

Ultimately we want to be able to recognize these in userspace, hence
make them available in both UEFI mode and userspace.

While we are at it, let's rename the fields a bit, reflecting more what
they measure, not what the metadata is that we store about them.

2 years agosort-utils: add generic uint16_t comparison call
Lennart Poettering [Sun, 16 Jul 2023 09:06:49 +0000 (11:06 +0200)] 
sort-utils: add generic uint16_t comparison call

2 years agoformat-table: add new table_get_current_column() helper
Lennart Poettering [Wed, 12 Jul 2023 20:50:25 +0000 (22:50 +0200)] 
format-table: add new table_get_current_column() helper

2 years agoformat-table: add new uint32_t hex field type
Lennart Poettering [Fri, 7 Jul 2023 15:26:33 +0000 (17:26 +0200)] 
format-table: add new uint32_t hex field type

2 years agoMerge pull request #29644 from poettering/json-iovec
Luca Boccassi [Fri, 20 Oct 2023 14:54:29 +0000 (15:54 +0100)] 
Merge pull request #29644 from poettering/json-iovec

add iovec/base64 json helpers and other iovec tweaks

2 years agoMerge pull request #29630 from DaanDeMeyer/manager-json
Daan De Meyer [Fri, 20 Oct 2023 14:42:12 +0000 (16:42 +0200)] 
Merge pull request #29630 from DaanDeMeyer/manager-json

Various refactoring in preparation for adding JSON dump to pid 1

2 years agoMerge pull request #29626 from bluca/auto_soft_reboot
Luca Boccassi [Fri, 20 Oct 2023 12:46:46 +0000 (13:46 +0100)] 
Merge pull request #29626 from bluca/auto_soft_reboot

systemctl: automatically softreboot/kexec if set up on reboot

2 years agorepart: port to new "struct iovec" JSON + primitive helpers 29644/head
Lennart Poettering [Fri, 20 Oct 2023 12:16:01 +0000 (14:16 +0200)] 
repart: port to new "struct iovec" JSON + primitive helpers

2 years agojson: add helpers for dispatching/building JSON with base64 struct iovecs
Lennart Poettering [Thu, 19 Oct 2023 15:41:01 +0000 (17:41 +0200)] 
json: add helpers for dispatching/building JSON with base64 struct iovecs

2 years agoiovec-util: add some useful helpers for dealing with iovecs that refer to dynamic...
Lennart Poettering [Thu, 19 Oct 2023 15:04:04 +0000 (17:04 +0200)] 
iovec-util: add some useful helpers for dealing with iovecs that refer to dynamic memory

2 years agotpm2-util: add line break where appropriate
Lennart Poettering [Thu, 19 Oct 2023 15:55:09 +0000 (17:55 +0200)] 
tpm2-util: add line break where appropriate

2 years agotpm2-util: add a bunch of line breaks for an overly long bitmask
Lennart Poettering [Thu, 19 Oct 2023 15:45:48 +0000 (17:45 +0200)] 
tpm2-util: add a bunch of line breaks for an overly long bitmask

2 years agojson: Introduce JSON_BUILD_CALLBACK 29630/head
Daan De Meyer [Fri, 20 Oct 2023 10:31:56 +0000 (12:31 +0200)] 
json: Introduce JSON_BUILD_CALLBACK

2 years agojson: Introduce JSON_BUILD_STRING_SET
Daan De Meyer [Thu, 19 Oct 2023 14:51:08 +0000 (16:51 +0200)] 
json: Introduce JSON_BUILD_STRING_SET

2 years agohashmap: Add extra uncounted entry to returned array from hashmap_dump_sorted()
Daan De Meyer [Fri, 20 Oct 2023 10:07:32 +0000 (12:07 +0200)] 
hashmap: Add extra uncounted entry to returned array from hashmap_dump_sorted()

This allows using the returned array as a strv.

2 years agomanager: Introduce manager_get_progress() helper
Daan De Meyer [Thu, 19 Oct 2023 14:49:08 +0000 (16:49 +0200)] 
manager: Introduce manager_get_progress() helper

2 years agounit: Move three helpers to unit.h
Daan De Meyer [Thu, 19 Oct 2023 14:45:23 +0000 (16:45 +0200)] 
unit: Move three helpers to unit.h

2 years agotimer: Add two more helper functions
Daan De Meyer [Thu, 19 Oct 2023 14:42:38 +0000 (16:42 +0200)] 
timer: Add two more helper functions

2 years agoswap: Move two functions to swap.h
Daan De Meyer [Thu, 19 Oct 2023 14:41:52 +0000 (16:41 +0200)] 
swap: Move two functions to swap.h

2 years agosocket: Add one more helper
Daan De Meyer [Thu, 19 Oct 2023 14:41:04 +0000 (16:41 +0200)] 
socket: Add one more helper

2 years agomount: Add more helpers
Daan De Meyer [Thu, 19 Oct 2023 14:38:47 +0000 (16:38 +0200)] 
mount: Add more helpers

2 years agoexecute: Add more helper functions
Daan De Meyer [Thu, 19 Oct 2023 14:37:35 +0000 (16:37 +0200)] 
execute: Add more helper functions

2 years agocore: Add two more to_string() functions
Daan De Meyer [Thu, 19 Oct 2023 14:35:52 +0000 (16:35 +0200)] 
core: Add two more to_string() functions

2 years agoAdd unit_type_to_capitalized_string()
Daan De Meyer [Thu, 19 Oct 2023 14:34:19 +0000 (16:34 +0200)] 
Add unit_type_to_capitalized_string()

2 years agoMerge pull request #29627 from poettering/io-split
Luca Boccassi [Fri, 20 Oct 2023 11:19:22 +0000 (12:19 +0100)] 
Merge pull request #29627 from poettering/io-split

split up io-util.[ch], and some clean-ups

2 years agorm-rf: Make sure we rewinddir() before readdir()
Daan De Meyer [Thu, 19 Oct 2023 17:42:07 +0000 (19:42 +0200)] 
rm-rf: Make sure we rewinddir() before readdir()

We don't know what state the passed in file descriptor is in. Let's
make sure we rewind it before iterating over it.

Fixes #29606

2 years agosystemctl: automatically softreboot/kexec if set up on reboot 29626/head
Luca Boccassi [Thu, 19 Oct 2023 12:58:03 +0000 (13:58 +0100)] 
systemctl: automatically softreboot/kexec if set up on reboot

Automatically softreboot if the nextroot has been set up with an OS
tree, or automatically kexec if a kernel has been loaded with kexec
--load.

Add SYSTEMCTL_SKIP_AUTO_KEXEC and SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT to
skip the automated switchover.

2 years agocredentials: document that their path is stable for system services
Joerg Behrmann [Fri, 20 Oct 2023 09:35:04 +0000 (11:35 +0200)] 
credentials: document that their path is stable for system services

2 years agomkosi: Use RuntimeTrees= to mount sources
Daan De Meyer [Tue, 17 Oct 2023 14:03:42 +0000 (16:03 +0200)] 
mkosi: Use RuntimeTrees= to mount sources

Instead of using ExtraTrees=, let's use the new RuntimeTrees= option
to mount the full repository into the VM/container. Let's also store
the sources under /usr/src/systemd and update the gdbinit file and
vscode HACKING guide section to match the new location.

2 years agonetif-naming-scheme: disable NAMING_BRIDGE_MULTIFUNCTION_SLOT
Yu Watanabe [Wed, 23 Aug 2023 15:01:19 +0000 (00:01 +0900)] 
netif-naming-scheme: disable NAMING_BRIDGE_MULTIFUNCTION_SLOT

This effectively reverts 66425daf2c68793adf24a48a26d58add8662e83f.

The commit assumes that if the network interface has multifunctions,
then the function fields of the pci devices under the same PCI bridge
device are unique.
But it seems not, at least on some setups. See issue #28929.
Let's revert the change, and always refuse to set slot base naming if
a PCI bridge is detected.

Fixes #28929.

2 years agoMerge pull request #29618 from bonktree/fchmodat2
Luca Boccassi [Fri, 20 Oct 2023 09:49:46 +0000 (10:49 +0100)] 
Merge pull request #29618 from bonktree/fchmodat2

seccomp: get `fchmodat2(2)` covered by `RestrictSUIDSGID=`

2 years agoman: document the order in which we talk to DNS servers
Lennart Poettering [Wed, 18 Oct 2023 16:14:00 +0000 (18:14 +0200)] 
man: document the order in which we talk to DNS servers

2 years agoio-util: split out iovw_xyz into iovec-wrapper.h 29627/head
Lennart Poettering [Thu, 19 Oct 2023 14:24:20 +0000 (16:24 +0200)] 
io-util: split out iovw_xyz into iovec-wrapper.h

Let's split these APIs out, they are kinda their own thing.

2 years agoiovec-util: make IOVEC_INCREMENT a regular function too
Lennart Poettering [Thu, 19 Oct 2023 14:36:43 +0000 (16:36 +0200)] 
iovec-util: make IOVEC_INCREMENT a regular function too

Even more than with the previous commit, this is not a trivial function
and there's no reason to believe this will actually be inlined nor that
it would be beneficial.

2 years agoiovec-util: make IOVEC_MAKE_STRING() safer
Lennart Poettering [Thu, 19 Oct 2023 14:30:23 +0000 (16:30 +0200)] 
iovec-util: make IOVEC_MAKE_STRING() safer

Let's not accept arbitrary types, but only char* and const char*.

2 years agoiovec-util: make IOVEC_NULL const
Lennart Poettering [Thu, 19 Oct 2023 14:27:16 +0000 (16:27 +0200)] 
iovec-util: make IOVEC_NULL const

compound initialized structs can be placed im immutable memory if const,
hence there's benefit in making this one const too

2 years agoiovec-util: make IOVEC_TOTAL_SIZE() a regular function
Lennart Poettering [Thu, 19 Oct 2023 14:33:51 +0000 (16:33 +0200)] 
iovec-util: make IOVEC_TOTAL_SIZE() a regular function

The function isn't necessarily fast (it's O(n)), and there's no reason
to have it defined as inline function, since it's neither fast, nor
entirely trivial.

2 years agoio-util: split out "struct iovec" related calls into their own .c/.h files
Lennart Poettering [Thu, 19 Oct 2023 14:01:38 +0000 (16:01 +0200)] 
io-util: split out "struct iovec" related calls into their own .c/.h files

This is preparation for #28891, which adds a bunch more helpers around
"struct iovec", at which point this really deserves its own .c/.h file.

The idea is that we sooner or later can consider "struct iovec" as an
entirely generic mechanism to reference some binary blob, and is the
go-to type for this purpose whenever we need one.

2 years agoexecutor: return instead of assert on invalid command line arguments
Luca Boccassi [Thu, 19 Oct 2023 19:53:10 +0000 (20:53 +0100)] 
executor: return instead of assert on invalid command line arguments

Before the split, it made sense to assert, as checks were on setup.
But now these come from deserialization, and the fuzzer hits the
asserts, so simply return an error instead.

2 years agoman: mention that inhibit blocks soft-reboot too
Luca Boccassi [Thu, 19 Oct 2023 13:52:21 +0000 (14:52 +0100)] 
man: mention that inhibit blocks soft-reboot too

2 years agotest-recurse-dir: work around nftw() ignoring symlinks()
Zbigniew Jędrzejewski-Szmek [Thu, 19 Oct 2023 14:46:56 +0000 (16:46 +0200)] 
test-recurse-dir: work around nftw() ignoring symlinks()

We have a test where we compare the results from nftw() and our own
resurce_dit_at(). nftw() skips a dangling symlink when running under mkosi and
the test fails. I don't understand why nftw() does that, but in our code we
don't need to test and care about the details of nftw(), which we don't use,
outside of the one test, so let's just skip symlinks in the test.

Closes #29603.

2 years agoMerge pull request #29628 from mrc0mmand/systemd-executor-test
Luca Boccassi [Thu, 19 Oct 2023 18:39:39 +0000 (19:39 +0100)] 
Merge pull request #29628 from mrc0mmand/systemd-executor-test

test: slightly improve sd-executor's coverage

2 years agopidref: make PIDREF_NULL const
Lennart Poettering [Thu, 19 Oct 2023 15:09:41 +0000 (17:09 +0200)] 
pidref: make PIDREF_NULL const

That way compiler can put it in an immutable section

2 years agoMerge pull request #29629 from bluca/mount_tunnel_pidref
Luca Boccassi [Thu, 19 Oct 2023 17:59:22 +0000 (18:59 +0100)] 
Merge pull request #29629 from bluca/mount_tunnel_pidref

mount tunnel: use PidRef

2 years agoMerge pull request #29623 from YHNdnzj/core-followup
Luca Boccassi [Thu, 19 Oct 2023 17:04:40 +0000 (18:04 +0100)] 
Merge pull request #29623 from YHNdnzj/core-followup

Follow-ups for recent changes to core/

2 years agotest: skip Protect{Home,System}= tests with coverage builds
Frantisek Sumsal [Thu, 19 Oct 2023 13:13:07 +0000 (15:13 +0200)] 
test: skip Protect{Home,System}= tests with coverage builds

With coverage builds we disable Protect{Home,System}= via a service.d
dropin in /etc, which has, unfortunately, higher priority than our
transient systemd-run stuff. Let's just skip the affected tests in that
case instead of making the test setup even more complicated.

2 years agopid1,vconsole-setup: lock /dev/console instead of the tty device
Zbigniew Jędrzejewski-Szmek [Tue, 17 Oct 2023 17:43:31 +0000 (19:43 +0200)] 
pid1,vconsole-setup: lock /dev/console instead of the tty device

As requested in https://github.com/systemd/systemd/pull/27867#pullrequestreview-1567161854.
/dev/console, /dev/tty0, and /dev/ttyN are "different" device nodes
that may point to a single underlying device. We want to use a single
lock so that we don't get a race if different writers are using a different
device path, so let's just always lock around /dev/console.
This effectively makes the locking less granular.

Fixup for a0043bfa51281c2374878e2a98cf2a3ee10fd92c.
Fixes https://github.com/systemd/systemd/issues/28721.
Maybe fixes https://github.com/systemd/systemd/issues/28778 and
https://github.com/systemd/systemd/issues/28634.

2 years agotest: unify checking for user xattrs support in cgroupfs
Frantisek Sumsal [Thu, 19 Oct 2023 10:28:37 +0000 (12:28 +0200)] 
test: unify checking for user xattrs support in cgroupfs

Also, run the coredump forwarding test only if user xattrs are
supported.

2 years agomeson: generate proper version tag when git fails on permission errors
Zbigniew Jędrzejewski-Szmek [Thu, 19 Oct 2023 10:55:59 +0000 (12:55 +0200)] 
meson: generate proper version tag when git fails on permission errors

When building with mkosi I would get the following:

    [1/477] Generating version.h with a custom command
    fatal: detected dubious ownership in repository at '/work/src'
    To add an exception for this directory, call:

            git config --global --add safe.directory /work/src

and then the tag would be generated as 'v254-'. This is obviously some problem
with the setup, but we should handle this gracefully. Let's fall back to 'v254'
instead.

In the case where we have a repo but no tags, use --dirty=^ too, as in the case
with tags.

I tested four cases:
- normal checkout
- checkout with .git removed
- checkout with .git chowned to root
- checkout wiht all tags removed

2 years agoUpdate TODO 29629/head
Luca Boccassi [Thu, 19 Oct 2023 15:00:21 +0000 (16:00 +0100)] 
Update TODO

2 years agomount tunnel: use PidRef
Luca Boccassi [Thu, 19 Oct 2023 15:00:00 +0000 (16:00 +0100)] 
mount tunnel: use PidRef

2 years agocore: properly cleanup ExecParameter's prefix array 29628/head
Frantisek Sumsal [Thu, 19 Oct 2023 14:47:46 +0000 (16:47 +0200)] 
core: properly cleanup ExecParameter's prefix array

2 years agotest: add coverage for #29610
Frantisek Sumsal [Thu, 19 Oct 2023 14:23:28 +0000 (16:23 +0200)] 
test: add coverage for #29610

As reproducing it is actually pretty easy, with the benefit of hindsight:

~# systemd-run -P -p MountImages="/this/should/definitely/not/exist.img:/run/img2\:3:nosuid" false
Running as unit: run-u42.service
free(): double free detected in tcache 2

2 years agotest: add a real-world state to the corpus
Frantisek Sumsal [Thu, 19 Oct 2023 14:12:45 +0000 (16:12 +0200)] 
test: add a real-world state to the corpus

To give the fuzzer a nice head start.

2 years agocore/service: check error first and log about errno 29623/head
Mike Yuan [Wed, 18 Oct 2023 15:29:00 +0000 (23:29 +0800)] 
core/service: check error first and log about errno

Follow-up for becdfcb9f1cb555c50dcfe51894cb0b155f7f01e

2 years agocgroup-util: use RET_GATHER more, return first error
Mike Yuan [Thu, 19 Oct 2023 12:23:54 +0000 (20:23 +0800)] 
cgroup-util: use RET_GATHER more, return first error

2 years agocore/exec-invoke: use correct exit status
Mike Yuan [Wed, 18 Oct 2023 13:22:19 +0000 (21:22 +0800)] 
core/exec-invoke: use correct exit status

These calls can fail not only due to OOM.

2 years agocore/namespace: merge if blocks
Mike Yuan [Wed, 18 Oct 2023 11:23:42 +0000 (19:23 +0800)] 
core/namespace: merge if blocks

2 years agoexecutor: fix double free of MountOptions
Luca Boccassi [Thu, 19 Oct 2023 11:24:19 +0000 (12:24 +0100)] 
executor: fix double free of MountOptions

This list is owned by ExecContext, which is cleaned up when sd-executor
fails, but it is also cleaned up when namespace setup exits, so we get
a double free.

Fixes https://github.com/systemd/systemd/issues/29610

Follow-up for bb5232b6a3

2 years agoMerge pull request #29617 from keszybz/efi-no-xmalloc0
Luca Boccassi [Thu, 19 Oct 2023 13:23:54 +0000 (14:23 +0100)] 
Merge pull request #29617 from keszybz/efi-no-xmalloc0

efi: drop duplicate initialization to 0

2 years agoseccomp: also check the mode parameter of `fchmodat2(2)` 29618/head
Arseny Maslennikov [Sun, 15 Oct 2023 08:00:00 +0000 (11:00 +0300)] 
seccomp: also check the mode parameter of `fchmodat2(2)`

If there is no libseccomp support, just ban the entire syscall instead
so wrappers will fall back to older, supported syscalls.
Also reflect all of this in `test-seccomp.c`.

2 years agoseccomp: include `fchmodat2` in `@file-system`
Arseny Maslennikov [Sun, 15 Oct 2023 08:00:00 +0000 (11:00 +0300)] 
seccomp: include `fchmodat2` in `@file-system`

2 years agocgroup-util: drop dead code block
Yu Watanabe [Thu, 19 Oct 2023 09:40:10 +0000 (18:40 +0900)] 
cgroup-util: drop dead code block

Follow-up for 4d1b2df199227ed4b934bbcb054364e92e93a1a6.

Fixes CID#1522888.

2 years agobasic/missing_syscall: generate defs for `fchmodat2(2)`
Arseny Maslennikov [Sun, 15 Oct 2023 08:00:00 +0000 (11:00 +0300)] 
basic/missing_syscall: generate defs for `fchmodat2(2)`

We will need this to set seccomp filters on this system call regardless
of libseccomp or kernel support.

2 years agoUpdate system call tables for Linux 6.6
Arseny Maslennikov [Sun, 15 Oct 2023 08:00:00 +0000 (11:00 +0300)] 
Update system call tables for Linux 6.6

We are doing this to obtain the definition of fchmodat2.

2 years agoseccomp: fix debug logging typo
Arseny Maslennikov [Sun, 15 Oct 2023 08:00:00 +0000 (11:00 +0300)] 
seccomp: fix debug logging typo

Fixes: da4dc9a67487 ("seccomp: rework how the S[UG]ID filter is installed")
2 years agoMerge pull request #29595 from YHNdnzj/systemctl-failed-system
Luca Boccassi [Thu, 19 Oct 2023 11:07:37 +0000 (12:07 +0100)] 
Merge pull request #29595 from YHNdnzj/systemctl-failed-system

systemctl: is-failed: check if system is degraded when no unit given

2 years agoefi: drop unused xmalloc0() 29617/head
Zbigniew Jędrzejewski-Szmek [Tue, 17 Oct 2023 08:56:45 +0000 (10:56 +0200)] 
efi: drop unused xmalloc0()

Keeping this separate to make it easy to revert if it's ever needed again.

2 years agoefi: do not memzero fields before initializing them
Zbigniew Jędrzejewski-Szmek [Tue, 17 Oct 2023 08:55:57 +0000 (10:55 +0200)] 
efi: do not memzero fields before initializing them

In all three cases we immediately overwrite the whole field anyway,
so the call to memzero is not needed.

2 years agovarlink: Add new varlink_collect method
Arthur Shau [Wed, 20 Sep 2023 01:52:39 +0000 (18:52 -0700)] 
varlink: Add new varlink_collect method

varlink_collect is meant to be used when the client is willing to wait for the reply from the varlink method, much like varlink_call.
However, unlike varlink_call, it allows the client to collect all "more" replies that may be sent by method before the "final" reply is enqueued.
It aggregates all of these replies into a json variant array that it returns to the client.

2 years agofuzz: unify logging setup
Frantisek Sumsal [Wed, 18 Oct 2023 21:11:13 +0000 (23:11 +0200)] 
fuzz: unify logging setup

Make sure we don't log anything when running in "fuzzing" mode. Also,
when at it, unify the setup logic into a helper, pretty similar to
the test_setup_logging() one.

Addresses:
  - https://github.com/systemd/systemd/pull/29558#pullrequestreview-1676060607
  - https://github.com/systemd/systemd/pull/29558#discussion_r1358940663

2 years agoMerge pull request #29611 from mrc0mmand/execute-serialize-fuzz
Luca Boccassi [Wed, 18 Oct 2023 22:33:00 +0000 (23:33 +0100)] 
Merge pull request #29611 from mrc0mmand/execute-serialize-fuzz

test: add a fuzzer for exec_{serialize,deserialize}_invocation()

2 years agocore: don't assert when serializing malformed state 29611/head
Frantisek Sumsal [Wed, 18 Oct 2023 17:57:06 +0000 (19:57 +0200)] 
core: don't assert when serializing malformed state

2 years agotest: add a fuzzer for exec_{serialize,deserialize}_invocation()
Frantisek Sumsal [Fri, 28 Jul 2023 08:33:08 +0000 (10:33 +0200)] 
test: add a fuzzer for exec_{serialize,deserialize}_invocation()

2 years agosystemctl: is-failed: check if system is degraded when no unit given 29595/head
Mike Yuan [Tue, 17 Oct 2023 12:47:54 +0000 (20:47 +0800)] 
systemctl: is-failed: check if system is degraded when no unit given

Closes #3335

2 years agosystemctl: minor modernization
Mike Yuan [Tue, 17 Oct 2023 12:35:31 +0000 (20:35 +0800)] 
systemctl: minor modernization

2 years agoMerge pull request #29594 from poettering/cgroup-rename-ret-params
Lennart Poettering [Wed, 18 Oct 2023 15:25:44 +0000 (17:25 +0200)] 
Merge pull request #29594 from poettering/cgroup-rename-ret-params

more pidfdification

2 years agotest: use Type=exec for the test unit
Frantisek Sumsal [Wed, 18 Oct 2023 12:11:33 +0000 (14:11 +0200)] 
test: use Type=exec for the test unit

Make sure everything we need is set up before continuing further with
the test. This should, hopefully, help with a race where we check
a dynamic user before it's created by NFTSet= stuff.

Before:
$ journalctl -o short-monotonic --grep '(test-nft|NFT|testsuite-75)' --no-hostname
...
[ 3657.929223] testsuite-75.sh[48]: + systemd-run -u test-nft.service -p DynamicUser=yes -p 'NFTSet=cgroup:inet:sd_test:c user:inet:sd_test:u group:inet:sd_test:g' sleep 10000
...
[ 3657.977372] systemd[1]: test-nft.service: Changed dead -> running
[ 3657.977388] systemd[1]: test-nft.service: Job 376 test-nft.service/start finished, result=done
[ 3657.977407] testsuite-75.sh[853]: Running as unit: test-nft.service; invocation ID: 8776af2ec7864a60a058cb5d403d1ca6
[ 3657.982437] testsuite-75.sh[856]:                 elements = { "system.slice/test-nft.service" }
[ 3657.984570] testsuite-75.sh[48]: + grep -qF test-nft.service /tmp/tmp.uqXKfyzcpJ
[ 3657.985400] testsuite-75.sh[859]: ++ getent passwd test-nft
[ 3657.986434] systemd[1]: varlink-12: New incoming message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test-nft","service":"io.systemd.DynamicUser"}}
[ 3657.986503] systemd[1]: varlink-12: Sending message: {"error":"io.systemd.UserDatabase.NoRecordFound","parameters":{}}
[ 3657.986643] systemd[1]: testsuite-75.service: Child 48 belongs to testsuite-75.service.
[ 3657.986660] systemd[1]: testsuite-75.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
[ 3657.986681] systemd[1]: testsuite-75.service: Failed with result 'exit-code'.
...
[ 3657.989885] systemd[1]: test-nft.service: User lookup succeeded: uid=64568 gid=64568
[ 3657.989936] systemd[1]: Added NFT set: family inet, table sd_test, set u, ID 64568
[ 3657.989965] systemd[1]: Added NFT set: family inet, table sd_test, set g, ID 64568

After:
$ journalctl -o short-monotonic --grep '(test-nft|NFT|testsuite-75)' --no-hostname
[ 1523.874408] testsuite-75.sh[49]: + systemd-run -u test-nft.service --service-type=exec -p DynamicUser=yes -p 'NFTSet=cgroup:inet:sd_test:c user:inet:sd_test:u group:inet:sd_test:g' sleep 10000
...
[ 1523.924091] systemd[1]: Starting test-nft.service...
[ 1523.928891] systemd[1]: test-nft.service: User lookup succeeded: uid=64568 gid=64568
[ 1523.929102] systemd[1]: Added NFT set: family inet, table sd_test, set u, ID 64568
[ 1523.929220] systemd[1]: Added NFT set: family inet, table sd_test, set g, ID 64568
...
[ 1523.933263] systemd[1]: Started test-nft.service.
[ 1523.933626] testsuite-75.sh[849]: Running as unit: test-nft.service; invocation ID: d1a5c3eacbc647a7a5fcbd46c7b2f863
[ 1523.940810] testsuite-75.sh[852]:                 elements = { "system.slice/test-nft.service" }
[ 1523.942880] testsuite-75.sh[49]: + grep -qF test-nft.service /tmp/tmp.gWka2x3mQq
[ 1523.944031] testsuite-75.sh[855]: ++ getent passwd test-nft
[ 1523.945496] systemd[1]: varlink-18: New incoming message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test-nft","service":"io.systemd.DynamicUser"}}
[ 1523.951593] systemd[1]: varlink-18: Sending message: {"parameters":{"record":{"userName":"test-nft","uid":64568,"gid":64568,"realName":"Dynamic User",...

2 years agomanager: move idle_pipe allocation to manager.c and make it atomic
Lennart Poettering [Wed, 18 Oct 2023 11:37:45 +0000 (13:37 +0200)] 
manager: move idle_pipe allocation to manager.c and make it atomic

Let's make sure it either fails or suceeds, but never fails half-way
leaving a half-initialized array around.

2 years agoMerge pull request #29583 from poettering/deserialize-fd-many
Luca Boccassi [Wed, 18 Oct 2023 15:06:22 +0000 (16:06 +0100)] 
Merge pull request #29583 from poettering/deserialize-fd-many

add serialize_fd_many() + deserialize_fd_many() helpers

2 years agoupdate TODO 29594/head
Lennart Poettering [Tue, 17 Oct 2023 08:57:26 +0000 (10:57 +0200)] 
update TODO

2 years agotest-cgroup: make test case a bit more robust towards previous aborted runs
Lennart Poettering [Tue, 17 Oct 2023 12:31:11 +0000 (14:31 +0200)] 
test-cgroup: make test case a bit more robust towards previous aborted runs

2 years agokillall: port killing spree loop over to PidRef
Lennart Poettering [Tue, 17 Oct 2023 11:43:29 +0000 (13:43 +0200)] 
killall: port killing spree loop over to PidRef

2 years agotest: port tests over to new /proc/ enumeration API
Lennart Poettering [Tue, 17 Oct 2023 11:43:59 +0000 (13:43 +0200)] 
test: port tests over to new /proc/ enumeration API

2 years agoprocess-util: add API for enumerating processes in /proc/ and pinning them via PidRef
Lennart Poettering [Tue, 17 Oct 2023 11:41:08 +0000 (13:41 +0200)] 
process-util: add API for enumerating processes in /proc/ and pinning them via PidRef

2 years agoprocess-util: add pidref_is_unwaited() and make pid_is_unwaited() return errors
Lennart Poettering [Tue, 17 Oct 2023 10:32:00 +0000 (12:32 +0200)] 
process-util: add pidref_is_unwaited() and make pid_is_unwaited() return errors

2 years agoprocess-util: add pidref_is_my_child()
Lennart Poettering [Tue, 17 Oct 2023 10:20:16 +0000 (12:20 +0200)] 
process-util: add pidref_is_my_child()

2 years agoprocess-util: change pid_is_alive() to not eat up errors, and add pidref_is_alive()
Lennart Poettering [Tue, 17 Oct 2023 10:12:05 +0000 (12:12 +0200)] 
process-util: change pid_is_alive() to not eat up errors, and add pidref_is_alive()

Let's no eat up errors, but propagate unexpected ones.

2 years agoprocess-util: add pidref_get_uid() and rename get_process_uid() → pidref_get_uid()
Lennart Poettering [Tue, 17 Oct 2023 09:27:06 +0000 (11:27 +0200)] 
process-util: add pidref_get_uid() and rename get_process_uid() → pidref_get_uid()

2 years agocore: port unit/process kill logic to pidref
Lennart Poettering [Tue, 17 Oct 2023 08:34:00 +0000 (10:34 +0200)] 
core: port unit/process kill logic to pidref

2 years agopidref: add new pidref_is_self() helper
Lennart Poettering [Tue, 17 Oct 2023 08:17:49 +0000 (10:17 +0200)] 
pidref: add new pidref_is_self() helper

This simply checks if the specified PidRef refers to the process we are
running in.

(In case you wonder why this is not a static inline: to avoid cyclic
header inclusion problems between pidref.h + process-util.h)

2 years agoprocess-util: add pidref_get_comm() and rename get_process_comm() to pid_get_comm()
Lennart Poettering [Tue, 17 Oct 2023 08:16:31 +0000 (10:16 +0200)] 
process-util: add pidref_get_comm() and rename get_process_comm() to pid_get_comm()