Add possibility to enter password with a prompt

This commit is contained in:
Benjamin Renard 2016-06-28 23:54:44 +02:00
parent 07048d3e26
commit 49337ceeed

View file

@ -39,6 +39,7 @@ import ldap
import ldap.modlist as modlist import ldap.modlist as modlist
import logging import logging
import sys import sys
import getpass
from optparse import OptionParser from optparse import OptionParser
@ -68,7 +69,7 @@ parser.add_option( "-P", "--pwd",
dest="pwd", dest="pwd",
action="store", action="store",
type='string', type='string',
help="LDAP bind password") help="LDAP bind password. Specify '-P -' to ask for a prompt.")
parser.add_option( "-b", "--basedn", parser.add_option( "-b", "--basedn",
dest="basedn", dest="basedn",
@ -153,6 +154,9 @@ if options.touch and not options.attrs:
logging.info('Force option attrs on touch mode') logging.info('Force option attrs on touch mode')
options.attrs=True options.attrs=True
if options.pwd == '-':
options.pwd=getpass.getpass()
excl_attrs=[] excl_attrs=[]
if options.excl_attrs: if options.excl_attrs:
for ex in options.excl_attrs.split(','): for ex in options.excl_attrs.split(','):