From 543eee323d080a57fe54f5f4869b1be65872d329 Mon Sep 17 00:00:00 2001 From: Michael Krebs Date: Fri, 15 Apr 2011 21:20:19 -0700 Subject: [PATCH] crash-reporter: Make use of list_proxies to send crashes via a proxy when appropriate BUG=chromium-os:6828 TEST=Manually ran crash_sender to make sure it would run curl with appropriate --proxy option. Manually ran curl using proxies from "http://proxyconfig.corp.google.com/wpad.dat". Ran a modified crash_sender manually to make sure it passed the appropriate "--proxy" arguments correctly. Review URL: http://codereview.chromium.org/6802003 Change-Id: Ie1414fca1a7dbc265d8aad0eea32a736a5d30d54 --- crash_reporter/crash_sender | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crash_reporter/crash_sender b/crash_reporter/crash_sender index 10fdf37bf..21bd48846 100644 --- a/crash_reporter/crash_sender +++ b/crash_reporter/crash_sender @@ -68,6 +68,9 @@ RESTRICTED_CERTIFICATES_PATH="/usr/share/chromeos-ca-certificates" # Temp directory for this process. TMP_DIR="" +# Path to list_proxies. +LIST_PROXIES="/usr/bin/list_proxies" + lecho() { logger -t "${TAG}" "$@" } @@ -258,11 +261,18 @@ send_crash() { return 1 fi + # Read in the first proxy, if any, for a given URL. NOTE: The + # double-quotes are necessary due to a bug in dash with the "local" + # builtin command and values that have spaces in them (see + # "https://bugs.launchpad.net/ubuntu/+source/dash/+bug/139097"). + local proxy="`${LIST_PROXIES} -quiet "${url}" | head -1`" + # if a direct connection should be used, unset the proxy variable. + [ "${proxy}" = "direct://" ] && proxy= local report_id="${TMP_DIR}/report_id" local curl_stderr="${TMP_DIR}/curl_stderr" set +e - curl "${url}" \ + curl "${url}" ${proxy:+--proxy "$proxy"} \ --capath "${RESTRICTED_CERTIFICATES_PATH}" --ciphers HIGH \ -F "prod=${CHROMEOS_PRODUCT}" \ -F "ver=${chromeos_version}" \