File 0003-obfuscated-password-support.patch of Package python-bugzilla

From e286a5be2446a00f91bb498f0feeffae4ec3aa05 Mon Sep 17 00:00:00 2001
From: Michal Vyskocil <mvyskocil@suse.cz>
Date: Wed, 26 Aug 2009 11:08:36 +0200
Subject: [PATCH] obfuscated password support in oscrc

The osc client introduced an obfuscated passwords (not secure, but many
times requested by a community), so this patch to readconfig method adds
an ability to read passx options.
It also fixes a small (but mandatory bug) in a condition which decides
about read or not.
---
 bugzilla/nvlbugzilla.py |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/bugzilla/nvlbugzilla.py b/bugzilla/nvlbugzilla.py
index 35202a4..0d88db1 100644
--- a/bugzilla/nvlbugzilla.py
+++ b/bugzilla/nvlbugzilla.py
@@ -138,11 +138,18 @@ If you want cache the cookies and speedup the repeated connections, remove it or
         for cookie in self._iter_domain_cookies():
             cookie.expires = 0
 
+    @classmethod
+    def _read_osc_password(cls, c):
+        # supports obfuscated passwords introduced in osc-0.121
+        if c.has_option(cls.obs_url, 'passx'):
+            return c.get(cls.obs_url, 'passx').decode('base64').decode('bz2')
+        return c.get(cls.obs_url, 'pass')
+
     def readconfig(self, configpath=None):
         super(NovellBugzilla, self).readconfig(configpath)
 
         oscrc=os.path.expanduser('~/.oscrc')
-        if not self.user and not self.password \
+        if not self.user or not self.password \
             and os.path.exists(oscrc):
             from ConfigParser import SafeConfigParser, NoOptionError
             c = SafeConfigParser()
@@ -156,7 +163,7 @@ If you want cache the cookies and speedup the repeated connections, remove it or
 
             try:
                 self.user = c.get(obs_url, 'user')
-                self.password = c.get(obs_url, 'pass')
+                self.password = self._read_osc_password(c)
                 bugzilla.base.log.info("Read credentials from ~/.oscrc")
             except NoOptionError, ne:
                 return
-- 
1.6.3.3