Package: python3.5
Version: 3.5.2-2
Severity: minor

Hi,

when using syslog.syslog() without an explicit call to syslog.openlog()
before, syslog.openlog() gets called automatically with no arguments
and then defaults the logging identifier based on sys.argv[0].
(See [1] for documentation, [2] for the code that does this.)

Specifically: "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." [1]

The path component stripping leaves the final slash in, though.
So, e.g., /usr/sbin/foo logs as "/foo" instead of as "foo". When reading
syslog unprepared, it gives the impression that the python script would
be buggy (though it isn't), or a chroot would be involved (which will
often not be the case, too). So I consider this a (minor) bug.

To reproduce, chmod +x and run this script with absolute path:

==>8=====================================================================

#!/usr/bin/python3 -Es

import syslog

syslog.syslog("Test from python!")

==>8=====================================================================

(The -Es is there because this is what firewalld uses, which I'm trying
to debug.)

On my machine (Debian stretch/testing), this gives the following syslog
result:

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

The slash is misleading/wrong.


A real-world example is firewalld. Run the following, to provoke an
error that gets syslogged:

  # firewall-cmd --permanent --delete-zone=test
  Error: INVALID_ZONE: test

Syslog:

| Aug 27 10:21:47 blackbox /firewalld: ERROR: INVALID_ZONE: test

Again, the slash is misleading/wrong.


I was referred on freenode/#python to [2] for how this happens. So this
does not appear to be Debian-specific. It would be nice if this could be
fixed in Debian at least; apart from that, please forward to upstream.

Regards,
Fabian


[1] /usr/share/doc/python3.5/html/library/syslog.html

[2] https://github.com/python/cpython/blob/master/Modules/syslogmodule.c#L98


-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 4.5.0-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages python3.5 depends on:
ii  libpython3.5-stdlib  3.5.2-2
ii  mime-support         3.60
ii  python3.5-minimal    3.5.2-2

python3.5 recommends no packages.

Versions of packages python3.5 suggests:
ii  binutils        2.26.1-1
ii  python3.5-doc   3.5.2-3
pn  python3.5-venv  <none>

-- no debconf information

Reply via email to