diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-05-01 02:22:54 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-05-01 02:22:54 +0000 |
| commit | fb58a57af6c9e88cc1696378fbd4bb72307bcbcb (patch) | |
| tree | 1b0bafec912be8e20abe3a9fa2eda7bda8449685 | |
| parent | 3105b28e6481afe61dfef43bd1237e75bfb7b26b (diff) | |
| parent | 3d28e3d3f9cc755389c933e86b9be1edf8ba1dc3 (diff) | |
| download | nova-fb58a57af6c9e88cc1696378fbd4bb72307bcbcb.tar.gz nova-fb58a57af6c9e88cc1696378fbd4bb72307bcbcb.tar.xz nova-fb58a57af6c9e88cc1696378fbd4bb72307bcbcb.zip | |
Merge "Make KillFilter to handle 'deleted' w/o rstrip."
| -rwxr-xr-x | nova/rootwrap/filters.py | 3 | ||||
| -rw-r--r-- | nova/tests/test_nova_rootwrap.py | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/nova/rootwrap/filters.py b/nova/rootwrap/filters.py index 566c03b56..a51ecae3d 100755 --- a/nova/rootwrap/filters.py +++ b/nova/rootwrap/filters.py @@ -119,7 +119,8 @@ class KillFilter(CommandFilter): command = os.readlink("/proc/%d/exe" % int(args[1])) # NOTE(dprince): /proc/PID/exe may have ' (deleted)' on # the end if an executable is updated or deleted - command = command.rstrip(" (deleted)") + if command.endswith(" (deleted)"): + command = command[:command.rindex(" ")] if command not in self.args[1]: # Affected executable not in accepted list return False diff --git a/nova/tests/test_nova_rootwrap.py b/nova/tests/test_nova_rootwrap.py index ee687eacd..ca2626b24 100644 --- a/nova/tests/test_nova_rootwrap.py +++ b/nova/tests/test_nova_rootwrap.py @@ -103,6 +103,20 @@ class RootwrapTestCase(test.TestCase): usercmd = ['kill', 'notapid'] self.assertFalse(f.match(usercmd)) + def test_KillFilter_deleted_exe(self): + """Makes sure deleted exe's are killed correctly""" + # See bug #967931. + def fake_readlink(blah): + return '/bin/commandddddd (deleted)' + + f = filters.KillFilter("/bin/kill", "root", + [""], + ["/bin/commandddddd"]) + usercmd = ['kill', 1234] + # Providing no signal should work + self.stubs.Set(os, 'readlink', fake_readlink) + self.assertTrue(f.match(usercmd)) + def test_ReadFileFilter(self): goodfn = '/good/file.name' f = filters.ReadFileFilter(goodfn) |
