utils/mnt: fix mount permissions

This is a follow up to #1550 where we enabled a `rw` permissions mode,
which is not ideal since it would theoretically be possible to set both
`ro` and `rw` modes at the same time. This commit fixes the issue by only
allowing one option at a time.

Fixes #1588
This commit is contained in:
Gianluca Zuccarelli 2024-03-06 11:20:17 +00:00 committed by Gianluca Zuccarelli
parent 2d2cdd8097
commit 6c0973238d
4 changed files with 25 additions and 10 deletions

View file

@ -4,7 +4,7 @@ import subprocess
import tempfile
from contextlib import contextmanager
from osbuild.util.mnt import MountGuard
from osbuild.util.mnt import MountGuard, MountPermissions
def is_manifest_list(data):
@ -123,7 +123,7 @@ def containers_storage_source(image, image_filepath, container_format):
with MountGuard() as mg:
# NOTE: the ostree.deploy.container needs explicit `rw` access to
# the containers-storage store even when bind mounted.
mg.mount(image_filepath, storage_path, rw=True)
mg.mount(image_filepath, storage_path, permissions=MountPermissions.READ_WRITE)
image_id = image["checksum"].split(":")[1]
image_source = f"{container_format}:[{driver}@{storage_path}+/run/containers/storage]{image_id}"