Rev 4714: Change to using os.open() allowing the users umask to handle perms. in http://bazaar.launchpad.net/~jameinel/bzr/2.0.4-faster-export-343218
John Arbash Meinel
john at arbash-meinel.com
Thu Dec 17 14:54:38 GMT 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.0.4-faster-export-343218
------------------------------------------------------------
revno: 4714
revision-id: john at arbash-meinel.com-20091217145420-5cmm4iqody73e5sm
parent: john at arbash-meinel.com-20091215220424-ck24mtbcu95fz0zv
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.0.4-faster-export-343218
timestamp: Thu 2009-12-17 08:54:20 -0600
message:
Change to using os.open() allowing the users umask to handle perms.
So a user with 0007 will not create other-readable files in the export.
-------------- next part --------------
=== modified file 'bzrlib/export/dir_exporter.py'
--- a/bzrlib/export/dir_exporter.py 2009-12-15 17:20:40 +0000
+++ b/bzrlib/export/dir_exporter.py 2009-12-17 14:54:20 +0000
@@ -78,16 +78,19 @@
(ie.file_id, ie.kind))
# The data returned here can be in any order, but we've already created all
# the directories
+ flags = os.O_CREAT | os.O_TRUNC | os.O_WRONLY | getattr(os, 'O_BINARY', 0)
for (relpath, executable), chunks in tree.iter_files_bytes(to_fetch):
if filtered:
filters = tree._content_filter_stack(relpath)
context = ContentFilterContext(relpath, tree, ie)
chunks = filtered_output_bytes(chunks, filters, context)
fullpath = osutils.pathjoin(dest, relpath)
- out = open(fullpath, 'wb')
+ # We set the mode and let the umask sort out the file info
+ mode = 0666
+ if executable:
+ mode = 0777
+ out = os.fdopen(os.open(fullpath, flags, mode))
try:
out.writelines(chunks)
finally:
out.close()
- if executable:
- os.chmod(fullpath, 0755)
More information about the bazaar-commits
mailing list