From 8429b9e4d575c9575ce1254793b78b077c5bca77 Mon Sep 17 00:00:00 2001 From: Ben Swartzlander Date: Fri, 1 Dec 2017 15:16:49 -0500 Subject: [PATCH] Always disable root-squash Initially, root squashing was only disabled for rw shares, but it should also be disabled for ro shares. Closes bug: #1735832 Change-Id: I916e8c6a8fb553350a977795cb1c4ab4ef817b98 --- manila/share/drivers/helpers.py | 9 ++------- manila/tests/share/drivers/test_helpers.py | 10 ++-------- releasenotes/notes/bug-1735832-43e9291ddd73286d.yaml | 4 ++++ 3 files changed, 8 insertions(+), 15 deletions(-) create mode 100644 releasenotes/notes/bug-1735832-43e9291ddd73286d.yaml diff --git a/manila/share/drivers/helpers.py b/manila/share/drivers/helpers.py index 271c11ba7d..983b7d5cc5 100644 --- a/manila/share/drivers/helpers.py +++ b/manila/share/drivers/helpers.py @@ -245,9 +245,7 @@ class NFSHelper(NASHelperBase): ':'.join((host, local_path))]) self._sync_nfs_temp_and_perm_files(server) for access in access_rules: - rules_options = '%s,no_subtree_check' - if access['access_level'] == const.ACCESS_LEVEL_RW: - rules_options = ','.join((rules_options, 'no_root_squash')) + rules_options = '%s,no_subtree_check,no_root_squash' access_to = self._get_parsed_address_or_cidr( access['access_to']) self._ssh_exec( @@ -297,10 +295,7 @@ class NFSHelper(NASHelperBase): 'name': share_name }) else: - rules_options = '%s,no_subtree_check' - if access['access_level'] == const.ACCESS_LEVEL_RW: - rules_options = ','.join((rules_options, - 'no_root_squash')) + rules_options = '%s,no_subtree_check,no_root_squash' self._ssh_exec( server, ['sudo', 'exportfs', '-o', diff --git a/manila/tests/share/drivers/test_helpers.py b/manila/tests/share/drivers/test_helpers.py index 65b9bb0060..ea704a5a82 100644 --- a/manila/tests/share/drivers/test_helpers.py +++ b/manila/tests/share/drivers/test_helpers.py @@ -134,10 +134,7 @@ class NFSHelperTestCase(test.TestCase): @ddt.data(const.ACCESS_LEVEL_RW, const.ACCESS_LEVEL_RO) def test_update_access(self, access_level): - expected_mount_options = '%s,no_subtree_check' - if access_level == const.ACCESS_LEVEL_RW: - expected_mount_options = ','.join((expected_mount_options, - 'no_root_squash')) + expected_mount_options = '%s,no_subtree_check,no_root_squash' self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files') local_path = os.path.join(CONF.share_mount_path, self.share_name) exec_result = ' '.join([local_path, '2.2.2.3']) @@ -231,10 +228,7 @@ class NFSHelperTestCase(test.TestCase): @ddt.data(const.ACCESS_LEVEL_RW, const.ACCESS_LEVEL_RO) def test_update_access_recovery_mode(self, access_level): - expected_mount_options = '%s,no_subtree_check' - if access_level == const.ACCESS_LEVEL_RW: - expected_mount_options = ','.join((expected_mount_options, - 'no_root_squash')) + expected_mount_options = '%s,no_subtree_check,no_root_squash' access_rules = [test_generic.get_fake_access_rule( '1.1.1.1', access_level), ] self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files') diff --git a/releasenotes/notes/bug-1735832-43e9291ddd73286d.yaml b/releasenotes/notes/bug-1735832-43e9291ddd73286d.yaml new file mode 100644 index 0000000000..6ebe82c12d --- /dev/null +++ b/releasenotes/notes/bug-1735832-43e9291ddd73286d.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - Root uses can now correctly read files on read-only shares + when the LVM or generic drivers are used.