automount: rmtree temp directory

ipa-client-automount uses the host keytab to acquire a TGT. The script
sets up a temporary directory for its ccache. At the end of the script
it removes the ccache and temp directory again.

In case of a failed kinit, the ccache is not created and the removal of
the ccache causes an exception. The automount installer now uses
shutil.rmtree() to remove the temporary directory and all its content.

Fixes: https://pagure.io/freeipa/issue/7862
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: François Cami <fcami@redhat.com>
This commit is contained in:
Christian Heimes 2019-04-08 07:44:02 +02:00 committed by François Cami
parent a5213140c3
commit 6fed17003d

View File

@ -26,6 +26,7 @@ from __future__ import print_function
import logging import logging
import sys import sys
import os import os
import shutil
import time import time
import tempfile import tempfile
import gssapi import gssapi
@ -487,8 +488,7 @@ def main():
except errors.PublicError as e: except errors.PublicError as e:
sys.exit("Cannot connect to the server due to generic error: %s" % str(e)) sys.exit("Cannot connect to the server due to generic error: %s" % str(e))
finally: finally:
os.remove(ccache_name) shutil.rmtree(ccache_dir)
os.rmdir(ccache_dir)
if not options.unattended and not ipautil.user_input("Continue to configure the system with these values?", False): if not options.unattended and not ipautil.user_input("Continue to configure the system with these values?", False):
sys.exit("Installation aborted") sys.exit("Installation aborted")