andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
Blob Blame History Raw
From 83f2b13037731f09e0e1db4d586d6afffb6bd536 Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Thu, 6 Aug 2020 14:50:19 -0400
Subject: [PATCH 2/5] Issue 51233 - ds-replcheck crashes in offline mode

Bug Description:  When processing all the DN's found in the Master LDIF
                  it is possible that the LDIF is not in the expected
                  order and ldifsearch fails (crashing the tool).

Fix Description:  If ldifsearch does not find an entry, start from the
                  beginning of the LDIF and try again.

relates: https://pagure.io/389-ds-base/issue/51233

Reviewed by: spichugi(Thanks!)
---
 ldap/admin/src/scripts/ds-replcheck | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ldap/admin/src/scripts/ds-replcheck b/ldap/admin/src/scripts/ds-replcheck
index aea32fdb4..eef68e174 100755
--- a/ldap/admin/src/scripts/ds-replcheck
+++ b/ldap/admin/src/scripts/ds-replcheck
@@ -637,6 +637,10 @@ def do_offline_report(opts, output_file=None):
     missing = False
     for dn in master_dns:
         mresult = ldif_search(MLDIF, dn)
+        if mresult['entry'] is None and mresult['conflict'] is None and not mresult['tombstone']:
+            # Try from the beginning
+            MLDIF.seek(0)
+            mresult = ldif_search(MLDIF, dn)
         rresult = ldif_search(RLDIF, dn)
 
         if dn in replica_dns:
-- 
2.26.2