All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 # 30-ask-hostname - request the user to type in the hostname of the local host
5 # Copyright © martin f. krafft <madduck@madduck.net>
6 # Released under the terms of the Artistic Licence 2.0
12 [ -f "$MOLLYGUARD_SETTINGS" ] && . "$MOLLYGUARD_SETTINGS"
17 (*-pretend-ssh) PRETEND_SSH=1;;
21 # require an interactive terminal connected to stdin
24 # we've been asked to always protect this host
25 case "${ALWAYS_QUERY_HOSTNAME:-0}" in
26 0|false|False|no|No|off|Off)
27 # only run if we are being called over SSH, that is if the current terminal
28 # was created by sshd.
29 PTS=$(readlink /proc/$$/fd/0)
30 if ! pgrep -f "^sshd.+${PTS#/dev/}\>" >/dev/null \
31 && [ -z "${SSH_CONNECTION:-}" ]; then
32 if [ $PRETEND_SSH -eq 1 ]; then
33 echo "I: $ME: this is not an SSH session, but --pretend-ssh was given..." >&2
38 echo "W: $ME: SSH session detected!" >&2
42 echo "I: $ME: $MOLLYGUARD_CMD is always molly-guarded on this system." >&2
46 HOSTNAME="$(hostname --short)"
50 echo "Good thing I asked; I won't $MOLLYGUARD_CMD $HOSTNAME ..." >&2
54 trap 'echo;sigh' 1 2 3 9 10 12 15
56 echo -n "Please type in hostname of the machine to $MOLLYGUARD_CMD: "
57 read HOSTNAME_USER || :
59 [ "$HOSTNAME_USER" = "$HOSTNAME" ] || sigh
61 trap - 1 2 3 9 10 12 15