MagicStack / MagicStack/asyncpg
Exception when attempting to fetch SSL info
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 8.1k
- Fork
- 468
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Thanks for creating asyncpg! It's dramatically improved the performance of my [open-source web application](https://github.com/RunestoneInteractive) ([Runestone Academy](https://runestone.academy/), a free interactive e-book).
To reproduce this bug, simply start asyncpg as a non-root user (one without permission to access `/root`).
* **asyncpg version**: 0.25
* **PostgreSQL version**: 12.7
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?**: I use AWS RDS; haven't tested locally
* **Python version**: 3.9.1
* **Platform**: Debian GNU/Linux 11 (bullseye)
* **Do you use pgbouncer?**: No
* **Did you install asyncpg with pip?**: Yes
* **If you built asyncpg locally, which version of Cython did you use?**: N/A
* **Can the issue be reproduced under both asyncio and
[uvloop](https://github.com/magicstack/uvloop)?**: I only use asyncio
I run asyncpg as a non-root user for improved security; this user lacks root access. During startup in asyncpg v. 0.25, I see the error like this:
```
File "/srv/web2py/applications/runestone/.venv/lib/python3.9/site-packages/asyncpg/connection.py", line 2085, in connect
return await connect_utils._connect(
File "/srv/web2py/applications/runestone/.venv/lib/python3.9/site-packages/asyncpg/connect_utils.py", line 874, in _connect
addrs, params, config = _parse_connect_arguments(timeout=timeout, **kwargs)
File "/srv/web2py/applications/runestone/.venv/lib/python3.9/site-packages/asyncpg/connect_utils.py", line 640, in _parse_connect_arguments
addrs, params = _parse_connect_dsn_and_args(
File "/srv/web2py/applications/runestone/.venv/lib/python3.9/site-packages/asyncpg/connect_utils.py", line 543, in _parse_connect_dsn_and_args
if not sslkey.exists():
File "/usr/local/lib/python3.9/pathlib.py", line 1424, in exists
self.stat()
File "/usr/local/lib/python3.9/pathlib.py", line 1232, in stat
return self._accessor.stat(self)
PermissionError: [Errno 13] Permission denied
```
In [connect_utils.py line 543](https://github.com/MagicStack/asyncpg/commit/383c711eb68bc6a042c121e1fddfde0cdefb8068#diff-fe0ec192392fe4131382e009b40723ba9469e62ab4760fed681a438d1d352bc3R529), asyncpg checks if a root-owned file exists. Unfortunately, a non-root user gets a permission denied exception instead of a False return value from `exists()`. It looks like wrapping this in a try/except would fix this bug. (It looks like [a later exception](https://github.com/MagicStack/asyncpg/commit/383c711eb68bc6a042c121e1fddfde0cdefb8068#diff-fe0ec192392fe4131382e009b40723ba9469e62ab4760fed681a438d1d352bc3R529) needs PermissionError added to it.)
For me, reverting to asyncpg v. 0.24 causes my code to run without problems.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu trong connect_utils.py, khoảng dòng 543, nơi sự tồn tại của khóa SSL được kiểm tra trong quá trình phân tích các đối số kết nối. Tái hiện kết nối với tư cách người dùng không phải root, không có quyền truy cập vào /root, sau đó xác minh rằng việc tra cứu SSL không còn gây ra PermissionError và kết nối tiếp tục như với asyncpg 0.24.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- postgresql, python
- Lĩnh vực
- database
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100