Skip to content
Snippets Groups Projects
Commit 871cce52 authored by Thomas Woerner's avatar Thomas Woerner
Browse files

ansible_freeipa_module: Set KRB5CCNAME for api_connect (non root)

In the case that the admin password has been set and become was not set
the call to backend.connect in api_connect failed. The solution is simply
to set os.environ["KRB5CCNAME"] in temp_kinit after kinit_password has
been called using the temporary ccache. os.environ["KRB5CCNAME"] is not
used automatically by api.Backend.[ldap2,rpcclient].connect. Afterwards
os.environ["KRB5CCNAME"] is unset in temp_kdestroy if ccache_name is not
None.

Fixes: #249 (Kerberos errors while using the modules with a non-sudoer user)
parent e70944c3
No related branches found
No related tags found
No related merge requests found
...@@ -108,6 +108,7 @@ def temp_kinit(principal, password): ...@@ -108,6 +108,7 @@ def temp_kinit(principal, password):
except RuntimeError as e: except RuntimeError as e:
raise RuntimeError("Kerberos authentication failed: {}".format(e)) raise RuntimeError("Kerberos authentication failed: {}".format(e))
os.environ["KRB5CCNAME"] = ccache_name
return ccache_dir, ccache_name return ccache_dir, ccache_name
...@@ -117,6 +118,7 @@ def temp_kdestroy(ccache_dir, ccache_name): ...@@ -117,6 +118,7 @@ def temp_kdestroy(ccache_dir, ccache_name):
""" """
if ccache_name is not None: if ccache_name is not None:
run([paths.KDESTROY, '-c', ccache_name], raiseonerr=False) run([paths.KDESTROY, '-c', ccache_name], raiseonerr=False)
del os.environ['KRB5CCNAME']
if ccache_dir is not None: if ccache_dir is not None:
shutil.rmtree(ccache_dir, ignore_errors=True) shutil.rmtree(ccache_dir, ignore_errors=True)
...@@ -142,7 +144,7 @@ def api_connect(context=None): ...@@ -142,7 +144,7 @@ def api_connect(context=None):
backend = api.Backend.rpcclient backend = api.Backend.rpcclient
if not backend.isconnected(): if not backend.isconnected():
backend.connect() backend.connect(ccache=os.environ.get('KRB5CCNAME', None))
def api_command(module, command, name, args): def api_command(module, command, name, args):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment