Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
25652884
Commit
25652884
authored
Jun 29, 2012
by
Petri Lehtinen
Browse files
Options
Browse Files
Download
Plain Diff
#5346: Preserve permissions of mbox, MMDF and Babyl mailbox files on flush()
parents
31a78c3d
5b5619f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
+23
-0
Lib/mailbox.py
Lib/mailbox.py
+3
-0
Lib/test/test_mailbox.py
Lib/test/test_mailbox.py
+17
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/mailbox.py
View file @
25652884
...
...
@@ -691,6 +691,9 @@ class _singlefileMailbox(Mailbox):
_sync_close
(
new_file
)
# self._file is about to get replaced, so no need to sync.
self
.
_file
.
close
()
# Make sure the new file's mode is the same as the old file's
mode
=
os
.
stat
(
self
.
_path
).
st_mode
os
.
chmod
(
new_file
.
name
,
mode
)
try
:
os
.
rename
(
new_file
.
name
,
self
.
_path
)
except
OSError
as
e
:
...
...
Lib/test/test_mailbox.py
View file @
25652884
...
...
@@ -969,6 +969,23 @@ class _TestSingleFile(TestMailbox):
self
.
_box
=
self
.
_factory
(
self
.
_path
)
self
.
assertEqual
(
len
(
self
.
_box
),
1
)
def
test_permissions_after_flush
(
self
):
# See issue #5346
# Make the mailbox world writable. It's unlikely that the new
# mailbox file would have these permissions after flush(),
# because umask usually prevents it.
mode
=
os
.
stat
(
self
.
_path
).
st_mode
|
0o666
os
.
chmod
(
self
.
_path
,
mode
)
self
.
_box
.
add
(
self
.
_template
%
0
)
i
=
self
.
_box
.
add
(
self
.
_template
%
1
)
# Need to remove one message to make flush() create a new file
self
.
_box
.
remove
(
i
)
self
.
_box
.
flush
()
self
.
assertEqual
(
os
.
stat
(
self
.
_path
).
st_mode
,
mode
)
class
_TestMboxMMDF
(
_TestSingleFile
):
...
...
Misc/NEWS
View file @
25652884
...
...
@@ -14,6 +14,9 @@ Core and Builtins
Library
-------
- Issue #5346: Preserve permissions of mbox, MMDF and Babyl mailbox
files on flush().
- Issue #10571: Fix the "--sign" option of distutils'
upload
command
.
Patch
by
Jakub
Wilk
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment