[New-bugs-announce] [issue3228] mailbox.mbox creates files with execute bit set

Piotr Lewandowski report at bugs.python.org
Sat Jun 28 21:23:39 CEST 2008

New submission from Piotr Lewandowski <piotr.lewandowski at gmail.com>:

$ umask

$ stat /tmp/foobar
stat: cannot stat `/tmp/foobar': No such file or directory

$ python -c "from mailbox import mbox; m=mbox('/tmp/foobar',
create=True); m.add(''); m.close()"

$ stat -c '%A' /tmp/foobar

Bug is probably present in _create_carefully() function in mailbox.py.
os.open() takes mode argument (which defaults to 0777) but it's not
supplied there.

$ grep -A2 'def _create_carefully' /usr/lib/python2.5/mailbox.py
def _create_carefully(path):
    """Create a file if it doesn't exist and open for reading and
    fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR)

components: Library (Lib)
messages: 68896
nosy: pl
severity: normal
status: open
title: mailbox.mbox creates files with execute bit set
type: behavior
versions: Python 2.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list