Sudo showing password in clear

オープン
#998 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
50/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
debian, python
領域
cli, security

調査の方向性

Reproduce the Debian 12 example, then start in invoke/context.py at Context.sudo and _sudo, following the runner.run call into invoke/runners.py. Check the pty=True path and password prompt handling; done means the sudo password is not displayed while the command and authentication behavior work correctly.

索引モデルが issue の本文から書いたものです。

説明

On Debian 12, Context.sudo shows the password in clear.

Task:

from invoke import task

@task
def test(c):
    c.run("whoami")
    c.sudo("whoami", pty=True)

Bug:

$ inv test
user
[sudo] password: <shows my password in clear>
Sorry, try again.
root
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/invoke/context.py", line 215, in _sudo
    return runner.run(cmd_str, watchers=watchers, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/invoke/runners.py", line 376, in run
    return self._run_body(command, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/invoke/runners.py", line 432, in _run_body
    return self.make_promise() if self._asynchronous else self._finish()
                                                          ^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/invoke/runners.py", line 493, in _finish
    raise Failure(result, reason=watcher_errors[0])
invoke.exceptions.Failure: Command was not fully executed due to watcher error.
=== stdout ===
root

=== stderr ===
[sudo] password: Sorry, try again.


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/inv", line 33, in <module>
    sys.exit(load_entry_point('invoke==2.0.0', 'console_scripts', 'inv')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/invoke/program.py", line 380, in run
    self.execute()
  File "/usr/lib/python3/dist-packages/invoke/program.py", line 565, in execute
    executor.execute(*self.tasks)
  File "/usr/lib/python3/dist-packages/invoke/executor.py", line 127, in execute
    result = call.task(*args, **call.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/invoke/tasks.py", line 115, in __call__
    result = self.body(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/tasks.py", line 7, in test
    c.sudo("whoami")
  File "/usr/lib/python3/dist-packages/invoke/context.py", line 170, in sudo
    return self._sudo(runner, command, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/invoke/context.py", line 227, in _sudo
    raise error
invoke.exceptions.AuthFailure: The password submitted to prompt '[sudo] password: ' was rejected.

Note that the command is executed correctly but we receive an AuthFailure

主要言語
Python
スター
4.8k
フォーク
412
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pyinvoke/invoke のほかの issue

pyinvoke/invoke の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。