errorhandling #2
@ -148,9 +148,11 @@ class Keepass(PasswordManager):
|
|||||||
password = getpass.getpass(f"KeePass password for database {self.database}: ")
|
password = getpass.getpass(f"KeePass password for database {self.database}: ")
|
||||||
kp = pykeepass.PyKeePass(self.database, password=password)
|
kp = pykeepass.PyKeePass(self.database, password=password)
|
||||||
entry = kp.find_entries(username=password_name, first=True)
|
entry = kp.find_entries(username=password_name, first=True)
|
||||||
|
if entry:
|
||||||
return entry.password # type: ignore
|
return entry.password # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class PasswordScript(PasswordManager):
|
class PasswordScript(PasswordManager):
|
||||||
command: list[str]
|
command: list[str]
|
||||||
@ -221,6 +223,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")
|
||||||
if self.password_manager:
|
if self.password_manager:
|
||||||
return self.password_manager.get_password(realm.password_name)
|
password = self.password_manager.get_password(realm.password_name)
|
||||||
|
else:
|
||||||
|
password = getpass.getpass(f"Enter password for {realm.password_name}: ")
|
||||||
|
|
||||||
return getpass.getpass(f"Enter password for {realm.password_name}: ")
|
if password:
|
||||||
|
return password
|
||||||
|
else:
|
||||||
|
raise SystemExit(f"No password found for {realm.password_name}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user