diff options
author | Adrian Likins <alikins@redhat.com> | 2007-09-25 14:20:17 -0400 |
---|---|---|
committer | Adrian Likins <alikins@redhat.com> | 2007-09-25 14:20:17 -0400 |
commit | 6d5746d617385978fb316ac90cc05eaa0f39b8b9 (patch) | |
tree | 19bbf6d6149b448f369f1a9efa5e8887945a0a9b | |
parent | 35c3766557793329b9e1ea31b18ea66830367845 (diff) | |
download | third_party-func-6d5746d617385978fb316ac90cc05eaa0f39b8b9.tar.gz third_party-func-6d5746d617385978fb316ac90cc05eaa0f39b8b9.tar.xz third_party-func-6d5746d617385978fb316ac90cc05eaa0f39b8b9.zip |
catch some potentially bad args to the process.kill method
We don't want empty args to end up killing the calling process,
aka, funcd, so we filter those out.
-rwxr-xr-x | modules/process.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/process.py b/modules/process.py index 2c40f9b..78e5aea 100755 --- a/modules/process.py +++ b/modules/process.py @@ -16,6 +16,7 @@ # other modules import sub_process +import codes # our modules from modules import func_module @@ -54,8 +55,16 @@ class ProcessModule(func_module.FuncModule): return results - def kill(self,pid,level=""): - rc = sub_process.call(["/bin/kill", pid, level], executable="/bin/kill", shell=False) + def kill(self,pid,signal="TERM"): + if pid == "0": + raise codes.FuncException("Killing pid group 0 not permitted") + if signal == "": + # this is default /bin/kill behaviour, it claims, but enfore it anyway + signal = "-TERM" + if signal[0] != "-": + signal = "-%s" % signal + rc = sub_process.call(["/bin/kill",signal, pid], executable="/bin/kill", shell=False) + print rc return rc def pkill(self,name,level=""): |