From 3d28e3d3f9cc755389c933e86b9be1edf8ba1dc3 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 27 Apr 2012 09:36:34 -0400 Subject: Make KillFilter to handle 'deleted' w/o rstrip. The initial code for this fixed used rstrip incorrectly. This implementation uses endswith and rindex instead and should read a bit more easily. Also added a unit test to test that 'deleted' exe's are filtered correctly. Fixes LP Bug #967931. Change-Id: I1783a8e2d59edd35734673b23e295f5a0b80b988 --- nova/rootwrap/filters.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'nova/rootwrap') 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 -- cgit