Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syslog: Default "ident" in syslog.openlog() shouldn't contain slash #82542

Closed
vaclavbartos mannequin opened this issue Oct 3, 2019 · 2 comments
Closed

syslog: Default "ident" in syslog.openlog() shouldn't contain slash #82542

vaclavbartos mannequin opened this issue Oct 3, 2019 · 2 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@vaclavbartos
Copy link
Mannequin

vaclavbartos mannequin commented Oct 3, 2019

BPO 38361
Nosy @miss-islington, @brandtbucher, @vaclavbartos
PRs
  • bpo-38361: syslog: fixed making default "ident" from sys.argv[0] #16557
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-01-15.17:46:37.267>
    created_at = <Date 2019-10-03.11:38:58.975>
    labels = ['type-bug', 'library', '3.9']
    title = 'syslog: Default "ident" in syslog.openlog() shouldn\'t contain slash'
    updated_at = <Date 2020-01-15.17:46:37.244>
    user = 'https://github.com/vaclavbartos'

    bugs.python.org fields:

    activity = <Date 2020-01-15.17:46:37.244>
    actor = 'brandtbucher'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-01-15.17:46:37.267>
    closer = 'brandtbucher'
    components = ['Library (Lib)']
    creation = <Date 2019-10-03.11:38:58.975>
    creator = 'vaclavbartos'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38361
    keywords = []
    message_count = 2.0
    messages = ['353839', '359984']
    nosy_count = 3.0
    nosy_names = ['miss-islington', 'brandtbucher', 'vaclavbartos']
    pr_nums = ['16557']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38361'
    versions = ['Python 3.9']

    @vaclavbartos
    Copy link
    Mannequin Author

    vaclavbartos mannequin commented Oct 3, 2019

    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

    @vaclavbartos vaclavbartos mannequin added extension-modules C modules in the Modules dir 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes type-bug An unexpected behavior, bug, or error labels Oct 3, 2019
    @miss-islington
    Copy link
    Contributor

    New changeset f04750b by Miss Islington (bot) (Václav Bartoš) in branch 'master':
    bpo-38361: syslog: fixed making default "ident" from sys.argv[0] (GH-16557)
    f04750b

    @brandtbucher brandtbucher added stdlib Python modules in the Lib dir and removed extension-modules C modules in the Modules dir 3.7 (EOL) end of life 3.8 only security fixes labels Jan 15, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants