回答:
sudoersのマニュアルによると:
It is generally not effective to "subtract" commands from ALL using the
’!’ operator. A user can trivially circumvent this by copying the
desired command to a different name and then executing that. For
example:
bill ALL = ALL, !SU, !SHELLS
Doesn’t really prevent bill from running the commands listed in SU or
SHELLS since he can simply copy those commands to a different name, or
use a shell escape from an editor or other program. Therefore, these
kind of restrictions should be considered advisory at best (and
reinforced by policy).
これが、sudoersポリシーが機能しない理由です。
ユーザーがroot権限を取得してパスワードを変更できないようにするには、次の手順を試してください。
あなたのsudoersがこのディレクティブを含んでいると仮定します:
root ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) ALL
ユーザー名をとするとfoo、彼のグループはとにfooなりsudoます。groupsコマンド出力は次のとおりです。
foo sudo
グループfooからユーザーを削除sudo:gpasswd -d foo sudoこの後、ユーザーfooはsudoでコマンドを実行できなくなります。
sudoersファイルを編集します。次のコマンドを使用します。
sudo visudo -f /etc/sudoers.d/foo
ユーザーfoo権限を定義します。例:
foo ALL=/usr/bin, !/usr/bin/passwd, !/usr/bin/su
この手段は、ユーザーはそのfooディレクトリ内の任意のコマンドを実行すること/usr/bin/を除き、passwdおよびsuコマンド。注:ユーザーfooがパスワードを変更したい場合は、passwdなしでコマンドを実行できますsudo。
ユーザーfoo権限の別の例:
foo ALL =/usr/bin, /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd root
つまり、ユーザーfooはディレクトリ内の任意のコマンドを実行でき/usr/bin/、すべてのマシンのrootを除くすべてのユーザーのパスワードを変更できます。
Cmnd_Aliases「権限のレベル」を定義および作成することにより、コマンドのグループを定義できます。sudoersマニュアルの「例」セクションに役立つ例があり、sudoersの使用方法に関する役立つリンクがあります。
foo ALL=/usr/bin/*, !/usr/bin/passwdなぜそうなのか、なんらかの考えをしなければなりませんでした。