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

Calls to platform._syscmd_ver() dependent functions consume STDIN #88738

Closed
Konstantin-Glukhov mannequin opened this issue Jul 6, 2021 · 12 comments
Closed

Calls to platform._syscmd_ver() dependent functions consume STDIN #88738

Konstantin-Glukhov mannequin opened this issue Jul 6, 2021 · 12 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Konstantin-Glukhov
Copy link
Mannequin

Konstantin-Glukhov mannequin commented Jul 6, 2021

BPO 44572
Nosy @pfmoore, @tjguk, @zware, @zooba, @pablogsal, @miss-islington, @Konstantin-Glukhov
PRs
  • bpo-44572: On Windows platform disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption #27050
  • bpo-44572: On Windows platform disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption #27092
  • [3.10] bpo-44572: On Windows, disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption (GH-27092) #27124
  • [3.9] bpo-44572: On Windows, disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption (GH-27092) #27125
  • 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 2021-07-14.16:17:42.724>
    created_at = <Date 2021-07-06.16:21:17.421>
    labels = ['type-bug', '3.9', '3.10', '3.11', 'library', 'OS-windows']
    title = 'Calls to platform._syscmd_ver() dependent functions consume STDIN'
    updated_at = <Date 2021-07-14.16:17:42.723>
    user = 'https://github.com/Konstantin-Glukhov'

    bugs.python.org fields:

    activity = <Date 2021-07-14.16:17:42.723>
    actor = 'steve.dower'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-07-14.16:17:42.724>
    closer = 'steve.dower'
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2021-07-06.16:21:17.421>
    creator = 'glukhov.k'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44572
    keywords = ['patch', '3.9regression']
    message_count = 12.0
    messages = ['397044', '397052', '397053', '397055', '397083', '397085', '397101', '397103', '397439', '397444', '397491', '397492']
    nosy_count = 7.0
    nosy_names = ['paul.moore', 'tim.golden', 'zach.ware', 'steve.dower', 'pablogsal', 'miss-islington', 'glukhov.k']
    pr_nums = ['27050', '27092', '27124', '27125']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44572'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @Konstantin-Glukhov
    Copy link
    Mannequin Author

    Konstantin-Glukhov mannequin commented Jul 6, 2021

    Starting with version 3.9.5 platform.win32* functions have been re-written and consume STDIN. The bug comes down to running 'ver', 'command /c ver', 'cmd /c ver' in platform._syscmd_ver() via subprocess.check_output().

    The following code demonstrate the problem:

    Python\396\python -c "import platform as p, sys;print(sys.stdin.tell());p.win32_ver();print(sys.stdin.tell())" < file
    0
    8000

    All functions dependent on platform._syscmd_ver(), including platform.uname(), consume STDIN.

    This behavior breaks all the scripts on Windows platform that have the calls mentioned above and use the following invocation:

    python script.py < file

    @Konstantin-Glukhov Konstantin-Glukhov mannequin added topic-IO 3.9 only security fixes stdlib Python modules in the Lib dir OS-windows type-bug An unexpected behavior, bug, or error labels Jul 6, 2021
    @Konstantin-Glukhov
    Copy link
    Mannequin Author

    Konstantin-Glukhov mannequin commented Jul 6, 2021

    The obvious fix is to add "stdin=subprocess.DEVNULL" argument to check_output() call.

    @zware
    Copy link
    Member

    zware commented Jul 6, 2021

    Would you like to create a pull request to that effect?

    @zware zware added 3.10 only security fixes 3.11 only security fixes and removed topic-IO labels Jul 6, 2021
    @Konstantin-Glukhov
    Copy link
    Mannequin Author

    Konstantin-Glukhov mannequin commented Jul 6, 2021

    I will try

    @Konstantin-Glukhov
    Copy link
    Mannequin Author

    Konstantin-Glukhov mannequin commented Jul 7, 2021

    Well, I opened pull request, but it was closed. You guys have a very good team work going on out there :) Good luck!

    @zware
    Copy link
    Member

    zware commented Jul 7, 2021

    The pull request you opened was invalid, because it was just trying to merge the main branch of the python/cpython repository into the 3.9 branch. What we need instead is a pull request between a branch from main in your own fork of python/cpython with the change you want to see in a new commit. You can find a more detailed walkthrough in the devguide, or if you prefer to leave it for someone else to do that is also a valid option :)

    @Konstantin-Glukhov
    Copy link
    Mannequin Author

    Konstantin-Glukhov mannequin commented Jul 7, 2021

    I do not understand why a one line change in the code requires full blown git clone. Shouldn't you guys have a system that allows to change code over the web interface and your bots will do the rest: checks, tests, regressions, etc.?

    @zware
    Copy link
    Member

    zware commented Jul 7, 2021

    You can make a PR entirely through the Github web interface, though we do generally encourage running the tests locally, especially since it would be good to add a new test for this case.

    @zooba
    Copy link
    Member

    zooba commented Jul 13, 2021

    New changeset 0ee0a74 by Konstantin-Glukhov in branch 'main':
    bpo-44572: On Windows, disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption (GH-27092)
    0ee0a74

    @pablogsal
    Copy link
    Member

    New changeset 425756a by Miss Islington (bot) in branch '3.10':
    bpo-44572: On Windows, disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption (GH-27092) (GH-27124)
    425756a

    @zooba
    Copy link
    Member

    zooba commented Jul 14, 2021

    New changeset 5fc784e by Miss Islington (bot) in branch '3.9':
    bpo-44572: On Windows, disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption (GH-27092)
    5fc784e

    @zooba
    Copy link
    Member

    zooba commented Jul 14, 2021

    Thanks for the contribution!

    @zooba zooba closed this as completed Jul 14, 2021
    @zooba zooba closed this as completed Jul 14, 2021
    @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 3.10 only security fixes 3.11 only security fixes OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants