diff options
author | Adrian Likins <alikins@redhat.com> | 2007-09-25 13:07:54 -0400 |
---|---|---|
committer | Adrian Likins <alikins@redhat.com> | 2007-09-25 13:07:54 -0400 |
commit | 50c32af5a366bfd5c3a74c468ed47f97684372ab (patch) | |
tree | 10becbc40a0bcc558972980b7c1677f99b2ce9b3 | |
parent | 91908a6228316dadf22de4eca88354bd59807fc3 (diff) | |
download | third_party-func-50c32af5a366bfd5c3a74c468ed47f97684372ab.tar.gz third_party-func-50c32af5a366bfd5c3a74c468ed47f97684372ab.tar.xz third_party-func-50c32af5a366bfd5c3a74c468ed47f97684372ab.zip |
Be a bit more paranoid about sub processes. Before
we could just send "aux; some_arbitrary_command_here" and
"some_arbitrary_command_here" would get executed.
Also, for some reason, if we send process.kill just one
argument, it kills funcd dead. I'm not sure why currently
-rwxr-xr-x | modules/process.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/process.py b/modules/process.py index 1accbf5..2c40f9b 100755 --- a/modules/process.py +++ b/modules/process.py @@ -40,7 +40,9 @@ class ProcessModule(func_module.FuncModule): flags.replace(";","") # prevent stupidity - cmd = sub_process.Popen("ps %s" % flags,stdout=sub_process.PIPE,shell=True) + + #FIXME: we need to swallow stdout/stderr as well, right now it spews to the console + cmd = sub_process.Popen(["/bin/ps", flags] ,executable="/bin/ps", stdout=sub_process.PIPE,shell=False) data = cmd.communicate()[0] results = [] @@ -51,13 +53,14 @@ class ProcessModule(func_module.FuncModule): return results + def kill(self,pid,level=""): - rc = sub_process.call("/bin/kill %s %s" % (pid, level), shell=True) + rc = sub_process.call(["/bin/kill", pid, level], executable="/bin/kill", shell=False) return rc def pkill(self,name,level=""): # example killall("thunderbird","-9") - rc = sub_process.call("/usr/bin/pkill %s %s" % (name, level), shell=True) + rc = sub_process.call(["/usr/bin/pkill", name, level], executable="/usr/bin/pkill", shell=False) return rc methods = ProcessModule() |