summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-10-13 17:58:27 -0400
committerRob Crittenden <rcritten@redhat.com>2011-10-13 01:01:44 -0400
commit77fdf6f7c72621127ca535722557b11c6c299086 (patch)
tree5c5b9a5834ecc1ffc6916b8b6ead2329123b8b4e
parent363c23a37c3631a0fb16df6b88bd5138677b818a (diff)
downloadfreeipa-77fdf6f7c72621127ca535722557b11c6c299086.zip
freeipa-77fdf6f7c72621127ca535722557b11c6c299086.tar.gz
freeipa-77fdf6f7c72621127ca535722557b11c6c299086.tar.xz
Save the value of hostname even if it doesn't appear in /etc/sysconfig/network
https://fedorahosted.org/freeipa/ticket/1871
-rw-r--r--ipapython/platform/redhat.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/ipapython/platform/redhat.py b/ipapython/platform/redhat.py
index 9825ddf..5ac3106 100644
--- a/ipapython/platform/redhat.py
+++ b/ipapython/platform/redhat.py
@@ -23,6 +23,7 @@ import re
import os
import stat
import sys
+import socket
from ipapython import ipautil
from ipapython.platform import base
@@ -133,6 +134,7 @@ def restore_context(filepath):
ipautil.run(["/sbin/restorecon", filepath], raiseonerr=False)
def backup_and_replace_hostname(fstore, statestore, hostname):
+ old_hostname = socket.gethostname()
try:
ipautil.run(['/bin/hostname', hostname])
except ipautil.CalledProcessError, e:
@@ -144,4 +146,5 @@ def backup_and_replace_hostname(fstore, statestore, hostname):
restore_context("/etc/sysconfig/network")
if 'HOSTNAME' in old_values:
statestore.backup_state('network', 'hostname', old_values['HOSTNAME'])
-
+ else:
+ statestore.backup_state('network', 'hostname', old_hostname)