mountfsd: Add relaxExtensionReleaseChecks

We currently pass this around as a mount option in pid1, which means
privileges are required by mountfsd to mount images that make use of it.
Add an explicit argument for it in varlink instead and remove it client
side from the mount options to remove the need for privileges.
This commit is contained in:
Daan De Meyer
2026-01-21 12:03:08 +01:00
parent 4b070c4c9f
commit a92a9efdc0
3 changed files with 39 additions and 13 deletions
+22 -1
View File
@@ -40,6 +40,7 @@
#include "fileio.h"
#include "format-util.h"
#include "fsck-util.h"
#include "fstab-util.h"
#include "gpt.h"
#include "hash-funcs.h"
#include "hexdecoct.h"
@@ -5185,13 +5186,32 @@ int mountfsd_mount_image_fd(
_cleanup_(sd_json_variant_unrefp) sd_json_variant *mount_options = NULL;
for (PartitionDesignator i = 0; i < _PARTITION_DESIGNATOR_MAX; i++) {
_cleanup_free_ char *filtered = NULL;
const char *o = mount_options_from_designator(options, i);
if (!o)
continue;
/* We communicate relaxExtensionReleaseCheck separately via the varlink API, so filter it out
* from the mount options we pass to mountfsd. */
if (IN_SET(i, PARTITION_ROOT, PARTITION_USR)) {
r = fstab_filter_options(
o,
"x-systemd.relax-extension-release-check\0",
/* ret_namefound= */ NULL,
/* ret_value= */ NULL,
/* ret_values= */ NULL,
&filtered);
if (r < 0)
return log_error_errno(r, "Failed to filter mount options: %m");
if (isempty(filtered))
continue;
}
r = sd_json_variant_merge_objectbo(
&mount_options,
SD_JSON_BUILD_PAIR_STRING(partition_designator_to_string(i), o));
SD_JSON_BUILD_PAIR_STRING(partition_designator_to_string(i), filtered ?: o));
if (r < 0)
return log_error_errno(r, "Failed to build mount options array: %m");
}
@@ -5208,6 +5228,7 @@ int mountfsd_mount_image_fd(
SD_JSON_BUILD_PAIR_BOOLEAN("growFileSystems", FLAGS_SET(flags, DISSECT_IMAGE_GROWFS)),
SD_JSON_BUILD_PAIR_CONDITION(!!ps, "imagePolicy", SD_JSON_BUILD_STRING(ps)),
JSON_BUILD_PAIR_VARIANT_NON_NULL("mountOptions", mount_options),
SD_JSON_BUILD_PAIR_BOOLEAN("relaxExtensionReleaseChecks", mount_options_relax_extension_release_checks(options)),
SD_JSON_BUILD_PAIR_BOOLEAN("veritySharing", FLAGS_SET(flags, DISSECT_IMAGE_VERITY_SHARE)),
SD_JSON_BUILD_PAIR_CONDITION(verity_data_fd >= 0, "verityDataFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd >= 0 ? 2 : 1)),
SD_JSON_BUILD_PAIR_CONDITION(verity && iovec_is_set(&verity->root_hash), "verityRootHash", JSON_BUILD_IOVEC_HEX(&verity->root_hash)),
@@ -62,6 +62,8 @@ static SD_VARLINK_DEFINE_METHOD(
SD_VARLINK_DEFINE_INPUT(imagePolicy, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The mount options to be used for the partitions of the image, keyed by the partition designator. Requires elevated privileges via polkit if specified, the polkit request details will list them in the 'mount_options' field."),
SD_VARLINK_DEFINE_INPUT(mountOptions, SD_VARLINK_STRING, SD_VARLINK_MAP|SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Whether to relax the extension release checks when mounting the image."),
SD_VARLINK_DEFINE_INPUT(relaxExtensionReleaseChecks, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Whether to automatically reuse already set up dm-verity devices that share the same roothash."),
SD_VARLINK_DEFINE_INPUT(veritySharing, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("File descriptor of the file containing the dm-verity data, if the image is a bare filesystem rather than a DDI."),