VISUDO(8) MAINTENANCE COMMANDS VISUDO(8) 名前 visudo - sudoers ファイルを編集する 書式 visudo [-c] [-q] [-s] [-V] [-f sudoers] 説明 visudo は vipw(8) によく似た安全なやり方で sudoers ファイルを編集する。 visudo は sudoers ファイルをロックして、重複した編集が同時に行われない ようにするとともに、整合性をざっと調べ、文法エラーのチェックを行う。 sudoers ファイルが現在編集中だった場合は、「try again later」というメッ セージを端末に表示する。 visudo が使用するエディタについては、コンパイル時に設定されたエディタの リストがプログラムに埋め込まれているが、sudoers ファイルの Defaults 行 で editor オプションを使えば、それを変更することができる。このリストは デフォルトでは、使用しているシステムにおける vi(1) のパスであり、 configure スクリプトによって割り出されたものだ。通常 visudo は、環境変 数 VISUAL や EDITOR の値が上述のエディタ・リストに含まれるエディタでな いかぎり、そうした環境変数を使用しない。とは言え、visudo が --with-env-editor オプションを付けて configure されている場合や、 sudoeres ファイルの Defaults 行で env_editor オプションがセットされてい る場合は、visudo は VISUAL や EDITOR によって指定されたどんなエディタで も使用することになる。これがセキュリティホールになりかねないことに注意 してほしい。単に VISUAL や EDITOR を設定するだけで、ユーザが任意のプロ グラムを実行できるようになってしまうからだ。 visudo は編集が終わると、sudoers ファイルの文法解析を行い、文法エラーが あれば、変更を保存しない。visudo はエラーを発見すると、エラーが起きた行 番号を知らせるメッセージを表示し、"What now?" というプロンプトを出す。 このとき、"e" を押せば、 sudoers ファイルを再編集できる。"x" を押せば、 変更を保存せず終了だし、"Q" を押せば、変更を保存して終了だ。 "Q" の選択 は、くれぐれも慎重にやってほしい。なぜなら、 visudo が文法エラーがある と考えるのなら、sudo も同様に考えるはずであり、エラーが訂正されるまで、 もう誰にも sudo が使えなくなってしまうからだ。文法エラーが発見されたと き、"e" を押して sudoers ファイルを編集しようとすると、カーソルがファイ ルのエラーが起きた行に飛ぶ (エディタにその機能があればだが)。 オプション visudo では以下のコマンドラインオプションが使用できる。 -c check-only モードを有効にする。現在の sudoers ファイルの文 法をチェックし、メッセージを標準出力に表示して、 sudoers の 状態を詳細に報告する。文法チェックが成功裡に終わった場合、 visudo は返り値 0 で終了する。文法エラーに出会った場合の返 り値は 1 である。 -f sudoers sudoers ファイルの位置を指定・変更する。このオプションを付 けると、 visudo はデフォルトの /etc/sudoers ではなく、ユー ザが選んだ sudoers ファイルを編集 (あるいは、チェック) する ことになる。ロックファイルとしては、指定された sudoers ファ イルの名前の末尾に ".tmp" を付けたものが使われる。 -q quiet モードを有効にする。このモードでは、文法エラーの詳細 情報は表示されない。このオプションに意味があるのは、-c オプ ションと組み合わせたときだけである。 -s sudoers ファイルの厳密 (strict) チェックを有効にする。エイ リアスを定義する前に使用すると、visudo がそれを文法エラーと 見なすようになるわけだ。ホスト名やユーザ名がアルファベット の大文字、数字、アンダースコア (’_’) だけから構成されている 場合、そうしたものとエイリアスとの区別は付かないことに注意 してほしい。 -V オプションに -V (version) を付けると、visudo はバージョンナ ンバーを表示して、終了する。 環境変数 以下の環境変数が参照されるかどうかは、sudoers の editor や env_editor オプションの値次第である。 VISUAL visudo が起動するエディタ EDITOR VISUAL が設定されていないとき visudo が使用するエディタ ファイル /etc/sudoers 誰が何を実行できるかのリスト /etc/sudoers.tmp visudo が使うロックファイル メッセージによる診断 sudoers file busy, try again later. 現在、ほかの誰かが sudoers ファイルを編集中だ。 /etc/sudoers.tmp: Permission denied visudo を root として実行しなかった。 Can’t find you in the passwd database あなたのユーザ ID はシステムの passwd ファイルに載っていない。 Warning: {User,Runas,Host,Cmnd}_Alias referenced but not defined User_Alias, Runas_Alias, Host_Alias, Cmnd_Alias のどれかを、定義し ないまま使用しようとしている。あるいは、記載したユーザ名かホスト名 の中に、アルファベットの大文字、数字、アンダースコア (’_’) のみから なるものがある。後者の場合は、この warning を無視して構わない (sudo は警告を出さないないだろう)。 -s (strict) モードでは、warning では なく、error になる。 Warning: unused {User,Runas,Host,Cmnd}_Alias 指摘された User_Alias (あるいは、Runas_Alias, Host_Alias, Cmnd_Alias) は定義されているが、一度も使用されていない。そうした使 用しないエイリアスは、コメントアウトするなり、消去するなりしてもよ いだろう。 -s (strict) モードでは、warning ではなく、error になる。 関連項目 vi(1), sudoers(5), sudo(8), vipw(8) 作者 sudo の製作には、多数の人々が長年に渡って取り組んできた。 visudo の当バ ージョンを書いたのは、 Todd Miller である。詳細については、配布物中の HISTORY ファイルか、 http://www.sudo.ws/sudo/history.html を御覧になっていただきたい。 警告 visudo が使用するエディタでシェル・エスケープが可能なかぎり、ユーザがル ート・シェルを獲得するのを防止する簡単な方法はない。 バグ visudo にバクを発見したと思ったら、下記のページにアクセスして、バグレポ ートを提出していただきたい。 http://www.sudo.ws/sudo/bugs/ サポート ある程度の無料サポートが sudo-users メーリングリストを通して利用できる 。購読やアーカイブの検索には下記 URL を御覧になること。 http://www.sudo.ws/mailman/listinfo/sudo-users 免責 visudo は「現状のまま」提供される。明示的な、あるいは黙示的ないかなる保 証も、商品性や特定目的への適合性についての黙示的な保証を含め、またそれ のみに止まらず、これを否認する。詳細な全文については、 sudo と一緒に配 布されている LICENSE ファイルや下記 Web ページを御覧いただきたい。 http://www.sudo.ws/sudo/license.html 1.7.2p1 June 11, 2009 VISUDO(8)
VISUDO(8) BSD System Manager’s Manual VISUDO(8) NAME visudo - edit the sudoers file SYNOPSIS visudo [-chqsV] [-f sudoers] DESCRIPTION visudo edits the sudoers file in a safe fashion, analogous to vipw(8). visudo locks the sudoers file against multiple simultaneous edits, pro- vides basic sanity checks, and checks for parse errors. If the sudoers file is currently being edited you will receive a message to try again later. There is a hard-coded list of one or more editors that visudo will use set at compile-time that may be overridden via the editor sudoers Default variable. This list defaults to /usr/local/bin/vi. Normally, visudo does not honor the VISUAL or EDITOR environment variables unless they contain an editor in the aforementioned editors list. However, if visudo is configured with the --with-env-editor option or the env_editor Default variable is set in sudoers, visudo will use any the editor defines by VISUAL or EDITOR. Note that this can be a security hole since it allows the user to execute any program they wish simply by setting VISUAL or EDITOR. visudo parses the sudoers file after the edit and will not save the changes if there is a syntax error. Upon finding an error, visudo will print a message stating the line number(s) where the error occurred and the user will receive the “What now?” prompt. At this point the user may enter ‘e’ to re-edit the sudoers file, ‘x’ to exit without saving the changes, or ‘Q’ to quit and save changes. The ‘Q’ option should be used with extreme care because if visudo believes there to be a parse error, so will sudo and no one will be able to sudo again until the error is fixed. If ‘e’ is typed to edit the sudoers file after a parse error has been detected, the cursor will be placed on the line where the error occurred (if the editor supports this feature). The options are as follows: -c Enable check-only mode. The existing sudoers file will be checked for syntax errors, owner and mode. A message will be printed to the standard output describing the status of sudoers unless the -q option was specified. If the check completes successfully, visudo will exit with a value of 0. If an error is encountered, visudo will exit with a value of 1. -f sudoers Specify and alternate sudoers file location. With this option visudo will edit (or check) the sudoers file of your choice, instead of the default, /etc/sudoers. The lock file used is the specified sudoers file with “.tmp” appended to it. In check-only mode only, the argument to -f may be ‘-’, indicating that sudoers will be read from the standard input. -h The -h (help) option causes visudo to print a short help mes- sage to the standard output and exit. -q Enable quiet mode. In this mode details about syntax errors are not printed. This option is only useful when combined with the -c option. -s Enable strict checking of the sudoers file. If an alias is used before it is defined, visudo will consider this a parse error. Note that it is not possible to differentiate between an alias and a host name or user name that consists solely of uppercase letters, digits, and the underscore (‘_’) charac- ter. -V The -V (version) option causes visudo to print its version number and exit. ENVIRONMENT The following environment variables may be consulted depending on the value of the editor and env_editor sudoers settings: VISUAL Invoked by visudo as the editor to use EDITOR Used by visudo if VISUAL is not set FILES /etc/sudoers List of who can run what /etc/sudoers.tmp Lock file for visudo DIAGNOSTICS sudoers file busy, try again later. Someone else is currently editing the sudoers file. /etc/sudoers.tmp: Permission denied You didn’t run visudo as root. Can’t find you in the passwd database Your user ID does not appear in the system passwd file. Warning: {User,Runas,Host,Cmnd}_Alias referenced but not defined Either you are trying to use an undeclared {User,Runas,Host,Cmnd}_Alias or you have a user or host name listed that consists solely of uppercase letters, digits, and the under- score (‘_’) character. In the latter case, you can ignore the warnings (sudo will not complain). In -s (strict) mode these are errors, not warnings. Warning: unused {User,Runas,Host,Cmnd}_Alias The specified {User,Runas,Host,Cmnd}_Alias was defined but never used. You may wish to comment out or remove the unused alias. In -s (strict) mode this is an error, not a warning. Warning: cycle in {User,Runas,Host,Cmnd}_Alias The specified {User,Runas,Host,Cmnd}_Alias includes a reference to itself, either directly or through an alias it includes. This is only a warning by default as sudo will ignore cycles when parsing the sudoers file. SEE ALSO vi(1), sudoers(5), sudo(8), vipw(8) AUTHORS Many people have worked on sudo over the years; this version consists of code written primarily by: Todd C. Miller See the CONTRIBUTORS file in the sudo distribution (http://www.sudo.ws/sudo/contributors.html) for an exhaustive list of people who have contributed to sudo. CAVEATS There is no easy way to prevent a user from gaining a root shell if the editor used by visudo allows shell escapes. BUGS If you feel you have found a bug in visudo, please submit a bug report at http://www.sudo.ws/sudo/bugs/ SUPPORT Limited free support is available via the sudo-users mailing list, see http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search the archives. DISCLAIMER visudo is provided “AS IS” and any express or implied warranties, includ- ing, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. See the LICENSE file distributed with sudo or http://www.sudo.ws/sudo/license.html for com- plete details. Sudo 1.8.6p3 July 12, 2012 Sudo 1.8.6p3
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa