mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-06-23 09:14:43 +00:00
ipaclient/action_plugins/ipaclient_get_otp: Enhanced error reporting
If kinit_password call failed because of wrong password or even because kinit was not found, there was a very unspecific error message. Now these errors will be properly reported. Fixes: RHBZ#1727277
This commit is contained in:
@@ -52,7 +52,8 @@ def run_cmd(args, stdin=None):
|
|||||||
close_fds=True)
|
close_fds=True)
|
||||||
stdout, stderr = p.communicate(stdin)
|
stdout, stderr = p.communicate(stdin)
|
||||||
|
|
||||||
return p.returncode
|
if p.returncode != 0:
|
||||||
|
raise RuntimeError(stderr)
|
||||||
|
|
||||||
|
|
||||||
def kinit_password(principal, password, ccache_name, config):
|
def kinit_password(principal, password, ccache_name, config):
|
||||||
@@ -197,12 +198,14 @@ class ActionModule(ActionBase):
|
|||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
if password:
|
if password:
|
||||||
# perform kinit -c ccache_name -l 1h principal
|
try:
|
||||||
res = kinit_password(principal, password, ccache_name,
|
# perform kinit -c ccache_name -l 1h principal
|
||||||
krb5conf_name)
|
kinit_password(principal, password, ccache_name,
|
||||||
if res:
|
krb5conf_name)
|
||||||
|
except Exception as e:
|
||||||
result['failed'] = True
|
result['failed'] = True
|
||||||
result['msg'] = 'kinit %s with password failed' % principal
|
result['msg'] = 'kinit %s with password failed: %s' % \
|
||||||
|
(principal, to_native(e))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user