summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2011-10-13 12:16:15 +0200
committerRob Crittenden <rcritten@redhat.com>2011-10-13 00:54:41 -0400
commit77cc5e024601ae7be6ce706499d5f403c8b71408 (patch)
treeab34bdf61acf747f32ae52344bed0259a1f00692
parent9bff6cb8a955c3f4b167e05856b40f6e2ee5dca8 (diff)
downloadfreeipa-77cc5e024601ae7be6ce706499d5f403c8b71408.tar.gz
freeipa-77cc5e024601ae7be6ce706499d5f403c8b71408.tar.xz
freeipa-77cc5e024601ae7be6ce706499d5f403c8b71408.zip
Hostname used by IPA must be a system hostname
Make sure that the hostname IPA uses is a system hostname. If user passes a non-system hostname, update the network settings and system hostname in the same way that ipa-client-install does. This step should prevent various services failures which may not be ready to talk to IPA with non-system hostname. https://fedorahosted.org/freeipa/ticket/1931
-rwxr-xr-xinstall/tools/ipa-server-install23
-rw-r--r--install/tools/man/ipa-server-install.12
-rwxr-xr-xipa-client/ipa-install/ipa-client-install4
-rw-r--r--ipaserver/install/installutils.py5
4 files changed, 27 insertions, 7 deletions
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index 7839dbd9f..6d643883b 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -524,6 +524,14 @@ def uninstall():
ipaservices.knownservices.ipa.disable()
+ old_hostname = sstore.restore_state('network','hostname')
+ system_hostname = get_fqdn()
+ if old_hostname is not None and old_hostname != system_hostname:
+ try:
+ ipautil.run(['/bin/hostname', old_hostname])
+ except CalledProcessError, e:
+ print >>sys.stderr, "Failed to set this machine hostname back to %s (%s)." % (old_hostname, str(e))
+
# Now for some sanity checking. Make sure everything was really
# uninstalled.
serverids = dsinstance.check_existing_installation()
@@ -751,6 +759,15 @@ def main():
host_name = host_name.lower()
logging.debug("will use host_name: %s\n" % host_name)
+ system_hostname = get_fqdn()
+ if host_name != system_hostname:
+ print >>sys.stderr
+ print >>sys.stderr, "Warning: hostname %s does not match system hostname %s." \
+ % (host_name, system_hostname)
+ print >>sys.stderr, "System hostname will be updated during the installation process"
+ print >>sys.stderr, "to prevent service failures."
+ print >>sys.stderr
+
if not options.domain_name:
domain_name = read_domain_name(host_name[host_name.find(".")+1:], options.unattended)
logging.debug("read domain_name: %s\n" % domain_name)
@@ -871,6 +888,12 @@ def main():
print "Please wait until the prompt is returned."
print ""
+ if host_name != system_hostname:
+ logging.debug("Chosen hostname (%s) differs from system hostname (%s) - change it" \
+ % (host_name, system_hostname))
+ # configure /etc/sysconfig/network to contain the custom hostname
+ ipaservices.backup_and_replace_hostname(fstore, sstore, host_name)
+
# Create DS group if it doesn't exist yet
try:
grp.getgrnam(dsinstance.DS_GROUP)
diff --git a/install/tools/man/ipa-server-install.1 b/install/tools/man/ipa-server-install.1
index 7cc4983b8..920c13450 100644
--- a/install/tools/man/ipa-server-install.1
+++ b/install/tools/man/ipa-server-install.1
@@ -43,7 +43,7 @@ The kerberos master password (normally autogenerated)
The password for the IPA admin user
.TP
\fB\-\-hostname\fR=\fIHOST_NAME\fR
-The fully\-qualified DNS name of this server
+The fully\-qualified DNS name of this server. If the hostname does not match system hostname, the system hostname will be updated accordingly to prevent service failures.
.TP
\fB\-\-ip\-address\fR=\fIIP_ADDRESS\fR
The IP address of this server. If this address does not match the address the host resolves to and --setup-dns is not selected the installation will fail.
diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install
index dd9b43684..fd927d225 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -955,8 +955,10 @@ def install(options, env, fstore, statestore):
if not options.unattended and not user_input("Continue to configure the system with these values?", False):
return CLIENT_INSTALL_ERROR
- if options.hostname:
+ if options.hostname and not options.on_master:
# configure /etc/sysconfig/network to contain the hostname we set.
+ # skip this step when run by ipa-server-install as it always configures
+ # hostname if different from system hostname
ipaservices.backup_and_replace_hostname(fstore, statestore, options.hostname)
if not options.unattended:
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 14c43fef0..ea629e5ea 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -160,11 +160,6 @@ def verify_fqdn(host_name, no_host_dns=False, local_hostname=True):
except socket.gaierror:
pass
- 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
return