Traceback when the credentials storage returns unicode

Bug #877374 reported by Julian Edwards
26
This bug affects 2 people
Affects Status Importance Assigned to Milestone
launchpadlib
Fix Released
Low
Brad Crittenden
python-launchpadlib (Ubuntu)
Fix Released
Undecided
Unassigned
Natty
Fix Released
Undecided
Unassigned
Oneiric
Fix Released
Undecided
Unassigned

Bug Description

In credentials.py there is this line:

credentials.load(StringIO(value))

When value is unicide (which is what is returned from kwallet) then the StringIO object contains gibberish as far as the parser is concerned and it blows up like this:

  File "/home/ed/canonical/lp-sourcedeps/eggs/launchpadlib-1.9.9-py2.6.egg/launchpadlib/credentials.py", line 89, in from_string
    credentials.load(StringIO(value))
  File "/home/ed/canonical/lp-sourcedeps/eggs/lazr.restfulclient-0.12.0-py2.6.egg/lazr/restfulclient/authorize/oauth.py", line 158, in load
    parser.readfp(readable_file)
  File "/usr/lib/python2.6/ConfigParser.py", line 306, in readfp

  File "/usr/lib/python2.6/ConfigParser.py", line 512, in _read

ConfigParser.ParsingError: File contains parsing errors: <???>
        [line 6]: '\x00\x00\x00\n'
        [line 7]: '\x00\x00\x00'

Related branches

Revision history for this message
Julian Edwards (julian-edwards) wrote :

The fix is to change the line to this:

credentials.load(StringIO(value.encode("utf8")))

Changed in launchpadlib:
status: New → Triaged
importance: Undecided → Critical
Changed in launchpadlib:
assignee: nobody → Julian Edwards (julian-edwards)
status: Triaged → In Progress
Revision history for this message
Julian Edwards (julian-edwards) wrote :

I can't re-create this any more which is rather annoying. I've left the bug here anyway in case it happens again.

Changed in launchpadlib:
assignee: Julian Edwards (julian-edwards) → nobody
importance: Critical → Low
status: In Progress → Triaged
Brad Crittenden (bac)
Changed in launchpadlib:
assignee: nobody → Brad Crittenden (bac)
status: Triaged → In Progress
Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 877374] Re: Traceback when the credentials storage returns unicode

On 18 October 2011 23:21, Julian Edwards <email address hidden> wrote:
> The fix is to change the line to this:
>
> credentials.load(StringIO(value.encode("utf8")))

I'm not sure that would be the true fix: utf-8 won't have sequences of \0 bytes.

This looks a lot like a similar bug with garbage being written in to
the gnome wallet, which is also hard to reproduce.

Brad Crittenden (bac)
Changed in launchpadlib:
status: In Progress → Fix Committed
Brad Crittenden (bac)
Changed in launchpadlib:
status: Fix Committed → Fix Released
Changed in python-launchpadlib (Ubuntu):
status: New → Fix Released
Revision history for this message
Clint Byrum (clint-fewbar) wrote : Please test proposed package

Hello Julian, or anyone else affected,

Accepted python-launchpadlib into oneiric-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in python-launchpadlib (Ubuntu Oneiric):
status: New → Fix Committed
tags: added: verification-needed
Changed in python-launchpadlib (Ubuntu Natty):
status: New → Fix Committed
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Hello Julian, or anyone else affected,

Accepted python-launchpadlib into natty-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Revision history for this message
Scott Kitterman (kitterman) wrote :

I was having this problem with oneric and the proposed package fixes it. Thanks to this I can use syncpackage now.

tags: added: verification-done-oneiric verification-needed-natty
removed: verification-needed
Revision history for this message
Brad Crittenden (bac) wrote :

I have tested this with gnome on natty. While I cannot reproduce the exact problem of unicode being returned (a kwallet problem)I have verified that any time the key is corrupt or unrecognized it is deemed invalid and the authorization dance is redone. So corrupt keys are treated as expired, allowing work to continue. That said, unicode should be handled properly as Scott showed under oneiric.

Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Brad, can you confirm that this is "verified" on natty? Your message seems to suggest a regression was created, though I suspect you are just noting a different bug that was already present.

tags: added: verification-done verification-needed
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

FYI for SRU verifiers, when an SRU is verified in some, but not all releases, leave both the 'verification-done' and 'verification-needed' tags in place. This will make the bug appear in purple on the SRU report:

http://people.canonical.com/~ubuntu-archive/pending-sru.html

We use this to determine whether or not something is ready to move to -updates... sometimes its ok for a partially verified bug to move forward, sometimes its not, but if both tags aren't present it will just appear in blue and we won't even look at it.

Revision history for this message
Brad Crittenden (bac) wrote :

Clint, I did not mean to imply a regression. I stated I have verified on gnome that key storage and retrieval works and that it recovers from a corrupted key as I intended. The bug was originally written against behavior with kwallet but since I don't have kubuntu installed I cannot test that scenario.

Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Thanks Brad!

tags: removed: verification-done-oneiric verification-needed verification-needed-natty
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-launchpadlib - 1.9.7-0ubuntu2.1

---------------
python-launchpadlib (1.9.7-0ubuntu2.1) natty-proposed; urgency=low

  * Add 100_base64_encode_credentials.patch cherrypicked from upstream
    tree to fix issue causing launchpadlib scripts to fail due to problems
    associated with keyring corruption. We encode launchpadlib's entries so
    the keyring won't be confused by unexpected characters.
     - Convert credentials from unicode when retrieved from the keyring.
       (LP: #877374)
     - Use base 64 encoding for credentials stored in the keyring.
       (LP: #745801)
     - Properly handle decoding base 64.
       (LP: #900307)
 -- Bryce Harrington <email address hidden> Fri, 09 Dec 2011 15:03:01 -0800

Changed in python-launchpadlib (Ubuntu Natty):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-launchpadlib - 1.9.8-2ubuntu0.1

---------------
python-launchpadlib (1.9.8-2ubuntu0.1) oneiric-proposed; urgency=low

  * Add 100_base64_encode_credentials.patch cherrypicked from upstream
    tree to fix issue causing launchpadlib scripts to fail due to problems
    associated with keyring corruption. We encode launchpadlib's entries so
    the keyring won't be confused by unexpected characters.
     - Convert credentials from unicode when retrieved from the keyring.
       (LP: #877374)
     - Use base 64 encoding for credentials stored in the keyring.
       (LP: #745801)
     - Properly handle decoding base 64.
       (LP: #900307)
 -- Bryce Harrington <email address hidden> Fri, 09 Dec 2011 14:55:16 -0800

Changed in python-launchpadlib (Ubuntu Oneiric):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.