Add possibility to enter password with a prompt
Benjamin Renard

Benjamin Renard commited on 2016-06-28 21:54:44
Showing 1 changed files, with 5 additions and 1 deletions.

... ...
@@ -39,6 +39,7 @@ import ldap
39 39
 import ldap.modlist as modlist
40 40
 import logging
41 41
 import sys
42
+import getpass
42 43
 
43 44
 from optparse import OptionParser
44 45
 
... ...
@@ -68,7 +69,7 @@ parser.add_option(	"-P", "--pwd",
68 69
 			dest="pwd",
69 70
 			action="store",
70 71
 			type='string',
71
-			help="LDAP bind password")
72
+			help="LDAP bind password. Specify '-P -' to ask for a prompt.")
72 73
 
73 74
 parser.add_option(	"-b", "--basedn",
74 75
 			dest="basedn",
... ...
@@ -153,6 +154,9 @@ if options.touch and not options.attrs:
153 154
 	logging.info('Force option attrs on touch mode')
154 155
 	options.attrs=True
155 156
 
157
+if options.pwd == '-':
158
+	options.pwd=getpass.getpass()
159
+
156 160
 excl_attrs=[]
157 161
 if options.excl_attrs:
158 162
 	for ex in options.excl_attrs.split(','):
159 163