systemd/.git
20 months agomanager: Freeze/Thaw: Don't fail units w/o cgroup
Adrian Vovk [Fri, 29 Mar 2024 00:38:09 +0000 (20:38 -0400)]
manager: Freeze/Thaw: Don't fail units w/o cgroup

Previously, it was impossible to freeze or thaw a slice if it is an
ancestor to a unit that had no running cgroup (i.e. a service with
RemainAfterExit=yes). Instead of failing with EBUSY (which would
confusingly get reported as "Unit has pending job") we just silently
no-op.

I noticed this because we now have user-runtime-dir@.service, which
would make it impossible to freeze/thaw user.slice or user-<UID>.slice

20 months agoMerge pull request #32010 from bluca/reexec_rate_limit
Luca Boccassi [Fri, 29 Mar 2024 17:16:36 +0000 (17:16 +0000)]
Merge pull request #32010 from bluca/reexec_rate_limit

core: serialize reload rate limit and apply ReloadLimit to reexec too

20 months agomkosi: Switch to linux-virtual on Ubuntu
Daan De Meyer [Fri, 29 Mar 2024 07:28:57 +0000 (08:28 +0100)]
mkosi: Switch to linux-virtual on Ubuntu

This now finally has support for credentials and erofs so let's switch
to this much smaller kernel package that doesn't pull in linux-firmware.

20 months agoudevadm-test: prettify test results
Yu Watanabe [Fri, 29 Mar 2024 04:03:49 +0000 (13:03 +0900)]
udevadm-test: prettify test results

20 months agocore: apply ReloadLimit to reexec too
Luca Boccassi [Fri, 29 Mar 2024 01:29:07 +0000 (01:29 +0000)]
core: apply ReloadLimit to reexec too

Same reason as the reload, reexec is disruptive and it requires the
same privileges, so if somebody wants to limit reloads, they'll also
want to limit reexecs, so use the same setting.

20 months agocore: serialize reload rate limit
Luca Boccassi [Fri, 29 Mar 2024 01:15:26 +0000 (01:15 +0000)]
core: serialize reload rate limit

Otherwise the rate limit is lost on reexec, and the privileges to call it
are the same as reloads

20 months agoMerge pull request #32013 from yuwata/align-table
Daan De Meyer [Fri, 29 Mar 2024 07:30:59 +0000 (08:30 +0100)]
Merge pull request #32013 from yuwata/align-table

core: align table

20 months agounit-def: append trailing comma for the last entry
Yu Watanabe [Fri, 29 Mar 2024 04:53:01 +0000 (13:53 +0900)]
unit-def: append trailing comma for the last entry

20 months agocore: align table
Yu Watanabe [Fri, 29 Mar 2024 04:51:15 +0000 (13:51 +0900)]
core: align table

20 months agoMerge pull request #31998 from yuwata/udev-event-mode
Yu Watanabe [Fri, 29 Mar 2024 02:31:58 +0000 (11:31 +0900)]
Merge pull request #31998 from yuwata/udev-event-mode

udev: make udevadm test and test-builtin not destructive

20 months agoportable: the 'flags' parameter is now used in DetachImageWithExtensions() and Reatta...
Luca Boccassi [Thu, 28 Mar 2024 22:17:26 +0000 (22:17 +0000)]
portable: the 'flags' parameter is now used in DetachImageWithExtensions() and ReattachImageWithExtensions()

20 months agoudev: make udevadm test and test-builtin not destructive
Yu Watanabe [Thu, 28 Mar 2024 07:24:59 +0000 (16:24 +0900)]
udev: make udevadm test and test-builtin not destructive

Previously, 'udevadm test' performs not only processing udev rules,
but made several destructive change on the system; updating udev
database, device node permission, devlinks, network interface
properties, and so on.

Similary, 'udevadm test-builtin' may perform something destructive,
especially by 'keyboard', 'kmod', and 'net_setup_link' builtins.

Let's make these commands and test executables not change device
configurations.

20 months agoMerge pull request #31986 from YHNdnzj/suspend-mem-mode
Yu Watanabe [Fri, 29 Mar 2024 00:30:54 +0000 (09:30 +0900)]
Merge pull request #31986 from YHNdnzj/suspend-mem-mode

sleep: add SleepMemMode= setting for configuring /sys/power/mem_sleep

20 months agonetwork: save the real rdnss address
Ronan Pigott [Thu, 28 Mar 2024 00:19:43 +0000 (17:19 -0700)]
network: save the real rdnss address

... instead of the router that informed us

Fixes: 86a66e9b9504 ("network: also save NTP servers and friends obtained by other protocols")

20 months agotest: make coverage runs happy with capsule@.service
Frantisek Sumsal [Thu, 28 Mar 2024 13:57:26 +0000 (14:57 +0100)]
test: make coverage runs happy with capsule@.service

capsule@.service uses DynamicUser=yes, so let's use the same tweak we
use for other such units.

20 months agologin: Fix fallback error handling
Daan De Meyer [Thu, 28 Mar 2024 16:05:33 +0000 (17:05 +0100)]
login: Fix fallback error handling

20 months agotest: disable IPv6AcceptRA= for test network interfaces with static address
Yu Watanabe [Thu, 28 Mar 2024 03:52:01 +0000 (12:52 +0900)]
test: disable IPv6AcceptRA= for test network interfaces with static address

This hopefully improves test performance.

20 months agoMerge pull request #31994 from yuwata/network-dhcp-server-follow-ups
Luca Boccassi [Thu, 28 Mar 2024 12:35:13 +0000 (12:35 +0000)]
Merge pull request #31994 from yuwata/network-dhcp-server-follow-ups

network: several fixlets for PersistLeases=

20 months agondisc-option: allow to set valid time of options
Yu Watanabe [Sun, 17 Mar 2024 06:23:38 +0000 (15:23 +0900)]
ndisc-option: allow to set valid time of options

When an option is delegated from an upstream server, its lifetime
may be limited by a time. Such functionality will be used later by
sd-radv.

This also remove 'offset' argument from the option setter
ndisc_option_set_xyz(), and make it update existing option.
See comments in ndisc_option_add_link_layer_address() for more details.

20 months agojournalctl-filter: use add_match_boot_id() instead of add_match_this_boot()
Yu Watanabe [Fri, 22 Mar 2024 08:46:00 +0000 (17:46 +0900)]
journalctl-filter: use add_match_boot_id() instead of add_match_this_boot()

The function add_match_this_boot() calls sd_journal_add_conjunction(),
hence, we cannot specify multiple devices in the extra match arguments,
e.g., "journalctl /dev/sda /dev/sdb" shows no entry.

20 months agosleep: add SleepMemMode= setting for configuring /sys/power/mem_sleep
Mike Yuan [Wed, 27 Mar 2024 11:45:34 +0000 (19:45 +0800)]
sleep: add SleepMemMode= setting for configuring /sys/power/mem_sleep

The setting is used when /sys/power/state is set to 'mem'
(common for suspend) or /sys/power/disk is set to 'suspend'
(hybrid-sleep). We default to kernel choice here, i.e.
respect what's set through 'mem_sleep_default=' kernel
cmdline option.

20 months agosleep: make write_mode take a path
Mike Yuan [Wed, 27 Mar 2024 11:45:08 +0000 (19:45 +0800)]
sleep: make write_mode take a path

Similar to the previous commit, preparation
for adding support for /sys/power/mem_sleep.

20 months agosleep-config: make sleep_mode_supported take a path
Mike Yuan [Tue, 26 Mar 2024 16:24:58 +0000 (00:24 +0800)]
sleep-config: make sleep_mode_supported take a path

Preparation for later commits.

20 months agostring-util: modernize string_contains_word_strv a bit
Mike Yuan [Tue, 26 Mar 2024 16:15:40 +0000 (00:15 +0800)]
string-util: modernize string_contains_word_strv a bit

Also correct the comment on flags.

20 months agosleep-config: fix potential memory leak
Mike Yuan [Wed, 27 Mar 2024 13:03:30 +0000 (21:03 +0800)]
sleep-config: fix potential memory leak

Follow-up for 77bd39385eae7b8e3182e66292b9f94bb54e235d

20 months agoman/systemd-sleep: reorder options
Mike Yuan [Wed, 27 Mar 2024 11:59:51 +0000 (19:59 +0800)]
man/systemd-sleep: reorder options

20 months agosleep-config: make sleep_operation_is_hibernation uppercase
Mike Yuan [Tue, 26 Mar 2024 16:30:06 +0000 (00:30 +0800)]
sleep-config: make sleep_operation_is_hibernation uppercase

20 months agoudev-event: split out update_clone()
Yu Watanabe [Thu, 28 Mar 2024 05:49:28 +0000 (14:49 +0900)]
udev-event: split out update_clone()

No functional change, preparation for later commits.

20 months agohomed: Release(): fix assertion failure
Adrian Vovk [Thu, 21 Mar 2024 23:28:38 +0000 (19:28 -0400)]
homed: Release(): fix assertion failure

This fixes a race condition crash in homed that would happen in the
following sequence of events:

1. Client 1 takes a ref on the home area
2. Client 1 calls some method via dbus
3. Client 2 calls Release()

In homed, the Release() would check if a ref is still held (in this
case: yes it is) and returns an error. Except that is done through a
code-path that asserts that no operations are ongoing. In this case,
it's valid to have an ongoing operation, and so the assertion fails
causing homed to crash.

20 months agorun: fix generated unit name clash after soft-reboot
Luca Boccassi [Wed, 27 Mar 2024 21:14:15 +0000 (21:14 +0000)]
run: fix generated unit name clash after soft-reboot

When sd-run connects to D-Bus rather than the private socket, it will
generate the transient unit name using the bus ID assigned by the D-Bus
broker/daemon. The issue is that this ID is only unique per D-Bus run,
if the broker/daemon restarts it starts again from 1, and it's a simple
incremental counter for each client.
So if a transient unit run-u6.service starts and fails, and it is not
collected (default on failure), and the system soft-reboots, any new
transient unit might conflict as the counter will restart:

Failed to start transient service unit: Unit run-u6.service was already loaded or has a fragment file.

Get the soft-reboot counter, and if it's greater than zero, append it
to the autogenerated unit name to avoid clashes.

20 months agoMerge pull request #31989 from mrc0mmand/test-loop-dev-check
Yu Watanabe [Thu, 28 Mar 2024 02:19:32 +0000 (11:19 +0900)]
Merge pull request #31989 from mrc0mmand/test-loop-dev-check

test: check for /dev/loop-control when checking lodev availability

20 months agoMerge pull request #31963 from yuwata/journalctl-authenticate-cleanups
Yu Watanabe [Thu, 28 Mar 2024 02:19:21 +0000 (11:19 +0900)]
Merge pull request #31963 from yuwata/journalctl-authenticate-cleanups

journalctl-authenticate: several cleanups

20 months agotest-network: add test cases for PersistLeases=no
Yu Watanabe [Thu, 28 Mar 2024 02:07:35 +0000 (11:07 +0900)]
test-network: add test cases for PersistLeases=no

20 months agonetwork: make [DHCPServer] in networkd.conf work
Yu Watanabe [Thu, 28 Mar 2024 01:39:26 +0000 (10:39 +0900)]
network: make [DHCPServer] in networkd.conf work

Follow-up for a3ed665a29ea9355c78a2a6b3a032b9504499dd6.

Fixes https://github.com/systemd/systemd/pull/31977#discussion_r1542196572.

20 months agonetwork: fix typo
Yu Watanabe [Thu, 28 Mar 2024 01:37:35 +0000 (10:37 +0900)]
network: fix typo

Follow-up for a3ed665a29ea9355c78a2a6b3a032b9504499dd6.

20 months agoMerge pull request #31985 from DaanDeMeyer/mkosi
Yu Watanabe [Thu, 28 Mar 2024 01:21:34 +0000 (10:21 +0900)]
Merge pull request #31985 from DaanDeMeyer/mkosi

mkosi: Copy built packages to output directory

20 months agotimedate: fix typo
Yu Watanabe [Thu, 28 Mar 2024 00:54:48 +0000 (09:54 +0900)]
timedate: fix typo

Follow-up for 3a51e31be9f626cf772733cb289ed64739fab0e4.

20 months agojournalctl-authenticate: return earlier if we are not on a TTY
Yu Watanabe [Tue, 26 Mar 2024 14:42:21 +0000 (23:42 +0900)]
journalctl-authenticate: return earlier if we are not on a TTY

No functional change, just refactoring.

20 months agojournalctl-authenticate: use open_tmpfile_linkable() and link_tmpfile()
Yu Watanabe [Tue, 26 Mar 2024 14:39:43 +0000 (23:39 +0900)]
journalctl-authenticate: use open_tmpfile_linkable() and link_tmpfile()

This also
- use path_join(),
- rename variables to more descriptive names.

20 months agojournalctl-authenticate: drop unnecessary safe_close()
Yu Watanabe [Tue, 26 Mar 2024 13:40:43 +0000 (22:40 +0900)]
journalctl-authenticate: drop unnecessary safe_close()

Follow-up for 7560fffcd2531786b9c1ca657667a43e90331326.

Addresses https://github.com/systemd/systemd/pull/31879#discussion_r1539063239.

20 months agojournalctl-authenticate: use is_dir() and refuse symlink for /var/log/journal
Yu Watanabe [Mon, 25 Mar 2024 13:15:51 +0000 (22:15 +0900)]
journalctl-authenticate: use is_dir() and refuse symlink for /var/log/journal

I am not sure it is explicitly documented that /var/log/journal should
be a directory, rather than a symlink to a directory, but the current
code of journald seems not to support symlinked directory well. Let's
refuse that at least here and now.

20 months agoanalyze: fix plot with soft-reboot
Luca Boccassi [Wed, 27 Mar 2024 16:35:20 +0000 (16:35 +0000)]
analyze: fix plot with soft-reboot

Clamp times and start counting from when soft-reboot is started
to avoid creating a huge graph, like it's done for the user
instance.

20 months agotest: cleanup the test script a bit
Frantisek Sumsal [Wed, 27 Mar 2024 19:13:24 +0000 (20:13 +0100)]
test: cleanup the test script a bit

20 months agotest: check for /dev/loop-control when checking lodev availability
Frantisek Sumsal [Wed, 27 Mar 2024 18:35:30 +0000 (19:35 +0100)]
test: check for /dev/loop-control when checking lodev availability

losetup in util-linux 2.40 started reporting lost loop devices [0] and
it has an unfortunate side-effect where it reports lost devices even in
containers, which then makes the loop device check "falsely" pass [1].

Let's just check for /dev/loop-control explicitly to "work around" this.

[0] https://github.com/util-linux/util-linux/commit/a6ca0456cc6d704a786f6b66d8bb2d89ff18eba7
[1] https://github.com/util-linux/util-linux/issues/2824

20 months agotimedated: Respond on org.freedesktop.timedate1.SetNTP only when really finished
Michal Koutný [Tue, 20 Feb 2024 18:26:16 +0000 (19:26 +0100)]
timedated: Respond on org.freedesktop.timedate1.SetNTP only when really finished

The method returns prematurely (before jobs it triggers terminate). This
is externally visible because other methods may fail if jobs did not
finish.
Postpone the DBus method response until we collect all signals for
finished jobs.
systemd-timedated keeps track of in-flight DBus requests and answers
them all in unspecified order when jobs finish. The capacity of requests
in systemd-timedated is limited.

Fixes: #17739

20 months agomkosi: Copy built packages to output directory
Daan De Meyer [Wed, 27 Mar 2024 13:05:44 +0000 (14:05 +0100)]
mkosi: Copy built packages to output directory

This allows the built packages to be inspected if needed, or installed
on the host system for anyone who's daring enough to do so.

20 months agomkosi: Update to latest
Daan De Meyer [Wed, 27 Mar 2024 14:49:06 +0000 (15:49 +0100)]
mkosi: Update to latest

20 months agonetwork/dhcp-server: introduce PersistLeases= setting
Yu Watanabe [Fri, 15 Mar 2024 17:32:50 +0000 (02:32 +0900)]
network/dhcp-server: introduce PersistLeases= setting

Requested at https://github.com/systemd/systemd/pull/31772#issuecomment-2000053357.

20 months agojournalctl-show/util: add missing header
Antonio Alvarez Feijoo [Wed, 27 Mar 2024 07:45:19 +0000 (08:45 +0100)]
journalctl-show/util: add missing header

```
[1237/2836] Compiling C object journalctl.p/src_journal_journalctl-show.c.o
FAILED: journalctl.p/src_journal_journalctl-show.c.o
cc -Ijournalctl.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -Wno-missing-field-initializers -Wno-unused-parameter -Wno-nonnull-compare -Warray-bounds -Warray-bounds=2 -Wdate-time -Wendif-labels -Werror=format=2 -Werror=format-signedness -Werror=implicit-function-declaration -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=missing-declarations -Werror=missing-prototypes -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wzero-length-bounds -fdiagnostics-show-option -fno-common -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -Wno-unused-result -Werror=shadow -fno-strict-aliasing -fvisibility=hidden -fno-omit-frame-pointer -include config.h -pthread -MD -MQ journalctl.p/src_journal_journalctl-show.c.o -MF journalctl.p/src_journal_journalctl-show.c.o.d -o journalctl.p/src_journal_journalctl-show.c.o -c ../src/journal/journalctl-show.c
../src/journal/journalctl-show.c: In function ‘setup_event’:
../src/journal/journalctl-show.c:330:38: error: ‘STDOUT_FILENO’ undeclared (first use in this function)
  330 |         r = sd_event_add_io(e, NULL, STDOUT_FILENO, EPOLLHUP|EPOLLERR, NULL, INT_TO_PTR(-ECANCELED));
      |                                      ^~~~~~~~~~~~~
../src/journal/journalctl-show.c:330:38: note: each undeclared identifier is reported only once for each function it appears in
[1238/2836] Compiling C object journalctl.p/src_journal_journalctl-util.c.o
FAILED: journalctl.p/src_journal_journalctl-util.c.o
cc -Ijournalctl.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -Wno-missing-field-initializers -Wno-unused-parameter -Wno-nonnull-compare -Warray-bounds -Warray-bounds=2 -Wdate-time -Wendif-labels -Werror=format=2 -Werror=format-signedness -Werror=implicit-function-declaration -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=missing-declarations -Werror=missing-prototypes -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wzero-length-bounds -fdiagnostics-show-option -fno-common -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -Wno-unused-result -Werror=shadow -fno-strict-aliasing -fvisibility=hidden -fno-omit-frame-pointer -include config.h -pthread -MD -MQ journalctl.p/src_journal_journalctl-util.c.o -MF journalctl.p/src_journal_journalctl-util.c.o.d -o journalctl.p/src_journal_journalctl-util.c.o -c ../src/journal/journalctl-util.c
../src/journal/journalctl-util.c: In function ‘acquire_journal’:
../src/journal/journalctl-util.c:36:60: error: ‘STDIN_FILENO’ undeclared (first use in this function)
   36 |                 r = sd_journal_open_files_fd(&j, (int[]) { STDIN_FILENO }, 1, arg_journal_additional_open_flags);
      |                                                            ^~~~~~~~~~~~
../src/journal/journalctl-util.c:36:60: note: each undeclared identifier is reported only once for each function it appears in
```

Fixes ade2db83fe7fa5011490f94fbeb5cf9263f26514

20 months agosd-ndisc-router: introduce sd_ndisc_router_set_sender_address()
Yu Watanabe [Wed, 6 Mar 2024 03:28:51 +0000 (12:28 +0900)]
sd-ndisc-router: introduce sd_ndisc_router_set_sender_address()

Currently this is not used, but will be used later to modify the sender
address.

20 months agondisc-option: add HomeAgent option support
Yu Watanabe [Sat, 16 Mar 2024 06:52:18 +0000 (15:52 +0900)]
ndisc-option: add HomeAgent option support

Currently, these are not used, but will be used later in sd-radv.

20 months agoMerge pull request #31965 from yuwata/logs-show-cleanups
Luca Boccassi [Wed, 27 Mar 2024 13:09:56 +0000 (13:09 +0000)]
Merge pull request #31965 from yuwata/logs-show-cleanups

logs-show: several cleanups

20 months agoMerge pull request #31964 from yuwata/journalctl-filter-cleanups
Luca Boccassi [Wed, 27 Mar 2024 13:07:43 +0000 (13:07 +0000)]
Merge pull request #31964 from yuwata/journalctl-filter-cleanups

journalctl-filter: several cleanups

20 months agoMerge pull request #31954 from DaanDeMeyer/mkosi
Daan De Meyer [Wed, 27 Mar 2024 12:27:44 +0000 (13:27 +0100)]
Merge pull request #31954 from DaanDeMeyer/mkosi

mkosi: Re-enable OpenSUSE build

20 months agomkosi: Specify --without docs if needed for fedora/centos
Daan De Meyer [Wed, 27 Mar 2024 12:00:11 +0000 (13:00 +0100)]
mkosi: Specify --without docs if needed for fedora/centos

20 months agoUpdate pkg/fedora to latest
Daan De Meyer [Wed, 27 Mar 2024 11:58:17 +0000 (12:58 +0100)]
Update pkg/fedora to latest

20 months agomkosi: Merge base and system images
Daan De Meyer [Wed, 27 Mar 2024 10:07:52 +0000 (11:07 +0100)]
mkosi: Merge base and system images

The only reason to have these split up is to be able to build extension
images that use the base image as a base tree and install extra packages.
Until we have such a use case, let's merge the base and system images to
simplify things a bit.

We keep the mkosi.images/ directory to not cause too many conflicts with
the integration tests PR.

20 months agomkosi: Re-enable OpenSUSE build
Daan De Meyer [Tue, 26 Mar 2024 09:42:00 +0000 (10:42 +0100)]
mkosi: Re-enable OpenSUSE build

20 months agomkosi: Update to latest
Daan De Meyer [Tue, 26 Mar 2024 10:16:55 +0000 (11:16 +0100)]
mkosi: Update to latest

20 months agoMerge pull request #31980 from bluca/soft_reboot_timestamps
Luca Boccassi [Wed, 27 Mar 2024 10:30:12 +0000 (10:30 +0000)]
Merge pull request #31980 from bluca/soft_reboot_timestamps

soft-reboot: fix timestamps accounting for sd-analyze, add new timestamp, add new counter

20 months agobuild(deps): bump pkg/debian from `1932e19` to `44fe1d4`
dependabot[bot] [Wed, 27 Mar 2024 09:12:48 +0000 (09:12 +0000)]
build(deps): bump pkg/debian from `1932e19` to `44fe1d4`

Bumps pkg/debian from `1932e19` to `44fe1d4`.

---
updated-dependencies:
- dependency-name: pkg/debian
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
20 months agocore: add counter for soft-reboot iterations
Luca Boccassi [Wed, 27 Mar 2024 00:30:45 +0000 (00:30 +0000)]
core: add counter for soft-reboot iterations

Allow to query via D-Bus how many times the current booted system has
been soft rebooted

20 months agoanalyze: show only current times after soft-reboot
Luca Boccassi [Tue, 26 Mar 2024 22:32:04 +0000 (22:32 +0000)]
analyze: show only current times after soft-reboot

The firmware/loader/kernel times are no longer relevant for the startup
sequence on soft-reboot, so use only the userspace timestamps

20 months agocore: add SoftRebootStartTimestamp
Luca Boccassi [Tue, 26 Mar 2024 22:30:43 +0000 (22:30 +0000)]
core: add SoftRebootStartTimestamp

Will be useful to calculate how long it took to shut down the system before starting
in the new root

20 months agocore: do not serialize timestamps that are re-measured on soft-reboot
Luca Boccassi [Tue, 26 Mar 2024 22:28:58 +0000 (22:28 +0000)]
core: do not serialize timestamps that are re-measured on soft-reboot

Otherwise the de-serialization overwrites the timestamps taken after
soft-reboot (e.g.: userspace start/finish) and sd-analyze shows bogus
data

20 months agoMerge pull request #31789 from jsitnicki/socket-pass-fds-to-exec
Yu Watanabe [Wed, 27 Mar 2024 01:18:13 +0000 (10:18 +0900)]
Merge pull request #31789 from jsitnicki/socket-pass-fds-to-exec

Pass socket FDs to all ExecXYZ= commands in socket unit but ExecStartPre=

20 months agoresolved: always return the validated answers when validating
Ronan Pigott [Tue, 26 Mar 2024 07:33:19 +0000 (00:33 -0700)]
resolved: always return the validated answers when validating

We normally expect sd-resolved only to return the validated subset of a
validated response. In some cases we give up on validating, because we
have enough information already to conclude the answer is bogus.

Let's be sure to always reply with only the validated subset in these
cases too, so that we don't return bogus answers and confuse primitive
clients that won't see the SERVFAIL rcode.

20 months agoresolved: minor dnssec fixups
Ronan Pigott [Tue, 26 Mar 2024 18:00:44 +0000 (11:00 -0700)]
resolved: minor dnssec fixups

Fixes: ce5b9d5b3c24 ("resolved: request DS with DNSKEY")

20 months agoshared/logs-show: restore infinite loop avoidance for corrupted journals
Zbigniew Jędrzejewski-Szmek [Tue, 26 Mar 2024 17:46:23 +0000 (18:46 +0100)]
shared/logs-show: restore infinite loop avoidance for corrupted journals

Fixes a bug introduced in e44f06065bf20e8d0e4adacff61350ebd36f299e: it was
supposed to be a refactoring, but unfortunately FOREACH_ARRAY is implemented
using a for loop, so when the 'goto finish' was replaced by 'break', it only
broke the inner loop, leading to a infinite loop.

20 months agohome: fix typo
Yu Watanabe [Tue, 26 Mar 2024 19:07:49 +0000 (04:07 +0900)]
home: fix typo

Follow-up for 5ec87d577f92effe27a62e965e02a6f9a40f81cc.

20 months agotest: integration test for PassFileDescriptorsToExec= option
Jakub Sitnicki [Thu, 14 Mar 2024 10:20:50 +0000 (11:20 +0100)]
test: integration test for PassFileDescriptorsToExec= option

Check if socket file descriptors are passed to ExecXYZ= commands from the
socket unit depending on whether PassFileDescriptorsToExec= option is set.

20 months agosocket: pass socket FDs to all ExecXYZ= commands but ExecStartPre=
Jakub Sitnicki [Thu, 15 Feb 2024 17:02:50 +0000 (18:02 +0100)]
socket: pass socket FDs to all ExecXYZ= commands but ExecStartPre=

Today listen file descriptors created by socket unit don't get passed to
commands in Exec{Start,Stop}{Pre,Post}= socket options.

This prevents ExecXYZ= commands from accessing the created socket FDs to do
any kind of system setup which involves the socket but is not covered by
existing socket unit options.

One concrete example is to insert a socket FD into a BPF map capable of
holding socket references, such as BPF sockmap/sockhash [1] or
reuseport_sockarray [2]. Or, similarly, send the file descriptor with
SCM_RIGHTS to another process, which has access to a BPF map for storing
sockets.

To unblock this use case, pass ListenXYZ= file descriptors to ExecXYZ=
commands as listen FDs [4]. As an exception, ExecStartPre= command does not
inherit any file descriptors because it gets invoked before the listen FDs
are created.

This new behavior can potentially break existing configurations. Commands
invoked from ExecXYZ= might not expect to inherit file descriptors through
sd_listen_fds protocol.

To prevent breakage, add a new socket unit parameter,
PassFileDescriptorsToExec=, to control whether ExecXYZ= programs inherit
listen FDs.

[1] https://docs.kernel.org/bpf/map_sockmap.html
[2] https://lore.kernel.org/r/20180808075917.3009181-1-kafai@fb.com
[3] https://man.archlinux.org/man/socket.7#SO_INCOMING_CPU
[4] https://www.freedesktop.org/software/systemd/man/latest/sd_listen_fds.html

20 months agoMerge pull request #31951 from bluca/resolve_reload
Yu Watanabe [Tue, 26 Mar 2024 17:37:52 +0000 (02:37 +0900)]
Merge pull request #31951 from bluca/resolve_reload

resolved: support reloading configuration at runtime

20 months agoMerge pull request #31959 from YHNdnzj/execute-pass-fds
Yu Watanabe [Tue, 26 Mar 2024 17:37:23 +0000 (02:37 +0900)]
Merge pull request #31959 from YHNdnzj/execute-pass-fds

core/execute: check if EXEC_PASS_FDS is set if got exec_params.fds

20 months agoMerge pull request #31960 from YHNdnzj/capsule-followup
Yu Watanabe [Tue, 26 Mar 2024 17:34:43 +0000 (02:34 +0900)]
Merge pull request #31960 from YHNdnzj/capsule-followup

Some follow-ups for capsule

20 months agodissect: fix memory leak
Antonio Alvarez Feijoo [Tue, 26 Mar 2024 13:53:44 +0000 (14:53 +0100)]
dissect: fix memory leak

20 months agoefi: skip check-alignment-* tests if pefile is not installed
Antonio Alvarez Feijoo [Tue, 26 Mar 2024 15:08:57 +0000 (16:08 +0100)]
efi: skip check-alignment-* tests if pefile is not installed

Otherwise, when building with ukify disabled, no one else requires pefile, and
if it is not installed, those tests fail:

```
================================== 12/1212 ===================================
test:         systemd:efi / check-alignment-systemd-bootx64.efi
start time:   14:21:54
duration:     0.08s
result:       exit status 1
command:      /mnt/work/systemd/upstream-fork/main/tools/check-efi-alignment.py /mnt/work/systemd/upstream-fork/main/build/src/boot/efi/systemd-bootx64.efi
----------------------------------- stderr -----------------------------------
Traceback (most recent call last):
  File "/mnt/work/systemd/upstream-fork/main/tools/check-efi-alignment.py", line 7, in <module>
    import pefile
ModuleNotFoundError: No module named 'pefile'
==============================================================================

================================== 13/1212 ===================================
test:         systemd:efi / check-alignment-linuxx64.efi.stub
start time:   14:21:54
duration:     0.08s
result:       exit status 1
command:      /mnt/work/systemd/upstream-fork/main/tools/check-efi-alignment.py /mnt/work/systemd/upstream-fork/main/build/src/boot/efi/linuxx64.efi.stub
----------------------------------- stderr -----------------------------------
Traceback (most recent call last):
  File "/mnt/work/systemd/upstream-fork/main/tools/check-efi-alignment.py", line 7, in <module>
    import pefile
ModuleNotFoundError: No module named 'pefile'
==============================================================================

================================== 14/1212 ===================================
test:         systemd:efi / check-alignment-addonx64.efi.stub
start time:   14:21:54
duration:     0.07s
result:       exit status 1
command:      /mnt/work/systemd/upstream-fork/main/tools/check-efi-alignment.py /mnt/work/systemd/upstream-fork/main/build/src/boot/efi/addonx64.efi.stub
----------------------------------- stderr -----------------------------------
Traceback (most recent call last):
  File "/mnt/work/systemd/upstream-fork/main/tools/check-efi-alignment.py", line 7, in <module>
    import pefile
ModuleNotFoundError: No module named 'pefile'
==============================================================================
```

Follow-up for 7ff3b88396f440bff60328b4bff7627a34d45e4a

20 months agohwdb: fix Asus T300FA rotation matrix (#31973)
Luxiter [Tue, 26 Mar 2024 17:32:03 +0000 (18:32 +0100)]
hwdb: fix Asus T300FA rotation matrix (#31973)

Closes #31972.

20 months agologs-show: read the current boot ID if nothing specified for add_match_boot_id()
Yu Watanabe [Fri, 22 Mar 2024 08:40:37 +0000 (17:40 +0900)]
logs-show: read the current boot ID if nothing specified for add_match_boot_id()

No functional change, just refactoring.

20 months agosd-id128: move get_boot_id_for_machine() to id128-util.c
Yu Watanabe [Fri, 22 Mar 2024 08:21:01 +0000 (17:21 +0900)]
sd-id128: move get_boot_id_for_machine() to id128-util.c

And rename it to id128_get_boot_for_machine().

This also splits out id128_get_boot() from sd_id128_get_boot(), and
make id128_get_boot_for_machine() use it.

20 months agojournalctl-filter: several cleanups for add_matches()
Yu Watanabe [Thu, 21 Mar 2024 19:19:42 +0000 (04:19 +0900)]
journalctl-filter: several cleanups for add_matches()

- split it into small pieces to reduce indentation,
- return earlier if no filter specified,
- use journal_add_matchf() and journal_add_match_pair(),
  chase_and_stat(), is_symlink(), and sd_device_new_from_devname(),
- replace sd_device_get_devname() + stat() with sd_device_get_devnum(),
- refuse to install filter by path with --root, --image, or --machine
  at least now, as previously it has not worked anyway.

20 months agojournalctl-filter: add missing sd_journal_add_conjunction()
Yu Watanabe [Thu, 21 Mar 2024 18:09:35 +0000 (03:09 +0900)]
journalctl-filter: add missing sd_journal_add_conjunction()

Otherwise, if --facility= is specified with extra matches with '+',
the facility filter will not be applied to the specified filter after '+'.

20 months agojournalctl-filter: several trivial cleanups
Yu Watanabe [Thu, 21 Mar 2024 18:08:54 +0000 (03:08 +0900)]
journalctl-filter: several trivial cleanups

- declare iterator in loop,
- use journal_add_match_pair() and journal_add_matchf(),
- log failures in the caller.

20 months agojournalctl-filter: modernize add_units()
Yu Watanabe [Thu, 21 Mar 2024 17:47:21 +0000 (02:47 +0900)]
journalctl-filter: modernize add_units()

- add missing assertions,
- use set_ensure_consume() and strv_consume(),
- use string_hash_ops_free and _cleanup_set_free_,
- use strv_fnmatch_full(),
- replace unused counter with a boolean flag,
- return earlier if no unit filtering is requested.

20 months agoMerge pull request #31879 from yuwata/journalctl-split
Yu Watanabe [Tue, 26 Mar 2024 14:45:20 +0000 (23:45 +0900)]
Merge pull request #31879 from yuwata/journalctl-split

journalctl: split journalctl.c into small pieces

20 months agondisc-option: sort options in sent message
Yu Watanabe [Sun, 17 Mar 2024 06:33:32 +0000 (15:33 +0900)]
ndisc-option: sort options in sent message

To make the sent message reproducible.

20 months agoMerge pull request #31943 from yuwata/sd-ndisc-option-getter-remover
Luca Boccassi [Tue, 26 Mar 2024 13:55:46 +0000 (13:55 +0000)]
Merge pull request #31943 from yuwata/sd-ndisc-option-getter-remover

sd-ndisc: introduce option getter and remover

20 months agosd-ndisc-protocol: list up all known options
Yu Watanabe [Sat, 16 Mar 2024 06:25:47 +0000 (15:25 +0900)]
sd-ndisc-protocol: list up all known options

See below for more details:
https://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml#icmpv6-parameters-5

20 months agobus-util: dedup bus_set_address_capsule
Mike Yuan [Tue, 26 Mar 2024 12:59:32 +0000 (20:59 +0800)]
bus-util: dedup bus_set_address_capsule

Follow-up for ad963c3f5680796ccd094b81f35ff7aa20b57247

20 months agoresolved: support reloading configuration at runtime
Luca Boccassi [Fri, 8 Mar 2024 23:02:19 +0000 (23:02 +0000)]
resolved: support reloading configuration at runtime

Drop connections and caches and reload config from files, to allow
for low-interruptions updates, and hook up to the usual SIGHUP and
ExecReload=. Mark servers and services configured directly via D-Bus
so that they can be kept around, and only the configuration file
settings are dropped and reloaded.

Fixes https://github.com/systemd/systemd/issues/17503
Fixes https://github.com/systemd/systemd/issues/20604

20 months agojournalctl-show: split out seek_journal()
Yu Watanabe [Thu, 21 Mar 2024 10:18:02 +0000 (19:18 +0900)]
journalctl-show: split out seek_journal()

No functional change, just refactoring.

20 months agojournalctl: split journalctl.c into small pieces
Yu Watanabe [Wed, 20 Mar 2024 18:50:09 +0000 (03:50 +0900)]
journalctl: split journalctl.c into small pieces

And introduces per-action functions.
No functional change, just refactoring.

20 months agojournalctl: use correct type for flags
Yu Watanabe [Tue, 19 Mar 2024 10:04:10 +0000 (19:04 +0900)]
journalctl: use correct type for flags

This also moves its declaration, as it is not changed in the loop.

20 months agojournalctl: merge three if blocks for seeking to the initial position
Yu Watanabe [Tue, 19 Mar 2024 09:54:24 +0000 (18:54 +0900)]
journalctl: merge three if blocks for seeking to the initial position

No functional change, just refactoring.

20 months agosystemctl,busctl: sort includes
Mike Yuan [Tue, 26 Mar 2024 12:48:46 +0000 (20:48 +0800)]
systemctl,busctl: sort includes

Follow-up for 56cb74c3cd1358d7d0b3f613feaf2eeab601a6bd
and 00431b2b66cb59540deda4ea018170a289673585

20 months agounits: sort lists in meson.build
Mike Yuan [Tue, 26 Mar 2024 12:36:28 +0000 (20:36 +0800)]
units: sort lists in meson.build

20 months agotest: use /run/ instead of /etc/ in TEST-75-RESOLVE
Luca Boccassi [Sat, 23 Mar 2024 01:32:44 +0000 (01:32 +0000)]
test: use /run/ instead of /etc/ in TEST-75-RESOLVE

20 months agodaemon-util: introduce notify_reloading helper
Mike Yuan [Tue, 26 Mar 2024 09:40:01 +0000 (17:40 +0800)]
daemon-util: introduce notify_reloading helper

Prompted by #31951

20 months agoMerge pull request #29721 from poettering/systemd-project
Zbigniew Jędrzejewski-Szmek [Tue, 26 Mar 2024 12:19:33 +0000 (13:19 +0100)]
Merge pull request #29721 from poettering/systemd-project

New capsule@.service feature

20 months agocore/execute: check if EXEC_PASS_FDS is set if got exec_params.fds
Mike Yuan [Tue, 26 Mar 2024 10:57:08 +0000 (18:57 +0800)]
core/execute: check if EXEC_PASS_FDS is set if got exec_params.fds

Prompted by #31789 (specifically
https://github.com/systemd/systemd/pull/31789#discussion_r1525267612)