3

構成変更を実行するために最初に実行するときに、一時的にルートを必要とするプログラムを作成しています (ファイルを に作成します/etc)。

グラフィカル ダイアログ ボックスでユーザーにパスワードを要求して、一時的に root を取得するにはどうすればよいですか?

gksudoプログラムはQtを使用しており、Ubuntuでのみ動作する場合はかなり満足していますが、それらがインストールされているか、インストールされているとは思いたくありません。私も使えませんSUID

私が考えることができる唯一のことは、独自のパスワードダイアログを提供し、それを(または安全性の低いいとこの1つをsudo介して)コマンドラインバイナリに供給することです。system()

しかし、それはかなりハックに思えます - コマンドラインのフロントエンドは一般的にひどいアイデアであり、絶対に避けるべきです. それで、より良い方法はありますか?おそらくlibsudo、またはIPCを使用する方法がありますか?

注意:これは複製ではありません。または、少なくとも、そこにある回答は、私が求めている質問としてそれを扱っていません。

4

1 に答える 1

1

からman sudo:

   -A          Normally, if sudo requires a password, it will read it from the
               user's terminal.  If the -A (askpass) option is specified, a
               (possibly graphical) helper program is executed to read the user's
               password and output the password to the standard output.  If the
               SUDO_ASKPASS environment variable is set, it specifies the path to
               the helper program.  Otherwise, if /etc/sudo.conf contains a line
               specifying the askpass program, that value will be used.  For
               example:

                   # Path to askpass helper program
                   Path askpass /usr/X11R6/bin/ssh-askpass

               If no askpass program is available, sudo will exit with an error.

多くのシステムにインストールされている ssh-askpass を使用するか、sudo に指定する独自のパスワード プロンプト コマンドを作成します。これはまだ少し面倒ですが、パスワードを sudo に伝えることについてあまり心配する必要はありません。

于 2013-03-02T00:36:54.470 に答える