Commit Graph
84408 Commits
Author SHA1 Message Date
Lennart Poettering 0eab6d2960 repart: split out main function that ponders about placement of partitions
Let's move the key code that places partitions into a function of its
own. That will make it easier to call this via varlink.
2025-11-01 21:58:28 +01:00
Lennart Poettering a47cbb6d9d repart: move definitions + dry_run + empty fields into Context
This is preparation for making this eventually available via Varlink,
where we'd like to create Context object for each call that we can free
once it is done, but not inherit state from an earlier call.

Also fixes a couple of cases where we accessed arg_node, but where we
should have accessed the Context-specific copy in .node.
2025-11-01 21:58:28 +01:00
Lennart Poettering eccd8d9a57 repart: use SD_JSON_BUILD_UNSIGNED for disk sizes, as we should 2025-11-01 21:58:28 +01:00
Lennart Poettering b64eb98054 sd-varlink: fix sd_varlink_collect() with empty replies
Follow-up for: 48c64813ec
2025-11-01 21:58:28 +01:00
Lennart Poettering 633a4b8839 man: add documentation for the various sd_json_dispatch_xyz() calls
Now that we comprehensively return accept null it's a good idea to
document which function maps null to what.
2025-11-01 21:58:28 +01:00
Lennart Poettering 93317e9c17 sd-json: parse signals also in string format 2025-11-01 21:43:37 +01:00
Lennart Poettering 786aaed943 sd-json: parse uid_t/gid_t as uint32_t first
Let's use the proper uint32_t parsers initially, so that the usual logic
of formatting integers as decimal strings, works too for uids/gids. Not
because it made any sense to encode them like that, but just to be
systematic here.
2025-11-01 21:43:37 +01:00
Lennart Poettering e01f8990f1 sd-json: make sure all dispatch helpers do something sensible in case of "null" JSON value
Most of our dispatch helpers already do something useful in case they
are invoked on a null JSON value: they translate this to the appropriate
niche value for the type, if there is one.

Add the same for *all* dispatchers we have, to make this fully
systematic.

For various types it's not always clear which niche value to pick. I
opted for UINT{8,16,32,64}_MAX for the various unsigned integers, which
maps our own use in most cases. I opted for -1 for the various signed
integer types. For arrays/blobs of stuff I opted for the empty
array/blob, and for booleans I opted for false.

Of course, in various cases this is not going to be the right niche
value, but that's entirely fine, after all before a json value reaches a
dispatcher function it must pass one of two type checks first:

1. Either the .type field of sd_json_dispatch_field must be
   _SD_JSON_VARIANT_TYPE_INVALID to not do a type check at all

2. Or the .type field is set, but then the SD_JSON_NULLABLE flag must be
   set in .flags.

This means, accidentally generating the niche values on null is not
really likely.
2025-11-01 21:43:37 +01:00
Yu Watanabe 3cc3b469cc Ignore --now when systemctl enable is called in a chroot (#39456) 2025-11-02 04:48:53 +09:00
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
Zbigniew Jędrzejewski-Szmek 77a1cc8fa0 systemctl: downgrade or silence warnings for --now
When calling systemctl enable/disable/reenable --now, we'd always fail with
error when operating offline. This seemly overly restricitive. In particular,
if systemd is not running at all, the service is not running either, so
complaining that we can't stop it is completely unnecessary. But even when
operating in a chroot where systemd is not running, let's just emit a warning
and return success. It's fairly common to have installation or package scripts
which do such calls and not starting/restarting the service in those scenarios
is the desired and expected operation. (If --now is called in combination
with --global or --root=, keep returning an error.)

Also make the messages nicer. I was adding some docs to tell the user to run
'systemctl enable --now', and checked how the command can fail, and the error
message that the user might see in some common scenarios was too complicated.
Split it up to be nicer.
2025-11-01 10:25:39 +01:00
Zbigniew Jędrzejewski-Szmek 0ff5985176 systemctl: convert return value of install_client_side() to enum
The checks are reordered to do checks that don't require interacting with the
system first.
2025-11-01 10:25:04 +01: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](https://github.com/softprops/action-gh-release/compare/da05d552573ad5aba039eaac05058a918a7bf631...6da8fa9354ddfdc4aeace5fc48d7f679b5214090)

---
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](https://github.com/redhat-plumbers-in-action/advanced-issue-labeler/compare/0db433d412193574252480b4fc22f2e4319a4ea3...e38e6809c5420d038eed380d49ee9a6ca7c92dbf)

---
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