hitch_test.sh (hitch-1.7.0) | : | hitch_test.sh (hitch-1.7.2) | ||
---|---|---|---|---|
skipping to change at line 168 | skipping to change at line 168 | |||
HITCH_USER= | HITCH_USER= | |||
test "$TEST_UID" -eq 0 && HITCH_USER=--user=nobody | test "$TEST_UID" -eq 0 && HITCH_USER=--user=nobody | |||
run_cmd hitch \ | run_cmd hitch \ | |||
--pidfile="$TEST_TMPDIR/hitch.pid" \ | --pidfile="$TEST_TMPDIR/hitch.pid" \ | |||
--log-filename=hitch.log \ | --log-filename=hitch.log \ | |||
--daemon \ | --daemon \ | |||
--dbg-listen="$TEST_TMPDIR/hitch_hosts" \ | --dbg-listen="$TEST_TMPDIR/hitch_hosts" \ | |||
$HITCH_USER \ | $HITCH_USER \ | |||
"$@" | "$@" | |||
run_cmd sleep 1 | ||||
} | } | |||
#- | #- | |||
# Usage: stop_hitch | # Usage: stop_hitch | |||
# | # | |||
# Kill a hitch daemon started with `start_hitch`, waiting for the | # Kill a hitch daemon started with `start_hitch`, waiting for the | |||
# process to terminate. | # process to terminate. | |||
stop_hitch() { | stop_hitch() { | |||
HITCH_PID=$(hitch_pid) | HITCH_PID=$(hitch_pid) | |||
skipping to change at line 334 | skipping to change at line 335 | |||
if [ "${1#-delay=}" != "$1" ] | if [ "${1#-delay=}" != "$1" ] | |||
then | then | |||
DELAY=${1#-delay=} | DELAY=${1#-delay=} | |||
shift | shift | |||
fi | fi | |||
(sleep "$DELAY"; printf '\n') | | (sleep "$DELAY"; printf '\n') | | |||
openssl s_client -prexit "$@" 2>&1 | openssl s_client -prexit "$@" 2>&1 | |||
} | } | |||
s_client_parse() { | # Extract a field from a subject line read from standard input. | |||
# | ||||
# openssl < 1.1.1: | ||||
# subject=/CN=site1.example.com | ||||
# subject=/C=NO/ST=Oslo/O=Varnish Software/L=Oslo/CN=*.example.com/OU=... | ||||
# openssl >= 1.1.1: | ||||
# subject=CN = site1.example.com | ||||
# subject=C = NO, ST = Oslo, O = Varnish Software, L = Oslo, CN = *.example.co | ||||
m, ... | ||||
# | ||||
_subject_field() { | ||||
sed -n 's/ *subject=//p' | | ||||
tr ,/ '\n' | | ||||
awk -F '[= ]*' -v RS='\n *' -v FIELD="$1" '$1 == FIELD {print $2; exit}' | ||||
} | ||||
#- | ||||
# Usage: subject_field_eq FIELD VALUE FILE | ||||
# | ||||
# Extract the field FIELD from a subject line found in FILE and compare it | ||||
# with VALUE. | ||||
# | ||||
# Example: | ||||
# | ||||
# subject_field_eq CN site1.example.com client.dump | ||||
# input examples we need to support here: | subject_field_eq() { | |||
# | SUBJECT_NAME=$(_subject_field "$1" <"$3") | |||
# openssl < 1.1.1: | run_cmd test "$SUBJECT_NAME" = "$2" | |||
# subject=/CN=site1.example.com | ||||
# subject=/C=NO/ST=Oslo/O=Varnish Software/L=Oslo/CN=*.example.com/OU=Varn | ||||
ish Software/emailAddress=foobar@example.com | ||||
# openssl >= 1.1.1: | ||||
# subject=CN = site1.example.com | ||||
# subject=C = NO, ST = Oslo, O = Varnish Software, L = Oslo, CN = *.exampl | ||||
e.com, OU = Varnish Software, emailAddress = foobar@example.com | ||||
# | ||||
# subject=/C=NO/ST=Oslo/O=Varnish Software/L=Oslo/CN=*.example.com/OU=Varnis | ||||
h Software/emailAddress=foobar@example.com | ||||
SUBJECT_NAME=$(grep "subject=" $1 | head -1 | cut -d= -f2- | sed -e 's/[,/]/ | ||||
\n/g' | | ||||
grep CN | cut -d'=' -f2 | tr -d '[:space:]') | ||||
} | ||||
subj_name_eq() { | ||||
s_client_parse "$2" | ||||
test "$SUBJECT_NAME" = "$1" | ||||
} | } | |||
End of changes. 3 change blocks. | ||||
23 lines changed or deleted | 29 lines changed or added |