Ignore --config-dir when value is None

Previous code incorrectly used an explicit --config-dir=None on the
privsep-helper command line when cfg.CONF.config_dir was None (the
default).  This change correctly skips the --config-dir flag entirely in
this situation.

Change-Id: I8d71b1e0c5ab702a39c3e56119611700a126a5d4
This commit is contained in:
Angus Lees 2016-02-08 18:05:52 +11:00
parent ca917939bc
commit a6e554bd49
2 changed files with 15 additions and 1 deletions

View File

@ -333,7 +333,8 @@ class RootwrapClientChannel(_ClientChannel):
pass
try:
cmd.extend(['--config-dir', cfg.CONF.config_dir])
if cfg.CONF.config_dir is not None:
cmd.extend(['--config-dir', cfg.CONF.config_dir])
except cfg.NoSuchOptError:
pass

View File

@ -117,6 +117,19 @@ class TestWithContext(testctx.TestContextTestCase):
self.assertEqual(expected, cmd)
def test_helper_command_default(self):
self.privsep_conf.config_file = ['/bar.conf']
cmd = daemon.RootwrapClientChannel._helper_command(
testctx.context, '/tmp/sockpath')
expected = [
'sudo', 'privsep-helper',
'--config-file', '/bar.conf',
# --config-dir arg should be skipped
'--privsep_context', testctx.context.pypath,
'--privsep_sock_path', '/tmp/sockpath',
]
self.assertEqual(expected, cmd)
def test_helper_command_default_dirtoo(self):
self.privsep_conf.config_file = ['/bar.conf', '/baz.conf']
self.privsep_conf.config_dir = '/foo.d'
cmd = daemon.RootwrapClientChannel._helper_command(