summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorTomas Babej <tbabej@redhat.com>2014-05-27 13:11:00 +0200
committerPetr Viktorin <pviktori@redhat.com>2014-06-16 19:48:18 +0200
commita7c2327a366d2dfbbdde5362e957fad23e233105 (patch)
treee031f0c11896def6e9f3a8bc70b1a7aedaf7ec2e /ipapython
parent3edfabb4c45ed44c4e8b6cd1dff44c20867ded80 (diff)
downloadfreeipa-a7c2327a366d2dfbbdde5362e957fad23e233105.tar.gz
freeipa-a7c2327a366d2dfbbdde5362e957fad23e233105.tar.xz
freeipa-a7c2327a366d2dfbbdde5362e957fad23e233105.zip
ipaplatform: Move Fedora-specific implementations of tasks to fedora base platform file
https://fedorahosted.org/freeipa/ticket/4052 Reviewed-By: Petr Viktorin <pviktori@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/platform/fedora18/__init__.py57
-rw-r--r--ipapython/platform/fedora19/__init__.py48
2 files changed, 0 insertions, 105 deletions
diff --git a/ipapython/platform/fedora18/__init__.py b/ipapython/platform/fedora18/__init__.py
index b7963c78e..f68c08390 100644
--- a/ipapython/platform/fedora18/__init__.py
+++ b/ipapython/platform/fedora18/__init__.py
@@ -50,63 +50,6 @@ __all__ = ['authconfig', 'service', 'knownservices',
# Just copy a referential list of timedate services
timedate_services = list(base.timedate_services)
-def backup_and_replace_hostname(fstore, statestore, hostname):
- old_hostname = socket.gethostname()
- try:
- ipautil.run(['/bin/hostname', hostname])
- except ipautil.CalledProcessError, e:
- print >>sys.stderr, "Failed to set this machine hostname to %s (%s)." % (hostname, str(e))
-
- filepath = '/etc/hostname'
- if os.path.exists(filepath):
- # read old hostname
- with open(filepath, 'r') as f:
- for line in f.readlines():
- line = line.strip()
- if not line or line.startswith('#'):
- # skip comment or empty line
- continue
- old_hostname = line
- break
- fstore.backup_file(filepath)
-
- with open(filepath, 'w') as f:
- f.write("%s\n" % hostname)
- os.chmod(filepath, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
- os.chown(filepath, 0, 0)
- restore_context(filepath)
-
- # store old hostname
- statestore.backup_state('network', 'hostname', old_hostname)
-
-def restore_network_configuration(fstore, statestore):
- old_filepath = '/etc/sysconfig/network'
- old_hostname = statestore.get_state('network', 'hostname')
- hostname_was_configured = False
-
- if fstore.has_file(old_filepath):
- # This is Fedora >=18 instance that was upgraded from previous
- # Fedora version which held network configuration
- # in /etc/sysconfig/network
- old_filepath_restore = '/etc/sysconfig/network.ipabkp'
- fstore.restore_file(old_filepath, old_filepath_restore)
- print "Deprecated configuration file '%s' was restored to '%s'" \
- % (old_filepath, old_filepath_restore)
- hostname_was_configured = True
-
- filepath = '/etc/hostname'
- if fstore.has_file(filepath):
- fstore.restore_file(filepath)
- hostname_was_configured = True
-
- if not hostname_was_configured and old_hostname:
- # hostname was not configured before but was set by IPA. Delete
- # /etc/hostname to restore previous configuration
- try:
- os.remove(filepath)
- except OSError:
- pass
-
authconfig = fedora16.authconfig
service = fedora16.service
knownservices = fedora16.knownservices
diff --git a/ipapython/platform/fedora19/__init__.py b/ipapython/platform/fedora19/__init__.py
index 9b931625b..0981f4ff4 100644
--- a/ipapython/platform/fedora19/__init__.py
+++ b/ipapython/platform/fedora19/__init__.py
@@ -70,51 +70,3 @@ service = fedora18.service
knownservices = fedora18.knownservices
restore_context = fedora18.restore_context
check_selinux_status = fedora18.check_selinux_status
-
-systemwide_ca_store = '/etc/pki/ca-trust/source/anchors/'
-
-
-def insert_ca_cert_into_systemwide_ca_store(cacert_path):
- # Add the 'ipa-' prefix to cert name to avoid name collisions
- cacert_name = os.path.basename(cacert_path)
- new_cacert_path = os.path.join(systemwide_ca_store, 'ipa-%s' % cacert_name)
-
- # Add the CA to the systemwide CA trust database
- try:
- shutil.copy(cacert_path, new_cacert_path)
- run(['/usr/bin/update-ca-trust'])
- except OSError, e:
- root_logger.info("Failed to copy %s to %s" % (cacert_path,
- new_cacert_path))
- except CalledProcessError, e:
- root_logger.info("Failed to add CA to the systemwide "
- "CA trust database: %s" % str(e))
- else:
- root_logger.info('Added the CA to the systemwide CA trust database.')
- return True
-
- return False
-
-
-def remove_ca_cert_from_systemwide_ca_store(cacert_path):
- # Derive the certificate name in the store
- cacert_name = os.path.basename(cacert_path)
- new_cacert_path = os.path.join(systemwide_ca_store, 'ipa-%s' % cacert_name)
-
- # Remove CA cert from systemwide store
- if os.path.exists(new_cacert_path):
- try:
- os.remove(new_cacert_path)
- run(['/usr/bin/update-ca-trust'])
- except OSError, e:
- root_logger.error('Could not remove: %s, %s'
- % (new_cacert_path, str(e)))
- return False
- except CalledProcessError, e:
- root_logger.error('Could not update systemwide CA trust '
- 'database: %s' % str(e))
- return False
- else:
- root_logger.info('Systemwide CA database updated.')
-
- return True