From 99288c496db818f88c85e2f58c5e7782105e53e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.bernigaud@opensides.be>
Date: Tue, 22 Mar 2016 10:49:32 +0100
Subject: [PATCH] Fixes #4634 Fixed migrate-dns for PTR records

---
 contrib/bin/fusiondirectory-setup | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/contrib/bin/fusiondirectory-setup b/contrib/bin/fusiondirectory-setup
index 4a50345cd..b04770f6e 100644
--- a/contrib/bin/fusiondirectory-setup
+++ b/contrib/bin/fusiondirectory-setup
@@ -1363,7 +1363,27 @@ sub migrate_dns {
           $result->code && die "Migration of DNS zone subentry failed, LDAP error: ".$result->error."\n";
         }
 
+        # Fix reverse zone PTR records DNs
+        $mesg = $ldap->search(
+          base    => $zoneDn,
+          filter  => "(&(objectClass=dNSZone)(!(relativeDomainName=@))(|(zoneName=*.arpa)(zoneName=*.arpa.)))"
+        );
+        $mesg->code && die $mesg->error;
+
+        @entries = $mesg->entries;
+
+        foreach my $entry (@entries) {
+          $entry->dn() =~ m/^([^,]+),(relativeDomainName=[^,]+),([^,]+,$zoneDn)$/ or next;
+          $result = $ldap->moddn (
+            $entry->dn(),
+            newrdn        => $1,
+            deleteoldrdn  => '1',
+            newsuperior   => $2
+          );
+          $result->code && die "Migration of DNS reverse zone subentry ".$entry->dn()." failed, LDAP error: ".$result->error."\n";
+        }
 
+        # Add DNS tab on server
         $mesg = $ldap->search(
           base    => $systemdn,
           scope   => 'base',
-- 
GitLab