Commit Graph
72187 Commits
Author SHA1 Message Date
Mike Yuan a2124b35e9 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.
2024-03-28 17:19:35 +08:00
Mike Yuan b786128322 sleep: make write_mode take a path
Similar to the previous commit, preparation
for adding support for /sys/power/mem_sleep.
2024-03-28 17:16:25 +08:00
Mike Yuan b0e3b85a7c sleep-config: make sleep_mode_supported take a path
Preparation for later commits.
2024-03-28 17:16:25 +08:00
Mike Yuan f8c700791e string-util: modernize string_contains_word_strv a bit
Also correct the comment on flags.
2024-03-28 17:16:25 +08:00
Mike Yuan a6fe020ab8 sleep-config: fix potential memory leak
Follow-up for 77bd39385e
2024-03-28 17:16:24 +08:00
Mike Yuan 0a3fd5ce43 man/systemd-sleep: reorder options 2024-03-28 17:16:24 +08:00
Mike Yuan 792dd6f46c sleep-config: make sleep_operation_is_hibernation uppercase 2024-03-28 17:16:21 +08:00
Adrian Vovk 1eba24dac4 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.
2024-03-28 13:35:37 +09:00
Luca Boccassi ed35851693 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.
2024-03-28 11:19:46 +09:00
Yu Watanabe 2a4fb037cb Merge pull request #31989 from mrc0mmand/test-loop-dev-check
test: check for /dev/loop-control when checking lodev availability
2024-03-28 11:19:32 +09:00
Yu Watanabe 74158eec0e Merge pull request #31963 from yuwata/journalctl-authenticate-cleanups
journalctl-authenticate: several cleanups
2024-03-28 11:19:21 +09:00
Yu Watanabe 5e4aad5e96 Merge pull request #31985 from DaanDeMeyer/mkosi
mkosi: Copy built packages to output directory
2024-03-28 10:21:34 +09:00
Yu Watanabe a128119a1d timedate: fix typo
Follow-up for 3a51e31be9.
2024-03-28 09:55:11 +09:00
Yu Watanabe 66a0fdcaa5 journalctl-authenticate: return earlier if we are not on a TTY
No functional change, just refactoring.
2024-03-28 09:40:34 +09:00
Yu Watanabe ef277c961f journalctl-authenticate: use open_tmpfile_linkable() and link_tmpfile()
This also
- use path_join(),
- rename variables to more descriptive names.
2024-03-28 09:38:10 +09:00
Yu Watanabe 2dac05e62b journalctl-authenticate: drop unnecessary safe_close()
Follow-up for 7560fffcd2.

Addresses https://github.com/systemd/systemd/pull/31879#discussion_r1539063239.
2024-03-28 09:36:29 +09:00
Yu Watanabe 4c56862170 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.
2024-03-28 09:36:29 +09:00
Luca Boccassi e6bd341e7d 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.
2024-03-27 22:25:45 +00:00
Frantisek Sumsal c75ee69e59 test: cleanup the test script a bit 2024-03-27 20:15:02 +01:00
Frantisek Sumsal 0348b500ef 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
2024-03-27 19:35:30 +01:00
Michal Koutný 3a51e31be9 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
2024-03-27 17:28:24 +00:00
Daan De Meyer 5524d2838c 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.
2024-03-27 16:14:17 +01:00
Daan De Meyer e11fe427f8 mkosi: Update to latest 2024-03-27 16:14:15 +01:00
Yu Watanabe a3ed665a29 network/dhcp-server: introduce PersistLeases= setting
Requested at https://github.com/systemd/systemd/pull/31772#issuecomment-2000053357.
2024-03-27 13:21:15 +00:00
Antonio Alvarez Feijoo f824cd660a 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 ade2db83fe
2024-03-27 13:14:46 +00:00
Yu Watanabe 95d3570b47 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.
2024-03-27 13:13:12 +00:00
Yu Watanabe 9f3587ae44 ndisc-option: add HomeAgent option support
Currently, these are not used, but will be used later in sd-radv.
2024-03-27 13:12:30 +00:00
Luca Boccassi 5e8adf9f50 Merge pull request #31965 from yuwata/logs-show-cleanups
logs-show: several cleanups
2024-03-27 13:09:56 +00:00
Luca Boccassi c3c5be4836 Merge pull request #31964 from yuwata/journalctl-filter-cleanups
journalctl-filter: several cleanups
2024-03-27 13:07:43 +00:00
Daan De Meyer a22236b471 Merge pull request #31954 from DaanDeMeyer/mkosi
mkosi: Re-enable OpenSUSE build
2024-03-27 13:27:44 +01:00
Daan De Meyer 0a6bf709dd mkosi: Specify --without docs if needed for fedora/centos 2024-03-27 13:00:11 +01:00
Daan De Meyer afc6ecd9cb Update pkg/fedora to latest 2024-03-27 12:58:17 +01:00
Daan De Meyer 6327988d65 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.
2024-03-27 12:20:50 +01:00
Daan De Meyer c2720fa55c mkosi: Re-enable OpenSUSE build 2024-03-27 12:20:50 +01:00
Daan De Meyer b2b3b4ed84 mkosi: Update to latest 2024-03-27 12:20:50 +01:00
Luca Boccassi 2682552698 Merge pull request #31980 from bluca/soft_reboot_timestamps
soft-reboot: fix timestamps accounting for sd-analyze, add new timestamp, add new counter
2024-03-27 10:30:12 +00:00
dependabot[bot] a0ae04b611 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>
2024-03-27 10:48:55 +01:00
Luca Boccassi 66f35161f6 core: add counter for soft-reboot iterations
Allow to query via D-Bus how many times the current booted system has
been soft rebooted
2024-03-27 01:27:35 +00:00
Luca Boccassi 7addfba9c4 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
2024-03-27 01:27:34 +00:00
Luca Boccassi 54f86b86ba core: add SoftRebootStartTimestamp
Will be useful to calculate how long it took to shut down the system before starting
in the new root
2024-03-27 01:25:49 +00:00
Luca Boccassi 375d091f71 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
2024-03-27 01:25:49 +00:00
Yu Watanabe 93998559f8 Merge pull request #31789 from jsitnicki/socket-pass-fds-to-exec
Pass socket FDs to all ExecXYZ= commands in socket unit but ExecStartPre=
2024-03-27 10:18:13 +09:00
Ronan Pigott 0dfea62ee3 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.
2024-03-27 10:17:15 +09:00
Ronan Pigott 4001710365 resolved: minor dnssec fixups
Fixes: ce5b9d5b3c ("resolved: request DS with DNSKEY")
2024-03-27 10:16:38 +09:00
Zbigniew Jędrzejewski-Szmek 1e8c0c671e shared/logs-show: restore infinite loop avoidance for corrupted journals
Fixes a bug introduced in e44f06065b: 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.
2024-03-27 10:16:16 +09:00
Yu Watanabe 193134de54 home: fix typo
Follow-up for 5ec87d577f.
2024-03-27 04:07:51 +09:00
Jakub Sitnicki d1813ba436 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.
2024-03-27 01:41:26 +08:00
Jakub Sitnicki 97df75d7bd 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
2024-03-27 01:41:26 +08:00
Yu Watanabe d30d0b04ae Merge pull request #31951 from bluca/resolve_reload
resolved: support reloading configuration at runtime
2024-03-27 02:37:52 +09:00
Yu Watanabe 18640f8211 Merge pull request #31959 from YHNdnzj/execute-pass-fds
core/execute: check if EXEC_PASS_FDS is set if got exec_params.fds
2024-03-27 02:37:23 +09:00