diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-10-31 18:27:15 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-10-31 18:27:15 +0000 |
| commit | a93f67c2accd48970d2a0154100a49728f5994dc (patch) | |
| tree | 08f374e57eb8e8a29e05b194b9ba7e33d822023b | |
| parent | 82a84d3b858aec73fe0f892d4590a7bf755a6e2e (diff) | |
| parent | 1d7d733d017c0a8fe2f171d9822d752ff72d9fc6 (diff) | |
Merge "Use env to set environ when starting dnsmasq"
| -rw-r--r-- | nova/network/linux_net.py | 3 | ||||
| -rw-r--r-- | nova/rootwrap/filters.py | 14 | ||||
| -rw-r--r-- | nova/tests/test_nova_rootwrap.py | 2 |
3 files changed, 11 insertions, 8 deletions
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 66156914c..9aafc50a1 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -831,7 +831,8 @@ def restart_dhcp(context, dev, network_ref): else: LOG.debug(_('Pid %d is stale, relaunching dnsmasq'), pid) - cmd = ['FLAGFILE=%s' % FLAGS.dhcpbridge_flagfile, + cmd = ['env', + 'FLAGFILE=%s' % FLAGS.dhcpbridge_flagfile, 'NETWORK_ID=%s' % str(network_ref['id']), 'dnsmasq', '--strict-order', diff --git a/nova/rootwrap/filters.py b/nova/rootwrap/filters.py index fc130139f..52808d9ec 100644 --- a/nova/rootwrap/filters.py +++ b/nova/rootwrap/filters.py @@ -73,19 +73,21 @@ class DnsmasqFilter(CommandFilter): """Specific filter for the dnsmasq call (which includes env)""" def match(self, userargs): - if (userargs[0].startswith("FLAGFILE=") and - userargs[1].startswith("NETWORK_ID=") and - userargs[2] == "dnsmasq"): + if (userargs[0] == 'env' and + userargs[1].startswith('FLAGFILE=') and + userargs[2].startswith('NETWORK_ID=') and + userargs[3] == 'dnsmasq'): return True return False def get_command(self, userargs): - return [self.exec_path] + userargs[3:] + dnsmasq_pos = userargs.index('dnsmasq') + return [self.exec_path] + userargs[dnsmasq_pos + 1:] def get_environment(self, userargs): env = os.environ.copy() - env['FLAGFILE'] = userargs[0].split('=')[-1] - env['NETWORK_ID'] = userargs[1].split('=')[-1] + env['FLAGFILE'] = userargs[1].split('=')[-1] + env['NETWORK_ID'] = userargs[2].split('=')[-1] return env diff --git a/nova/tests/test_nova_rootwrap.py b/nova/tests/test_nova_rootwrap.py index f67f2f56c..dc615bf5d 100644 --- a/nova/tests/test_nova_rootwrap.py +++ b/nova/tests/test_nova_rootwrap.py @@ -55,7 +55,7 @@ class RootwrapTestCase(test.TestCase): self.assertTrue(filtermatch is None) def test_DnsmasqFilter(self): - usercmd = ['FLAGFILE=A', 'NETWORK_ID=foobar', 'dnsmasq', 'foo'] + usercmd = ['env', 'FLAGFILE=A', 'NETWORK_ID=foobar', 'dnsmasq', 'foo'] f = filters.DnsmasqFilter("/usr/bin/dnsmasq", "root") self.assertTrue(f.match(usercmd)) self.assertEqual(f.get_command(usercmd), ['/usr/bin/dnsmasq', 'foo']) |
