Lennart Poettering
9bb64f1b8d
pidref: make PIDREF_NULL const
...
That way compiler can put it in an immutable section
2023-10-19 18:59:51 +01:00
Luca Boccassi
759cca0348
Merge pull request #29629 from bluca/mount_tunnel_pidref
...
mount tunnel: use PidRef
2023-10-19 18:59:22 +01:00
Luca Boccassi
6fbd1b0457
Merge pull request #29623 from YHNdnzj/core-followup
...
Follow-ups for recent changes to core/
2023-10-19 18:04:40 +01:00
Frantisek Sumsal
e98f7f9122
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.
2023-10-19 18:03:57 +01:00
Zbigniew Jędrzejewski-Szmek
af189d7b50
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 a0043bfa51 .
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 .
2023-10-19 18:03:21 +01:00
Frantisek Sumsal
a2dd592002
test: unify checking for user xattrs support in cgroupfs
...
Also, run the coredump forwarding test only if user xattrs are
supported.
2023-10-19 18:01:07 +01:00
Zbigniew Jędrzejewski-Szmek
725e646854
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
2023-10-19 17:52:44 +02:00
Luca Boccassi
8c08523736
Update TODO
2023-10-19 16:31:05 +01:00
Luca Boccassi
5f48198af8
mount tunnel: use PidRef
2023-10-19 16:31:05 +01:00
Mike Yuan
bca0805311
core/service: check error first and log about errno
...
Follow-up for becdfcb9f1
2023-10-19 21:37:39 +08:00
Mike Yuan
f65a40fb0b
cgroup-util: use RET_GATHER more, return first error
2023-10-19 21:37:33 +08:00
Mike Yuan
dbc0342e61
core/exec-invoke: use correct exit status
...
These calls can fail not only due to OOM.
2023-10-19 21:37:33 +08:00
Mike Yuan
bbe92ea5cc
core/namespace: merge if blocks
2023-10-19 21:37:33 +08:00
Luca Boccassi
9dc6a6af28
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
2023-10-19 14:24:55 +01:00
Luca Boccassi
41204a6d74
Merge pull request #29617 from keszybz/efi-no-xmalloc0
...
efi: drop duplicate initialization to 0
2023-10-19 14:23:54 +01:00
Yu Watanabe
be3b6b6fe5
cgroup-util: drop dead code block
...
Follow-up for 4d1b2df199 .
Fixes CID#1522888.
2023-10-19 20:24:54 +08:00
Luca Boccassi
1ca8cc9fb6
Merge pull request #29595 from YHNdnzj/systemctl-failed-system
...
systemctl: is-failed: check if system is degraded when no unit given
2023-10-19 12:07:37 +01:00
Zbigniew Jędrzejewski-Szmek
6e98ddf825
efi: drop unused xmalloc0()
...
Keeping this separate to make it easy to revert if it's ever needed again.
2023-10-19 12:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
586f19976a
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.
2023-10-19 12:24:53 +02:00
Arthur Shau
1bd0b9c053
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.
2023-10-19 11:52:09 +02:00
Frantisek Sumsal
4820c9d417
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
2023-10-19 10:05:20 +01:00
Luca Boccassi
47174dc054
Merge pull request #29611 from mrc0mmand/execute-serialize-fuzz
...
test: add a fuzzer for exec_{serialize,deserialize}_invocation()
2023-10-18 23:33:00 +01:00
Frantisek Sumsal
892eb4d795
core: don't assert when serializing malformed state
2023-10-18 22:44:16 +02:00
Frantisek Sumsal
81c4be64da
test: add a fuzzer for exec_{serialize,deserialize}_invocation()
2023-10-18 22:44:16 +02:00
Mike Yuan
2ee346160c
systemctl: is-failed: check if system is degraded when no unit given
...
Closes #3335
2023-10-19 00:12:28 +08:00
Mike Yuan
def1e20a18
systemctl: minor modernization
2023-10-19 00:12:27 +08:00
Lennart Poettering
81c1c387fe
Merge pull request #29594 from poettering/cgroup-rename-ret-params
...
more pidfdification
2023-10-18 17:25:44 +02:00
Frantisek Sumsal
7e9c7d6f5b
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",...
2023-10-18 16:08:44 +01:00
Lennart Poettering
06044356de
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.
2023-10-18 16:07:41 +01:00
Luca Boccassi
668d60627e
Merge pull request #29583 from poettering/deserialize-fd-many
...
add serialize_fd_many() + deserialize_fd_many() helpers
2023-10-18 16:06:22 +01:00
Lennart Poettering
1158b06b47
update TODO
2023-10-18 14:49:40 +02:00
Lennart Poettering
d0547385d9
test-cgroup: make test case a bit more robust towards previous aborted runs
2023-10-18 14:49:40 +02:00
Lennart Poettering
2d79017564
killall: port killing spree loop over to PidRef
2023-10-18 14:49:40 +02:00
Lennart Poettering
957f84e950
test: port tests over to new /proc/ enumeration API
2023-10-18 14:49:40 +02:00
Lennart Poettering
eefb7d22ce
process-util: add API for enumerating processes in /proc/ and pinning them via PidRef
2023-10-18 14:49:40 +02:00
Lennart Poettering
4d9f092b5e
process-util: add pidref_is_unwaited() and make pid_is_unwaited() return errors
2023-10-18 14:49:40 +02:00
Lennart Poettering
6774be4206
process-util: add pidref_is_my_child()
2023-10-18 14:49:40 +02:00
Lennart Poettering
becdfcb9f1
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.
2023-10-18 14:40:25 +02:00
Lennart Poettering
8b51341545
process-util: add pidref_get_uid() and rename get_process_uid() → pidref_get_uid()
2023-10-18 14:39:33 +02:00
Lennart Poettering
4d1b2df199
core: port unit/process kill logic to pidref
2023-10-18 14:39:33 +02:00
Lennart Poettering
a7a877697f
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)
2023-10-18 14:39:33 +02:00
Lennart Poettering
d7d748548b
process-util: add pidref_get_comm() and rename get_process_comm() to pid_get_comm()
2023-10-18 14:39:33 +02:00
Lennart Poettering
d57d521cae
dbus-unit: make sure GetProcesses() D-Bus call internally uses pidfd
...
This way we can be sure to provide an atomic view of the process tree of
a unit.
2023-10-18 14:39:33 +02:00
Lennart Poettering
fc87713bed
process-util: add pidref_is_kernel_thread()
2023-10-18 14:39:33 +02:00
Lennart Poettering
a034620f1a
process-util: add pidref_get_cmdline()
2023-10-18 14:39:33 +02:00
Lennart Poettering
6f25a110ad
cgroup-show: use size_t for array sizes
2023-10-18 14:39:33 +02:00
Lennart Poettering
3d7ba61a7b
pidref: we never have to verify PID 1
...
The process exists as long as the kernel/userns exists at all, hence we
don't have to verify a pidfd to it.
2023-10-18 14:39:33 +02:00
Lennart Poettering
f2a2e60be6
cgroup-util: make cg_pidref_get_path() PidRef parameter const
2023-10-18 14:39:33 +02:00
Lennart Poettering
44c55e5a3f
pidref: make signal sending calls take const PidRef
2023-10-18 14:38:07 +02:00
Lennart Poettering
cf45db5598
fd-util: use close_many() where appropriate
2023-10-18 14:03:47 +02:00