Add a function for formatting network locations of the form host:port
for use in URLs.
If the host part is a literal IPv6 address, it must be enclosed in
square brackets (RFC 2732).
https://fedorahosted.org/freeipa/ticket/1869
In the ticket it is suggested to create a host name and network address
objects; I have created a new ticket for 3.0 to do that:
https://fedorahosted.org/freeipa/ticket/1917
Honza
--
Jan Cholasta
From 8e541046eac53fe5f341da7b2c6460f586d17b74 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Fri, 30 Sep 2011 10:09:55 +0200
Subject: [PATCH] Add a function for formatting network locations of the form
host:port for use in URLs.
If the host part is a literal IPv6 address, it must be enclosed in square
brackets (RFC 2732).
ticket 1869
---
install/tools/ipa-csreplica-manage|8
install/tools/ipa-replica-conncheck |4 ++--
install/tools/ipa-replica-install |6 +++---
install/tools/ipa-server-install |2 +-
ipa-client/ipa-install/ipa-client-install | 14 +++---
ipa-client/ipaclient/ipadiscovery.py |8
ipalib/rpc.py |4 ++--
ipapython/dogtag.py |6 +++---
ipapython/ipautil.py | 18 ++
ipaserver/install/bindinstance.py |2 +-
ipaserver/install/cainstance.py | 10 +-
ipaserver/install/dsinstance.py |2 +-
ipaserver/install/replication.py |6 +++---
ipaserver/ipaldap.py |7 ---
tests/test_ipaserver/test_ldap.py |2 +-
15 files changed, 59 insertions(+), 40 deletions(-)
diff --git a/install/tools/ipa-csreplica-manage b/install/tools/ipa-csreplica-manage
index 39d5056..c33f3bc 100755
--- a/install/tools/ipa-csreplica-manage
+++ b/install/tools/ipa-csreplica-manage
@@ -111,7 +111,7 @@ class CSReplicationManager(replication.ReplicationManager):
dn = 'cn=%s,cn=mapping tree,cn=config' % esc1_suffix
# TODO: should we detect proto/port somehow ?
mod = [(ldap.MOD_DELETE, 'nsslapd-referral',
-'ldap://%s:%s/%s' % (hostname, PORT, esc2_suffix))]
+'ldap://%s/%s' % (ipautil.format_netloc(hostname, PORT), esc2_suffix))]
try:
self.conn.modify_s(dn, mod)
@@ -226,7 +226,7 @@ def del_link(realm, replica1, replica2, dirman_passwd, force=False):
except errors.NotFound:
sys.exit('%s' has no replication agreement for '%s' % (replica1, replica2))
except ldap.SERVER_DOWN, e:
-sys.exit(Unable to connect to %s:%d: %s % (replica1, PORT, convert_error(e)))
+sys.exit(Unable to connect to %s: %s % (ipautil.format_netloc(replica1, PORT), convert_error(e)))
except Exception, e:
sys.exit(Failed to get data from '%s': %s % (replica1, convert_error(e)))
@@ -322,7 +322,7 @@ def add_link(realm, replica1, replica2, dirman_passwd, options):
except ldap.NO_SUCH_OBJECT:
sys.exit('%s does not have a CA configured.' % replica2)
except ldap.SERVER_DOWN, e:
-sys.exit(Unable to connect to %s:636: %s % (replica2, convert_error(e)))
+sys.exit(Unable to connect to %s: %s % (ipautil.format_netloc(replica2, 636), convert_error(e)))
except Exception, e:
sys.exit(Failed to get data from '%s': %s % (replica1, convert_error(e)))
@@ -337,7 +337,7 @@ def add_link(realm, replica1, replica2, dirman_passwd, options):
except ldap.NO_SUCH_OBJECT:
sys.exit(Cannot find replica '%s' % replica1)
except ldap.SERVER_DOWN, e:
-sys.exit(Unable to connect to %s:%d %s % (replica1, PORT, convert_error(e)))
+sys.exit(Unable to connect to %s %s % (ipautil.format_netloc(replica1, PORT), convert_error(e)))
except Exception, e:
sys.exit(Failed to get data from '%s': %s % (replica1, convert_error(e)))
diff --git a/install/tools/ipa-replica-conncheck b/install/tools/ipa-replica-conncheck
index ac1817e..65d7ef5 100755
--- a/install/tools/ipa-replica-conncheck
+++ b/install/tools/ipa-replica-conncheck
@@ -201,8 +201,8 @@ def configure_krb5_conf(realm, kdc, filename):
#the following are necessary only if DNS discovery does not work
#[realms]
-realms_info =[{'name':'kdc', 'type':'option', 'value':kdc+':88'},
- {'name':'admin_server', 'type':'option', 'value':kdc+':749'}]
+realms_info =[{'name':'kdc', 'type':'option', 'value':ipautil.format_netloc(kdc, 88)},
+ {'name':'admin_server', 'type':'option', 'value':ipautil.format_netloc(kdc, 749)}]
realms = [{'name':realm, 'type':'subsection', 'value':realms_info}]
opts.append({'name':'realms', 'type':'section', 'value':realms})
diff --git a/install/tools/ipa-replica-install b/install/tools/ipa-replica-install
index 6238044..960cca6 100755
--- a/install/tools/ipa-replica-install
+++ b/install/tools/ipa-replica-install
@@ -230,7