zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone

Blame SOURCES/0074-Ticket-49566-ds-replcheck-needs-to-work-with-hidden-.patch

b045b9
From 22cf575ae7aea204c3e3974c645725a25f4e09e6 Mon Sep 17 00:00:00 2001
b045b9
From: Mark Reynolds <mreynolds@redhat.com>
b045b9
Date: Wed, 14 Feb 2018 20:25:34 -0500
b045b9
Subject: [PATCH] Ticket 49566 - ds-replcheck needs to work with hidden
b045b9
 conflict entries
b045b9
b045b9
Description:  Conflict entries are now hidden and the tool needs to account
b045b9
              for it.  The filter needs to include "objectclass=ldapsubentry"
b045b9
b045b9
              Added option to prompt for password, and cleaned up man page.
b045b9
b045b9
https://pagure.io/389-ds-base/issue/49566
b045b9
b045b9
Reviewed by: spichugi(Thanks!)
b045b9
b045b9
(cherry picked from commit 9e2009ae7105dda5493d4d60b20f15ffb369ab26)
b045b9
---
b045b9
 ldap/admin/src/scripts/ds-replcheck | 23 ++++++++++++++++-------
b045b9
 man/man1/ds-replcheck.1             | 14 +++++++++++---
b045b9
 2 files changed, 27 insertions(+), 10 deletions(-)
b045b9
b045b9
diff --git a/ldap/admin/src/scripts/ds-replcheck b/ldap/admin/src/scripts/ds-replcheck
b045b9
index 0b7e70ee8..45c4670a3 100755
b045b9
--- a/ldap/admin/src/scripts/ds-replcheck
b045b9
+++ b/ldap/admin/src/scripts/ds-replcheck
b045b9
@@ -14,6 +14,7 @@ import time
b045b9
 import ldap
b045b9
 import ldapurl
b045b9
 import argparse
b045b9
+import getpass
b045b9
 
b045b9
 from ldap.ldapobject import SimpleLDAPObject
b045b9
 from ldap.cidict import cidict
b045b9
@@ -878,14 +879,16 @@ def do_online_report(opts, output_file=None):
b045b9
     controls = [paged_ctrl]
b045b9
     req_pr_ctrl = controls[0]
b045b9
     try:
b045b9
-        master_msgid = master.search_ext(opts['suffix'], ldap.SCOPE_SUBTREE, "objectclass=*",
b045b9
+        master_msgid = master.search_ext(opts['suffix'], ldap.SCOPE_SUBTREE,
b045b9
+                                         "(|(objectclass=*)(objectclass=ldapsubentry))",
b045b9
                                          ['*', 'createtimestamp', 'nscpentrywsi', 'nsds5replconflict'],
b045b9
                                          serverctrls=controls)
b045b9
     except ldap.LDAPError as e:
b045b9
         print("Error: Failed to get Master entries: %s", str(e))
b045b9
         exit(1)
b045b9
     try:
b045b9
-        replica_msgid = replica.search_ext(opts['suffix'], ldap.SCOPE_SUBTREE, "objectclass=*",
b045b9
+        replica_msgid = replica.search_ext(opts['suffix'], ldap.SCOPE_SUBTREE,
b045b9
+                                           "(|(objectclass=*)(objectclass=ldapsubentry))",
b045b9
                                            ['*', 'createtimestamp', 'nscpentrywsi', 'nsds5replconflict'],
b045b9
                                            serverctrls=controls)
b045b9
     except ldap.LDAPError as e:
b045b9
@@ -928,7 +931,8 @@ def do_online_report(opts, output_file=None):
b045b9
                 if m_pctrls[0].cookie:
b045b9
                     # Copy cookie from response control to request control
b045b9
                     req_pr_ctrl.cookie = m_pctrls[0].cookie
b045b9
-                    master_msgid = master.search_ext(opts['suffix'], ldap.SCOPE_SUBTREE, "objectclass=*",
b045b9
+                    master_msgid = master.search_ext(opts['suffix'], ldap.SCOPE_SUBTREE,
b045b9
+                        "(|(objectclass=*)(objectclass=ldapsubentry))",
b045b9
                         ['*', 'createtimestamp', 'nscpentrywsi', 'nsds5replconflict'], serverctrls=controls)
b045b9
                 else:
b045b9
                     m_done = True  # No more pages available
b045b9
@@ -947,7 +951,8 @@ def do_online_report(opts, output_file=None):
b045b9
                 if r_pctrls[0].cookie:
b045b9
                     # Copy cookie from response control to request control
b045b9
                     req_pr_ctrl.cookie = r_pctrls[0].cookie
b045b9
-                    replica_msgid = replica.search_ext(opts['suffix'], ldap.SCOPE_SUBTREE, "objectclass=*",
b045b9
+                    replica_msgid = replica.search_ext(opts['suffix'], ldap.SCOPE_SUBTREE,
b045b9
+                        "(|(objectclass=*)(objectclass=ldapsubentry))",
b045b9
                         ['*', 'createtimestamp', 'nscpentrywsi', 'nsds5replconflict'], serverctrls=controls)
b045b9
                 else:
b045b9
                     r_done = True  # No more pages available
b045b9
@@ -976,8 +981,9 @@ def main():
b045b9
     parser = argparse.ArgumentParser(description=desc)
b045b9
     parser.add_argument('-v', '--verbose', help='Verbose output', action='store_true', default=False, dest='verbose')
b045b9
     parser.add_argument('-o', '--outfile', help='The output file', dest='file', default=None)
b045b9
-    parser.add_argument('-D', '--binddn', help='The Bind DN', dest='binddn', default="")
b045b9
-    parser.add_argument('-w', '--bindpw', help='The Bind password', dest='bindpw', default="")
b045b9
+    parser.add_argument('-D', '--binddn', help='The Bind DN', dest='binddn', default=None)
b045b9
+    parser.add_argument('-w', '--bindpw', help='The Bind password', dest='bindpw', default=None)
b045b9
+    parser.add_argument('-W', '--prompt', help='Prompt for the bind password', action='store_true', dest='prompt', default=False)
b045b9
     parser.add_argument('-m', '--master_url', help='The LDAP URL for the Master server (REQUIRED)',
b045b9
                         dest='murl', default=None)
b045b9
     parser.add_argument('-r', '--replica_url', help='The LDAP URL for the Replica server (REQUIRED)',
b045b9
@@ -1012,7 +1018,7 @@ def main():
b045b9
     elif (args.mldif is None and
b045b9
           (args.suffix is None or
b045b9
            args.binddn is None or
b045b9
-           args.bindpw is None or
b045b9
+           (args.bindpw is None and args.prompt is False) or
b045b9
            args.murl is None or
b045b9
            args.rurl is None)):
b045b9
             print("\n-------> Missing required options for online mode!\n")
b045b9
@@ -1098,6 +1104,9 @@ def main():
b045b9
             print("Can't open file: " + args.file)
b045b9
             exit(1)
b045b9
 
b045b9
+    if args.prompt:
b045b9
+        opts['bindpw'] = getpass.getpass('Enter password:')
b045b9
+
b045b9
     if opts['mldif'] is not None and opts['rldif'] is not None:
b045b9
         print ("Performing offline report...")
b045b9
         do_offline_report(opts, OUTPUT_FILE)
b045b9
diff --git a/man/man1/ds-replcheck.1 b/man/man1/ds-replcheck.1
b045b9
index 21b4802a5..3f14e11c8 100644
b045b9
--- a/man/man1/ds-replcheck.1
b045b9
+++ b/man/man1/ds-replcheck.1
b045b9
@@ -2,7 +2,7 @@
b045b9
 .\" First parameter, NAME, should be all caps
b045b9
 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
b045b9
 .\" other parameters are allowed: see man(7), man(1)
b045b9
-.TH DS-REPLCHECK 1 "May 2, 2017"
b045b9
+.TH DS-REPLCHECK 1 "Feb 14, 2018"
b045b9
 .\" Please adjust this date whenever revising the manpage.
b045b9
 .\"
b045b9
 .\" Some roff macros, for reference:
b045b9
@@ -19,7 +19,7 @@
b045b9
 ds-replcheck - Performs replication synchronization report between two replicas
b045b9
 
b045b9
 .SH SYNOPSIS
b045b9
-ds-replcheck [-h] [-o FILE] [-D BINDDN] [-w BINDPW] [-m MURL]
b045b9
+ds-replcheck [-h] [-o FILE] [-D BINDDN] [[-w BINDPW] [-W]] [-m MURL]
b045b9
              [-r RURL] [-b SUFFIX] [-l LAG] [-Z CERTDIR]
b045b9
              [-i IGNORE] [-p PAGESIZE] [-M MLDIF] [-R RLDIF]
b045b9
 
b045b9
@@ -41,6 +41,10 @@ The Directory Manager DN, or root DN.a (online mode)
b045b9
 .B \fB\-w\fR \fIPASSWORD\fR
b045b9
 The Directory Manager password (online mode)
b045b9
 .TP
b045b9
+.B \fB\-W\fR
b045b9
+.br
b045b9
+Prompt for the Directory Manager password (online mode)
b045b9
+.TP
b045b9
 .B \fB\-m\fR \fILDAP_URL\fR
b045b9
 The LDAP Url for the first replica (online mode)
b045b9
 .TP
b045b9
@@ -59,6 +63,10 @@ The directory containing a certificate database for StartTLS/SSL connections.  (
b045b9
 .B \fB\-i\fR \fIIGNORE LIST\fR
b045b9
 Comma separated list of attributes to ignore in the report  (online & offline)
b045b9
 .TP
b045b9
+.B \fB\-c\fR
b045b9
+.br
b045b9
+Display verbose conflict entry information
b045b9
+.TP
b045b9
 .B \fB\-M\fR \fILDIF FILE\fR
b045b9
 The LDIF file for the first replica  (offline mode)
b045b9
 .TP
b045b9
@@ -81,5 +89,5 @@ ds-replcheck was written by the 389 Project.
b045b9
 .SH "REPORTING BUGS"
b045b9
 Report bugs to https://pagure.io/389-ds-base/new_issue
b045b9
 .SH COPYRIGHT
b045b9
-Copyright \(co 2017 Red Hat, Inc.
b045b9
+Copyright \(co 2018 Red Hat, Inc.
b045b9
 
b045b9
-- 
b045b9
2.13.6
b045b9