diff --git a/etc/manila/rootwrap.d/share.filters b/etc/manila/rootwrap.d/share.filters index 2453eaf772..04ac6eb2a5 100644 --- a/etc/manila/rootwrap.d/share.filters +++ b/etc/manila/rootwrap.d/share.filters @@ -81,7 +81,7 @@ service: CommandFilter, service, root mktemp: CommandFilter, mktemp, root # manila/share/drivers/ganesha/manager.py: -shcat: RegExpFilter, sh, root, sh, -c, cat > /.* +shcat: RegExpFilter, sh, root, sh, -c, echo '((.|\n)*)' > /.* # manila/share/drivers/ganesha/manager.py: dbus-addexport: RegExpFilter, dbus-send, root, dbus-send, --print-reply, --system, --dest=org\.ganesha\.nfsd, /org/ganesha/nfsd/ExportMgr, org\.ganesha\.nfsd\.exportmgr\.(Add|Remove)Export, .*, .* diff --git a/manila/share/drivers/ganesha/manager.py b/manila/share/drivers/ganesha/manager.py index 53c59afe67..66aceea35e 100644 --- a/manila/share/drivers/ganesha/manager.py +++ b/manila/share/drivers/ganesha/manager.py @@ -226,8 +226,10 @@ class GaneshaManager(object): ("dir", "base")) tmpf = self.execute('mktemp', '-p', dirpath, "-t", fname + ".XXXXXX")[0][:-1] - self.execute('sh', '-c', 'cat > ' + pipes.quote(tmpf), - process_input=data, message='writing ' + tmpf) + self.execute( + 'sh', '-c', + 'echo %s > %s' % (pipes.quote(data), pipes.quote(tmpf)), + message='writing ' + tmpf) self.execute('mv', tmpf, path) def _write_conf_file(self, name, data): diff --git a/manila/tests/share/drivers/ganesha/test_manager.py b/manila/tests/share/drivers/ganesha/test_manager.py index 5651e2513b..ef5dc25e22 100644 --- a/manila/tests/share/drivers/ganesha/test_manager.py +++ b/manila/tests/share/drivers/ganesha/test_manager.py @@ -227,14 +227,14 @@ class GaneshaManagerTestCase(test.TestCase): def test_write_file(self): test_data = 'fakedata' self.mock_object(manager.pipes, 'quote', - mock.Mock(return_value='fakefile.conf.RANDOM')) + mock.Mock(side_effect=['fakedata', + 'fakefile.conf.RANDOM'])) test_args = [ ('mktemp', '-p', '/fakedir0/export.d', '-t', 'fakefile.conf.XXXXXX'), - ('sh', '-c', 'cat > fakefile.conf.RANDOM'), + ('sh', '-c', 'echo fakedata > fakefile.conf.RANDOM'), ('mv', 'fakefile.conf.RANDOM', test_path)] test_kwargs = { - 'process_input': test_data, 'message': 'writing fakefile.conf.RANDOM' } @@ -249,7 +249,9 @@ class GaneshaManagerTestCase(test.TestCase): mock.call(*test_args[0]), mock.call(*test_args[1], **test_kwargs), mock.call(*test_args[2])]) - manager.pipes.quote.assert_called_once_with('fakefile.conf.RANDOM') + manager.pipes.quote.assert_has_calls([ + mock.call('fakedata'), + mock.call('fakefile.conf.RANDOM')]) def test_write_conf_file(self): test_data = 'fakedata'