From 8db0713737ed95d6ea9f2359724957241d4208ef Mon Sep 17 00:00:00 2001 From: Tom Scavo Date: Sat, 4 Feb 2017 12:33:06 -0500 Subject: [PATCH] Fix bug that prevented output of HTTP response file --- lib/saml_tools.sh | 48 +++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/lib/saml_tools.sh b/lib/saml_tools.sh index 2962206..c6bfe67 100755 --- a/lib/saml_tools.sh +++ b/lib/saml_tools.sh @@ -1,7 +1,7 @@ #!/bin/bash ####################################################################### -# Copyright 2013--2016 Internet2 +# Copyright 2013--2017 Internet2 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ # # The function records the details of the various processing steps # and the resulting HTTP transaction in files stored in the given -# temporary directory. If the -v option is specified on the command +# temporary directory. If the -V option is specified on the command # line, a curl trace of the transaction is also provided. # ####################################################################### @@ -258,7 +258,7 @@ probe_saml_idp_endpoint () { # # The function records the details of the various processing steps # and the resulting HTTP transaction in files stored in the given -# temporary directory. If the -v option is specified on the command +# temporary directory. If the -V option is specified on the command # line, a curl trace of the transaction is also provided. In the # temporary directory, see these log files for details: # @@ -315,7 +315,6 @@ probe_saml2_idp_endpoint () { # default curl options curl_opts="--silent --show-error" curl_opts="$curl_opts --insecure --tlsv1" - curl_opts="$curl_opts --output /dev/null" local opt local OPTARG @@ -407,6 +406,14 @@ probe_saml2_idp_endpoint () { tmp_log_file="$tmp_dir/${FUNCNAME}_log" echo "$FUNCNAME using temporary directory: $tmp_dir" > "$tmp_log_file" + # temporary files + cookie_jar_file="${tmp_dir}/idp_cookie_jar.txt" + curl_opts="$curl_opts --cookie-jar $cookie_jar_file --cookie $cookie_jar_file" + header_file="${tmp_dir}/idp_http_header.txt" + curl_opts="$curl_opts --dump-header $header_file" + [ -z "$response_file" ] && response_file=/dev/null + curl_opts="$curl_opts --output $response_file" + # log input data printf "$FUNCNAME using connection timeout (option -t): %d\n" "$connect_timeout" >> "$tmp_log_file" printf "$FUNCNAME using max time (option -m): %d\n" "$max_time" >> "$tmp_log_file" @@ -414,15 +421,10 @@ probe_saml2_idp_endpoint () { printf "$FUNCNAME using IdP endpoint binding: %s\n" "$idp_endpoint_binding" >> "$tmp_log_file" printf "$FUNCNAME using IdP endpoint location: %s\n" "$idp_endpoint_location" >> "$tmp_log_file" printf "$FUNCNAME using SAML message (flattened): %s\n" "$( echo $saml_message | /usr/bin/tr -d '\n\r' )" >> "$tmp_log_file" - - # temporary files - header_file="${tmp_dir}/idp_http_header.txt" - curl_opts="$curl_opts --dump-header $header_file" - printf "$FUNCNAME using IdP header file: %s\n" "$header_file" >> "$tmp_log_file" - cookie_jar_file="${tmp_dir}/idp_cookie_jar.txt" - curl_opts="$curl_opts --cookie-jar $cookie_jar_file --cookie $cookie_jar_file" printf "$FUNCNAME using IdP cookie file: %s\n" "$cookie_jar_file" >> "$tmp_log_file" - + printf "$FUNCNAME using IdP header file: %s\n" "$header_file" >> "$tmp_log_file" + printf "$FUNCNAME using IdP response file: %s\n" "$response_file" >> "$tmp_log_file" + ################################################################### # Compute the protocol URL. ################################################################### @@ -546,7 +548,7 @@ probe_saml2_idp_endpoint () { # # The function records the details of the various processing steps # and the resulting HTTP transaction in files stored in the given -# temporary directory. If the -v option is specified on the command +# temporary directory. If the -V option is specified on the command # line, a curl trace of the transaction is also provided. In the # temporary directory, see this log file for details: # @@ -614,7 +616,6 @@ probe_shibboleth_sso_endpoint () { # default curl options curl_opts="--silent --show-error" curl_opts="$curl_opts --insecure --tlsv1" - curl_opts="$curl_opts --output /dev/null" local opt local OPTARG @@ -713,6 +714,14 @@ probe_shibboleth_sso_endpoint () { tmp_log_file="$tmp_dir/${FUNCNAME}_log" echo "$FUNCNAME using temporary directory: $tmp_dir" > "$tmp_log_file" + # temporary files + cookie_jar_file="${tmp_dir}/idp_cookie_jar.txt" + curl_opts="$curl_opts --cookie-jar $cookie_jar_file --cookie $cookie_jar_file" + header_file="${tmp_dir}/idp_http_header.txt" + curl_opts="$curl_opts --dump-header $header_file" + [ -z "$response_file" ] && response_file=/dev/null + curl_opts="$curl_opts --output $response_file" + # log global env vars printf "$FUNCNAME using SP with entityID: %s\n" "$SAML1_SP_ENTITY_ID" >> "$tmp_log_file" printf "$FUNCNAME using SP ACS URL: %s\n" "$SAML1_SP_ACS_URL" >> "$tmp_log_file" @@ -724,15 +733,10 @@ probe_shibboleth_sso_endpoint () { printf "$FUNCNAME using max redirects (option -r): %d\n" "$max_redirs" >> "$tmp_log_file" printf "$FUNCNAME using IdP endpoint location: %s\n" "$idp_shibboleth_sso_location" >> "$tmp_log_file" printf "$FUNCNAME using IdP endpoint binding: %s\n" "$idp_shibboleth_sso_binding" >> "$tmp_log_file" - - # temporary files - header_file="${tmp_dir}/idp_http_header.txt" - curl_opts="$curl_opts --dump-header $header_file" - printf "$FUNCNAME using IdP header file: %s\n" "$header_file" >> "$tmp_log_file" - cookie_jar_file="${tmp_dir}/idp_cookie_jar.txt" - curl_opts="$curl_opts --cookie-jar $cookie_jar_file --cookie $cookie_jar_file" printf "$FUNCNAME using IdP cookie file: %s\n" "$cookie_jar_file" >> "$tmp_log_file" - + printf "$FUNCNAME using IdP header file: %s\n" "$header_file" >> "$tmp_log_file" + printf "$FUNCNAME using IdP response file: %s\n" "$response_file" >> "$tmp_log_file" + ################################################################### # Compute the protocol URL. ###################################################################