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