summaryrefslogtreecommitdiff
path: root/keystoneclient/common
diff options
context:
space:
mode:
authorDirk Mueller <dirk@dmllr.de>2014-05-30 15:06:10 +0200
committerDirk Mueller <dirk@dmllr.de>2014-06-16 16:23:29 +0200
commit69ca1cd48336d36fe2992f1c261baef73d1d4db6 (patch)
treeb9c50afd8f37aebc7b4504ca6b2a51fcbec9e845 /keystoneclient/common
parent04ded03cb076f63b026a995bb2908291297557f0 (diff)
downloadpython-keystoneclient-69ca1cd48336d36fe2992f1c261baef73d1d4db6.tar.gz
Adjust Python 2.6 OSerror-on-EPIPE workaround
Adjust the code to raise exceptions.CertificateConfigError when the certificates are still missing even in the Python 2.6 subprocess bug-workaround case. Change-Id: I9fdfa830e6f9bc9e8eab496da2597e4118577ec5 Closes-Bug: #1324921
Diffstat (limited to 'keystoneclient/common')
-rw-r--r--keystoneclient/common/cms.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/keystoneclient/common/cms.py b/keystoneclient/common/cms.py
index 7438659..85fa307 100644
--- a/keystoneclient/common/cms.py
+++ b/keystoneclient/common/cms.py
@@ -65,6 +65,7 @@ def set_subprocess(_subprocess=None):
def _check_files_accessible(files):
err = None
+ retcode = -1
try:
for try_file in files:
with open(try_file, 'r'):
@@ -74,8 +75,19 @@ def _check_files_accessible(files):
# the given file.
err = ('Hit OSError in _process_communicate_handle_oserror()\n'
'Likely due to %s: %s') % (try_file, e.strerror)
+ # Emulate openssl behavior, which returns with code 2 when
+ # access to a file failed:
- return err
+ # You can get more from
+ # http://www.openssl.org/docs/apps/cms.html#EXIT_CODES
+ #
+ # $ openssl cms -verify -certfile not_exist_file -CAfile \
+ # not_exist_file -inform PEM -nosmimecap -nodetach \
+ # -nocerts -noattr
+ # Error opening certificate file not_exist_file
+ retcode = 2
+
+ return retcode, err
def _process_communicate_handle_oserror(process, data, files):
@@ -91,12 +103,11 @@ def _process_communicate_handle_oserror(process, data, files):
# The quick exit is typically caused by the openssl command not being
# able to read an input file, so check ourselves if can't read a file.
- err = _check_files_accessible(files)
+ retcode, err = _check_files_accessible(files)
if process.stderr:
msg = process.stderr.read()
err = err + msg.decode('utf-8')
output = ''
- retcode = -1
else:
retcode = process.poll()
if err is not None: