Catch CTRL+C and CTRL+D in password prompts

This commit is contained in:
Daniel Dizdarevic 2023-05-08 18:16:06 +02:00
parent fa128a9cea
commit 206b94299b

View File

@ -229,10 +229,14 @@ class Config:
"""
if realm.account is None:
raise RuntimeError("Can't get password without acccount - should use kerberos instead")
if self.password_manager:
password = self.password_manager.get_password(realm.password_name)
else:
password = getpass.getpass(f"Enter password for {realm.password_name}: ")
try:
if self.password_manager:
password = self.password_manager.get_password(realm.password_name)
else:
password = getpass.getpass(f"Enter password for {realm.password_name}: ")
except (KeyboardInterrupt, EOFError):
exit()
if password:
return password