From 09b31834e274f7d0658f3a99a6c09c0284eb4617 Mon Sep 17 00:00:00 2001 From: Balazs Kocso Date: Mon, 17 Dec 2018 13:33:17 +0100 Subject: [PATCH] furnace/utils.py: add readonly support for BindMountContext --- furnace/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/furnace/utils.py b/furnace/utils.py index 554c045..bf04178 100644 --- a/furnace/utils.py +++ b/furnace/utils.py @@ -22,7 +22,7 @@ from json import JSONEncoder from pathlib import Path -from .libc import mount, umount, umount2, MS_BIND, MNT_DETACH +from .libc import mount, umount, umount2, MS_BIND, MNT_DETACH, MS_RDONLY logger = logging.getLogger(__name__) @@ -64,8 +64,15 @@ def __exit__(self, type, value, traceback): class BindMountContext(MountContext): + def __init__(self, source, destination, read_only=False): + super().__init__(source, destination) + self.read_only = read_only + def get_mount_parameters(self): - return None, MS_BIND, None + flags = MS_BIND + if self.read_only: + flags |= MS_RDONLY + return None, flags, None class OverlayfsMountContext(MountContext):