andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

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

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