summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2011-03-24 10:57:08 -0400
committerStephen Gallagher <sgallagh@redhat.com>2011-03-24 14:13:44 -0400
commit764bda08267d867a30ceb07d398dc30be1f4b699 (patch)
tree533b9011af44ab500169e6d8f27df0d323fd1ca6 /src/tools
parent675f529e1a0ada1b1a400a59465560ab88a6e24c (diff)
downloadsssd-764bda08267d867a30ceb07d398dc30be1f4b699.tar.gz
sssd-764bda08267d867a30ceb07d398dc30be1f4b699.tar.xz
sssd-764bda08267d867a30ceb07d398dc30be1f4b699.zip
sss_obfuscate: abort on ctrl+c
There is a python bug (http://bugs.python.org/issue11236) where getpass.getpass() does not throw KeyboardInterrupt on ctrl+c. This workaround is the closest we can get: if we detect the control character in the string that we read, we'll cancel.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/sss_obfuscate12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/tools/sss_obfuscate b/src/tools/sss_obfuscate
index 5a5742b9c..fbea1213d 100644
--- a/src/tools/sss_obfuscate
+++ b/src/tools/sss_obfuscate
@@ -44,13 +44,25 @@ def main():
try:
pprompt = lambda: (getpass.getpass("Enter password: "), getpass.getpass("Re-enter password: "))
p1, p2 = pprompt()
+
+ #Work around bug in Python 2.6
+ if '\x03' in p1 or '\x03' in p2:
+ raise KeyboardInterrupt
+
while p1 != p2:
print('Passwords do not match. Try again')
p1, p2 = pprompt()
+
+ #Work around bug in Python 2.6
+ if '\x03' in p1 or '\x03' in p2:
+ raise KeyboardInterrupt
password = p1
+
except EOFError:
print >> sys.stderr, '\nUnexpected end-of-file. Password change aborted'
return 1
+ except KeyboardInterrupt:
+ return 1
else:
try: