# HG changeset patch # User Alain Leufroy # Date 1614932978 -3600 # Fri Mar 05 09:29:38 2021 +0100 # Node ID e2a0270f2d92e506ffe0bd42be7f7f25756fa1b9 # Parent 200ba211497961bb9b5f6de8dd87753fcf8dd024 edit: prevent broken mount point Do not allow users to edit layers having active descendants. diff --git a/overlayctl b/overlayctl --- a/overlayctl +++ b/overlayctl @@ -610,7 +610,13 @@ of the edited overlay. """ layer = build_layer(name) - # XXX check descendants not active + to_stop = [layer for layer in _iter_descendants(layer) if layer.automountunit.is_active()] + if to_stop: + # XXX automatic stop/start + logger.error( + 'You should prefere to stop the following overlays: \n\n%s\n', + ', '.join(x.name for x in to_stop)) + return if not appended and not prepended and not removed: with NamedTemporaryFile() as fobj: fobj.write(b'# -*- encoding: utf-8 -*-\n') diff --git a/test_overlayctl.py b/test_overlayctl.py --- a/test_overlayctl.py +++ b/test_overlayctl.py @@ -471,6 +471,17 @@ self.get_mount_dir('base1'), ]) + def test_cannot_edit_layer_with_active_descendant(self): + # Because OverlayFS does not like it, we protect users from + # having broken mount point. + self.get_mount_dir('base').mkdir() + overlayctl.creater('lower', ['base']) + overlayctl.creater('layer', ['lower']) + self.systemctl.reset_mock() + self.systemctl.status.return_value = {'Active': 'active'} + overlayctl.editer('lower', removed=['base']) + self.check_mount_unit('lower', [self.get_mount_dir('base')]) + class TestMove(BaseTest): """Tests for the `move` command."""