On 26.9.2011 13:22, Martin Kosek wrote:
On Mon, 2011-09-26 at 11:54 +0200, Jan Cholasta wrote:
On 26.9.2011 10:59, Martin Kosek wrote:
On Mon, 2011-09-12 at 09:50 +0200, Jan Cholasta wrote:
On 7.9.2011 15:13, Rob Crittenden wrote:
Jan Cholasta wrote:
On 6.9.2011 19:49, Rob Crittenden wrote:
Jan Cholasta wrote:
https://fedorahosted.org/freeipa/ticket/1717

Honza

nack, what if there are multiple interfaces and you want IPA to use one
(that doesn't happen to be the system hostname one)?

rob

Then the user configures the system hostname to match the hostname of
the interface. Or should we configure it automatically from the install?

Honza


We can't dictate which interface matches the hostname. At most we can
warn about this, but not fail to install.

rob

Changed to print a warning message instead of raising an error.

Honza


With this patch, ipa-replica-prepare always reports the warning:

# ipa-replica-prepare vm-050.idm.lab.bos.redhat.com
Warning: The host name 'vm-050.idm.lab.bos.redhat.com' does not match the 
system host name 'vm-134.idm.lab.bos.redhat.com'.
           Some services may not work properly.
Directory Manager (existing master) password:

Reopening 1717.

Martin


Fixed. Patch attached.

Honza


Looks functional, but I would suggest changing the option name. Maybe
its just me but I couldn't tell what no_system_hostname option does
until I studied the change.

The negative logic may be confusing, I would change it something like
system_hostname_check=False ->  system hostname check is not executed.
Plus, lets write a doc string for this function it is documented
properly.

Martin


Option name changed, docstring added.

Honza

--
Jan Cholasta
>From 5b24530f7785175dd2153ae09668144d6543aeb7 Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jchol...@redhat.com>
Date: Mon, 26 Sep 2011 11:34:16 +0200
Subject: [PATCH] Fix ipa-replica-prepare always warning the user about not
 using the system hostname.

ticket 1717
---
 install/tools/ipa-replica-prepare |    2 +-
 ipaserver/install/installutils.py |   20 +++++++++++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/install/tools/ipa-replica-prepare b/install/tools/ipa-replica-prepare
index c360190..16536b3 100755
--- a/install/tools/ipa-replica-prepare
+++ b/install/tools/ipa-replica-prepare
@@ -244,7 +244,7 @@ def main():
         options.setup_pkinit = False
 
     try:
-        installutils.verify_fqdn(replica_fqdn)
+        installutils.verify_fqdn(replica_fqdn, system_name_check=False)
     except RuntimeError, e:
         msg = str(e)
         if msg.startswith('Unable to resolve host name'):
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index d9b391f..345bf06 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -117,7 +117,16 @@ def verify_dns_records(host_name, responses, resaddr, family):
         raise RuntimeError("The DNS forward record %s does not match the reverse address %s" % (rec.dns_name, rev.rdata.ptrdname))
 
 
-def verify_fqdn(host_name,no_host_dns=False):
+def verify_fqdn(host_name, no_host_dns=False, system_name_check=True):
+    """
+    Verify that the given host name is fully-qualified.
+
+    Raises `RuntimeError` if the host name is not fully-qualified.
+
+    :param host_name: The host name to verify.
+    :param no_host_dns: If true, skip DNS resolution of the host name.
+    :param system_name_check: If true, check if the host name matches the system host name.
+    """
     if len(host_name.split(".")) < 2 or host_name == "localhost.localdomain":
         raise RuntimeError("Invalid hostname '%s', must be fully-qualified." % host_name)
 
@@ -127,10 +136,11 @@ def verify_fqdn(host_name,no_host_dns=False):
     if ipautil.valid_ip(host_name):
         raise RuntimeError("IP address not allowed as a hostname")
 
-    system_host_name = socket.gethostname()
-    if not (host_name + '.').startswith(system_host_name + '.'):
-        print "Warning: The host name '%s' does not match the system host name '%s'." % (host_name, system_host_name)
-        print "         Some services may not work properly."
+    if system_name_check:
+        system_host_name = socket.gethostname()
+        if not (host_name + '.').startswith(system_host_name + '.'):
+            print "Warning: The host name '%s' does not match the system host name '%s'." % (host_name, system_host_name)
+            print "         Some services may not work properly."
 
     if no_host_dns:
         print "Warning: skipping DNS resolution of host", host_name
-- 
1.7.6.2

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

Reply via email to