diff options
author | Dirk Mueller <dirk@dmllr.de> | 2013-05-18 12:17:59 +0200 |
---|---|---|
committer | Dirk Mueller <dirk@dmllr.de> | 2013-06-12 20:00:45 +0200 |
commit | 8b95b1e91d46f1bc7a37d210dc15e6f4072afaaa (patch) | |
tree | abb62f5cae6c6dbdb6d61cdfd00ffad2627ce91b /tests | |
parent | 706fa4b31d1e13ab8774bcd10a917849d14033d9 (diff) | |
download | oslo-8b95b1e91d46f1bc7a37d210dc15e6f4072afaaa.tar.gz oslo-8b95b1e91d46f1bc7a37d210dc15e6f4072afaaa.tar.xz oslo-8b95b1e91d46f1bc7a37d210dc15e6f4072afaaa.zip |
Handle relative path arguments in Killfilter
KillFilter currently expects an absolute path
to be specified for the process name to kill. This
is inconvenient when the exact location of the running
binary is not known or differs accross installs.
Extend KillFilter to accept also commands in $PATH
to be killed if the given argument is not absolute.
Change-Id: I6b90206b587ff3f949af2c256a78ca21af31867a
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_rootwrap.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/unit/test_rootwrap.py b/tests/unit/test_rootwrap.py index 25b2051..0e08b5e 100644 --- a/tests/unit/test_rootwrap.py +++ b/tests/unit/test_rootwrap.py @@ -107,6 +107,20 @@ class RootwrapTestCase(utils.BaseTestCase): usercmd = ['kill', p.pid] # Providing no signal should work self.assertTrue(f.match(usercmd) or f2.match(usercmd)) + + # verify that relative paths are matched against $PATH + f = filters.KillFilter("root", "cat") + # Our own PID does not match so it should fail + usercmd = ['kill', os.getpid()] + self.assertFalse(f.match(usercmd)) + # Filter should find cat in /bin or /usr/bin + usercmd = ['kill', p.pid] + self.assertTrue(f.match(usercmd)) + # Filter shouldn't be able to find binary in $PATH, so fail + with fixtures.EnvironmentVariable("PATH", "/foo:/bar"): + self.assertFalse(f.match(usercmd)) + pass + finally: # Terminate the "cat" process and wait for it to finish p.terminate() |