-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for connecting to a unix socket
- Loading branch information
1 parent
5c7407f
commit 8ce8cde
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
tid="simple connect" | ||
|
||
SCRIPT_DIR=`dirname $0` | ||
|
||
start_sshd_unix() | ||
{ | ||
${SUDO} env NC=${NC} SSHD=${SSHD} OBJ=${OBJ} ${SCRIPT_DIR}/sshd-unix.sh& | ||
|
||
trace "wait for sshd-unix" | ||
i=0; | ||
while [ ! -f ${OBJ}/sshd-unix.pid -a $i -lt 10 ]; do | ||
i=`expr $i + 1` | ||
sleep $i | ||
done | ||
|
||
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" | ||
chmod 0666 ${OBJ}/sshd.socket | ||
} | ||
|
||
stop_sshd_unix() | ||
{ | ||
kill `cat ${OBJ}/sshd-unix.pid` | ||
} | ||
|
||
|
||
# create client config | ||
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 | ||
|
||
start_sshd_unix | ||
|
||
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" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
# create an ssh server listening on a Unix socket, using netcat | ||
|
||
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 | ||
touch ${OBJ}/sshd-unix.log ; chmod 0644 ${OBJ}/sshd-unix.log | ||
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 |