Use of authentication.conf causes update to fail

Bug #217650 reported by Jussi
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Vincent Ladeuil

Bug Description

update mirror branch (checkout) at Windows XP Professional SP2 from another branch at Linux server using sftp connection works correctly:

-----------
C:\Projects\development>\Python25\Scripts\bzr update
Connected (version 2.0, client OpenSSH_3.8.1p1)
SSH x@y password:
Authentication (password) successful!
Secsh channel 1 opened.
[chan 1] Opened sftp connection (server version 3)
Tree is up to date at revision 16.
-----------

However, when using authentication.conf file at C:\Documents and Settings\x\Application Data\bazaar\2.0 with user and password, update fails:

-----------
C:\Projects\development>\Python25\Scripts\bzr update
Connected (version 2.0, client OpenSSH_3.8.1p1)
bzr: ERROR: exceptions.AttributeError: 'unicode' object has no attribute 'get'

Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\bzrlib\commands.py", line 846, in run_bzr_catch_errors
    return run_bzr(argv)
  File "C:\Python25\Lib\site-packages\bzrlib\commands.py", line 802, in run_bzr
    ret = run(*run_argv)
  File "C:\Python25\Lib\site-packages\bzrlib\commands.py", line 504, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "C:\Python25\Lib\site-packages\bzrlib\builtins.py", line 1089, in run
    possible_transports=possible_transports)
  File "C:\Python25\Lib\site-packages\bzrlib\decorators.py", line 127, in read_locked
    return unbound(self, *args, **kwargs)
  File "C:\Python25\Lib\site-packages\bzrlib\branch.py", line 1792, in get_master_branch
    possible_transports=possible_transports)
  File "C:\Python25\Lib\site-packages\bzrlib\branch.py", line 110, in open
    possible_transports=possible_transports)
  File "C:\Python25\Lib\site-packages\bzrlib\bzrdir.py", line 691, in open
    return BzrDir.open_from_transport(t, _unsupported=_unsupported)
  File "C:\Python25\Lib\site-packages\bzrlib\bzrdir.py", line 728, in open_from_transport
    redirected)
  File "C:\Python25\Lib\site-packages\bzrlib\transport\__init__.py", line 1658, in do_catching_redirections
    return action(transport)
  File "C:\Python25\Lib\site-packages\bzrlib\bzrdir.py", line 705, in find_format
    transport, _server_formats=_server_formats)
  File "C:\Python25\Lib\site-packages\bzrlib\bzrdir.py", line 1466, in find_format
    return format.probe_transport(transport)
  File "C:\Python25\Lib\site-packages\bzrlib\bzrdir.py", line 1476, in probe_transport
    format_string = transport.get(".bzr/branch-format").read()
  File "C:\Python25\Lib\site-packages\bzrlib\transport\sftp.py", line 238, in get
    f = self._get_sftp().file(path, mode='rb')
  File "C:\Python25\Lib\site-packages\bzrlib\transport\sftp.py", line 216, in _get_sftp
    connection, credentials = self._create_connection()
  File "C:\Python25\Lib\site-packages\bzrlib\transport\sftp.py", line 208, in _create_connection
    self._host, self._port)
  File "C:\Python25\Lib\site-packages\bzrlib\transport\ssh.py", line 321, in connect_sftp
    t = self._connect(username, password, host, port)
  File "C:\Python25\Lib\site-packages\bzrlib\transport\ssh.py", line 317, in _connect
    _paramiko_auth(username, password, host, port, t)
  File "C:\Python25\Lib\site-packages\bzrlib\transport\ssh.py", line 514, in _paramiko_auth
    password = auth.get_password('ssh', host, username, port=port)
  File "C:\Python25\Lib\site-packages\bzrlib\config.py", line 1083, in get_password
    credentials = self.get_credentials(scheme, host, port, user, path)
  File "C:\Python25\Lib\site-packages\bzrlib\config.py", line 995, in get_credentials
    auth_def.get, ['scheme', 'host', 'user', 'path'])
AttributeError: 'unicode' object has no attribute 'get'

bzr 1.4rc1 on python 2.5.2 (win32)
arguments: ['C:\\Python25\\Scripts\\bzr', 'update']
encoding: 'cp1252', fsenc: 'mbcs', lang: None
plugins:
  launchpad C:\Python25\lib\site-packages\bzrlib\plugins\launchpad [unknown]
-----------

Error occurs both with ANSI encoded file and with UTF-8 encoded file.

Related branches

Revision history for this message
Jussi (iinatti) wrote :

The reason was missing section header in authentication.conf file.

Perhaps an exception catch and a more informative error message could be implemented for this situation.

Revision history for this message
John A Meinel (jameinel) wrote :

Hmm... it seems that the code is being overly optimistic about what will be returned by "self._get_config().items()"

It seems to assume everything will be in a subsection, and will (as you notice) crash with a traceback if anything is outside of one.

Specifically, a auth config like:

foo = bar

[host]
scheme = foo
host = bar
user = me
path = ???

The "foo = bar" line will cause it to crash and burn. Perhaps a simple check would be:

=== modified file 'bzrlib/config.py'
--- bzrlib/config.py 2008-04-13 17:38:34 +0000
+++ bzrlib/config.py 2008-04-16 14:13:45 +0000
@@ -991,6 +991,11 @@
         """
         credentials = None
         for auth_def_name, auth_def in self._get_config().items():
+ if isinstance(auth_def, basestr):
+ trace.warning('Authentication configuration items must be in'
+ ' a section for each host.'
+ ' Not like: %s', auth_def_name)
+ continue
             a_scheme, a_host, a_user, a_path = map(
                 auth_def.get, ['scheme', 'host', 'user', 'path'])

would this have fixed it for you?

It wouldn't be hard to write a simple test for this and get it merged.

Changed in bzr:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
codeslinger (codeslinger) wrote :

see also Bug #199440 and Bug #183705

there is a lot of broken behavior with authentication.conf
does it even work at all?

Vincent Ladeuil (vila)
Changed in bzr:
assignee: nobody → v-ladeuil
Vincent Ladeuil (vila)
Changed in bzr:
status: Triaged → Fix Committed
Vincent Ladeuil (vila)
Changed in bzr:
milestone: none → 1.5
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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