From b4afd1a8ea0e70476f4d25aaaa60b24e29aeb0e1 Mon Sep 17 00:00:00 2001 From: mig4 <42650719@auril.club> Date: Tue, 1 Nov 2022 18:40:39 +0000 Subject: [PATCH] Avoid crash when deleting a password When using keyring, osc would crash when called as `osc config ENDPOINT --change-password` and when the password didn't exist in the backend. This prevents it by first checking if a password exists. --- osc/credentials.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osc/credentials.py b/osc/credentials.py index 272105e0b6..1d6f58e9e2 100644 --- a/osc/credentials.py +++ b/osc/credentials.py @@ -246,7 +246,11 @@ def set_password(self, url, user, password): def delete_password(self, url, user): self._load_backend() - keyring.delete_password(urlsplit(url)[1], user) + service = urlsplit(url)[1] + data = keyring.get_password(service, user) + if data is None: + return + keyring.delete_password(service, user) class KeyringCredentialsDescriptor(AbstractCredentialsManagerDescriptor):