From: martin f. krafft Date: Wed, 12 Mar 2008 18:54:14 +0000 (+0100) Subject: Also require $SSH_CONNECTION to be unset or warn X-Git-Tag: 0.3.1~1 X-Git-Url: https://git.madduck.net/code/molly-guard.git/commitdiff_plain/86a25141cdf635e1386d9fbfd3b15febfec778bc?hp=048c6a97f910e0dc1401015065cf56ff9bc86e19 Also require $SSH_CONNECTION to be unset or warn This takes care of some more cases, such as #469951, in which screen was used, which creates a new pty which is thus no longer owned by sshd. Signed-off-by: martin f. krafft --- diff --git a/shutdown b/shutdown index 2489827..29bd8fe 100755 --- a/shutdown +++ b/shutdown @@ -90,12 +90,13 @@ test -t 0 || do_real_cmd # only run if we are being called over SSH, that is if the current terminal # was created by sshd. PTS=$(readlink /proc/$$/fd/0) -if ! pgrep -f "^sshd.+${PTS#/dev/}[[:space:]]*$" >/dev/null; then - if [ $PRETEND_SSH -eq 1 ]; then - echo "I: this is not an SSH session, but --pretend-ssh was given..." - else - do_real_cmd - fi +if ! pgrep -f "^sshd.+${PTS#/dev/}[[:space:]]*$" >/dev/null \ + && [ -z "$SSH_CONNECTION" ]; then + if [ $PRETEND_SSH -eq 1 ]; then + echo "I: this is not an SSH session, but --pretend-ssh was given..." + else + do_real_cmd + fi else echo "W: $ME: SSH session detected!" fi