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

ctypes test overwrites /dev/null #43660

Closed
scotdoyle mannequin opened this issue Jul 12, 2006 · 6 comments
Closed

ctypes test overwrites /dev/null #43660

scotdoyle mannequin opened this issue Jul 12, 2006 · 6 comments
Assignees
Labels
extension-modules C modules in the Modules dir

Comments

@scotdoyle
Copy link
Mannequin

scotdoyle mannequin commented Jul 12, 2006

BPO 1521375
Nosy @theller
Files
  • gccdevnull.txt: Patch for Lib/ctypes/util.py
  • util.diff: Another patch for Lib/ctypes/util.py
  • 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 = 'https://github.com/theller'
    closed_at = <Date 2006-07-13.17:44:47.000>
    created_at = <Date 2006-07-12.18:22:15.000>
    labels = ['extension-modules']
    title = 'ctypes test overwrites /dev/null'
    updated_at = <Date 2006-07-13.17:44:47.000>
    user = 'https://bugs.python.org/scotdoyle'

    bugs.python.org fields:

    activity = <Date 2006-07-13.17:44:47.000>
    actor = 'theller'
    assignee = 'theller'
    closed = True
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2006-07-12.18:22:15.000>
    creator = 'scotdoyle'
    dependencies = []
    files = ['2066', '2067']
    hgrepos = []
    issue_num = 1521375
    keywords = []
    message_count = 6.0
    messages = ['29144', '29145', '29146', '29147', '29148', '29149']
    nosy_count = 2.0
    nosy_names = ['theller', 'scotdoyle']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1521375'
    versions = ['Python 2.5']

    @scotdoyle
    Copy link
    Mannequin Author

    scotdoyle mannequin commented Jul 12, 2006

    Steps to reproduce on Debian Sarge:

    1. ls -l /dev/null
    2. wget
      http://www.python.org/ftp/python/2.5/Python-2.5b2.tgz
    3. tar xvzf Pyth*
    4. cd Pyth*
    5. ./configure
    6. make
    7. su
    8. make test
    9. ls -l /dev/null

    /dev/null goes from being a special character device to
    a normal file of length zero.

    The following command can be used instead of step 8
    above to delete /dev/null
    ./python -c 'import ctypes.test.test_find'

    To recreate /dev/null:

    1. su
    2. rm /dev/null
    3. mknod -m 666 /dev/null c 1 3
    4. chown root:root /dev/null

    @scotdoyle scotdoyle mannequin closed this as completed Jul 12, 2006
    @scotdoyle scotdoyle mannequin assigned theller Jul 12, 2006
    @scotdoyle scotdoyle mannequin added the extension-modules C modules in the Modules dir label Jul 12, 2006
    @scotdoyle scotdoyle mannequin closed this as completed Jul 12, 2006
    @scotdoyle scotdoyle mannequin assigned theller Jul 12, 2006
    @scotdoyle scotdoyle mannequin added the extension-modules C modules in the Modules dir label Jul 12, 2006
    @theller
    Copy link

    theller commented Jul 12, 2006

    Logged In: YES
    user_id=11105

    Now, that is an 'interesting' bug. ctypes.util.find_library
    does execute shell commands that happen to have '/dev/null'
    in them, but it is completely unclear to me how one can
    overwrite /dev/null (even if root). Can you see anything
    that's wrong there (That code is not from me, and I'm not at
    all an expert in linux programming)?

    BTW, I cannot reproduce this on ubuntu with 'sudo ./python
    -c "import ctypes.test.test_find"'.

    @scotdoyle
    Copy link
    Mannequin Author

    scotdoyle mannequin commented Jul 12, 2006

    Logged In: YES
    user_id=1554504

    Hey Thomas, that pointer is just what I needed :-)

    /dev/null was being deleted by gcc. Discussion at
    http://www.cs.helsinki.fi/linux/linux-kernel/2001-38/1503.html

    The attached patch fixed the problem on Debian Sarge and
    Ubuntu 6.06.

    @theller
    Copy link

    theller commented Jul 13, 2006

    Logged In: YES
    user_id=11105

    Scot, your patch is not correct because 'cmd' is never
    executed. However, I was able to reproduce the overwriting
    of /dev/null by calling 'ctypes.util.find_library' for a
    shared lib that does not exist. Attached is a new patch
    'util.diff' which fixes the problem for me. Can you please
    verify that it also works for you?

    Thanks for finding the bug and locating the problem!

    @scotdoyle
    Copy link
    Mannequin Author

    scotdoyle mannequin commented Jul 13, 2006

    Logged In: YES
    user_id=1554504

    Yes, not executing the command was one way to fix the bug :-)

    Thanks for catching that. I verified the new patch to work.

    @theller
    Copy link

    theller commented Jul 13, 2006

    Logged In: YES
    user_id=11105

    Thanks. Commited as r50619.

    @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
    extension-modules C modules in the Modules dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant