<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>7567</bug_id>
          
          <creation_ts>2015-04-03 18:27:25 +0000</creation_ts>
          <short_desc>distrodata/distro_check don&apos;t take into account proxies</short_desc>
          <delta_ts>2016-01-22 07:55:36 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>core</component>
          <version>1.9</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>2.0</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Aníbal Limón">anibal.limon</reporter>
          <assigned_to name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</assigned_to>
          <cc>alexander.kanevskiy</cc>
    
    <cc>anibal.limon</cc>
    
    <cc>benjamin.esquivel</cc>
    
    <cc>bogdanx.a.voiculescu</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>ross.burton</cc>
          
          <qa_contact name="Bogdan Alexandru Voiculescu">bogdanx.a.voiculescu</qa_contact>
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>50080</commentid>
    <comment_count>0</comment_count>
    <who name="Aníbal Limón">anibal.limon</who>
    <bug_when>2015-04-03 18:27:25 +0000</bug_when>
    <thetext>When try to run distro_check it needs to manual specify proxy exports into local.conf.

It needs to do automatically like fetcher.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>53643</commentid>
    <comment_count>1</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2015-09-02 17:15:12 +0000</bug_when>
    <thetext>Patch sent to the OE mailing list.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54398</commentid>
    <comment_count>2</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2015-09-21 16:15:47 +0000</bug_when>
    <thetext>patch already sent to the OE mailing list, just waiting for its revision/merge. Moving it to 2.0.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54838</commentid>
    <comment_count>3</comment_count>
    <who name="Alexander Kanevskiy">alexander.kanevskiy</who>
    <bug_when>2015-09-30 15:01:32 +0000</bug_when>
    <thetext>any progress on patch after one week ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55028</commentid>
    <comment_count>4</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2015-10-07 13:44:40 +0000</bug_when>
    <thetext>Patch merged on master:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=12cd705b28412c1342c1c022340c13b1ef2c8a71</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55066</commentid>
    <comment_count>5</comment_count>
    <who name="Alexander Kanevskiy">alexander.kanevskiy</who>
    <bug_when>2015-10-08 13:41:13 +0000</bug_when>
    <thetext>Is this code ever being tested in real environment where proxy is the only way out to internet ?

I&apos;m observing where it still tries to connect directly, even if proxy variables are present.

$ netstat -tnap | grep SYN
tcp        0      1 10.xx.xx.xxx:56652     130.89.148.12:80        SYN_SENT    20862/python


After a bit more looking inside, it looks like problem is in argument that is passed to 
urllib.urlopen()


it passes dictionary like this:

{&apos;HTTP_PROXY&apos;: None, &apos;ALL_PROXY&apos;: None, &apos;https_proxy&apos;: &apos;http://proxy-chain:911&apos;, &apos;NO_PROXY&apos;: None, &apos;all_proxy&apos;: None, &apos;http_proxy&apos;: &apos;http://proxy-chain:911&apos;, &apos;ftp_proxy&apos;: &apos;http://proxy-chain:911&apos;, &apos;HTTPS_PROXY&apos;: None, &apos;FTP_PROXY&apos;: None, &apos;FTPS_PROXY&apos;: None, &apos;ftps_proxy&apos;: None, &apos;no_proxy&apos;: &apos;localhost, 127.0.0.1&apos;}

Where, in reality, urlopen() expects proxies dictionary in format:
proxies = {&apos;http&apos;: &apos;http://www.someproxy.com:3128&apos;}

https://docs.python.org/2/library/urllib.html#urllib.urlopen

function get_proxies(d) should be looking something like this to work correctly:

def get_proxies(d):
    proxies = {}
    for proto in [ &apos;http&apos;, &apos;https&apos;, &apos;ftp&apos;]:
        for key in [ proto+&apos;_proxy&apos;, proto.upper()+&apos;_PROXY&apos;]:
            proxy = d.getVar(key, True)
            if proxy:
               proxies[proto] = proxy
               break
    return proxies</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55067</commentid>
    <comment_count>6</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2015-10-08 13:50:47 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; Is this code ever being tested in real environment where proxy is the only
&gt; way out to internet ?

I did test it. Let me check again and provide a patch if necessary.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55068</commentid>
    <comment_count>7</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2015-10-08 14:06:52 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; Is this code ever being tested in real environment where proxy is the only
&gt; way out to internet ?
&gt; 
&gt; I&apos;m observing where it still tries to connect directly, even if proxy
&gt; variables are present.
&gt; 
&gt; $ netstat -tnap | grep SYN
&gt; tcp        0      1 10.xx.xx.xxx:56652     130.89.148.12:80        SYN_SENT 
&gt; 20862/python
&gt; 
&gt; 
&gt; After a bit more looking inside, it looks like problem is in argument that
&gt; is passed to 
&gt; urllib.urlopen()
&gt; 
&gt; 
&gt; it passes dictionary like this:
&gt; 
&gt; {&apos;HTTP_PROXY&apos;: None, &apos;ALL_PROXY&apos;: None, &apos;https_proxy&apos;:
&gt; &apos;http://proxy-chain:911&apos;, &apos;NO_PROXY&apos;: None, &apos;all_proxy&apos;: None, &apos;http_proxy&apos;:
&gt; &apos;http://proxy-chain:911&apos;, &apos;ftp_proxy&apos;: &apos;http://proxy-chain:911&apos;,
&gt; &apos;HTTPS_PROXY&apos;: None, &apos;FTP_PROXY&apos;: None, &apos;FTPS_PROXY&apos;: None, &apos;ftps_proxy&apos;:
&gt; None, &apos;no_proxy&apos;: &apos;localhost, 127.0.0.1&apos;}
&gt; 
&gt; Where, in reality, urlopen() expects proxies dictionary in format:
&gt; proxies = {&apos;http&apos;: &apos;http://www.someproxy.com:3128&apos;}
&gt; 
&gt; https://docs.python.org/2/library/urllib.html#urllib.urlopen
&gt; 
&gt; function get_proxies(d) should be looking something like this to work
&gt; correctly:
&gt; 
&gt; def get_proxies(d):
&gt;     proxies = {}
&gt;     for proto in [ &apos;http&apos;, &apos;https&apos;, &apos;ftp&apos;]:
&gt;         for key in [ proto+&apos;_proxy&apos;, proto.upper()+&apos;_PROXY&apos;]:
&gt;             proxy = d.getVar(key, True)
&gt;             if proxy:
&gt;                proxies[proto] = proxy
&gt;                break
&gt;     return proxies

Alex,

you are right. If proxies are passed through the environment, then the variables end with &apos;_proxies&apos;, if these are passed through a python dictionary, the keys do not have this world. Sending a fix today.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55090</commentid>
    <comment_count>8</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2015-10-08 19:44:10 +0000</bug_when>
    <thetext>Patch sent to the ML:

http://lists.openembedded.org/pipermail/openembedded-core/2015-October/111390.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56243</commentid>
    <comment_count>9</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2015-11-05 16:27:38 +0000</bug_when>
    <thetext>Fixed in oe-core 92fb327b08e4f9cfb2400610c2983afe579b3592.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58122</commentid>
    <comment_count>10</comment_count>
    <who name="Bogdan Alexandru Voiculescu">bogdanx.a.voiculescu</who>
    <bug_when>2016-01-22 07:55:36 +0000</bug_when>
    <thetext>Verified on 8c8c4ede3ff5ac8ca739020d9efed91159acccc1

Tested on a network with proxy, adding &apos;INHERIT += &quot;distrodata&quot;&apos; on local.conf
with the following commands

    for distrotask in distrodataall distro_checkall checklicenseall; do
        bitbake core-image-minimal -c $distrotask
    done</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>