pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0056-validate-mutually-exclusive-options-in-vault-add.patch

590d18
From 97f52ad53a6284b20e275e8ae28c599d96fc0b30 Mon Sep 17 00:00:00 2001
590d18
From: Petr Vobornik <pvoborni@redhat.com>
590d18
Date: Wed, 12 Aug 2015 11:07:22 +0200
590d18
Subject: [PATCH] validate mutually exclusive options in vault-add
590d18
590d18
https://fedorahosted.org/freeipa/ticket/5195
590d18
590d18
Reviewed-By: Tomas Babej <tbabej@redhat.com>
590d18
---
590d18
 ipalib/plugins/vault.py | 12 ++++++++++++
590d18
 1 file changed, 12 insertions(+)
590d18
590d18
diff --git a/ipalib/plugins/vault.py b/ipalib/plugins/vault.py
590d18
index fe4eec325dde4a9ecd8a7ce5af1a124fc5c6a9ae..055e8d00f1616c15b217e7570eeedd46efba7c81 100644
590d18
--- a/ipalib/plugins/vault.py
590d18
+++ b/ipalib/plugins/vault.py
590d18
@@ -597,6 +597,18 @@ class vault_add(PKQuery, Local):
590d18
         if 'public_key_file' in options:
590d18
             del options['public_key_file']
590d18
 
590d18
+        if vault_type != u'symmetric' and (password or password_file):
590d18
+            raise errors.MutuallyExclusiveError(
590d18
+                reason=_('Password can be specified only for '
590d18
+                         'symmetric vault')
590d18
+            )
590d18
+
590d18
+        if vault_type != u'asymmetric' and (public_key or public_key_file):
590d18
+            raise errors.MutuallyExclusiveError(
590d18
+                reason=_('Public key can be specified only for '
590d18
+                         'asymmetric vault')
590d18
+            )
590d18
+
590d18
         if self.api.env.in_server:
590d18
             backend = self.api.Backend.ldap2
590d18
         else:
590d18
-- 
590d18
2.4.3
590d18