Merge "ganesha: fix execute call using invalid argument"

This commit is contained in:
Jenkins 2015-02-19 05:20:26 +00:00 committed by Gerrit Code Review
commit e4dac43a5f
3 changed files with 11 additions and 7 deletions

View File

@ -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, .*, .*

View File

@ -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):

View File

@ -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'