summaryrefslogtreecommitdiffstats
path: root/nova/rootwrap
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2012-04-27 09:36:34 -0400
committerDan Prince <dprince@redhat.com>2012-04-27 12:06:45 -0400
commit3d28e3d3f9cc755389c933e86b9be1edf8ba1dc3 (patch)
tree66514da7ae86e4d1a79444a4c22e37b2a0a7e4a7 /nova/rootwrap
parent8972e9544dead61c198037f24eecf0f04558a914 (diff)
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
Diffstat (limited to 'nova/rootwrap')
-rwxr-xr-xnova/rootwrap/filters.py3
1 files changed, 2 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