
以下の内容のスクリプト a.sh があるとします。
#!/bin/sh
sudo ls <some_unprivileged_path>
もし私が実行したら須藤命令して実行する灰その直後に「sudo」はパスワードを尋ねないので「timestamp_timeout」です。
私はこの状況を防ごうとしています。これまでいくつかの設定を試し、変更することでこれを防ぐことができました。タイムスタンプタイプにppid。
「man sudoers」の関連部分:
ppid A single time stamp record is used for all processes with the same parent process ID (usually the shell). Commands run from the same shell (or other common parent process)
will not require a password for timestamp_timeout minutes (5 by default). Commands run via sudo with a different parent process ID, for example from a shell script, will be
authenticated separately.
tty One time stamp record is used for each terminal, which means that a user's login sessions are authenticated separately. If no terminal is present, the behavior is the same as
ppid. Commands run from the same terminal will not require a password for timestamp_timeout minutes (5 by default).
シェルはコマンドを実行するためにフォークするので、デフォルトよりも少し安全であると思われます。ただし、デフォルトではなく ppid を使用するとセキュリティ上の問題が発生するかどうかはわかりません。
(もっと安全なツールや習慣がたくさんあることは知っていますが、私は「sudo」と UNIX のいくつかの概念をもう少し理解しようとしています)