Commit Graph

84397 Commits

Author SHA1 Message Date
Daan De Meyer
10e82fde7b parse-util: Add parse_capability_set()
Let's extract common capability parsing code into a generic function
parse_capability_set() with a comprehensive set of unit tests.

We also replace usages of UINT64_MAX with CAP_MASK_UNSET where
applicable and replace the default value of CapabilityBoundingSet
with CAP_MASK_ALL which more clearly identifies that it is initialized
to all capabilities.

AI (copilot) was used to extract the generic function and write the
unit tests, with manual review and fixing afterwards to make sure
everything was correct.
2025-11-02 04:47:21 +09:00
Daan De Meyer
1a3b3c57c6 test: migrate test-load-fragment to use ASSERT_* macros
Replace all assert_se() calls with appropriate ASSERT_* macros from tests.h:
- assert_se(r >= 0) → ASSERT_OK(r)
- assert_se(r == 0) → ASSERT_OK_ZERO(r)
- assert_se(r == -ERR) → ASSERT_ERROR(r, ERR)
- assert_se(expr == value) → ASSERT_EQ(expr, value)
- assert_se(str1, str2) → ASSERT_STREQ(str1, str2)
- assert_se(ptr) → ASSERT_NOT_NULL(ptr)
- assert_se(!ptr) → ASSERT_NULL(ptr)
- assert_se(expr) → ASSERT_TRUE(expr)
- assert_se(!expr) → ASSERT_FALSE(expr)

Also added unsigned suffixes (U) to numeric literals in comparisons with
unsigned types (size_t, rlim_t) to eliminate signedness warnings.

This code was written with the help of AI.
2025-11-02 04:47:21 +09:00
Luca Boccassi
10fc43e504 test: add test case for verity deferred removal without sharing
I recently found out (the hard way) that on an older version
there was a bug when the verity sharing is disabled: the
deferred close flag was not set correctly, so verity devices
were leaked.

This is not an issue in main currently, but add a test case
to cover it just in case, to avoid future regressions.
2025-11-02 04:43:06 +09:00
Lennart Poettering
7517e41a49 resolvectl: do not use strjoina() on user provided strings 2025-11-02 04:41:07 +09:00
dependabot[bot]
25a507d290 build(deps): bump softprops/action-gh-release from 2.2.2 to 2.4.1
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.2.2 to 2.4.1.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](da05d55257...6da8fa9354)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: 2.4.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 18:12:26 +09:00
dependabot[bot]
61f7ec3fc5 build(deps): bump redhat-plumbers-in-action/advanced-issue-labeler
Bumps [redhat-plumbers-in-action/advanced-issue-labeler](https://github.com/redhat-plumbers-in-action/advanced-issue-labeler) from 3.2.2 to 3.2.3.
- [Release notes](https://github.com/redhat-plumbers-in-action/advanced-issue-labeler/releases)
- [Commits](0db433d412...e38e6809c5)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/advanced-issue-labeler
  dependency-version: 3.2.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 18:12:00 +09:00
Yu Watanabe
7829c9cc48 discover-image: introduce bus_property_get_image_is_read_only() with BUS_DEFINE_PROPERTY_GET() macro
This also makes image_is_read_only() return bool.

Follow-up for ee327e086e.
2025-11-01 18:11:18 +09:00
Yu Watanabe
cbd8a12bce Several cleanups around strv_extendf() (#39508) 2025-11-01 18:10:42 +09:00
Daan De Meyer
dd15dd1a58 core: Add RootDirectoryFileDescriptor= (#39480)
RootDirectory= but via a open_tree() file descriptor. This allows
setting up the execution environment for a service by the client in a
mount namespace and then starting a transient unit in that execution
environment using the new property.

We also add --root-directory= and --same-root-dir= to systemd-run to
have it run services within the given root directory. As systemd-run
might be invoked from a different mount namespace than what systemd is
running in, systemd-run opens the given path with open_tree() and then
sends it to systemd using the new RootDirectoryFileDescriptor= property.
2025-10-31 22:30:46 +01:00
Yu Watanabe
23fbaa463a analyze: add missing help entry
Follow-up for 0fe29d0672.
2025-10-31 21:03:16 +00:00
Mike Yuan
f8574e252a core/exec-invoke: correct fd array size for collect_open_file_fds()
Follow-up for f70346fb87
2025-10-31 17:32:34 +00:00
Florian
f2875c73a2 man: fix outdated link to freedesktop.org documentation (#39511)
Freedesktop changed their link format.
2025-11-01 02:03:43 +09:00
Yu Watanabe
9011b1cfc0 reread-partition-table: take exclusive lock when requested
Before aa47d8ade1, we took an exclusive lock
for the whole block device, but with the commit, a shared lock is taken.
That causes, during we requesting the kernel to reread partition table,
udev workers can process the block device or its partitions.

Let's make udev workers not process block devices during rereading
partition table again.

Follow-up for aa47d8ade1.
2025-10-31 17:12:44 +01:00
Yu Watanabe
154de15bdf vmspawn: replace strv_extendf() with strv_extend_joined() when concatenating strings 2025-11-01 00:59:41 +09:00
Yu Watanabe
323fafbb55 vmspawn: use strv_extendf() at one more place 2025-11-01 00:59:41 +09:00
Yu Watanabe
2b2b04d6d0 dns-rr: use strv_extendf() at one more place 2025-11-01 00:59:41 +09:00
Yu Watanabe
bafbcd3b27 core/exec-invoke: use heap allocation to build environment variables
We sometimes forget to increase the size N_ENV_VARS. Let's use heap
allocation.
2025-11-01 00:59:41 +09:00
Yu Watanabe
19bbcd35d7 strv: introduce strv_extend_joined() and strv_extend_joined_with_size() 2025-11-01 00:59:36 +09:00
Yu Watanabe
69350ee3e3 string-util: introduce strextendv_with_separator() 2025-11-01 00:58:42 +09:00
Yu Watanabe
3c66f40262 strv: introduce strv_extendf_with_size() 2025-11-01 00:58:39 +09:00
Daan De Meyer
9e26ced980 core: Add RootDirectoryFileDescriptor=
RootDirectory= but via a open_tree() file descriptor. This allows
setting up the execution environment for a service by the client in
a mount namespace and then starting a transient unit in that execution
environment using the new property.

We also add --root-directory= and --same-root-dir= to systemd-run to
have it run services within the given root directory. As systemd-run
might be invoked from a different mount namespace than what systemd is
running in, systemd-run opens the given path with open_tree() and then
sends it to systemd using the new RootDirectoryFileDescriptor= property.
2025-10-31 13:09:51 +01:00
Yu Watanabe
0885e4a6e7 Various --bind-user= fixes (#39498) 2025-10-31 20:43:54 +09:00
Yu Watanabe
b1ba55a8a7 network: do not restart DHCPv4 client on stopping/restarting networkd
Follow-up for fc35a9f8d1 (v255).
Fixes #39299.
2025-10-31 17:59:22 +09:00
Lennart Poettering
31c220d8f5 importd: support OS tree "mangling" unpriv too (#39406)
Split out of #38728 

(background: os tree "mangling" is what we do if a tarball with an OS
image inside it if is nested inside an extra top-level dir inside the
tarball, which we need to "mangle" and move everything inside one level
up)
2025-10-31 09:46:36 +01:00
Yu Watanabe
3f9db926e4 network: propagate error in link_carrier_lost()
Follow-up for 07021ed4f5 (v258).
2025-10-31 17:33:58 +09:00
Daan De Meyer
def01c7efe nspawn/vmspawn: Add --bind-user-group= option
Useful to add the bound users to the wheel group.
2025-10-31 08:57:38 +01:00
Daan De Meyer
b430f2bc94 nspawn-bind-user: Write membership records 2025-10-31 08:57:38 +01:00
Daan De Meyer
3fbf4ac24b userdbctl: Write empty JSON object into membership files 2025-10-31 08:57:38 +01:00
Daan De Meyer
cfabf3eb3b TEST-87-AUX-UTILS-VM: Propagate SYSTEMD_PAGER at one more place 2025-10-31 08:57:38 +01:00
Daan De Meyer
472161f368 userdb: Add missing .membership extension to membership files
Follow up for fe0342edf4

This also drops the mkosi testuser from the wheel and systemd-journal
groups as the integration tests rely on the testuser not being to read
the full journal.
2025-10-31 08:57:08 +01:00
Daan De Meyer
097b6d3f66 nspawn: Fix docs 2025-10-31 08:26:04 +01:00
Christoph Anton Mitterer
bfb365d924 man: clarify quoting of $ in command lines (#39494)
When the special executable prefix `:` is used, `$$` yield the literal `$$`.
2025-10-31 15:28:57 +09:00
dgengtek
4207abb6e1 man: clarify requirements for BridgeVLAN to work 2025-10-31 15:26:14 +09:00
Yu Watanabe
404d9bfb62 mount-setup: Add memory_hugetlb_accounting to cgroupfs mount (#39486)
This mount option will count HugeTLB memory usage towards the cgroup’s
overall memory usage for the memory controller.

See
https://lore.kernel.org/all/20231006184629.155543-4-nphamcs@gmail.com/T/#u
for the patch introducing the new mount option.
2025-10-31 15:20:10 +09:00
Daan De Meyer
456ee3c5f9 core: Rename bus_set_transient_std_fd() and remove unused name argument 2025-10-30 23:37:06 +01:00
Lennart Poettering
2348c56367 import: make sure image mangling works unpriv too 2025-10-30 22:57:43 +01:00
Lennart Poettering
7912b1ebe5 import-common: rework import_mangle_os_tree() to operate based on fd to tree 2025-10-30 22:56:19 +01:00
Lennart Poettering
70733160ee os-util: add fd_is_os_tree() which is like path_is_os_tree() but operates on an fd 2025-10-30 22:56:19 +01:00
Daan De Meyer
886c078702 mount-setup: Add memory_hugetlb_accounting to cgroupfs mount
This mount option will count HugeTLB memory usage towards the cgroup’s
overall memory usage for the memory controller.

See https://lore.kernel.org/all/20231006184629.155543-4-nphamcs@gmail.com/T/#u
for the patch introducing the new mount option.
2025-10-30 22:28:41 +01:00
Daan De Meyer
5ce388aec8 mount-setup: Add optional function which provides extra mount options 2025-10-30 22:28:39 +01:00
Lennart Poettering
96d03f8e41 importd: port export-tar code to use the one systemd-dissect already uses (#39405)
Split out of #38728.

(Testcase is part of that PR)
2025-10-30 22:15:34 +01:00
Daan De Meyer
c46344d597 mount-setup: Reformat table
Preparation for the next commit.
2025-10-30 19:59:29 +01:00
Daan De Meyer
056f437487 core: several cleanups/fixes for fd passing (#39491) 2025-10-30 19:57:16 +01:00
Mike Yuan
a274cb0cff core/exec-invoke: switch keep_fds to heap allocation
Hardcoding total size of the array is error-prone, especially
considering the exeuctable_fd is added far below, so the '4' is
not entirely obvious. Also we seldomly do VLAs.
2025-10-30 17:47:30 +01:00
Mike Yuan
f70346fb87 core/exec-invoke: store all stashed fds in ExecParameters, incl. OpenFile= ones
Keeping a half-detached counter around brings nothing
but confusion, and leads to fd leak in error paths.
2025-10-30 17:47:30 +01:00
Mike Yuan
f4314f2fbc core/exec-invoke: do not discard stashed fds when stdio is connected to socket
This makes zero sense. Not sure how it got introduced...
2025-10-30 17:47:30 +01:00
Mike Yuan
d93fff5c0c core/service: also pass sockets to control processes when stdio is named fd 2025-10-30 17:47:30 +01:00
Mike Yuan
c954830fa9 core/service: only pass socket fds to control processes
If socket is used as stdio, we'd currently imply EXEC_PASS_FDS
and dump the whole set of fds to the control processes. This is
pretty much unexpected and unnecessary though, instead let's
pass only the socket fds.

Yes, this is a compat break, but a relatively minor one I'd
argue. And we can always revisit things if users do complain.
2025-10-30 17:47:29 +01:00
Mike Yuan
d85d98f406 core/execute: merge n_storage_fds and n_extra_fds into stashed_fds
The distinction between fdstore and extra fds is only meaningful
to struct Service. As far as executor is concerned they're just
some fds to pass to the service. Let's just merge it hence,
for the sake of simplicity.
2025-10-30 17:47:29 +01:00
Mike Yuan
f78e7ca7da core/execute: serialize fd_names only if there're fds to pass 2025-10-30 17:47:29 +01:00