New submission from STINNER Victor <vstin...@python.org>:

One way to disable logging in a configuration file is to use /dev/null as the 
filename for logs. It is fine to use that with FileHandler.

The problem is when TimedRotatingFileHandler is used. When Python decides to 
rotate the "file", it calls os.rename() on /dev/null *device* and create a new 
/dev/null *file* which will be quickly filled by all applications on the system 
writing into /dev/null.

The problem is only possible if the process is allowed to rename the device 
/dev/null. For example, a regular user gets a permission error.

I see different options:

* TimedRotatingFileHandler should disable rotation if it detects that the file 
is a device (not a regular file)
* logging should switch to NullHandler if filename is equal to os.path.devnull.

I guess that the problem is the same if the filename points to a socket or a 
named pipe.


RotatingFileHandler may also be affected, I didn't check.


... I'm quite sure that I had the same issue with Twisted years ago, but I 
don't recall the details :-) Twisted didn't use the logging module if I recall 
correctly.


RHEL downstream issue: https://bugzilla.redhat.com/show_bug.cgi?id=2009200

----------
components: Library (Lib)
messages: 403371
nosy: vinay.sajip, vstinner
priority: normal
severity: normal
status: open
title: logging TimedRotatingFileHandler must not rename devices like /dev/null
versions: Python 3.11

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45401>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to