+

Add possibility to enter password with a prompt

Benjamin Renard [2016-06-28 21:54:44]
Add possibility to enter password with a prompt
Filename
check_syncrepl_extended
diff --git a/check_syncrepl_extended b/check_syncrepl_extended
index 2909e57..5f65785 100755
--- a/check_syncrepl_extended
+++ b/check_syncrepl_extended
@@ -39,6 +39,7 @@ import ldap
 import ldap.modlist as modlist
 import logging
 import sys
+import getpass

 from optparse import OptionParser

@@ -68,7 +69,7 @@ parser.add_option(	"-P", "--pwd",
 			dest="pwd",
 			action="store",
 			type='string',
-			help="LDAP bind password")
+			help="LDAP bind password. Specify '-P -' to ask for a prompt.")

 parser.add_option(	"-b", "--basedn",
 			dest="basedn",
@@ -153,6 +154,9 @@ if options.touch and not options.attrs:
 	logging.info('Force option attrs on touch mode')
 	options.attrs=True

+if options.pwd == '-':
+	options.pwd=getpass.getpass()
+
 excl_attrs=[]
 if options.excl_attrs:
 	for ex in options.excl_attrs.split(','):
ViewGit