Rev 3121: (jam) avoid creating files that we cannot write to in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Dec 17 16:13:58 GMT 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3121
revision-id:pqm at pqm.ubuntu.com-20071217161351-bz4ut40863m03doj
parent: pqm at pqm.ubuntu.com-20071217060447-sictlq5nibqhpuec
parent: john at arbash-meinel.com-20071217151728-0ce4m40iq9pd983d
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2007-12-17 16:13:51 +0000
message:
(jam) avoid creating files that we cannot write to
modified:
bzrlib/lockable_files.py control_files.py-20051111201905-bb88546e799d669f
bzrlib/tests/test_lockable_files.py test_lockable_files.py-20051225183927-365c7fd99591caf1
------------------------------------------------------------
revno: 3107.2.2
revision-id:john at arbash-meinel.com-20071217151728-0ce4m40iq9pd983d
parent: john at arbash-meinel.com-20071213201706-nt8f4om80gyn6l6v
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-integration
timestamp: Mon 2007-12-17 09:17:28 -0600
message:
feedback from Martin.
modified:
bzrlib/tests/test_lockdir.py test_lockdir.py-20060220222025-33d4221569a3d600
------------------------------------------------------------
revno: 3107.2.1
revision-id:john at arbash-meinel.com-20071213201706-nt8f4om80gyn6l6v
parent: pqm at pqm.ubuntu.com-20071213141047-tklbta8rymzfpj6y
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-integration
timestamp: Thu 2007-12-13 14:17:06 -0600
message:
Fix LockableFiles to not use modes that allow the user to write to things they create.
It seems that cygwin + FAT32 will report all directories as readonly,
even though they are not.
Regardless, someone might have .bzr/repository as readonly, but still
allow you to create files in a subdirectory.
Either way, there is no reason to have a file that we are going to
write to be created readonly.
modified:
bzrlib/lockable_files.py control_files.py-20051111201905-bb88546e799d669f
bzrlib/tests/test_lockable_files.py test_lockable_files.py-20051225183927-365c7fd99591caf1
bzrlib/tests/test_lockdir.py test_lockdir.py-20060220222025-33d4221569a3d600
=== modified file 'bzrlib/lockable_files.py'
--- a/bzrlib/lockable_files.py 2007-08-15 04:33:34 +0000
+++ b/bzrlib/lockable_files.py 2007-12-13 20:17:06 +0000
@@ -132,7 +132,11 @@
self._dir_mode = 0755
self._file_mode = 0644
else:
- self._dir_mode = st.st_mode & 07777
+ # Check the directory mode, but also make sure the created
+ # directories and files are read-write for this user. This is
+ # mostly a workaround for filesystems which lie about being able to
+ # write to a directory (cygwin & win32)
+ self._dir_mode = (st.st_mode & 07777) | 00700
# Remove the sticky and execute bits for files
self._file_mode = self._dir_mode & ~07111
if not self._set_dir_mode:
=== modified file 'bzrlib/tests/test_lockable_files.py'
--- a/bzrlib/tests/test_lockable_files.py 2007-04-19 14:55:20 +0000
+++ b/bzrlib/tests/test_lockable_files.py 2007-12-13 20:17:06 +0000
@@ -17,11 +17,13 @@
from StringIO import StringIO
import bzrlib
-import bzrlib.errors as errors
+from bzrlib import (
+ errors,
+ lockdir,
+ osutils,
+ )
from bzrlib.errors import BzrBadParameterNotString, NoSuchFile, ReadOnlyError
from bzrlib.lockable_files import LockableFiles, TransportLock
-from bzrlib import lockdir
-from bzrlib.lockdir import LockDir
from bzrlib.tests import TestCaseInTempDir
from bzrlib.tests.test_smart import TestCaseWithSmartMedium
from bzrlib.tests.test_transactions import DummyWeave
@@ -347,7 +349,7 @@
self.lockable.create_lock()
def get_lockable(self):
- return LockableFiles(self.transport, 'my-lock', LockDir)
+ return LockableFiles(self.transport, 'my-lock', lockdir.LockDir)
def test_lock_created(self):
self.assertTrue(self.transport.has('my-lock'))
@@ -357,10 +359,16 @@
self.assertFalse(self.transport.has('my-lock/held/info'))
self.assertTrue(self.transport.has('my-lock'))
+ def test__file_modes(self):
+ self.transport.mkdir('readonly')
+ osutils.make_readonly('readonly')
+ lockable = LockableFiles(self.transport.clone('readonly'), 'test-lock',
+ lockdir.LockDir)
+ # The directory mode should be read-write-execute for the current user
+ self.assertEqual(00700, lockable._dir_mode & 00700)
+ # Files should be read-write for the current user
+ self.assertEqual(00600, lockable._file_mode & 00700)
- # TODO: Test the lockdir inherits the right file and directory permissions
- # from the LockableFiles.
-
class TestLockableFiles_RemoteLockDir(TestCaseWithSmartMedium,
_TestLockableFiles_mixin):
More information about the bazaar-commits
mailing list