Commit Graph

72344 Commits

Author SHA1 Message Date
Mike Yuan
b7e4e152cf core: use log_unit_debug in *_set_state 2024-04-07 10:20:39 +01:00
Luca Boccassi
9dd174dc23 run: query for SoftRebootsCount only for system scope runs
Only the system manager records soft reboots, and the user session is
restarted anyway so it doesn't suffer from the ID clash issue

Follow-up for ed35851693
2024-04-07 10:20:04 +01:00
Frantisek Sumsal
b3a8264831 test: improve debug-ability of test-execute
Since e56a8790a0 debugging test-execute fails has been a royal PITA, since
we ditch all potentially useful output from the test units (that, for
the most part, run `sh -x ...`). Let's improve the situation a bit by
setting EXEC_OUTPUT_NULL only when running the single test case that
needs it, and inheriting stdout otherwise.

For example, with a purposefully introduced error we get this output
with this patch:
exec-personality-x86-64.service: About to execute: sh -x -c "c=\$\$(uname -m); test \"\$\$c\" = \"foo_bar\""
Serializing sd-executor-state to memfd.
...
        Personality: x86-64
        LockPersonality: no
        SystemCallErrorNumber: kill
++ uname -m
+ c=x86_64
+ test x86_64 = foo_bar
Received SIGCHLD from PID 1520588 (sh).
Child 1520588 (sh) died (code=exited, status=1/FAILURE)
exec-personality-x86-64.service: Child 1520588 belongs to exec-personality-x86-64.service.
exec-personality-x86-64.service: Main process exited, code=exited, status=1/FAILURE
exec-personality-x86-64.service: Failed with result 'exit-code'.
...
        Exit Status: 1
src/test/test-execute.c:456:test_exec_personality: exec-personality-x86-64.service: can_unshare=yes: exit status 1, expected 0
(test-execute-root) terminated by signal ABRT.
Assertion 'r >= 0' failed at src/test/test-execute.c:1433, function prepare_ns(). Aborting.
Aborted

But without it, we'd miss the most important part:
exec-personality-x86-64.service: About to execute: sh -x -c "c=\$\$(uname -m); test \"\$\$c\" = \"foo_bar\""
Serializing sd-executor-state to memfd.
...
        Personality: x86-64
        LockPersonality: no
        SystemCallErrorNumber: kill
Received SIGCHLD from PID 1521365 (sh).
Child 1521365 (sh) died (code=exited, status=1/FAILURE)
exec-personality-x86-64.service: Child 1521365 belongs to exec-personality-x86-64.service.
exec-personality-x86-64.service: Main process exited, code=exited, status=1/FAILURE
exec-personality-x86-64.service: Failed with result 'exit-code'.
...
        Exit Status: 1
src/test/test-execute.c:456:test_exec_personality: exec-personality-x86-64.service: can_unshare=yes: exit status 1, expected 0
(test-execute-root) terminated by signal ABRT.
Assertion 'r >= 0' failed at src/test/test-execute.c:1433, function prepare_ns(). Aborting.
Aborted
2024-04-06 13:24:36 +01:00
Luca Boccassi
3abc3671f5 Merge pull request #31131 from poettering/dlopen-kmod
turn libkmod into a dlopen() dependency, too
2024-04-06 13:19:27 +01:00
Vito Caputo
a7d8cacce0 man: fix typo s/veno/reno/ 2024-04-06 07:12:33 +02:00
Luca Boccassi
b9c5a0d2cc Merge pull request #32115 from YHNdnzj/service-main-pid-take
core/service: a few improvements for main pid handling
2024-04-05 23:53:13 +01:00
Luca Boccassi
e92042269e Merge pull request #32123 from mrc0mmand/assorted-tweaks
A couple of assorted tweaks
2024-04-05 22:22:06 +01:00
Luca Boccassi
1281115957 Merge pull request #32125 from YHNdnzj/post-merge-stuff
Trivial post merge stuff
2024-04-05 22:18:31 +01:00
Mike Yuan
120be68b8d core/service: add a FIXME to use pidfd to monitor foreign processes 2024-04-06 02:22:19 +08:00
Mike Yuan
a3980843ef core/service: complain louder if new MAINPID= is refused 2024-04-06 02:22:19 +08:00
Mike Yuan
c603f523d0 core/service: make service_set_main_pidref consume pidref
Currently, the memory management of service_set_main_pidref
is a bit odd. Normally we either invalidate the original
resource on caller's side after the call succeeds, or
just pass the ownership wholly. But service_set_main_pidref
take a pointer, and calls pidref_done() internally.

Let's just make it consume the passed pidref. This is more
straightforward.
2024-04-06 02:22:19 +08:00
Mike Yuan
36b21fac8f sleep: rename SleepMemMode= to MemorySleepMode=
Addresses https://github.com/systemd/systemd/pull/31986#discussion_r1554053623
2024-04-06 02:16:54 +08:00
Mike Yuan
99f3b67f3f os-util: use ENDSWITH_SET where appropriate
Addresses https://github.com/systemd/systemd/pull/31435#discussion_r1553969156

Co-authored-by: Lennart Poettering <lennart@poettering.net>
2024-04-06 02:16:53 +08:00
Frantisek Sumsal
1d07188b15 base-filesystem: check for __s390x__ first
On s390x both __s390__ and __s390x__ are defined, and with the original
order we'd go through the __s390__ branch and emit a warning:

[169/2118] Compiling C object src/shared/libsystemd-shared-256.a.p/base-filesystem.c.o
../src/shared/base-filesystem.c:136:11: note: ‘#pragma message: Please add an entry above specifying whether your architecture uses /lib64/, /lib32/, or no such links.’
  136 | #  pragma message "Please add an entry above specifying whether your architecture uses /lib64/, /lib32/, or no such links."
      |           ^~~~~~~
2024-04-05 19:44:44 +02:00
Frantisek Sumsal
3ebd598624 test: account for build dir being under one of the tmpfs-ed directories
If we're running test-execute from the build directory which is under
one of the tmpfs-ed directories (i.e. /root or /tmp), test-execute might
behave strangely, since in that case manager_new() pins the system
systemd-executor binary instead of the build dir one, which may lead to
a very confusing test fails (if there's enough difference between the
system and built sd-executor binary). Let's account for that and
bind-mount the build dir under the tmpfs-ed directory if necessary.
2024-04-05 19:44:41 +02:00
Frantisek Sumsal
a9805f8ca9 test: make test-fd-util more lenient when using fd_move_above_stdio()
On s390x this test fails when the SUT uses the z90crypt kernel module,
as it's an another FD the test doesn't account for:

/* test_rearrange_stdio */
Successfully forked off 'rearrange' as PID 57293.
test_rearrange_stdio: r=0
/proc/57293/fd:
total 0
lrwx------. 1 root root 64 Apr  5 06:18 0 -> /dev/pts/0
lrwx------. 1 root root 64 Apr  5 06:18 1 -> /dev/pts/0
lrwx------. 1 root root 64 Apr  5 06:18 2 -> /dev/pts/0
lrwx------. 1 root root 64 Apr  5 06:18 3 -> /dev/z90crypt
rearrange terminated by signal ABRT.

Debugging this was pain, since the child process didn't log anything
once we closed stdout/stderr (for obvious reasons). Let's fix both
issues by switching logging to kmsg once we close stdin/stdout/stderr,
and also by making the test work fine when there are some extra FDs in
the child's environment.
2024-04-05 19:40:23 +02:00
Zbigniew Jędrzejewski-Szmek
c1e7f938ca Merge pull request #31435 from bluca/portable_fix_versioned
portable: assorted bug fixes
2024-04-05 17:04:17 +02:00
Antonio Alvarez Feijoo
1eeae735ad sd-journal: fix check in journal_file_verify_header()
Fixes 6ea51363c8
2024-04-05 13:03:19 +02:00
Frantisek Sumsal
e55db9e792 log: fix comment 2024-04-05 12:14:18 +02:00
Daan De Meyer
aaa872a713 core: Serialize both pid and pidfd to keep downgrades working
Currently, when downgrading from a version with pidfd support to a
version without pidfd support, all information about running processes
is lost as the newer systemd will serialized pidfds which are not recognized
by the older systemd when deserializing.

To improve the situation, let's serialize both the pid and the pidfd.
This is safe because existing versions will either replace the first
deserialized pidref with the second one or discard the second one in
favor of the first one depending on the unit and field. Older versions
that don't support pidfd's will silently discard any fields that contain
a pidfd as those will try to parse the field as a pid and since a pidfd
field will start with '@', those versions will debug error log and ignore
the value.

To make sure we reuse the existing pidfd as much as possible, the pidfd
is serialized first. Both for scopes and service main pids, if the same
pid is seen multiple times, the first pidref is kept. So by serializing
the pidfd first we make sure the original pidfd is used instead of the
new one which is opened when deserializing the first pid field.

For other control units, older versions with pidfd support will discard
the first pidfd and replace it with a new pidfd from the second pid field.
This is a slight regression on downgrades, but we make sure it doesn't
happen for future versions (and older versions when this commit is
backported) by modifying the logic to only use the first successfully
deserialized pidref so that the raw pid without pidfd is discarded instead
of it replacing the existing pidfd.
2024-04-05 12:56:26 +09:00
Luca Boccassi
1ce28e5a24 meson: set -fno-ssa-phiopt when building bpf with gcc
There are bugs in the kernel verifier that cause legitimate code
to be rejected, disabling this optimization makes bpf programs
built with a new enough gcc work again.

Fixes https://github.com/systemd/systemd/issues/31888
2024-04-05 12:55:53 +09:00
Kirk
57cd604fde hwdb: fix missing colon (#32108)
Missing colon prevents this from working correctly on the Chuwi UBook X and UBook X Pro.
2024-04-05 10:18:59 +09:00
Luca Boccassi
360f486cc6 Merge pull request #32085 from yuwata/udev-check-processing
udev: check ID_PROCESSING udev property more
2024-04-04 23:46:26 +01:00
Yu Watanabe
36ca167220 Merge pull request #31373 from yuwata/network-neighbor-advertisement
network: add basic support of neighbor advertisement
2024-04-05 05:54:12 +09:00
Yu Watanabe
e17e438ede udevadm-test: also show security labels if specified
Follow-up for 03b6879f4d.
2024-04-04 21:30:26 +01:00