← Back to team overview

holland-coredev team mailing list archive

[Bug 1076033] [NEW] Broken handling of unicode in mysql credentials

 

Public bug reported:

If characters outside of ascii are in MySQL credentials, holland will
fail with a UnicodeEncodeError.

This happens in two places:

* holland's parsing of my.cnf files has a few places where it incorrectly uses 'str(value)'
* holland type conversion for 'port' -> int had a hack 'str(value)' fallback.

Further, there is a bug in the required upstream MySQL connector,
MySQLdb that will fail as well, if you pass a unicode passwd keyword:

>>> import MySQLdb
>>> MySQLdb.connect(passwd=u'пароль', charset='utf8')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib64/python2.4/site-packages/MySQLdb/__init__.py", line 75, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib64/python2.4/site-packages/MySQLdb/connections.py", line 164, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

This is actually broken in most python/mysql connectors including mysql-
connector-python and oursql, so a potential connector bug in the future.

I think the correct behavior here is to encode to 'utf8' bytes first
before passing to the underlying connector.  Alternatively, with
libmysqlclient, just generating a valid my.cnf should be handled
properly, so long as holland handles unicode properly.

** Affects: holland-backup
     Importance: High
     Assignee: Andrew Garner (muzazzi)
         Status: In Progress

** Changed in: holland-backup
    Milestone: None => 1.0.8

** Changed in: holland-backup
   Importance: Undecided => High

** Changed in: holland-backup
       Status: New => In Progress

** Changed in: holland-backup
     Assignee: (unassigned) => Andrew Garner (muzazzi)

-- 
You received this bug notification because you are a member of Holland
Build, which is subscribed to holland-backup.
https://bugs.launchpad.net/bugs/1076033

Title:
  Broken handling of unicode in mysql credentials

Status in Holland Backup Framework:
  In Progress

Bug description:
  If characters outside of ascii are in MySQL credentials, holland will
  fail with a UnicodeEncodeError.

  This happens in two places:

  * holland's parsing of my.cnf files has a few places where it incorrectly uses 'str(value)'
  * holland type conversion for 'port' -> int had a hack 'str(value)' fallback.

  Further, there is a bug in the required upstream MySQL connector,
  MySQLdb that will fail as well, if you pass a unicode passwd keyword:

  >>> import MySQLdb
  >>> MySQLdb.connect(passwd=u'пароль', charset='utf8')
  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "/usr/lib64/python2.4/site-packages/MySQLdb/__init__.py", line 75, in Connect
      return Connection(*args, **kwargs)
    File "/usr/lib64/python2.4/site-packages/MySQLdb/connections.py", line 164, in __init__
      super(Connection, self).__init__(*args, **kwargs2)
  UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

  This is actually broken in most python/mysql connectors including
  mysql-connector-python and oursql, so a potential connector bug in the
  future.

  I think the correct behavior here is to encode to 'utf8' bytes first
  before passing to the underlying connector.  Alternatively, with
  libmysqlclient, just generating a valid my.cnf should be handled
  properly, so long as holland handles unicode properly.

To manage notifications about this bug go to:
https://bugs.launchpad.net/holland-backup/+bug/1076033/+subscriptions


Follow ups

References