[issue27875] Syslogs /usr/sbin/foo as /foo instead of as foo

Fabian Pietsch report at bugs.python.org
Sat Aug 27 05:48:31 EDT 2016


New submission from Fabian Pietsch:

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.

----------
files: test-syslog.py
messages: 273770
nosy: canvon
priority: normal
severity: normal
status: open
title: Syslogs /usr/sbin/foo as /foo instead of as foo
type: behavior
Added file: https://bugs.python.org/file44240/test-syslog.py

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


More information about the Python-bugs-list mailing list