summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilas Sewell <silas@sewell.ch>2008-11-25 10:19:03 -0700
committerAdrian Likins <alikins@redhat.com>2008-11-25 12:58:28 -0500
commit2713a451f5c33bc17e2d79cfaedbb074c716b896 (patch)
tree6d517fdf9fc18d2680da986a003447200381928e
parent6b16e2f8250ed91c4d5c7642e15b2e2d30b49352 (diff)
downloadfunc-2713a451f5c33bc17e2d79cfaedbb074c716b896.tar.gz
func-2713a451f5c33bc17e2d79cfaedbb074c716b896.tar.xz
func-2713a451f5c33bc17e2d79cfaedbb074c716b896.zip
* Added close_fds=True to sub_process calls.
-rw-r--r--func/minion/modules/djangoctl.py3
-rw-r--r--func/minion/modules/hardware.py2
-rw-r--r--func/minion/modules/mount.py8
-rw-r--r--func/minion/modules/nagios-check.py2
-rw-r--r--func/minion/modules/networktest.py2
-rw-r--r--func/minion/modules/process.py6
-rw-r--r--func/minion/modules/reboot.py2
-rw-r--r--func/minion/modules/service.py6
-rw-r--r--func/minion/modules/smart.py2
-rw-r--r--func/minion/modules/snmp.py2
-rw-r--r--func/minion/modules/sysctl.py3
-rw-r--r--func/minion/modules/virt.py3
12 files changed, 23 insertions, 18 deletions
diff --git a/func/minion/modules/djangoctl.py b/func/minion/modules/djangoctl.py
index 9404f21..e2d01b0 100644
--- a/func/minion/modules/djangoctl.py
+++ b/func/minion/modules/djangoctl.py
@@ -108,7 +108,8 @@ class Django(func_module.FuncModule):
command = "django-admin.py %s --pythonpath=%s --settings=settings" % (
command, project_path)
cmdref = sub_process.Popen(command.split(), stdout=sub_process.PIPE,
- stderr=sub_process.PIPE, shell=False)
+ stderr=sub_process.PIPE, shell=False,
+ close_fds=True)
data = cmdref.communicate()
return (cmdref.returncode, data[0], data[1])
diff --git a/func/minion/modules/hardware.py b/func/minion/modules/hardware.py
index 5a72da4..8c0852f 100644
--- a/func/minion/modules/hardware.py
+++ b/func/minion/modules/hardware.py
@@ -36,7 +36,7 @@ class HardwareModule(func_module.FuncModule):
for easier parsing. Each device is a entry in the return hash.
"""
- cmd = sub_process.Popen(["/usr/bin/lshal"],shell=False,stdout=sub_process.PIPE)
+ cmd = sub_process.Popen(["/usr/bin/lshal"],shell=False,stdout=sub_process.PIPE,close_fds=True)
data = cmd.communicate()[0]
data = data.split("\n")
diff --git a/func/minion/modules/mount.py b/func/minion/modules/mount.py
index 3c4abcc..e3f57af 100644
--- a/func/minion/modules/mount.py
+++ b/func/minion/modules/mount.py
@@ -24,7 +24,7 @@ class MountModule(func_module.FuncModule):
description = "Mounting, unmounting and getting information on mounted filesystems."
def list(self):
- cmd = sub_process.Popen(["/bin/cat", "/proc/mounts"], executable="/bin/cat", stdout=sub_process.PIPE, shell=False)
+ cmd = sub_process.Popen(["/bin/cat", "/proc/mounts"], executable="/bin/cat", stdout=sub_process.PIPE, shell=False, close_fds=True)
data = cmd.communicate()[0]
mounts = []
@@ -53,7 +53,7 @@ class MountModule(func_module.FuncModule):
os.makedirs(dir)
except:
return False
- cmd = sub_process.Popen(cmdline, executable="/bin/mount", stdout=sub_process.PIPE, shell=False)
+ cmd = sub_process.Popen(cmdline, executable="/bin/mount", stdout=sub_process.PIPE, shell=False, close_fds=True)
if cmd.wait() == 0:
return True
else:
@@ -65,7 +65,7 @@ class MountModule(func_module.FuncModule):
return True
if killall:
- cmd = sub_process.Popen(["/sbin/fuser", "-mk", dir], executable="/sbin/fuser", stdout=sub_process.PIPE, shell=False)
+ cmd = sub_process.Popen(["/sbin/fuser", "-mk", dir], executable="/sbin/fuser", stdout=sub_process.PIPE, shell=False, close_fds=True)
cmd.wait()
cmdline = ["/bin/umount"]
@@ -75,7 +75,7 @@ class MountModule(func_module.FuncModule):
cmdline.append("-l")
cmdline.append(dir)
- cmd = sub_process.Popen(cmdline, executable="/bin/umount", stdout=sub_process.PIPE, shell=False)
+ cmd = sub_process.Popen(cmdline, executable="/bin/umount", stdout=sub_process.PIPE, shell=False, close_fds=True)
if cmd.wait() == 0:
return True
else:
diff --git a/func/minion/modules/nagios-check.py b/func/minion/modules/nagios-check.py
index 89f2c61..3c5aa06 100644
--- a/func/minion/modules/nagios-check.py
+++ b/func/minion/modules/nagios-check.py
@@ -29,7 +29,7 @@ class Nagios(func_module.FuncModule):
nagios_path='/usr/lib/nagios/plugins'
command = '%s/%s' % (nagios_path, check_command)
- cmdref = sub_process.Popen(command.split(),stdout=sub_process.PIPE,stderr=sub_process.PIPE, shell=False)
+ cmdref = sub_process.Popen(command.split(),stdout=sub_process.PIPE,stderr=sub_process.PIPE, shell=False, close_fds=True)
data = cmdref.communicate()
return (cmdref.returncode, data[0], data[1])
diff --git a/func/minion/modules/networktest.py b/func/minion/modules/networktest.py
index 53fd453..0d5456b 100644
--- a/func/minion/modules/networktest.py
+++ b/func/minion/modules/networktest.py
@@ -59,7 +59,7 @@ class NetworkTest(func_module.FuncModule):
def __run_command(self, command, opts=[]):
full_cmd = [command] + opts
- cmd = sub_process.Popen(full_cmd, stdout=sub_process.PIPE)
+ cmd = sub_process.Popen(full_cmd, stdout=sub_process.PIPE, close_fds=True)
return [line for line in cmd.communicate()[0].split('\n')]
def register_method_args(self):
diff --git a/func/minion/modules/process.py b/func/minion/modules/process.py
index 80e76fd..070a681 100644
--- a/func/minion/modules/process.py
+++ b/func/minion/modules/process.py
@@ -209,14 +209,16 @@ class ProcessModule(func_module.FuncModule):
if signal[0] != "-":
signal = "-%s" % signal
rc = sub_process.call(["/bin/kill",signal, pid],
- executable="/bin/kill", shell=False)
+ executable="/bin/kill", shell=False,
+ close_fds=True)
print rc
return rc
def pkill(self,name,level=""):
# example killall("thunderbird","-9")
rc = sub_process.call(["/usr/bin/pkill", name, level],
- executable="/usr/bin/pkill", shell=False)
+ executable="/usr/bin/pkill", shell=False,
+ close_fds=True)
return rc
def register_method_args(self):
diff --git a/func/minion/modules/reboot.py b/func/minion/modules/reboot.py
index 70a4db0..631cb24 100644
--- a/func/minion/modules/reboot.py
+++ b/func/minion/modules/reboot.py
@@ -18,7 +18,7 @@ class Reboot(func_module.FuncModule):
description = "Reboots a machine."
def reboot(self, when='now', message=''):
- return sub_process.call(["/sbin/shutdown", '-r', when, message])
+ return sub_process.call(["/sbin/shutdown", '-r', when, message], close_fds=True)
def register_method_args(self):
"""
diff --git a/func/minion/modules/service.py b/func/minion/modules/service.py
index 7f3d381..1a1eefc 100644
--- a/func/minion/modules/service.py
+++ b/func/minion/modules/service.py
@@ -30,7 +30,7 @@ class Service(func_module.FuncModule):
filename = os.path.join("/etc/rc.d/init.d/",service_name)
if os.path.exists(filename):
- return sub_process.call(["/sbin/service", service_name, command])
+ return sub_process.call(["/sbin/service", service_name, command], close_fds=True)
else:
raise codes.FuncException("Service not installed: %s" % service_name)
@@ -61,7 +61,7 @@ class Service(func_module.FuncModule):
only provide whether or not they are running, not specific runlevel info.
"""
- chkconfig = sub_process.Popen(["/sbin/chkconfig", "--list"], stdout=sub_process.PIPE)
+ chkconfig = sub_process.Popen(["/sbin/chkconfig", "--list"], stdout=sub_process.PIPE, close_fds=True)
data = chkconfig.communicate()[0]
results = []
for line in data.split("\n"):
@@ -80,7 +80,7 @@ class Service(func_module.FuncModule):
"""
Get a list of which services are running, stopped, or disabled.
"""
- chkconfig = sub_process.Popen(["/sbin/service", "--status-all"], stdout=sub_process.PIPE)
+ chkconfig = sub_process.Popen(["/sbin/service", "--status-all"], stdout=sub_process.PIPE, close_fds=True)
data = chkconfig.communicate()[0]
results = []
for line in data.split("\n"):
diff --git a/func/minion/modules/smart.py b/func/minion/modules/smart.py
index e8e4844..26e7091 100644
--- a/func/minion/modules/smart.py
+++ b/func/minion/modules/smart.py
@@ -36,7 +36,7 @@ class SmartModule(func_module.FuncModule):
flags.replace(";","") # prevent stupidity
- cmd = sub_process.Popen("/usr/sbin/smartd %s" % flags,stdout=sub_process.PIPE,shell=True)
+ cmd = sub_process.Popen("/usr/sbin/smartd %s" % flags,stdout=sub_process.PIPE,shell=True,close_fds=True)
data = cmd.communicate()[0]
results = []
diff --git a/func/minion/modules/snmp.py b/func/minion/modules/snmp.py
index c06655d..b8033ee 100644
--- a/func/minion/modules/snmp.py
+++ b/func/minion/modules/snmp.py
@@ -29,7 +29,7 @@ class Snmp(func_module.FuncModule):
"""
command = '%s -c %s %s %s' % (base_snmp_command, rocommunity, hostname, oid)
- cmdref = sub_process.Popen(command.split(),stdout=sub_process.PIPE,stderr=sub_process.PIPE, shell=False)
+ cmdref = sub_process.Popen(command.split(), stdout=sub_process.PIPE, stderr=sub_process.PIPE, shell=False, close_fds=True)
data = cmdref.communicate()
return (cmdref.returncode, data[0], data[1])
diff --git a/func/minion/modules/sysctl.py b/func/minion/modules/sysctl.py
index 36b5605..22222f7 100644
--- a/func/minion/modules/sysctl.py
+++ b/func/minion/modules/sysctl.py
@@ -18,7 +18,8 @@ class SysctlModule(func_module.FuncModule):
def __run(self, cmd):
cmd = sub_process.Popen(cmd.split(), stdout=sub_process.PIPE,
- stderr=sub_process.PIPE, shell=False)
+ stderr=sub_process.PIPE, shell=False,
+ close_fds=True)
return [line for line in cmd.communicate()[0].strip().split('\n')]
def list(self):
diff --git a/func/minion/modules/virt.py b/func/minion/modules/virt.py
index 2c68ab4..634a100 100644
--- a/func/minion/modules/virt.py
+++ b/func/minion/modules/virt.py
@@ -44,7 +44,8 @@ class FuncLibvirtConnection(object):
def __init__(self):
- cmd = sub_process.Popen("uname -r", shell=True, stdout=sub_process.PIPE)
+ cmd = sub_process.Popen("uname -r", shell=True, stdout=sub_process.PIPE,
+ close_fds=True)
output = cmd.communicate()[0]
if output.find("xen") != -1: