Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Linux sudo raises UnexpectedExit instead of AuthFailure on incorrect password

Đang mở
#918 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
authentication, cli

Hướng nghiên cứu

Start with the Linux sudo path in invoke/context.py, especially _sudo, then trace the runner behavior named in invoke/runners.py through _finish. Compare the incorrect-password result with the macOS behavior; done means invoke.sudo raises AuthFailure rather than UnexpectedExit for the reported Linux case.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

On Linux, invoke.sudo raises UnexpectedExit instead of AuthFailure on incorrect password.

>>> import invoke
>>> invoke.sudo("ls", password="a")
[sudo] password: Sorry, try again.
[sudo] password: Sorry, try again.
[sudo] password: sudo: 3 incorrect password attempts
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/__init__.py", line 68, in sudo
    return Context().sudo(command, **kwargs)
  File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/context.py", line 170, in sudo
    return self._sudo(runner, command, **kwargs)
  File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/context.py", line 215, in _sudo
    return runner.run(cmd_str, watchers=watchers, **kwargs)
  File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/runners.py", line 376, in run
    return self._run_body(command, **kwargs)
  File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/runners.py", line 432, in _run_body
    return self.make_promise() if self._asynchronous else self._finish()
  File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/runners.py", line 499, in _finish
    raise UnexpectedExit(result)
invoke.exceptions.UnexpectedExit: Encountered a bad command exit code!

Command: "sudo -S -p '[sudo] password: ' ls"

Exit code: 1

Stdout: already printed

Stderr: already printed

Version info

invoke: 2.0.0 (also tested on 1.7.1)
OS: Ubuntu 20.04.5 LTS
Python: 3.7.13 (also tested on 3.8.13 and 3.10.5)

I tested this on macOS and it raises AuthFailure as expected.

Ngôn ngữ chính
Python
Star
4.8k
Fork
412
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pyinvoke/invoke

Tất cả issue của pyinvoke/invoke

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.