[New-bugs-announce] [issue38361] syslog: Default "ident" in syslog.openlog() shouldn't contain slash

Vaclav Bartos report at bugs.python.org
Thu Oct 3 07:38:58 EDT 2019


New submission from Vaclav Bartos <bartos at cesnet.cz>:

When `syslog.openlog()` is called without parameters (or `syslog.syslog()` is called directly), the `ident` parameter should be set to "sys.argv[0] with leading path components stripped" (citation from docs).

I suppose this means that when sys.argv[0] is "/some/path/to/script", the ident should be set to "script" (this is the behavior in Python 2.7)

However, in Python 3.x, it gets set to "/script", i.e. the last slash is included in the string. I suppose this is not intended, it is just a "one-off" error in parsing the string.

The fix is trivial, see the linked GitHub PR.


To reproduce the bug:

$ python3
>>> import sys
>>> import syslog
>>> sys.argv[0] = "/some/path/to/script"
>>> syslog.syslog("TEST MESSAGE")
>>> 
$ tail -n 1 /var/log/messages
Oct  3 11:11:46 localhost /script: TEST MESSAGE

----------
components: Extension Modules
messages: 353839
nosy: vaclavbartos
priority: normal
pull_requests: 16147
severity: normal
status: open
title: syslog: Default "ident" in syslog.openlog() shouldn't contain slash
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38361>
_______________________________________


More information about the New-bugs-announce mailing list