Merge lp:~vila/bzr/1233413-netrc into lp:bzr

Proposed by Vincent Ladeuil on 2013-10-01
Status: Merged
Approved by: Vincent Ladeuil on 2013-10-04
Approved revision: 6589
Merged at revision: 6588
Proposed branch: lp:~vila/bzr/1233413-netrc
Merge into: lp:bzr
Diff against target: 33 lines (+7/-4)
2 files modified
bzrlib/plugins/netrc_credential_store/tests/test_netrc.py (+5/-4)
doc/en/release-notes/bzr-2.7.txt (+2/-0)
To merge this branch: bzr merge lp:~vila/bzr/1233413-netrc
Reviewer Review Type Date Requested Status
Andrew Starr-Bochicchio 2013-10-01 Approve on 2013-10-03
Review via email: mp+188597@code.launchpad.net

Commit message

Make .netrc 0600 in tests so python-2.7.5-8's netrc is happy.

Description of the change

See bug report for details, in a nutshell, starting with python-2.7.5-8, the
netrc module checks ~/.netrc permissions.

This leads to test failures as tests create it with default
permissions. Restricting to 0600 is enough to fix.

To post a comment you must log in.
Jelmer Vernooij (jelmer) wrote :

Won't this break Windows?

I had tried to fix this using bzrlib's osutils.chmod_if_possible which should be Windows safe AFAIK, but for some reason it doesn't seem to work for me.

lp:~vila/bzr/1233413-netrc updated on 2013-10-01
6589. By Vincent Ladeuil on 2013-10-01

Use osutils.chmod_if_possible as raised during review.

Vincent Ladeuil (vila) wrote :

> Won't this break Windows?

.netrc on windows ? Well, nothing in the tests say that won't run on windows so I can fix that.

Still working here with chmod_if_possible (see

> I had tried to fix this using bzrlib's osutils.chmod_if_possible which should be Windows safe AFAIK, but for some reason it doesn't seem to work for me.

Weird, can you try my fix and confirms it works for you ?

I can confirm that your branch works as expected. (Not sure what I did wrong? I guess must have done something stupid as it was such an obvious fix...)

review: Approve
Vincent Ladeuil (vila) wrote :

@Andrew: Thanks ! Yeah, should have been something obscure or testing the wrong thing may be ?

Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/plugins/netrc_credential_store/tests/test_netrc.py'
--- bzrlib/plugins/netrc_credential_store/tests/test_netrc.py 2009-03-23 14:59:43 +0000
+++ bzrlib/plugins/netrc_credential_store/tests/test_netrc.py 2013-10-01 16:36:45 +0000
@@ -43,11 +43,12 @@
43machine host login joe password secret43machine host login joe password secret
44default login anonymous password joe@home44default login anonymous password joe@home
45"""45"""
46 f = open(osutils.pathjoin(self.test_home_dir, '.netrc'), 'wb')46 netrc_path = osutils.pathjoin(self.test_home_dir, '.netrc')
47 try:47 with open(netrc_path, 'wb') as f:
48 f.write(netrc_content)48 f.write(netrc_content)
49 finally:49 # python's netrc will complain about access permissions starting with
50 f.close()50 # 2.7.5-8 so we restrict the access unconditionally
51 osutils.chmod_if_possible(netrc_path, 0600)
5152
52 def _get_netrc_cs(self):53 def _get_netrc_cs(self):
53 return config.credential_store_registry.get_credential_store('netrc')54 return config.credential_store_registry.get_credential_store('netrc')
5455
=== modified file 'doc/en/release-notes/bzr-2.7.txt'
--- doc/en/release-notes/bzr-2.7.txt 2013-07-27 12:53:28 +0000
+++ doc/en/release-notes/bzr-2.7.txt 2013-10-01 16:36:45 +0000
@@ -56,6 +56,8 @@
56 suite. This can include new facilities for writing tests, fixes to 56 suite. This can include new facilities for writing tests, fixes to
57 spurious test failures and changes to the way things should be tested.57 spurious test failures and changes to the way things should be tested.
5858
59* Restrict access to '.netrc' in tests or recent python (2.7.5-8) will
60 complain. (Vincent Ladeuil, #1233413)
5961
60..62..
61 vim: tw=74 ft=rst ff=unix63 vim: tw=74 ft=rst ff=unix