New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mailbox.mbox.flush() loses mailbox owner #117467
Comments
The suggestion LGTM. Do you mind to create a PR, @softins? |
Sure, will do. I think I will actually change |
Silently ignoring arbitrary exceptions is never a good idea. KeyboardInterrupt, MemoryError and RecursionError can be raised by virtually any code. It is better to make the exception check more specific, for example: |
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…17510) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
In the
flush()
method for mbox mailboxes, after writing the new file, it correctly copies the file modes from the old file to the new one:cpython/Lib/mailbox.py
Lines 753 to 755 in 027fa2e
However, it doesn't copy the user.group ownership of the old file to the new one, and I think it should.
I implemented a python program to modify a mailbox, in this case to delete old messages from a spam folder. The program runs as root, so that it can operate on folders belonging to different users without having to suid to each user. I found that on flushing after any changes, the mailbox was owned by root.root instead of by its original owner.
Suggest the following code instead:
Linked PRs
The text was updated successfully, but these errors were encountered: