
Angenommen, ich habe ein Skript a.sh mit folgendem Inhalt:
#!/bin/sh
sudo ls <some_unprivileged_path>
Wenn ich ausführesudobefehlen und ausführenAscheunmittelbar danach 'sudo' fragt nicht nach meinem Passwort wegen der"Zeitstempel_Timeout."
Ich versuche, diese Situation zu verhindern. Ich habe bisher einige Konfigurationen ausprobiert und konnte dies verhindern, indem ichZeitstempeltypZuppid.
Zugehöriger Teil der „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).
Da die Shell zur Ausführung eines Befehls eine Aufspaltung durchführt, scheint dies etwas sicherer als die Standardeinstellung zu sein. Ich bin mir jedoch nicht sicher, ob es bei Verwendung von ppid anstelle der Standardeinstellung Sicherheitsprobleme gibt?
(Ich weiß, dass es viel sicherere Tools oder Gewohnheiten gibt, aber ich versuche, „sudo“ und einige Konzepte von Unix ein bisschen besser zu verstehen.)