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

[asyncio] bind() on a unix socket raises PermissionError on Android for a non-root user #83022

Closed
xdegaye mannequin opened this issue Nov 18, 2019 · 6 comments
Closed
Labels
3.8 only security fixes 3.9 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@xdegaye
Copy link
Mannequin

xdegaye mannequin commented Nov 18, 2019

BPO 38841
Nosy @asvetlov, @xdegaye, @1st1, @miss-islington
PRs
  • bpo-38841: Skip asyncio test_create_datagram_endpoint_existing_sock_unix #17294
  • [3.8] bpo-38841: Skip asyncio test_create_datagram_endpoint_existing_sock_unix (GH-17294) #17299
  • 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 2019-11-20.20:39:37.124>
    created_at = <Date 2019-11-18.22:36:11.271>
    labels = ['type-bug', '3.8', '3.9', 'expert-asyncio']
    title = '[asyncio] bind() on a unix socket raises PermissionError on Android for a non-root user'
    updated_at = <Date 2019-11-20.20:39:37.098>
    user = 'https://github.com/xdegaye'

    bugs.python.org fields:

    activity = <Date 2019-11-20.20:39:37.098>
    actor = 'xdegaye'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-11-20.20:39:37.124>
    closer = 'xdegaye'
    components = ['asyncio']
    creation = <Date 2019-11-18.22:36:11.271>
    creator = 'xdegaye'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38841
    keywords = ['patch']
    message_count = 6.0
    messages = ['356924', '356978', '356979', '356995', '357096', '357100']
    nosy_count = 4.0
    nosy_names = ['asvetlov', 'xdegaye', 'yselivanov', 'miss-islington']
    pr_nums = ['17294', '17299']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38841'
    versions = ['Python 3.8', 'Python 3.9']

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented Nov 18, 2019

    This is the same kind of issue as reported in bpo-28684.

    python -m test -v test_asyncio -m test_create_datagram_endpoint_existing_sock_unix
    == CPython 3.9.0a0 (heads/abifa-dirty:cf805c25e6, Nov 18 2019, 16:40:26) [Clang 8.0.2 (https://andro
    id.googlesource.com/toolchain/clang 40173bab62ec7462
    == Linux-3.10.0+-x86_64-with-libc little-endian
    == cwd: /data/local/tmp/python/tmp/test_python_6046
    == CPU count: 2
    == encodings: locale=UTF-8, FS=utf-8
    0:00:00 Run tests sequentially
    test_create_datagram_endpoint_existing_sock_unix (test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests) ... ERROR
    /data/local/tmp/python/lib/python3.9/unittest/case.py:687: ResourceWarning: unclosed <socket.socket
    fd=7, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_DGRAM, proto=0>
    outcome.errors.clear()
    ResourceWarning: Enable tracemalloc to get the object allocation traceback
    ======================================================================
    ERROR: test_create_datagram_endpoint_existing_sock_unix (test.test_asyncio.test_base_events.BaseEven
    tLoopWithSelectorTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/data/local/tmp/python/lib/python3.9/test/test_asyncio/test_base_events.py", line 1707, in t
    est_create_datagram_endpoint_existing_sock_unix
        sock.bind(path)
    PermissionError: [Errno 13] Permission denied

    Ran 1 test in 0.014s

    FAILED (errors=1)
    test test_asyncio failed
    test_asyncio failed

    == Tests result: FAILURE ==

    1 test failed:
    test_asyncio

    Total duration: 542 ms
    Tests result: FAILURE

    @xdegaye xdegaye mannequin added 3.9 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error labels Nov 18, 2019
    @asvetlov
    Copy link
    Contributor

    Do I understand you correctly: is Android forbids UDP Unix sockets for non-root user?
    Maybe the socket path should point on another location to get the test passed?

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented Nov 19, 2019

    No, it is the SELinux configuration on android devices that forbids binds to named UNIX sockets. Changing from a named UNIX socket to an unnamed UNIX socket would fix the problem. I don't know if all platforms support unnamed UNIX sockets.

    The fix in issue bpo-28684 (referenced in the OP) provides a new decorator to skip the test for platforms such as android.

    @asvetlov
    Copy link
    Contributor

    Please feel free to make a PR for applying @skip_unless_bind_unix_socket decorator.

    @miss-islington
    Copy link
    Contributor

    New changeset 559bad1 by Miss Islington (bot) (xdegaye) in branch 'master':
    bpo-38841: Skip asyncio test_create_datagram_endpoint_existing_sock_unix (GH-17294)
    559bad1

    @miss-islington
    Copy link
    Contributor

    New changeset b762375 by Miss Islington (bot) in branch '3.8':
    bpo-38841: Skip asyncio test_create_datagram_endpoint_existing_sock_unix (GH-17294)
    b762375

    @xdegaye xdegaye mannequin added the 3.8 only security fixes label Nov 20, 2019
    @xdegaye xdegaye mannequin closed this as completed Nov 20, 2019
    @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.8 only security fixes 3.9 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants