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/ (+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:

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
1=== modified file 'bzrlib/plugins/netrc_credential_store/tests/'
2--- bzrlib/plugins/netrc_credential_store/tests/ 2009-03-23 14:59:43 +0000
3+++ bzrlib/plugins/netrc_credential_store/tests/ 2013-10-01 16:36:45 +0000
4@@ -43,11 +43,12 @@
5 machine host login joe password secret
6 default login anonymous password joe@home
7 """
8- f = open(osutils.pathjoin(self.test_home_dir, '.netrc'), 'wb')
9- try:
10+ netrc_path = osutils.pathjoin(self.test_home_dir, '.netrc')
11+ with open(netrc_path, 'wb') as f:
12 f.write(netrc_content)
13- finally:
14- f.close()
15+ # python's netrc will complain about access permissions starting with
16+ # 2.7.5-8 so we restrict the access unconditionally
17+ osutils.chmod_if_possible(netrc_path, 0600)
19 def _get_netrc_cs(self):
20 return config.credential_store_registry.get_credential_store('netrc')
22=== modified file 'doc/en/release-notes/bzr-2.7.txt'
23--- doc/en/release-notes/bzr-2.7.txt 2013-07-27 12:53:28 +0000
24+++ doc/en/release-notes/bzr-2.7.txt 2013-10-01 16:36:45 +0000
25@@ -56,6 +56,8 @@
26 suite. This can include new facilities for writing tests, fixes to
27 spurious test failures and changes to the way things should be tested.
29+* Restrict access to '.netrc' in tests or recent python (2.7.5-8) will
30+ complain. (Vincent Ladeuil, #1233413)
32 ..
33 vim: tw=74 ft=rst ff=unix