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
This commit is contained in:
Ben Swartzlander 2017-12-01 15:16:49 -05:00
parent c4b59336c2
commit 8429b9e4d5
3 changed files with 8 additions and 15 deletions

View File

@ -245,9 +245,7 @@ class NFSHelper(NASHelperBase):
':'.join((host, local_path))]) ':'.join((host, local_path))])
self._sync_nfs_temp_and_perm_files(server) self._sync_nfs_temp_and_perm_files(server)
for access in access_rules: for access in access_rules:
rules_options = '%s,no_subtree_check' rules_options = '%s,no_subtree_check,no_root_squash'
if access['access_level'] == const.ACCESS_LEVEL_RW:
rules_options = ','.join((rules_options, 'no_root_squash'))
access_to = self._get_parsed_address_or_cidr( access_to = self._get_parsed_address_or_cidr(
access['access_to']) access['access_to'])
self._ssh_exec( self._ssh_exec(
@ -297,10 +295,7 @@ class NFSHelper(NASHelperBase):
'name': share_name 'name': share_name
}) })
else: else:
rules_options = '%s,no_subtree_check' rules_options = '%s,no_subtree_check,no_root_squash'
if access['access_level'] == const.ACCESS_LEVEL_RW:
rules_options = ','.join((rules_options,
'no_root_squash'))
self._ssh_exec( self._ssh_exec(
server, server,
['sudo', 'exportfs', '-o', ['sudo', 'exportfs', '-o',

View File

@ -134,10 +134,7 @@ class NFSHelperTestCase(test.TestCase):
@ddt.data(const.ACCESS_LEVEL_RW, const.ACCESS_LEVEL_RO) @ddt.data(const.ACCESS_LEVEL_RW, const.ACCESS_LEVEL_RO)
def test_update_access(self, access_level): def test_update_access(self, access_level):
expected_mount_options = '%s,no_subtree_check' expected_mount_options = '%s,no_subtree_check,no_root_squash'
if access_level == const.ACCESS_LEVEL_RW:
expected_mount_options = ','.join((expected_mount_options,
'no_root_squash'))
self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files') self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
local_path = os.path.join(CONF.share_mount_path, self.share_name) local_path = os.path.join(CONF.share_mount_path, self.share_name)
exec_result = ' '.join([local_path, '2.2.2.3']) 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) @ddt.data(const.ACCESS_LEVEL_RW, const.ACCESS_LEVEL_RO)
def test_update_access_recovery_mode(self, access_level): def test_update_access_recovery_mode(self, access_level):
expected_mount_options = '%s,no_subtree_check' expected_mount_options = '%s,no_subtree_check,no_root_squash'
if access_level == const.ACCESS_LEVEL_RW:
expected_mount_options = ','.join((expected_mount_options,
'no_root_squash'))
access_rules = [test_generic.get_fake_access_rule( access_rules = [test_generic.get_fake_access_rule(
'1.1.1.1', access_level), ] '1.1.1.1', access_level), ]
self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files') self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')

View File

@ -0,0 +1,4 @@
---
fixes:
- Root uses can now correctly read files on read-only shares
when the LVM or generic drivers are used.