URL: https://github.com/freeipa/freeipa/pull/96
Author: tomaskrizek
 Title: #96: Show error message for invalid IPs in client install
Action: opened

PR body:
"""
Re-raise the thrown exception to get an error message
instead of a traceback during ipa-client-install with
invalid IP address.

https://fedorahosted.org/freeipa/ticket/6340
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/96/head:pr96
git checkout pr96
From 3c00a11e7ba25612b9938c2d19d07075bd4b0ccb Mon Sep 17 00:00:00 2001
From: Tomas Krizek <tkri...@redhat.com>
Date: Tue, 20 Sep 2016 12:10:09 +0200
Subject: [PATCH] Show error message for invalid IPs in client install

Re-raise the thrown exception to get an error message
instead of a traceback during ipa-client-install with
invalid IP address.

https://fedorahosted.org/freeipa/ticket/6340
---
 ipapython/ipautil.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 6ef39ab..64901b5 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -133,8 +133,11 @@ class CheckedIPAddress(UnsafeIPAddress):
     """
     def __init__(self, addr, match_local=False, parse_netmask=True,
                  allow_loopback=False, allow_multicast=False):
+        try:
+            super(CheckedIPAddress, self).__init__(addr)
+        except netaddr.core.AddrFormatError as e:
+            raise ValueError(e)
 
-        super(CheckedIPAddress, self).__init__(addr)
         if isinstance(addr, CheckedIPAddress):
             self.prefixlen = addr.prefixlen
             return
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to