From 992f60d0fb3f309dafe5465f69c1af45a839d227 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Tue, 11 Nov 2014 11:57:38 -0200 Subject: [PATCH] Set proxy env vars on interactive shell and also on crontab to make all scripts be able to use it. Ticket #3789 --- etc/inc/services.inc | 7 +++++++ root/.shrc | 9 +++++++++ root/.tcshrc | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 608d41241..2ab55eca4 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -2272,6 +2272,13 @@ function configure_cron() { $crontab_contents .= "# " .gettext( "Created:") . " " . date("F j, Y, g:i a") . "\n"; $crontab_contents .= "#\n"; + if (isset($config['system']['proxyurl']) && !empty($config['system']['proxyurl'])) { + $http_proxy = $config['system']['proxyurl']; + if (isset($config['system']['proxyport']) && !empty($config['system']['proxyport'])) + $http_proxy .= ':' . $config['system']['proxyport']; + $crontab_contents .= "HTTP_PROXY={$http_proxy}"; + } + foreach ($config['cron']['item'] as $item) { $crontab_contents .= "\n{$item['minute']}\t"; $crontab_contents .= "{$item['hour']}\t"; diff --git a/root/.shrc b/root/.shrc index 700597a4e..6f3c2fc5c 100644 --- a/root/.shrc +++ b/root/.shrc @@ -1,3 +1,12 @@ +HTTP_PROXY=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyurl)' /conf/config.xml` +if [ "${HTTP_PROXY}" != "" ]; then + HTTP_PROXY_PORT=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyport)' /conf/config.xml` + if [ "${HTTP_PROXY_PORT}" != "" ]; then + HTTP_PROXY="${HTTP_PROXY}:${HTTP_PROXY_PORT}" + fi + export HTTP_PROXY +fi + # Detect interactive logins and display the shell if [ -n "${SSH_TTY}" -o "${TERM}" = "cons25" ]; then /etc/rc.initial diff --git a/root/.tcshrc b/root/.tcshrc index e03cc94e2..38cf8975b 100644 --- a/root/.tcshrc +++ b/root/.tcshrc @@ -19,3 +19,12 @@ if ($term == "xterm" || $term == "vt100" || $term == "vt102" || $term == "vt220" bindkey "\e[7~" beginning-of-line # Home rxvt/konsole bindkey "\e[8~" end-of-line # End rxvt/konsole endif + +set http_proxy=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyurl)' /conf/config.xml` +if (${http_proxy} != "") then + set http_proxy_port=`/usr/local/bin/xmllint --xpath 'string(//pfsense/system/proxyport)' /conf/config.xml` + if (${http_proxy_port} != "") then + set http_proxy="${http_proxy}:${http_proxy_port}" + endif + setenv HTTP_PROXY ${http_proxy} +endif