From 1286806e83a5c719d9281ed40586c378c87165b5 Mon Sep 17 00:00:00 2001 From: Elias Wimmer Date: Thu, 18 Mar 2021 17:27:56 +0100 Subject: [PATCH] Fix generic share resize with 0.0.0.0/24 access Add missing quotes to exportfs command to protect being interpreted as file redirect Closes-Bug: #1911695 Change-Id: Ie95a476e9a81c58df998c3f44da137b023b53cc6 (cherry picked from commit 258625260682142d085979e9a345d9ba46b118ad) --- manila/share/drivers/helpers.py | 5 +++-- manila/tests/share/drivers/test_helpers.py | 18 +++++++++++++----- ...hare-world-accessable-b444d88b67b05af0.yaml | 4 ++++ 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/bug-1911695-resize-share-world-accessable-b444d88b67b05af0.yaml diff --git a/manila/share/drivers/helpers.py b/manila/share/drivers/helpers.py index 085e97d520..78c92164a8 100644 --- a/manila/share/drivers/helpers.py +++ b/manila/share/drivers/helpers.py @@ -383,8 +383,9 @@ class NFSHelper(NASHelperBase): out, err = self._ssh_exec(server, ['sudo', 'exportfs']) hosts = self.get_host_list(out, local_path) for host in hosts: - self._ssh_exec(server, ['sudo', 'exportfs', '-u', - ':'.join((host, local_path))]) + self._ssh_exec(server, + ['sudo', 'exportfs', '-u', + '"{}"'.format(':'.join((host, local_path)))]) self._sync_nfs_temp_and_perm_files(server) @nfs_synchronized diff --git a/manila/tests/share/drivers/test_helpers.py b/manila/tests/share/drivers/test_helpers.py index d38aaf2b01..072c31e69b 100644 --- a/manila/tests/share/drivers/test_helpers.py +++ b/manila/tests/share/drivers/test_helpers.py @@ -355,13 +355,16 @@ class NFSHelperTestCase(test.TestCase): @ddt.data( ('/shares/fake_share1\n\t\t1.1.1.10\n' '/shares/fake_share2\n\t\t1.1.1.16\n' + '/shares/fake_share3\n\t\t\n' '/mnt/fake_share1 1.1.1.11', False), ('/shares/fake_share_name\n\t\t1.1.1.10\n' '/shares/fake_share_name\n\t\t1.1.1.16\n' + '/shares/fake_share_name\n\t\t\n' '/mnt/fake_share1\n\t\t1.1.1.11', True), ('/mnt/fake_share_name\n\t\t1.1.1.11\n' '/shares/fake_share_name\n\t\t1.1.1.10\n' - '/shares/fake_share_name\n\t\t1.1.1.16\n', True)) + '/shares/fake_share_name\n\t\t1.1.1.16\n' + '/shares/fake_share_name\n\t\t\n', True)) @ddt.unpack def test_disable_access_for_maintenance(self, output, hosts_match): fake_maintenance_path = "fake.path" @@ -397,10 +400,15 @@ class NFSHelperTestCase(test.TestCase): if hosts_match: self._helper._ssh_exec.assert_has_calls([ - mock.call(self.server, ['sudo', 'exportfs', '-u', - ':'.join(['1.1.1.10', local_path])]), - mock.call(self.server, ['sudo', 'exportfs', '-u', - ':'.join(['1.1.1.16', local_path])]), + mock.call(self.server, + ['sudo', 'exportfs', '-u', + '"{}"'.format(':'.join(['1.1.1.10', local_path]))]), + mock.call(self.server, + ['sudo', 'exportfs', '-u', + '"{}"'.format(':'.join(['1.1.1.16', local_path]))]), + mock.call(self.server, + ['sudo', 'exportfs', '-u', + '"{}"'.format(':'.join(['', local_path]))]), ]) self._helper._sync_nfs_temp_and_perm_files.assert_called_once_with( diff --git a/releasenotes/notes/bug-1911695-resize-share-world-accessable-b444d88b67b05af0.yaml b/releasenotes/notes/bug-1911695-resize-share-world-accessable-b444d88b67b05af0.yaml new file mode 100644 index 0000000000..278148f223 --- /dev/null +++ b/releasenotes/notes/bug-1911695-resize-share-world-accessable-b444d88b67b05af0.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Resizing 0.0.0.0/24 accessible NFS shares with generic driver