ipautil: use file in a temporary dir as ccache in private_ccache

python-gssapi chokes on empty ccache files, so instead of creating an empty
temporary ccache file in private_ccache, create a temporary directory and
use a non-existent file in that directory as the ccache.

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

Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Simo Sorce <ssorce@redhat.com>
This commit is contained in:
Jan Cholasta
2015-11-18 08:34:35 +01:00
parent e137f305ed
commit 662158b781

View File

@@ -1345,8 +1345,10 @@ def posixify(string):
def private_ccache(path=None):
if path is None:
(desc, path) = tempfile.mkstemp(prefix='krbcc')
os.close(desc)
dir_path = tempfile.mkdtemp(prefix='krbcc')
path = os.path.join(dir_path, 'ccache')
else:
dir_path = None
original_value = os.environ.get('KRB5CCNAME', None)
@@ -1362,6 +1364,11 @@ def private_ccache(path=None):
if os.path.exists(path):
os.remove(path)
if dir_path is not None:
try:
os.rmdir(dir_path)
except OSError:
pass
if six.PY2: