summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbhijeet Kasurde <akasurde@redhat.com>2025-01-14 16:35:31 +0100
committerGitHub <noreply@github.com>2025-01-14 16:35:31 +0100
commit85884013870f930d9fda0dd7d1f6bfabacbe9dff (patch)
tree11d491d8824654bdd54dcc8f5a9be52ce2c2d7fd
parentfix[doc.py]: path will be undefined (#84464) (diff)
downloadansible-85884013870f930d9fda0dd7d1f6bfabacbe9dff.tar.xz
ansible-85884013870f930d9fda0dd7d1f6bfabacbe9dff.zip
User: Update prompt for SSH key passphrase prompt (#84521)
* update prompt for SSH key passphrase prompt * introduce timeout in SSH key passphrase interaction Fixes: #84484 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
-rw-r--r--changelogs/fragments/user_passphrase.yml4
-rw-r--r--lib/ansible/modules/user.py12
2 files changed, 13 insertions, 3 deletions
diff --git a/changelogs/fragments/user_passphrase.yml b/changelogs/fragments/user_passphrase.yml
new file mode 100644
index 0000000000..edbb4fa377
--- /dev/null
+++ b/changelogs/fragments/user_passphrase.yml
@@ -0,0 +1,4 @@
+---
+bugfixes:
+ - user - Update prompt for SSH key passphrase (https://github.com/ansible/ansible/issues/84484).
+ - user - Set timeout for passphrase interaction.
diff --git a/lib/ansible/modules/user.py b/lib/ansible/modules/user.py
index 8fdc71aae8..376d15f772 100644
--- a/lib/ansible/modules/user.py
+++ b/lib/ansible/modules/user.py
@@ -490,6 +490,7 @@ uid:
import ctypes.util
+from datetime import datetime
import grp
import calendar
import os
@@ -1279,11 +1280,16 @@ class User(object):
env=env)
out_buffer = b''
err_buffer = b''
+ first_prompt = b'Enter passphrase'
+ second_prompt = b'Enter same passphrase again'
+ prompt = first_prompt
+ start = datetime.now()
+ timeout = 900
while p.poll() is None:
r_list = select.select([master_out_fd, master_err_fd], [], [], 1)[0]
- first_prompt = b'Enter passphrase (empty for no passphrase):'
- second_prompt = b'Enter same passphrase again'
- prompt = first_prompt
+ now = datetime.now()
+ if (now - start).seconds > timeout:
+ return (1, '', f'Timeout after {timeout} while reading passphrase for SSH key')
for fd in r_list:
if fd == master_out_fd:
chunk = os.read(master_out_fd, 10240)