[master/rhel7] set proxy related environmental variables (#854029)

Brian C. Lane bcl at redhat.com
Fri Mar 7 01:34:13 UTC 2014


On Thu, Mar 06, 2014 at 04:20:35PM -0500, David Shea wrote:
> On 03/06/2014 02:29 PM, Brian C. Lane wrote:
> >pre and post scripts using utilities like curl should use the global
> >proxy setting from the cmdline. libreport will also use this to setup
> >the proxy for bug reporting.
> >
> >Resolves: rhbz#854029
> >---
> >  anaconda | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >
> >diff --git a/anaconda b/anaconda
> >index 192561d..270295e 100755
> >--- a/anaconda
> >+++ b/anaconda
> >@@ -765,6 +765,7 @@ if __name__ == "__main__":
> >      from pyanaconda import kickstart
> >      from pyanaconda import ntp
> >      from pyanaconda import keyboard
> >+    from pyanaconda.iutil import ProxyString, ProxyStringError
> >      verdesc = "%s for %s %s" % (getAnacondaVersion(),
> >                                  product.productName, product.productVersion)
> >@@ -935,6 +936,24 @@ if __name__ == "__main__":
> >      # cmdline flags override kickstart settings
> >      if anaconda.proxy:
> >          ksdata.method.proxy = anaconda.proxy
> >+
> >+        # Setup proxy environmental variables so that pre/post scripts use it
> >+        # as well as libreport
> >+        try:
> >+            proxy = ProxyString(anaconda.proxy)
> >+        except ProxyStringError as e:
> >+            log.info("Failed to parse proxy \"%s\": %s" % (anaconda.proxy, e))
> >+        finally:
> >+            # Set environmental variables to be used by pre/post scripts
> >+            os.environ["PROXY"] = proxy.noauth_url
> >+            os.environ["PROXY_USER"] = proxy.username or ""
> >+            os.environ["PROXY_PASSWORD"] = proxy.password or ""
> >+
> >+            # Variables used by curl, libreport, etc.
> >+            os.environ["http_proxy"] = proxy.url
> >+            os.environ["ftp_proxy"] = proxy.url
> >+            os.environ["HTTPS_PROXY"] = proxy.url
> >+
> >      if flags.noverifyssl:
> >          ksdata.method.noverifyssl = flags.noverifyssl
> >      if opts.multiLib:
> 
> Shouldn't all the os.environ setting stuff be in the try and not the
> finally? If ProxyString throws an exception the proxy variable won't
> be set.

Oh geez. good catch, they should actually be in an else: clause since
they should only be done if there isn't an exception. Fixed locally.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)


More information about the anaconda-patches mailing list