X-Git-Url: https://git.madduck.net/code/molly-guard.git/blobdiff_plain/3fb8d0418be397c5f4e29aa2e74dd2cf378b68e0..bd31543e20a53d41dd86c5f78f05b3fb3d5b8664:/run.d/30-ask-hostname?ds=sidebyside diff --git a/run.d/30-ask-hostname b/run.d/30-ask-hostname index 6e33fe1..fc8f107 100755 --- a/run.d/30-ask-hostname +++ b/run.d/30-ask-hostname @@ -19,14 +19,11 @@ for arg in "$@"; do done # require an interactive terminal connected to stdin -if ! test -t 0; then - echo "E: $ME: not connected to a terminal." - exit 1 -fi +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." + 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. @@ -34,12 +31,12 @@ else 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..." + 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!" + echo "W: $ME: SSH session detected!" >&2 fi fi @@ -47,7 +44,7 @@ HOSTNAME="$(hostname --short)" sigh() { - echo "Good thing I asked; I won't $MOLLYGUARD_CMD $HOSTNAME ..." + echo "Good thing I asked; I won't $MOLLYGUARD_CMD $HOSTNAME ..." >&2 exit 1 }