Bug 689794

Summary: ctrl+c does not work during python getpass.getpass() (was: Unable to terminate sss_obfuscate)
Product: Red Hat Enterprise Linux 6 Reporter: Kaushik Banerjee <kbanerje>
Component: pythonAssignee: Dave Malcolm <dmalcolm>
Status: CLOSED ERRATA QA Contact: Petr Šplíchal <psplicha>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 6.1CC: dpal, grajaiya, jgalipea, ohudlick, prc, psplicha, sgallagh, syeghiay
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: python-2.6.6-21.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 10:24:06 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Kaushik Banerjee 2011-03-22 13:26:36 UTC
Description of problem:
ctrl+c doesn't terminate sss_obfuscate and traceback messages appear on using ctrl+d

Version-Release number of selected component (if applicable):
sssd-tools-1.5.1-15.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Run the command "sss_obfuscate -d AD"
2. Try to interrupt with ctrl+c or ctrl+d
3.
  
Actual results:
1. ctrl+c doesn't interrupt sss_obfuscate.
2. ctrl+d interrupts sss_obfuscate with traceback messages.
# sss_obfuscate -d AD
Enter password: Traceback (most recent call last):
  File "/usr/sbin/sss_obfuscate", line 101, in <module>
    ret = main()
  File "/usr/sbin/sss_obfuscate", line 45, in main
    p1, p2 = pprompt()
  File "/usr/sbin/sss_obfuscate", line 44, in <lambda>
    pprompt = lambda: (getpass.getpass("Enter password: "), getpass.getpass("Re-enter password: "))
  File "/usr/lib64/python2.6/getpass.py", line 71, in unix_getpass
    passwd = _raw_input(prompt, stream, input=input)
  File "/usr/lib64/python2.6/getpass.py", line 135, in _raw_input
    raise EOFError
EOFError


Expected results:
1. ctrl+c should interrupt sss_obfuscate.
2. ctrl+d should stop sss_obfuscate without any traceback messages.

Additional info:

Comment 2 Stephen Gallagher 2011-03-22 13:41:00 UTC
The ctrl+c issue is a python bug being tracked here:
http://bugs.python.org/issue11236

Also, I don't know whether I consider the traceback from ctrl+d to be a bug. You're not supposed to force an EOF in that function. It triggers completion based on a newline. Throwing a traceback seems like an appropriate behavior.

Please suggest an appropriate error message if you want me to at least override this.

Comment 3 Kaushik Banerjee 2011-03-22 14:30:05 UTC
The basic issue here is that, at the moment, user cannot interrupt the sss_obfuscate command and only ctrl+d with traceback messages work.
Maybe we can add a exception with the message "Password change aborted"?

Also, there is no limit on maximum retries either. We should set a limit of maximum 3 retries on mis-matched passwords.

Comment 4 Kaushik Banerjee 2011-03-23 12:17:04 UTC
Logged a second bug https://bugzilla.redhat.com/show_bug.cgi?id=690131 to track the issue related to ctrl+d and leave this bug to track the ctrl+c issue.

Comment 5 Stephen Gallagher 2011-03-23 12:27:51 UTC
The ctrl+c issue is a python bug as mentioned in the above comments. It is the same issue as reported in http://bugs.python.org/issue11236

Reassigning to the Python maintainer.

Comment 6 RHEL Program Management 2011-04-04 02:13:08 UTC
Since RHEL 6.1 External Beta has begun, and this bug remains
unresolved, it has been rejected as it is not proposed as
exception or blocker.

Red Hat invites you to ask your support representative to
propose this request, if appropriate and relevant, in the
next release of Red Hat Enterprise Linux.

Comment 7 Dave Malcolm 2011-06-09 20:29:52 UTC
Patch is upstream, albeit not for 2.6; 2.7 version is here:
   http://hg.python.org/cpython/rev/a3b4887edba4/

Easy manual reproducer:
  python -c"import getpass; print(repr(getpass.getpass('-> ')))"
and try to press either ctrl-Z or ctrl-C.  Currently, nothing happens, and you need to press "return" to finish; the returned string contains '\x03' or '\x1a'  (or press Ctrl-D, which raises a EOFError exception).

Upon applying the patch, Ctrl-C raises a KeyboardInterupt, and Ctrl-Z backgrounds the task.

Comment 13 errata-xmlrpc 2011-12-06 10:24:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1564.html