validate mutually exclusive options in vault-add

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

Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Petr Vobornik 2015-08-12 11:07:22 +02:00 committed by Tomas Babej
parent 196ef09bd2
commit 7d7ffb6252

View File

@ -597,6 +597,18 @@ class vault_add(PKQuery, Local):
if 'public_key_file' in options:
del options['public_key_file']
if vault_type != u'symmetric' and (password or password_file):
raise errors.MutuallyExclusiveError(
reason=_('Password can be specified only for '
'symmetric vault')
)
if vault_type != u'asymmetric' and (public_key or public_key_file):
raise errors.MutuallyExclusiveError(
reason=_('Public key can be specified only for '
'asymmetric vault')
)
if self.api.env.in_server:
backend = self.api.Backend.ldap2
else: