pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0031-ipa-client-automount-handle-NFS-configuration-file-c.patch

b01884
From c69875c8afdd877baf7139c0cd5241f70105cbd4 Mon Sep 17 00:00:00 2001
b01884
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
b01884
Date: Tue, 26 Feb 2019 13:59:06 +0100
b01884
Subject: [PATCH] ipa-client-automount: handle NFS configuration file changes
b01884
MIME-Version: 1.0
b01884
Content-Type: text/plain; charset=UTF-8
b01884
Content-Transfer-Encoding: 8bit
b01884
b01884
nfs-utils in Fedora 30 and later switched its configuration
b01884
file from /etc/sysconfig/nfs to /etc/nfs.conf, providing a
b01884
conversion service (nfs-convert.service) for upgrades.
b01884
However, for new installs the original configuration file
b01884
is missing. This change:
b01884
* adds a tuple-based osinfo.version_number method to handle
b01884
  more kinds of OS versioning schemes
b01884
* detects RHEL and Fedora versions with the the new nfs-utils
b01884
  behavior
b01884
* avoids backing up the new NFS configuration file as we do
b01884
  not have to modify it.
b01884
b01884
See: https://bugzilla.redhat.com/show_bug.cgi?id=1676981
b01884
b01884
Fixes: https://pagure.io/freeipa/issue/7868
b01884
Signed-off-by: François Cami <fcami@redhat.com>
b01884
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
b01884
Reviewed-By: Christian Heimes <cheimes@redhat.com>
b01884
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
b01884
---
b01884
 client/ipa-client-automount.in  | 18 ++++++++++--------
b01884
 ipaplatform/fedora/constants.py |  9 ++++++++-
b01884
 ipaplatform/fedora/paths.py     |  3 +++
b01884
 ipaplatform/fedora/services.py  |  2 +-
b01884
 ipaplatform/osinfo.py           |  9 +++++++++
b01884
 ipaplatform/rhel/constants.py   |  7 +++++++
b01884
 ipaplatform/rhel/paths.py       |  4 +++-
b01884
 7 files changed, 41 insertions(+), 11 deletions(-)
b01884
b01884
diff --git a/client/ipa-client-automount.in b/client/ipa-client-automount.in
b01884
index 15926bd..f9eda9c 100755
b01884
--- a/client/ipa-client-automount.in
b01884
+++ b/client/ipa-client-automount.in
b01884
@@ -335,14 +335,16 @@ def configure_nfs(fstore, statestore):
b01884
     """
b01884
     Configure secure NFS
b01884
     """
b01884
-    replacevars = {
b01884
-        constants.SECURE_NFS_VAR: 'yes',
b01884
-    }
b01884
-    ipautil.backup_config_and_replace_variables(fstore,
b01884
-        paths.SYSCONFIG_NFS, replacevars=replacevars)
b01884
-    tasks.restore_context(paths.SYSCONFIG_NFS)
b01884
-
b01884
-    print("Configured %s" % paths.SYSCONFIG_NFS)
b01884
+    # Newer Fedora releases ship /etc/nfs.conf instead of /etc/sysconfig/nfs
b01884
+    # and do not require changes there. On these, SECURE_NFS_VAR == None
b01884
+    if constants.SECURE_NFS_VAR:
b01884
+        replacevars = {
b01884
+            constants.SECURE_NFS_VAR: 'yes',
b01884
+        }
b01884
+        ipautil.backup_config_and_replace_variables(fstore,
b01884
+            paths.SYSCONFIG_NFS, replacevars=replacevars)
b01884
+        tasks.restore_context(paths.SYSCONFIG_NFS)
b01884
+        print("Configured %s" % paths.SYSCONFIG_NFS)
b01884
 
b01884
     # Prepare the changes
b01884
     # We need to use IPAChangeConf as simple regexp substitution
b01884
diff --git a/ipaplatform/fedora/constants.py b/ipaplatform/fedora/constants.py
b01884
index d48696e..744b30a 100644
b01884
--- a/ipaplatform/fedora/constants.py
b01884
+++ b/ipaplatform/fedora/constants.py
b01884
@@ -10,6 +10,12 @@ This Fedora base platform module exports platform related constants.
b01884
 from __future__ import absolute_import
b01884
 
b01884
 from ipaplatform.redhat.constants import RedHatConstantsNamespace
b01884
+from ipaplatform.osinfo import osinfo
b01884
+
b01884
+# Fedora 28 and earlier use /etc/sysconfig/nfs
b01884
+# Fedora 30 and later use /etc/nfs.conf
b01884
+# Fedora 29 has both
b01884
+HAS_NFS_CONF = osinfo.version_number >= (30,)
b01884
 
b01884
 
b01884
 class FedoraConstantsNamespace(RedHatConstantsNamespace):
b01884
@@ -22,6 +28,7 @@ class FedoraConstantsNamespace(RedHatConstantsNamespace):
b01884
     # secure remote password, and DSA cert authentication.
b01884
     # see https://fedoraproject.org/wiki/Changes/CryptoPolicy
b01884
     TLS_HIGH_CIPHERS = "PROFILE=SYSTEM:!3DES:!PSK:!SRP:!aDSS"
b01884
-
b01884
+    if HAS_NFS_CONF:
b01884
+        SECURE_NFS_VAR = None
b01884
 
b01884
 constants = FedoraConstantsNamespace()
b01884
diff --git a/ipaplatform/fedora/paths.py b/ipaplatform/fedora/paths.py
b01884
index a9bdedf..4e993c0 100644
b01884
--- a/ipaplatform/fedora/paths.py
b01884
+++ b/ipaplatform/fedora/paths.py
b01884
@@ -26,6 +26,7 @@ in Fedora-based systems.
b01884
 from __future__ import absolute_import
b01884
 
b01884
 from ipaplatform.redhat.paths import RedHatPathNamespace
b01884
+from ipaplatform.fedora.constants import HAS_NFS_CONF
b01884
 
b01884
 
b01884
 class FedoraPathNamespace(RedHatPathNamespace):
b01884
@@ -33,6 +34,8 @@ class FedoraPathNamespace(RedHatPathNamespace):
b01884
         "/etc/httpd/conf.modules.d/02-ipa-wsgi.conf"
b01884
     )
b01884
     NAMED_CRYPTO_POLICY_FILE = "/etc/crypto-policies/back-ends/bind.config"
b01884
+    if HAS_NFS_CONF:
b01884
+        SYSCONFIG_NFS = '/etc/nfs.conf'
b01884
 
b01884
 
b01884
 paths = FedoraPathNamespace()
b01884
diff --git a/ipaplatform/fedora/services.py b/ipaplatform/fedora/services.py
b01884
index 5ff64f1..543cb1b 100644
b01884
--- a/ipaplatform/fedora/services.py
b01884
+++ b/ipaplatform/fedora/services.py
b01884
@@ -34,7 +34,7 @@ fedora_system_units = redhat_services.redhat_system_units.copy()
b01884
 # Fedora 28 and earlier have fedora-domainname.service. Starting from
b01884
 # Fedora 29, the service is called nis-domainname.service as defined in
b01884
 # ipaplatform.redhat.services.
b01884
-HAS_FEDORA_DOMAINNAME_SERVICE = int(osinfo.version_id) <= 28
b01884
+HAS_FEDORA_DOMAINNAME_SERVICE = osinfo.version_number <= (28,)
b01884
 
b01884
 if HAS_FEDORA_DOMAINNAME_SERVICE:
b01884
     fedora_system_units['domainname'] = 'fedora-domainname.service'
b01884
diff --git a/ipaplatform/osinfo.py b/ipaplatform/osinfo.py
b01884
index a38165d..35b024e 100644
b01884
--- a/ipaplatform/osinfo.py
b01884
+++ b/ipaplatform/osinfo.py
b01884
@@ -178,6 +178,15 @@ class OSInfo(Mapping):
b01884
         return self._info.get('VERSION_ID')
b01884
 
b01884
     @property
b01884
+    def version_number(self):
b01884
+        """Version number tuple based on version_id
b01884
+        """
b01884
+        version_id = self._info.get('VERSION_ID')
b01884
+        if not version_id:
b01884
+            return ()
b01884
+        return tuple(int(p) for p in version_id.split('.'))
b01884
+
b01884
+    @property
b01884
     def platform_ids(self):
b01884
         """Ordered tuple of detected platforms (including override)
b01884
         """
b01884
diff --git a/ipaplatform/rhel/constants.py b/ipaplatform/rhel/constants.py
b01884
index 72335ac..073e332 100644
b01884
--- a/ipaplatform/rhel/constants.py
b01884
+++ b/ipaplatform/rhel/constants.py
b01884
@@ -10,10 +10,17 @@ This RHEL base platform module exports platform related constants.
b01884
 from __future__ import absolute_import
b01884
 
b01884
 from ipaplatform.redhat.constants import RedHatConstantsNamespace
b01884
+from ipaplatform.osinfo import osinfo
b01884
+
b01884
+# RHEL 7 and earlier use /etc/sysconfig/nfs
b01884
+# RHEL 8 uses /etc/nfs.conf
b01884
+HAS_NFS_CONF = osinfo.version_number >= (8,)
b01884
 
b01884
 
b01884
 class RHELConstantsNamespace(RedHatConstantsNamespace):
b01884
     IPA_ADTRUST_PACKAGE_NAME = "ipa-server-trust-ad"
b01884
     IPA_DNS_PACKAGE_NAME = "ipa-server-dns"
b01884
+    if HAS_NFS_CONF:
b01884
+        SECURE_NFS_VAR = None
b01884
 
b01884
 constants = RHELConstantsNamespace()
b01884
diff --git a/ipaplatform/rhel/paths.py b/ipaplatform/rhel/paths.py
b01884
index d8b64ab..c081ada 100644
b01884
--- a/ipaplatform/rhel/paths.py
b01884
+++ b/ipaplatform/rhel/paths.py
b01884
@@ -26,10 +26,12 @@ in RHEL-based systems.
b01884
 from __future__ import absolute_import
b01884
 
b01884
 from ipaplatform.redhat.paths import RedHatPathNamespace
b01884
+from ipaplatform.rhel.constants import HAS_NFS_CONF
b01884
 
b01884
 
b01884
 class RHELPathNamespace(RedHatPathNamespace):
b01884
-    pass
b01884
+    if HAS_NFS_CONF:
b01884
+        SYSCONFIG_NFS = '/etc/nfs.conf'
b01884
 
b01884
 
b01884
 paths = RHELPathNamespace()
b01884
-- 
b01884
2.9.3
b01884