summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/certs.py
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/certs.py
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/certs.py')
-rw-r--r--ipaserver/install/certs.py10
1 files changed, 5 insertions, 5 deletions
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")