From 1d7d733d017c0a8fe2f171d9822d752ff72d9fc6 Mon Sep 17 00:00:00 2001 From: Andrew Laski Date: Tue, 30 Oct 2012 16:54:41 -0400 Subject: Use env to set environ when starting dnsmasq Explictly use env to setup needed environment variables for dnsmasq when starting to avoid problems with subprocess mis-interpreting the first command line argument as the executable name. Also update DnsmasqFilter to accept any command that starts with env followed by a set of args that include an equals sign, as long as the next arg is the dnsmasq command. fixes bug #1073253 Change-Id: I8ac08ba2d2309934a67ed2cb28049ed5d3277d63 --- nova/rootwrap/filters.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'nova/rootwrap') 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 -- cgit