1c3e5d14cSdtucker#!/bin/sh 2c3e5d14cSdtucker 3c3e5d14cSdtucker# ssh-debug 4c3e5d14cSdtucker 5c3e5d14cSdtucker# A wrapper script around sshd to invoke when debugging to debug the 6c3e5d14cSdtucker# work-in-progress versions of sshd-auth and sshd-session, instead 7c3e5d14cSdtucker# of debugging the installed ones that probably don't have the change 8c3e5d14cSdtucker# you are working on. 9c3e5d14cSdtucker# 10c3e5d14cSdtucker# Placed in the Public Domain. 11c3e5d14cSdtucker 12c3e5d14cSdtuckerunset DIR SSHD SSHD_AUTH SSHD_SESSION 13c3e5d14cSdtucker 14c3e5d14cSdtuckerfatal() { 15c3e5d14cSdtucker echo >&2 $@ 16c3e5d14cSdtucker exit 1 17c3e5d14cSdtucker} 18c3e5d14cSdtucker 19c3e5d14cSdtuckercase "$0" in 20c3e5d14cSdtucker/*) DIR="`dirname $0`" ;; 21c3e5d14cSdtucker./sshd-debug.sh) DIR="`pwd`" ;; 22c3e5d14cSdtucker*) echo "Need full path or working directory."; exit 1 ;; 23c3e5d14cSdtuckeresac 24c3e5d14cSdtucker 25c3e5d14cSdtuckerfor i in sshd/obj/sshd sshd/sshd sshd; do 26c3e5d14cSdtucker if [ -f "${DIR}/$i" ] && [ -x "${DIR}/$i" ]; then 27c3e5d14cSdtucker SSHD="${DIR}/$i" 28c3e5d14cSdtucker fi 29c3e5d14cSdtuckerdone 30c3e5d14cSdtucker[ -z "${SSHD}" ] && fatal "Could not find sshd" 31c3e5d14cSdtucker 32c3e5d14cSdtuckerfor i in sshd-auth/obj/sshd-auth sshd-auth/sshd-auth sshd-auth; do 33c3e5d14cSdtucker if [ -f "${DIR}/$i" ] && [ -x "${DIR}/$i" ]; then 34c3e5d14cSdtucker SSHD_AUTH="${DIR}/$i" 35c3e5d14cSdtucker fi 36c3e5d14cSdtuckerdone 37c3e5d14cSdtucker[ -z "${SSHD_AUTH}" ] && fatal "Could not find sshd-auth" 38c3e5d14cSdtucker 39c3e5d14cSdtuckerfor i in sshd-session/obj/sshd-session sshd-session/sshd-session sshd-session; do 40c3e5d14cSdtucker if [ -f "${DIR}/$i" ] && [ -x "${DIR}/$i" ]; then 41c3e5d14cSdtucker SSHD_SESSION="${DIR}/$i" 42c3e5d14cSdtucker fi 43c3e5d14cSdtuckerdone 44c3e5d14cSdtucker[ -z "${SSHD_SESSION}" ] && fatal "Could not find sshd-session" 45c3e5d14cSdtucker 46c3e5d14cSdtuckerecho >&2 Debugging ${SSHD} auth ${SSHD_AUTH} session ${SSHD_SESSION} 47c3e5d14cSdtucker 48c3e5d14cSdtucker# Append SshdSessionPath and SshdAuthPath pointing to the build directory. 49*3bb7d5b0Sjsg# If you explicitly specify these in the command line, the first-match 50c3e5d14cSdtucker# keyword semantics will override these. 51c3e5d14cSdtuckerexec "${SSHD}" $@ \ 52c3e5d14cSdtucker -oSshdAuthPath="${SSHD_AUTH}" -oSshdSessionPath="${SSHD_SESSION}" 53