classification
Title: [asyncio] bind() on a unix socket raises PermissionError on Android for a non-root user
Type: behavior Stage: resolved
Components: asyncio Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, miss-islington, xdegaye, yselivanov
Priority: normal Keywords: patch

Created on 2019-11-18 22:36 by xdegaye, last changed 2019-11-20 20:39 by xdegaye. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17294 merged xdegaye, 2019-11-20 15:16
PR 17299 merged miss-islington, 2019-11-20 20:02
Messages (6)
msg356924 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2019-11-18 22:36
This is the same kind of issue as reported in #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
msg356978 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-11-19 16:49
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?
msg356979 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2019-11-19 17:35
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 #28684 (referenced in the OP) provides a new decorator to skip the test for platforms such as android.
msg356995 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-11-19 22:00
Please feel free to make a PR for applying @skip_unless_bind_unix_socket decorator.
msg357096 - (view) Author: miss-islington (miss-islington) Date: 2019-11-20 20:02
New changeset 559bad1a70ed50cc9caa7cb303b6ac1fe6a34af3 by Miss Islington (bot) (xdegaye) in branch 'master':
bpo-38841: Skip asyncio test_create_datagram_endpoint_existing_sock_unix (GH-17294)
https://github.com/python/cpython/commit/559bad1a70ed50cc9caa7cb303b6ac1fe6a34af3
msg357100 - (view) Author: miss-islington (miss-islington) Date: 2019-11-20 20:20
New changeset b762375ba28893be73f166576aecde44ad2f4001 by Miss Islington (bot) in branch '3.8':
bpo-38841: Skip asyncio test_create_datagram_endpoint_existing_sock_unix (GH-17294)
https://github.com/python/cpython/commit/b762375ba28893be73f166576aecde44ad2f4001
History
Date User Action Args
2019-11-20 20:39:37xdegayesetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.8
2019-11-20 20:20:29miss-islingtonsetmessages: + msg357100
2019-11-20 20:02:28miss-islingtonsetnosy: + miss-islington
messages: + msg357096
2019-11-20 20:02:21miss-islingtonsetpull_requests: + pull_request16791
2019-11-20 15:16:08xdegayesetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request16787
2019-11-19 22:00:21asvetlovsetmessages: + msg356995
2019-11-19 17:35:02xdegayesetmessages: + msg356979
2019-11-19 16:49:41asvetlovsetmessages: + msg356978
2019-11-18 22:36:11xdegayecreate