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