Rev 6588: Make .netrc 0600 in tests to fix python-2.7.5-8's netrc happy. in file:///home/vila/src/bzr/bugs/1233413-netrc/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Oct 1 13:13:46 UTC 2013


At file:///home/vila/src/bzr/bugs/1233413-netrc/

------------------------------------------------------------
revno: 6588
revision-id: v.ladeuil+lp at free.fr-20131001131346-pkcqu4do6wt0amn1
parent: pqm at pqm.ubuntu.com-20130810150930-5heu5saz1ovys4wo
fixes bug: https://launchpad.net/bugs/1233413
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 1233413-netrc
timestamp: Tue 2013-10-01 15:13:46 +0200
message:
  Make .netrc 0600 in tests to fix python-2.7.5-8's netrc happy.
-------------- next part --------------
=== modified file 'bzrlib/plugins/netrc_credential_store/tests/test_netrc.py'
--- a/bzrlib/plugins/netrc_credential_store/tests/test_netrc.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/plugins/netrc_credential_store/tests/test_netrc.py	2013-10-01 13:13:46 +0000
@@ -15,6 +15,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 from cStringIO import StringIO
+import os
 
 from bzrlib import (
     config,
@@ -43,11 +44,12 @@
 machine host login joe password secret
 default login anonymous password joe at home
 """
-        f = open(osutils.pathjoin(self.test_home_dir, '.netrc'), 'wb')
-        try:
+        netrc_path = osutils.pathjoin(self.test_home_dir, '.netrc')
+        with open(netrc_path, 'wb') as f:
             f.write(netrc_content)
-        finally:
-            f.close()
+        # python's netrc will complain about access permissions starting with
+        # 2.7.5-8 so we restrict the access unconditionally
+        os.chmod(netrc_path, 0600)
 
     def _get_netrc_cs(self):
         return  config.credential_store_registry.get_credential_store('netrc')

=== modified file 'doc/en/release-notes/bzr-2.7.txt'
--- a/doc/en/release-notes/bzr-2.7.txt	2013-07-27 12:53:28 +0000
+++ b/doc/en/release-notes/bzr-2.7.txt	2013-10-01 13:13:46 +0000
@@ -56,6 +56,8 @@
    suite.  This can include new facilities for writing tests, fixes to 
    spurious test failures and changes to the way things should be tested.
 
+* Restrict access to '.netrc' in tests or recent python (2.7.5-8) will
+  complain. (Vincent Ladeuil, #1233413)
 
 ..
    vim: tw=74 ft=rst ff=unix



More information about the bazaar-commits mailing list