Skip to content

Commit

Permalink
Avoid crash when deleting a password
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mig4 committed Nov 1, 2022
1 parent 774f840 commit b4afd1a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion osc/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b4afd1a

Please sign in to comment.