andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 4 months ago
Clone
Blob Blame History Raw
From 4bd0b7b1fe8fb970d3a17d971033822d404835da Mon Sep 17 00:00:00 2001
From: William Brown <firstyear@redhat.com>
Date: Thu, 26 Nov 2015 13:11:17 +1000
Subject: [PATCH 371/375] Ticket 48332 - allow users to specify to relax the
 FQDN constraint

Bug Description:  There are situations when the machine name for ds may not
match the dns name. In these cases we should allow installation without the
strict hostname checks we carry out.

Fix Description:  Add a new option, General.StrictHostCheck which defaults
to true. If true, host name checking is carried out. If false, it is disabled
and any hostname in General.FullMachineName is considered valid.

https://fedorahosted.org/389/ticket/48332

Author: wibrown

Review by: rmeggins (Thanks!)

(cherry picked from commit 026956c7e3b4dc00b6738f9a195e6653fed03d79)
(cherry picked from commit 5d0f57335c1bf97529849d5d47cad769083052d0)
(cherry picked from commit e62ef7f4d19d78d015efa915f7740f4d8b615da4)
(cherry picked from commit 3f2ea36e763c8e08b88265bd365c6daa5081419c)
---
 ldap/admin/src/scripts/DSCreate.pm.in | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
index b7f9498..dbfcedf 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -150,9 +150,18 @@ sub sanityCheckParams {
         debug(0, "WARNING: The root password is less than 8 characters long.  You should choose a longer one.\n");
     }
 
-    if (@errs = checkHostname($inf->{General}->{FullMachineName}, 0)) {
-        debug(1, @errs);
-        return @errs;
+    $inf->{General}->{StrictHostCheck} = lc $inf->{General}->{StrictHostCheck};
+
+    if ("true" ne $inf->{General}->{StrictHostCheck} && "false" ne $inf->{General}->{StrictHostCheck}) {
+        debug(1, "StrictHostCheck is not a valid boolean");
+        return ('error_invalid_boolean', $inf->{General}->{StrictHostCheck});
+    }
+
+    if ($inf->{General}->{StrictHostCheck} eq "true" ) {
+        if (@errs = checkHostname($inf->{General}->{FullMachineName}, 0)) {
+            debug(1, @errs);
+            return @errs;
+        }
     }
 
     return ();
@@ -888,6 +897,10 @@ sub setDefaults {
                                                   "@datadir@",
                                                   $inf->{General}->{prefix});
 
+    if (!defined($inf->{General}->{StrictHostCheck})) {
+        $inf->{General}->{StrictHostCheck} = "true";
+    }
+
     if (!defined($inf->{slapd}->{inst_dir})) {
         $inf->{slapd}->{inst_dir} = "$inf->{General}->{ServerRoot}/slapd-$servid";
     }
-- 
2.4.3