From 0501ba4e94c207083f6c4010815592ef87785855 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Sat, 31 May 2008 17:19:56 +0200 Subject: [PATCH 1/1] better detection of rc setting --- run.d/30-query-hostname | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/run.d/30-query-hostname b/run.d/30-query-hostname index fc8f107..634a4c9 100755 --- a/run.d/30-query-hostname +++ b/run.d/30-query-hostname @@ -22,23 +22,26 @@ done test -t 0 || exit 0 # we've been asked to always protect this host -if [ ${ALWAYS_QUERY_HOSTNAME:-0} -eq 1 ]; then - echo "I: $ME: $MOLLYGUARD_CMD is always molly-guarded on this system." >&2 -else - # 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 \ - && [ -z "${SSH_CONNECTION:-}" ]; then - if [ $PRETEND_SSH -eq 1 ]; then - echo "I: $ME: this is not an SSH session, but --pretend-ssh was given..." >&2 - else - exit 0 - fi - else - echo "W: $ME: SSH session detected!" >&2 - fi -fi +case "${ALWAYS_QUERY_HOSTNAME:-0}" in + 0|false|False|no|No|off|Off) + # 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 \ + && [ -z "${SSH_CONNECTION:-}" ]; then + if [ $PRETEND_SSH -eq 1 ]; then + echo "I: $ME: this is not an SSH session, but --pretend-ssh was given..." >&2 + else + exit 0 + fi + else + echo "W: $ME: SSH session detected!" >&2 + fi + ;; + *) + echo "I: $ME: $MOLLYGUARD_CMD is always molly-guarded on this system." >&2 + ;; +esac HOSTNAME="$(hostname --short)" -- 2.39.5