From 4d01d3a137a7411f6fb2e06f6eafa0d06a2320f9 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Tue, 16 Sep 2014 21:37:46 +0200 Subject: [PATCH] Specify the correct Samba share path When configuring a new Samba share, the generic driver doesn't specify the correct share path. It specifies "path = /shares" instead of "path = /shares/share-GUID". As a result, a host with access to one share can access any other shares deployed by the tenant. Change-Id: I8ec94c522f65cd66f5e53841ac73d078973c6b85 Closes-Bug: #1370223 --- manila/share/drivers/generic.py | 5 +++-- manila/tests/share/drivers/test_generic.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/manila/share/drivers/generic.py b/manila/share/drivers/generic.py index 7c21a9d9df..85deadcea0 100644 --- a/manila/share/drivers/generic.py +++ b/manila/share/drivers/generic.py @@ -736,9 +736,10 @@ class CIFSHelper(NASHelperBase): def create_export(self, server, share_name, recreate=False): """Create share at samba server.""" + share_path = os.path.join(self.configuration.share_mount_path, + share_name) create_cmd = [ - 'sudo', 'net', 'conf', 'addshare', - share_name, self.configuration.share_mount_path, + 'sudo', 'net', 'conf', 'addshare', share_name, share_path, 'writeable=y', 'guest_ok=y', ] try: diff --git a/manila/tests/share/drivers/test_generic.py b/manila/tests/share/drivers/test_generic.py index 61a065da4c..6795ea901a 100644 --- a/manila/tests/share/drivers/test_generic.py +++ b/manila/tests/share/drivers/test_generic.py @@ -921,6 +921,9 @@ class CIFSHelperTestCase(test.TestCase): expected_location = '//%s/%s' % ( self.server_details['public_address'], self.share_name) self.assertEqual(ret, expected_location) + share_path = os.path.join( + self._helper.configuration.share_mount_path, + self.share_name) self._helper._ssh_exec.assert_has_calls([ mock.call( self.server_details, @@ -930,8 +933,7 @@ class CIFSHelperTestCase(test.TestCase): self.server_details, [ 'sudo', 'net', 'conf', 'addshare', self.share_name, - self._helper.configuration.share_mount_path, - 'writeable=y', 'guest_ok=y', + share_path, 'writeable=y', 'guest_ok=y', ] ), mock.call(self.server_details, mock.ANY), @@ -943,6 +945,9 @@ class CIFSHelperTestCase(test.TestCase): expected_location = '//%s/%s' % ( self.server_details['public_address'], self.share_name) self.assertEqual(ret, expected_location) + share_path = os.path.join( + self._helper.configuration.share_mount_path, + self.share_name) self._helper._ssh_exec.assert_has_calls([ mock.call( self.server_details, @@ -956,8 +961,7 @@ class CIFSHelperTestCase(test.TestCase): self.server_details, [ 'sudo', 'net', 'conf', 'addshare', self.share_name, - self._helper.configuration.share_mount_path, - 'writeable=y', 'guest_ok=y', + share_path, 'writeable=y', 'guest_ok=y', ] ), mock.call(self.server_details, mock.ANY),