mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix directory manager password validation in ipa-nis-manage.
ticket 1283, 1284
This commit is contained in:
committed by
Martin Kosek
parent
645e55651e
commit
d2b483cbb3
@@ -62,7 +62,7 @@ def get_dirman_password():
|
|||||||
"""Prompt the user for the Directory Manager password and verify its
|
"""Prompt the user for the Directory Manager password and verify its
|
||||||
correctness.
|
correctness.
|
||||||
"""
|
"""
|
||||||
password = installutils.read_password("Directory Manager", confirm=False, validate=False)
|
password = installutils.read_password("Directory Manager", confirm=False, validate=False, retry=False)
|
||||||
|
|
||||||
return password
|
return password
|
||||||
|
|
||||||
@@ -101,11 +101,17 @@ def main():
|
|||||||
|
|
||||||
dirman_password = ""
|
dirman_password = ""
|
||||||
if options.password:
|
if options.password:
|
||||||
pw = ipautil.template_file(options.password, [])
|
try:
|
||||||
|
pw = ipautil.template_file(options.password, [])
|
||||||
|
except IOError:
|
||||||
|
sys.exit("File \"%s\" not found or not readable" % options.password)
|
||||||
dirman_password = pw.strip()
|
dirman_password = pw.strip()
|
||||||
else:
|
else:
|
||||||
dirman_password = get_dirman_password()
|
dirman_password = get_dirman_password()
|
||||||
|
|
||||||
|
if not dirman_password:
|
||||||
|
sys.exit("No password supplied")
|
||||||
|
|
||||||
api.bootstrap(context='cli', debug=options.debug)
|
api.bootstrap(context='cli', debug=options.debug)
|
||||||
api.finalize()
|
api.finalize()
|
||||||
|
|
||||||
|
|||||||
@@ -288,15 +288,18 @@ def get_password(prompt):
|
|||||||
else:
|
else:
|
||||||
return sys.stdin.readline().rstrip()
|
return sys.stdin.readline().rstrip()
|
||||||
|
|
||||||
def read_password(user, confirm=True, validate=True):
|
def read_password(user, confirm=True, validate=True, retry=True):
|
||||||
correct = False
|
correct = False
|
||||||
pwd = ""
|
pwd = ""
|
||||||
while not correct:
|
while not correct:
|
||||||
|
if not retry:
|
||||||
|
correct = True
|
||||||
pwd = get_password(user + " password: ")
|
pwd = get_password(user + " password: ")
|
||||||
if not pwd:
|
if not pwd:
|
||||||
continue
|
continue
|
||||||
if validate and len(pwd) < 8:
|
if validate and len(pwd) < 8:
|
||||||
print "Password must be at least 8 characters long"
|
print "Password must be at least 8 characters long"
|
||||||
|
pwd = ""
|
||||||
continue
|
continue
|
||||||
if not confirm:
|
if not confirm:
|
||||||
correct = True
|
correct = True
|
||||||
@@ -305,6 +308,7 @@ def read_password(user, confirm=True, validate=True):
|
|||||||
if pwd != pwd_confirm:
|
if pwd != pwd_confirm:
|
||||||
print "Password mismatch!"
|
print "Password mismatch!"
|
||||||
print ""
|
print ""
|
||||||
|
pwd = ""
|
||||||
else:
|
else:
|
||||||
correct = True
|
correct = True
|
||||||
print ""
|
print ""
|
||||||
|
|||||||
Reference in New Issue
Block a user