replica-manage: fail nicely when DM psswd required

Some commands do not allow anonymous bind and would fail with
misleading message.

https://fedorahosted.org/freeipa/ticket/4987

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Stanislav Laznicka 2016-04-15 13:22:25 +02:00 committed by Martin Basti
parent 3d07c889ce
commit 37865aa1d7

View File

@ -68,6 +68,9 @@ commands = {
"dnanextrange-set":(2, 2, "<master fqdn> <range>", "must provide a master and ID range"),
}
# tuple of commands that need proper Directory Manager password
dirman_passwd_req_commands = ("list-ruv", "clean-ruv", "abort-clean-ruv")
def parse_options():
parser = IPAOptionParser(version=version.VERSION)
@ -1564,7 +1567,8 @@ def main(options, args):
if not test_connection(realm, host, options.nolookup):
dirman_passwd = installutils.read_password("Directory Manager",
confirm=False, validate=False, retry=False)
if dirman_passwd is None:
if dirman_passwd is None or (
not dirman_passwd and args[0] in dirman_passwd_req_commands):
sys.exit("Directory Manager password required")
options.dirman_passwd = dirman_passwd