From c5231d61dd52df24f1c810964021bc100a4a6ce9 Mon Sep 17 00:00:00 2001 From: lethliel Date: Tue, 29 Oct 2019 11:04:22 +0100 Subject: [PATCH] fix credentials with passx entries Existing passx enries resulted in a stacktrace because the cp.get() call for the passx entries was missing. Also added a delete_password function for ObfuscatedPasswordManager to delete passx entries --- osc/credentials.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osc/credentials.py b/osc/credentials.py index 59c17ace..ec894218 100644 --- a/osc/credentials.py +++ b/osc/credentials.py @@ -65,6 +65,8 @@ class AbstractCredentialsManager(object): class PlaintextConfigFileCredentialsManager(AbstractCredentialsManager): def get_password(self, url, user, defer=True): + if self._cp.has_option(url, 'passx', proper=True): + return self._cp.get(url, 'passx', raw=True) return self._cp.get(url, 'pass', raw=True) def set_password(self, url, user, password): @@ -101,6 +103,10 @@ class ObfuscatedConfigFileCredentialsManager( password = base64.b64encode(compressed_pw).decode("ascii") super(self.__class__, self).set_password(url, user, password) + def delete_password(self, url, user): + self._cp.remove_option(url, 'passx') + super(self.__class__, self).delete_password(url, user) + @classmethod def decode_password(cls, password): compressed_pw = base64.b64decode(password.encode("ascii"))