Hello,

This patch addresses ticket https://fedorahosted.org/freeipa/ticket/3758.

-- 
Regards,

Ana Krivokapic
Associate Software Engineer
FreeIPA team
Red Hat Inc.

From aa8c36c9bf5f3a349fdf319f3e08a8b56081abef Mon Sep 17 00:00:00 2001
From: Ana Krivokapic <[email protected]>
Date: Wed, 4 Sep 2013 16:04:59 +0200
Subject: [PATCH] Fix invocations of FileError in ipa-client-install

Some of the FileErrors in ipa-client-install were raised incorrectly
(without the 'reason' argument), which resulted in bad error messages
during ipa-client-install.

https://fedorahosted.org/freeipa/ticket/3758
---
 ipa-client/ipa-install/ipa-client-install | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install
index 280edd793326150c416fe1b82f9866435e9c6509..17fcdf34e0578623cc1098cb5ea9bd5ff5fcb977 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -1493,33 +1493,34 @@ def get_ca_cert_from_file(url):
 
     try:
         parsed = urlparse.urlparse(url, 'file')
-    except Exception, e:
-        raise errors.FileError("unable to parse file url '%s'" % (url))
+    except Exception:
+        raise errors.FileError(reason="unable to parse file url '%s'" % url)
 
     if parsed.scheme != 'file':
-        raise errors.FileError("url is not a file scheme '%s'" % (url))
+        raise errors.FileError(reason="url is not a file scheme '%s'" % url)
 
     filename = parsed.path
 
     if not os.path.exists(filename):
-        raise errors.FileError("file '%s' does not exist" % (filename))
+        raise errors.FileError(reason="file '%s' does not exist" % filename)
 
     if not os.path.isfile(filename):
-        raise errors.FileError("file '%s' is not a file" % (filename))
+        raise errors.FileError(reason="file '%s' is not a file" % filename)
 
     root_logger.debug("trying to retrieve CA cert from file %s", filename)
     try:
         cert = x509.load_certificate_from_file(filename)
-    except Exception, e:
+    except Exception:
         raise errors.NoCertificateError(entry=filename)
 
     try:
         x509.write_certificate(cert.der_data, CACERT)
     except Exception, e:
-        raise errors.FileError(reason =
-            u"cannot write certificate file '%s': %s" % (CACERT, e))
+        raise errors.FileError(
+            reason=u"cannot write certificate file '%s': %s" % (CACERT, e)
+        )
     else:
-        del(cert)
+        del cert
 
 def get_ca_cert_from_http(url, ca_file, warn=True):
     '''
@@ -1600,7 +1601,8 @@ def validate_new_ca_cert(existing_ca_cert, ca_file, ask, override=False):
         new_ca_cert = x509.load_certificate_from_file(ca_file)
     except Exception, e:
         raise errors.FileError(
-            "Unable to read new ca cert '%s': %s" % (ca_file, e))
+            reason="Unable to read new ca cert '%s': %s" % (ca_file, e)
+        )
 
     if existing_ca_cert is None:
         root_logger.info(
-- 
1.8.3.1

_______________________________________________
Freeipa-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to