classification
Title: Syslogs /usr/sbin/foo as /foo instead of as foo
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.9
process
Status: closed Resolution: duplicate
Dependencies: Superseder: syslog: Default "ident" in syslog.openlog() shouldn't contain slash
View: 38361
Assigned To: Nosy List: andrei.avk, canvon, jafo
Priority: normal Keywords:

Created on 2016-08-27 09:48 by canvon, last changed 2021-07-09 18:54 by ned.deily. This issue is now closed.

Files
File name Uploaded Description Edit
test-syslog.py canvon, 2016-08-27 09:48 Test script to produce a broken syslog entry.
Messages (2)
msg273770 - (view) Author: Fabian Pietsch (canvon) Date: 2016-08-27 09:48
When calling syslog.syslog() without calling syslog.openlog() before, openlog() gets called with no arguments. Documentation says: "The optional ident keyword argument is a string which is prepended to every message, and defaults to sys.argv[0] with leading
path components stripped." -- "35.13. syslog — Unix syslog library routines"

It leaves the final slash in, though. This produces syslog output for /usr/sbin/foo with identifier "/foo" instead of "foo". When reading syslog unprepared, one can easily think that to be a bug in the specific python script at hand (which it's not), or a chroot to be involved (which it's not, usually). So I consider this a bug.

On freenode/#python I was referred to https://github.com/python/cpython/blob/master/Modules/syslogmodule.c#L98 for the code that does this.

This issue is forwarded from a minor bug report reported by me at Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=835577

A test script is attached, which, when called with absolute path, produces this in syslog:

  Aug 27 08:53:27 blackbox /test-syslog.py: Test from python!

The slash is misleading/wrong.
msg397041 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-07-06 14:37
This was fixed in https://github.com/python/cpython/pull/16557 , so can be closed.
History
Date User Action Args
2021-07-09 18:54:59ned.deilysetstatus: open -> closed
superseder: syslog: Default "ident" in syslog.openlog() shouldn't contain slash
stage: needs patch -> resolved
resolution: duplicate
versions: + Python 3.9, - Python 3.5, Python 3.6, Python 3.8
2021-07-06 14:37:03andrei.avksetnosy: + andrei.avk
messages: + msg397041
2021-02-22 18:55:17deragonsetversions: + Python 3.8
2016-08-27 15:06:06SilentGhostsetnosy: + jafo
stage: needs patch

components: + Extension Modules
versions: + Python 3.5, Python 3.6
2016-08-27 09:48:31canvoncreate