logging.py: mutiple system users writing to same file getting permission errors.

evenrik evenson at gmail.com
Thu Dec 6 13:35:36 EST 2007


An a redhat box I have root, apache and other normal users run code
that uses the logging module to write to the same log file.  Since
umasks are set to 2 or 022 this gets permission errors.

I have fixed my issue by patching the logging code everywhere there is
an open for write with:
try:
    old_umask = os.umask(0)
    # open for write here
finally:
    os.umask(old_umask)

Is there a better way to solve this issue?
Are there any security problems with this solution other than the log
file not being protected?



More information about the Python-list mailing list