|
|
ac7d03 |
From c1258d68268bc93536ba66921d65a2550bdf475e Mon Sep 17 00:00:00 2001
|
|
|
ac7d03 |
From: Stanislav Laznicka <slaznick@redhat.com>
|
|
|
ac7d03 |
Date: Tue, 9 May 2017 17:45:20 +0200
|
|
|
ac7d03 |
Subject: [PATCH] ca/cert-show: check certificate_out in options
|
|
|
ac7d03 |
|
|
|
ac7d03 |
If --certificate-out was specified on the command line, it will appear
|
|
|
ac7d03 |
among the options. If it was empty, it will be None.
|
|
|
ac7d03 |
|
|
|
ac7d03 |
This check was done properly in the ca plugin. Lets' just unify how this
|
|
|
ac7d03 |
is handled and improve user experience by announcing which option causes
|
|
|
ac7d03 |
the failure.
|
|
|
ac7d03 |
|
|
|
ac7d03 |
https://pagure.io/freeipa/issue/6885
|
|
|
ac7d03 |
|
|
|
ac7d03 |
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
|
|
|
ac7d03 |
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
|
|
|
ac7d03 |
---
|
|
|
ac7d03 |
ipaclient/plugins/ca.py | 8 ++++++--
|
|
|
ac7d03 |
ipaclient/plugins/cert.py | 12 +++++++++---
|
|
|
ac7d03 |
2 files changed, 15 insertions(+), 5 deletions(-)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
diff --git a/ipaclient/plugins/ca.py b/ipaclient/plugins/ca.py
|
|
|
ac7d03 |
index fcdf484635c7611d905f28629a380a0152c7bde1..fe9c55f4c07b4682de1ad882b6c5651dafece716 100644
|
|
|
ac7d03 |
--- a/ipaclient/plugins/ca.py
|
|
|
ac7d03 |
+++ b/ipaclient/plugins/ca.py
|
|
|
ac7d03 |
@@ -4,7 +4,7 @@
|
|
|
ac7d03 |
|
|
|
ac7d03 |
import base64
|
|
|
ac7d03 |
from ipaclient.frontend import MethodOverride
|
|
|
ac7d03 |
-from ipalib import util, x509, Str
|
|
|
ac7d03 |
+from ipalib import errors, util, x509, Str
|
|
|
ac7d03 |
from ipalib.plugable import Registry
|
|
|
ac7d03 |
from ipalib.text import _
|
|
|
ac7d03 |
|
|
|
ac7d03 |
@@ -26,7 +26,11 @@ class WithCertOutArgs(MethodOverride):
|
|
|
ac7d03 |
filename = None
|
|
|
ac7d03 |
if 'certificate_out' in options:
|
|
|
ac7d03 |
filename = options.pop('certificate_out')
|
|
|
ac7d03 |
- util.check_writable_file(filename)
|
|
|
ac7d03 |
+ try:
|
|
|
ac7d03 |
+ util.check_writable_file(filename)
|
|
|
ac7d03 |
+ except errors.FileError as e:
|
|
|
ac7d03 |
+ raise errors.ValidationError(name='certificate-out',
|
|
|
ac7d03 |
+ error=str(e))
|
|
|
ac7d03 |
|
|
|
ac7d03 |
result = super(WithCertOutArgs, self).forward(*keys, **options)
|
|
|
ac7d03 |
if filename:
|
|
|
ac7d03 |
diff --git a/ipaclient/plugins/cert.py b/ipaclient/plugins/cert.py
|
|
|
ac7d03 |
index 9ec6970b18d0cdc3863259faee3a697f63799c3f..93cd3cef1a14925bc0795b32e97e44d69897be5c 100644
|
|
|
ac7d03 |
--- a/ipaclient/plugins/cert.py
|
|
|
ac7d03 |
+++ b/ipaclient/plugins/cert.py
|
|
|
ac7d03 |
@@ -50,9 +50,15 @@ class CertRetrieveOverride(MethodOverride):
|
|
|
ac7d03 |
)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
def forward(self, *args, **options):
|
|
|
ac7d03 |
- certificate_out = options.pop('certificate_out', None)
|
|
|
ac7d03 |
- if certificate_out is not None:
|
|
|
ac7d03 |
- util.check_writable_file(certificate_out)
|
|
|
ac7d03 |
+ if 'certificate_out' in options:
|
|
|
ac7d03 |
+ certificate_out = options.pop('certificate_out')
|
|
|
ac7d03 |
+ try:
|
|
|
ac7d03 |
+ util.check_writable_file(certificate_out)
|
|
|
ac7d03 |
+ except errors.FileError as e:
|
|
|
ac7d03 |
+ raise errors.ValidationError(name='certificate-out',
|
|
|
ac7d03 |
+ error=str(e))
|
|
|
ac7d03 |
+ else:
|
|
|
ac7d03 |
+ certificate_out = None
|
|
|
ac7d03 |
|
|
|
ac7d03 |
result = super(CertRetrieveOverride, self).forward(*args, **options)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
--
|
|
|
ac7d03 |
2.9.4
|
|
|
ac7d03 |
|