[Freeipa-devel] [PATCH] 070 Fix reverse zone creation in ipa-replica-prepare

2011-05-27 Thread Martin Kosek
This patch replaces Rob's patch 791.
---
When a new reverse zone was created in ipa-replica-prepare (this
may happen when a new replica is from different subnet), the master
DNS address was corrupted by invalid A/ record. This caused
problems for example in installing replica.

https://fedorahosted.org/freeipa/ticket/1223

>From 0434292b18c7bc5acf20715e49a13625289c6e76 Mon Sep 17 00:00:00 2001
From: Martin Kosek 
Date: Fri, 27 May 2011 17:05:45 +0200
Subject: [PATCH] Fix reverse zone creation in ipa-replica-prepare

When a new reverse zone was created in ipa-replica-prepare (this
may happen when a new replica is from different subnet), the master
DNS address was corrupted by invalid A/ record. This caused
problems for example in installing replica.

https://fedorahosted.org/freeipa/ticket/1223
---
 install/tools/ipa-dns-install |   32 +++-
 install/tools/ipa-replica-install |   17 +
 install/tools/ipa-replica-prepare |4 +++-
 install/tools/ipa-server-install  |   29 +++--
 ipaserver/install/bindinstance.py |7 ---
 ipaserver/install/installutils.py |   15 +++
 6 files changed, 37 insertions(+), 67 deletions(-)

diff --git a/install/tools/ipa-dns-install b/install/tools/ipa-dns-install
index aac85bf230d006455c5f4289ec9f5fd997261d52..a763297678907effd0497517d6d1607ac1e5a2f3 100755
--- a/install/tools/ipa-dns-install
+++ b/install/tools/ipa-dns-install
@@ -62,31 +62,6 @@ def parse_options():
 
 return safe_options, options
 
-def resolve_host(host_name):
-ip = None
-try:
-addrinfos = socket.getaddrinfo(host_name, None,
-   socket.AF_UNSPEC, socket.SOCK_DGRAM)
-except:
-print "Unable to lookup the IP address of the provided host"
-return None
-
-for ai in addrinfos:
-ip = ai[4][0]
-if ip == "127.0.0.1" or ip == "::1":
-print "The hostname resolves to the localhost address (127.0.0.1/::1)"
-print "Please change your /etc/hosts file so that the hostname."
-print "resolves to the ip address of your network interface."
-print ""
-print "Please fix your /etc/hosts file and restart the setup program."
-print ""
-sys.exit("Aborting installation.")
-
-if addrinfos:
-ip = addrinfos[0][4][0]
-
-return ip
-
 def main():
 safe_options, options = parse_options()
 
@@ -211,6 +186,13 @@ except KeyboardInterrupt:
 print "Installation cancelled."
 except RuntimeError, e:
 print str(e)
+except HostnameLocalhost:
+print "The hostname resolves to the localhost address (127.0.0.1/::1)"
+print "Please change your /etc/hosts file so that the hostname"
+print "resolves to the ip address of your network interface."
+print "The KDC service does not listen on localhost"
+print ""
+print "Please fix your /etc/hosts file and restart the setup program"
 except Exception, e:
 message = "Unexpected error - see ipaserver-install.log for details:\n %s" % str(e)
 print message
diff --git a/install/tools/ipa-replica-install b/install/tools/ipa-replica-install
index 49df7fef9aceb3dbf8dd1dfdd91dd03132798484..293a0a06c8e4ff608d8327135ea1b4e008ab4d33 100755
--- a/install/tools/ipa-replica-install
+++ b/install/tools/ipa-replica-install
@@ -30,6 +30,7 @@ from ipapython import ipautil
 from ipaserver.install import dsinstance, installutils, krbinstance, service
 from ipaserver.install import bindinstance, httpinstance, ntpinstance, certs
 from ipaserver.install.replication import check_replication_plugin
+from ipaserver.install.installutils import HostnameLocalhost, resolve_host
 from ipaserver.plugins.ldap2 import ldap2
 from ipapython import version
 from ipalib import api, errors, util
@@ -38,9 +39,6 @@ from ipapython import sysrestore
 
 CACERT="/etc/ipa/ca.crt"
 
-class HostnameLocalhost(Exception):
-pass
-
 class ReplicaConfig:
 def __init__(self):
 self.realm_name = ""
@@ -131,19 +129,6 @@ def get_host_name(no_host_dns):
 
 return hostname
 
-def resolve_host(host_name):
-try:
-addrinfos = socket.getaddrinfo(host_name, None,
-   socket.AF_UNSPEC, socket.SOCK_STREAM)
-for ai in addrinfos:
-ip = ai[4][0]
-if ip == "127.0.0.1" or ip == "::1":
-raise HostnameLocalhost
-
-return addrinfos[0][4][0]
-except:
-return None
-
 def set_owner(config, dir):
 pw = pwd.getpwnam(dsinstance.DS_USER)
 os.chown(dir, pw.pw_uid, pw.pw_gid)
diff --git a/install/tools/ipa-replica-prepare b/install/tools/ipa-replica-prepare
index e9122351f5236bef4e82a15d1ab47c896ff03554..a41ca5121cd451093af3ee7c9d7282e300df53ca 100755
--- a/install/tools/ipa-replica-prepare
+++ b/install/tools/ipa-replica-prepare
@@ -30,6 +30,7 @@ from ipapython import ipautil
 from ipaserver.install import bindinstance, ds

Re: [Freeipa-devel] [PATCH] 070 Fix reverse zone creation in ipa-replica-prepare

2011-05-27 Thread Rob Crittenden

Martin Kosek wrote:

This patch replaces Rob's patch 791.
---
When a new reverse zone was created in ipa-replica-prepare (this
may happen when a new replica is from different subnet), the master
DNS address was corrupted by invalid A/ record. This caused
problems for example in installing replica.

https://fedorahosted.org/freeipa/ticket/1223


ack

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 070 Fix reverse zone creation in ipa-replica-prepare

2011-05-27 Thread Martin Kosek
On Fri, 2011-05-27 at 11:58 -0400, Rob Crittenden wrote:
> Martin Kosek wrote:
> > This patch replaces Rob's patch 791.
> > ---
> > When a new reverse zone was created in ipa-replica-prepare (this
> > may happen when a new replica is from different subnet), the master
> > DNS address was corrupted by invalid A/ record. This caused
> > problems for example in installing replica.
> >
> > https://fedorahosted.org/freeipa/ticket/1223
> 
> ack

Pushed to master, ipa-2-0.

Martin

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel