Skip to content

Commit

Permalink
regress/connect-unix.sh: wait for socket (squash this)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverkurth committed Sep 5, 2023
1 parent 7217f43 commit 01454b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions regress/connect-unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SCRIPT_DIR=`dirname $0`

start_sshd_unix()
{
${SCRIPT_DIR}/sshd-unix.sh& echo $! > ${OBJ}/sshd-unix.pid
${SUDO} env NC=${NC} SSHD=${SSHD} OBJ=${OBJ} ${SCRIPT_DIR}/sshd-unix.sh& echo $! > ${OBJ}/sshd-unix.pid

trace "wait for sshd-unix"
i=0;
Expand All @@ -17,6 +17,14 @@ start_sshd_unix()
done

test -f ${OBJ}/sshd-unix.pid || fatal "no sshd-unix running on sshd.socket"

i=0;
while [ ! -S ${OBJ}/sshd.socket -a $i -lt 10 ]; do
i=`expr $i + 1`
sleep $i
done

test -S ${OBJ}/sshd.socket || fatal "no sshd.socket created"
}

stop_sshd_unix()
Expand All @@ -29,12 +37,9 @@ stop_sshd_unix()
sed -e /Hostname/d -e /HostKeyAlias/d -e /Port/d -e /StrictHostKeyChecking/d < $OBJ/ssh_config > $OBJ/ssh_unix_config
echo StrictHostKeyChecking=no >> $OBJ/ssh_unix_config

export NC
export SSHD
export OBJ
start_sshd_unix

trace "direct unix socket connect SSH=${SSH}"
trace "direct unix socket connect"
${SSH} -F ${OBJ}/ssh_unix_config ${OBJ}/sshd.socket true
if [ $? -ne 0 ]; then
fail "ssh direct connect unix failed"
Expand Down
2 changes: 1 addition & 1 deletion regress/sshd-unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ run_sshd_unix() {
# see example in netcat man page, modified here for a unix socket
rm -f ${OBJ}/sshd.fifo && mkfifo ${OBJ}/sshd.fifo
rm -f ${OBJ}/sshd.socket
cat ${OBJ}/sshd.fifo | ${SSHD} -i -f ${OBJ}/sshd_config "$@" -E${OBJ}/sshd-unix.log | ${NC} -l -U ${OBJ}/sshd.socket > ${OBJ}/sshd.fifo
cat ${OBJ}/sshd.fifo | ${SSHD} -i -f ${OBJ}/sshd_config "$@" -E ${OBJ}/sshd-unix.log | ${NC} -l -U ${OBJ}/sshd.socket > ${OBJ}/sshd.fifo
}

run_sshd_unix

0 comments on commit 01454b1

Please sign in to comment.