summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-08-14 10:23:31 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-14 10:24:13 -0700
commitb6b0a7ab02212a98ac6c3e100bcd9dafcf604aca (patch)
tree566445419059f8e7bae794aab0b960c6ccbffdf0
parentda2abd0709f7c7e6c6c83ccf622a4fc5f3424586 (diff)
downloadchef-b6b0a7ab02212a98ac6c3e100bcd9dafcf604aca.tar.gz
fix proxy var issues
- if the env var is already set, leave it alone - look for '://' to see if we were given a scheme or not (https_proxy may be passed an 'http://' url)
-rw-r--r--lib/chef/application.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index 5b404a3a50..7a80b700d6 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -73,7 +73,6 @@ class Chef::Application
end
end
-
# Parse configuration (options and config file)
def configure_chef
parse_options
@@ -219,30 +218,39 @@ class Chef::Application
# Set ENV['http_proxy']
def configure_http_proxy
if http_proxy = Chef::Config[:http_proxy]
- env['http_proxy'] = configure_proxy("http", http_proxy,
- Chef::Config[:http_proxy_user], Chef::Config[:http_proxy_pass])
+ http_proxy_string = configure_proxy("http", http_proxy,
+ Chef::Config[:http_proxy_user], Chef::Config[:http_proxy_pass])
+ env['http_proxy'] = http_proxy_string unless env['http_proxy']
+ env['HTTP_PROXY'] = http_proxy_string unless env['HTTP_PROXY']
end
end
# Set ENV['https_proxy']
def configure_https_proxy
if https_proxy = Chef::Config[:https_proxy]
- env['https_proxy'] = configure_proxy("https", https_proxy,
- Chef::Config[:https_proxy_user], Chef::Config[:https_proxy_pass])
+ https_proxy_string = configure_proxy("https", https_proxy,
+ Chef::Config[:https_proxy_user], Chef::Config[:https_proxy_pass])
+ env['https_proxy'] = https_proxy_string unless env['https_proxy']
+ env['HTTPS_PROXY'] = https_proxy_string unless env['HTTPS_PROXY']
end
end
# Set ENV['ftp_proxy']
def configure_ftp_proxy
if ftp_proxy = Chef::Config[:ftp_proxy]
- env['ftp_proxy'] = configure_proxy("ftp", ftp_proxy,
+ ftp_proxy_string = configure_proxy("ftp", ftp_proxy,
Chef::Config[:ftp_proxy_user], Chef::Config[:ftp_proxy_pass])
+ env['ftp_proxy'] = ftp_proxy_string unless env['ftp_proxy']
+ env['FTP_PROXY'] = ftp_proxy_string unless env['FTP_PROXY']
end
end
# Set ENV['no_proxy']
def configure_no_proxy
- env['no_proxy'] = Chef::Config[:no_proxy] if Chef::Config[:no_proxy]
+ if Chef::Config[:no_proxy]
+ env['no_proxy'] = Chef::Config[:no_proxy] unless env['no_proxy']
+ env['NO_PROXY'] = Chef::Config[:no_proxy] unless env['NO_PROXY']
+ end
end
# Builds a proxy uri. Examples:
@@ -256,7 +264,7 @@ class Chef::Application
# pass = password
def configure_proxy(scheme, path, user, pass)
begin
- path = "#{scheme}://#{path}" unless path.start_with?(scheme)
+ path = "#{scheme}://#{path}" unless path.include?('://')
# URI.split returns the following parts:
# [scheme, userinfo, host, port, registry, path, opaque, query, fragment]
parts = URI.split(URI.encode(path))