summaryrefslogtreecommitdiffstats
path: root/ipaserver/install
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2009-11-30 15:28:09 -0500
committerRob Crittenden <rcritten@redhat.com>2009-11-30 15:28:41 -0500
commit7c2c2d6130648fb6dd7c0e52d802cc6eff39ef95 (patch)
treedd7e58b79a237757406bca959c2fff733ad09798 /ipaserver/install
parent29aa8fb05dbebe96ba44a4f6547cb7580562ef48 (diff)
downloadfreeipa-7c2c2d6130648fb6dd7c0e52d802cc6eff39ef95.tar.gz
freeipa-7c2c2d6130648fb6dd7c0e52d802cc6eff39ef95.tar.xz
freeipa-7c2c2d6130648fb6dd7c0e52d802cc6eff39ef95.zip
Add option to have ipautil.run() not raise an exception
There are times where a caller will want to determine the course of action based on the returncode instead of relying on it != 0. This also lets the caller get the contents of stdout and stderr.
Diffstat (limited to 'ipaserver/install')
-rw-r--r--ipaserver/install/cainstance.py12
-rw-r--r--ipaserver/install/certs.py10
-rw-r--r--ipaserver/install/dsinstance.py2
-rw-r--r--ipaserver/install/httpinstance.py2
-rw-r--r--ipaserver/install/service.py2
5 files changed, 14 insertions, 14 deletions
diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py
index a4fcec4a1..198b0c644 100644
--- a/ipaserver/install/cainstance.py
+++ b/ipaserver/install/cainstance.py
@@ -612,7 +612,7 @@ class CAInstance(service.Service):
# pkisilent doesn't return 1 on error so look at the output of
# /sbin/service pki-ca status. It will tell us if the instance
# still needs to be configured.
- (stdout, stderr) = ipautil.run(["/sbin/service", "pki-ca", "status"])
+ (stdout, stderr, returncode) = ipautil.run(["/sbin/service", "pki-ca", "status"])
try:
stdout.index("CONFIGURED!")
raise RuntimeError("pkisilent failed to configure instance.")
@@ -640,7 +640,7 @@ class CAInstance(service.Service):
def __get_agent_cert(self, nickname):
args = ["/usr/bin/certutil", "-L", "-d", self.ca_agent_db, "-n", nickname, "-a"]
- (out, err) = ipautil.run(args)
+ (out, err, returncode) = ipautil.run(args)
out = out.replace('-----BEGIN CERTIFICATE-----', '')
out = out.replace('-----END CERTIFICATE-----', '')
return out
@@ -692,7 +692,7 @@ class CAInstance(service.Service):
'%s:%d' % (self.host_name, AGENT_SECURE_PORT),
]
logging.debug("running sslget %s" % args)
- (stdout, stderr) = ipautil.run(args)
+ (stdout, stderr, returncode) = ipautil.run(args)
data = stdout.split('\r\n')
params = get_defList(data)
@@ -713,7 +713,7 @@ class CAInstance(service.Service):
'%s:%d' % (self.host_name, AGENT_SECURE_PORT),
]
logging.debug("running sslget %s" % args)
- (stdout, stderr) = ipautil.run(args)
+ (stdout, stderr, returncode) = ipautil.run(args)
data = stdout.split('\r\n')
outputList = get_outputList(data)
@@ -844,7 +844,7 @@ class CAInstance(service.Service):
# makes openssl throw up.
data = base64.b64decode(chain)
- (certs, stderr) = ipautil.run(["/usr/bin/openssl",
+ (certs, stderr, returncode) = ipautil.run(["/usr/bin/openssl",
"pkcs7",
"-inform",
"DER",
@@ -989,7 +989,7 @@ class CAInstance(service.Service):
"""
# Start by checking to see if policy is already installed.
- (stdout, stderr) = ipautils.run(["/usr/sbin/semodule", "-l"])
+ (stdout, stderr, returncode) = ipautil.run(["/usr/sbin/semodule", "-l"])
# Ok, so stdout is a huge string of the output. Look through that
# for our policy
diff --git a/ipaserver/install/certs.py b/ipaserver/install/certs.py
index ca5351201..c4923a751 100644
--- a/ipaserver/install/certs.py
+++ b/ipaserver/install/certs.py
@@ -382,7 +382,7 @@ class CertDB(object):
root_nicknames = self.find_root_cert(nickname)
fd = open(self.cacert_fname, "w")
for root in root_nicknames:
- (cert, stderr) = self.run_certutil(["-L", "-n", root, "-a"])
+ (cert, stderr, returncode) = self.run_certutil(["-L", "-n", root, "-a"])
fd.write(cert)
fd.close()
os.chmod(self.cacert_fname, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
@@ -424,13 +424,13 @@ class CertDB(object):
def get_cert_from_db(self, nickname):
try:
args = ["-L", "-n", nickname, "-a"]
- (cert, err) = self.run_certutil(args)
+ (cert, err, returncode) = self.run_certutil(args)
return cert
except ipautil.CalledProcessError:
return ''
def find_cacert_serial(self):
- (out,err) = self.run_certutil(["-L", "-n", self.cacert_name])
+ (out, err, returncode) = self.run_certutil(["-L", "-n", self.cacert_name])
data = out.split('\n')
for line in data:
x = re.match(r'\s+Serial Number: (\d+) .*', line)
@@ -485,7 +485,7 @@ class CertDB(object):
"-f", self.passwd_fname]
if not self.self_signed_ca:
args.append("-a")
- (stdout, stderr) = self.run_certutil(args)
+ (stdout, stderr, returncode) = self.run_certutil(args)
os.remove(self.noise_fname)
return (stdout, stderr)
@@ -746,7 +746,7 @@ class CertDB(object):
if passwd_fname:
args = args + ["-w", passwd_fname]
try:
- (stdout, stderr) = ipautil.run(args)
+ (stdout, stderr, returncode) = ipautil.run(args)
except ipautil.CalledProcessError, e:
if e.returncode == 17:
raise RuntimeError("incorrect password")
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index 60436dee2..5eff32e25 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -105,7 +105,7 @@ def is_ds_running():
"""
ret = True
try:
- (sout, serr) = ipautil.run(["/sbin/service", "dirsrv", "status"])
+ (sout, serr, rcode) = ipautil.run(["/sbin/service", "dirsrv", "status"])
if sout.find("is stopped") >= 0:
ret = False
except ipautil.CalledProcessError:
diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
index 7e7adfa79..94e155bf0 100644
--- a/ipaserver/install/httpinstance.py
+++ b/ipaserver/install/httpinstance.py
@@ -100,7 +100,7 @@ class HTTPInstance(service.Service):
if selinux:
try:
# returns e.g. "httpd_can_network_connect --> off"
- (stdout, stderr) = ipautil.run(["/usr/sbin/getsebool",
+ (stdout, stderr, returncode) = ipautil.run(["/usr/sbin/getsebool",
"httpd_can_network_connect"])
self.backup_state("httpd_can_network_connect", stdout.split()[2])
except:
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index a07a382ab..758688982 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -54,7 +54,7 @@ def chkconfig_del(service_name):
ipautil.run(["/sbin/chkconfig", "--del", service_name])
def is_enabled(service_name):
- (stdout, stderr) = ipautil.run(["/sbin/chkconfig", "--list", service_name])
+ (stdout, stderr, returncode) = ipautil.run(["/sbin/chkconfig", "--list", service_name])
runlevels = {}
for runlevel in range(0, 7):