From f90a4b9554656c984c8ac47e3503d83fb52d0b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Tue, 12 Mar 2019 22:30:39 +0100 Subject: [PATCH] ipa-{server,replica}-install: add too-restritive mask detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the mask used during the installation is "too restrictive", ie.0027, installing FreeIPA results in a broken server or replica. Check for too-restrictive mask at install time and error out. Fixes: https://pagure.io/freeipa/issue/7193 Signed-off-by: François Cami Reviewed-By: Florence Blanc-Renaud --- ipaserver/install/installutils.py | 11 +++++++++++ ipaserver/install/server/install.py | 12 +++++++++++- ipaserver/install/server/replicainstall.py | 7 ++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 5408cf4e2..03b29c27d 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -1389,3 +1389,14 @@ def default_subject_base(realm_name): def default_ca_subject_dn(subject_base): return DN(('CN', 'Certificate Authority'), subject_base) + + +def validate_mask(): + try: + mask = os.umask(0) + finally: + os.umask(mask) + mask_str = None + if mask & 0b111101101 > 0: + mask_str = "{:04o}".format(mask) + return mask_str diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py index b4c57752f..04c9f3adc 100644 --- a/ipaserver/install/server/install.py +++ b/ipaserver/install/server/install.py @@ -42,7 +42,7 @@ from ipaserver.install import ( from ipaserver.install.installutils import ( IPA_MODULES, BadHostError, get_fqdn, get_server_ip_address, is_ipa_configured, load_pkcs12, read_password, verify_fqdn, - update_hosts_file) + update_hosts_file, validate_mask) if six.PY3: unicode = str @@ -316,6 +316,16 @@ def install_check(installer): tasks.check_selinux_status() check_ldap_conf() + mask_str = validate_mask() + if mask_str: + print("Unexpected system mask: %s, expected 0022" % mask_str) + if installer.interactive: + if not user_input("Do you want to continue anyway?", True): + raise ScriptError( + "Unexpected system mask: %s" % mask_str) + else: + raise ScriptError("Unexpected system mask: %s" % mask_str) + if options.master_password: msg = ("WARNING:\noption '-P/--master-password' is deprecated. " "KDC master password of sufficient strength is autogenerated " diff --git a/ipaserver/install/server/replicainstall.py b/ipaserver/install/server/replicainstall.py index d0155fac8..35f443a6f 100644 --- a/ipaserver/install/server/replicainstall.py +++ b/ipaserver/install/server/replicainstall.py @@ -41,7 +41,7 @@ from ipaserver.install import ( adtrust, bindinstance, ca, dns, dsinstance, httpinstance, installutils, kra, krbinstance, otpdinstance, custodiainstance, service) from ipaserver.install.installutils import ( - ReplicaConfig, load_pkcs12, is_ipa_configured) + ReplicaConfig, load_pkcs12, is_ipa_configured, validate_mask) from ipaserver.install.replication import ( ReplicationManager, replica_conn_check) from ipaserver.masters import find_providing_servers, find_providing_server @@ -570,6 +570,11 @@ def common_check(no_ntp): tasks.check_selinux_status() check_ldap_conf() + mask_str = validate_mask() + if mask_str: + raise ScriptError( + "Unexpected system mask: %s, expected 0022" % mask_str) + if is_ipa_configured(): raise ScriptError( "IPA server is already configured on this system.\n"