Tibor Baranya <t...@fallen.hu> added the comment:

Just for further clarification on how .netrc is supposed to work, I tested some 
other implementations. Sorry if this comment gets too long, but it seems netrc 
is not really a standardized solution.

In my last comment I referred curl and wget, but of course the original 
implementation is ftp (which points to the netrc manual). The manual itself 
doesn't talk about priorities, but all the mentioned 3 tools are in common in 
that they take the first entry if the same machine is in the netrc file 
multiple times.

When trying to force using the second entry, though, breaks this consistency 
quickly: none of the above tools seem to support a query with host and login 
name provided.
ftp: doesn't support providing a user name from shell (and doesn't use netrc 
when opening a connection interactively)
curl: if username is provided, it interactively asks for a password and uses 
that (which may be an issue on my end, as source code suggested there is a 
login-based lookup)
wget: if username is provided without a password, it doesn't send a auth 
information at all (also wget doesn't send default auth information for http, 
which behavior can be altered somehow)

Actually these results suprised me, as I remembered I used host+login based 
lookup previously. And the answer was git clone via https: git's implementation 
is exactly what I would expect:
* if only host is provided, the first entry is used
* if both host and login is provided, it looks up the password for the 
appropriate login
* if no matching machine entry can be found, it uses the default entry
* it also supports login matching for the default entry

I'm about the send a pull request with my understanding on how netrc should 
work. Of course all comments are welcome, and I'm happy to alter the 
implementation (or break it up to smaller pieces if necessary). My priorities 
were:

* Not to break backward compatibility.
* Provide a way to consistently pick up the first entry, without the need to 
make modifications in all of the dependent libraries (see doc change).
* __repr__() had a bug: for the default entry, it gives 'machine default', 
instead of 'default'.
* another bug: 'machine default' is actually not supported, as the netrc.hosts 
dictionary cannot make a difference between the default entry and a machine 
called default (this has a partial fixed)

As r.david.murray mentioned, the hosts dictionary should probably be deprecated.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue11416>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to