Catch CTRL+C and CTRL+D in password prompts

This commit is contained in:
Daniel Dizdarevic 2023-05-08 18:16:06 +02:00 committed by Stefan Bühler
parent 04fd42c63b
commit f1d57487be

View File

@ -229,7 +229,11 @@ class Config:
""" """
if realm.account is None: if realm.account is None:
raise RuntimeError("Can't get password without acccount - should use kerberos instead") raise RuntimeError("Can't get password without acccount - should use kerberos instead")
try:
if self.password_manager: if self.password_manager:
return self.password_manager.get_password(realm.password_name) return self.password_manager.get_password(realm.password_name)
return getpass.getpass(f"Enter password for {realm.password_name}: ") return getpass.getpass(f"Enter password for {realm.password_name}: ")
except (KeyboardInterrupt, EOFError):
raise SystemExit("Password prompt / retrieval aborted")