<div>Hello guys,</div><div><br></div><div>I made a little patch in opkg to authentication in repositories that using passwords in the directories. The patch working when use libcurl or wget to donwload.</div><div><br></div>
<div>Diff:</div><div><br></div><div><div>Index: libopkg/opkg_conf.c</div><div>===================================================================</div><div>--- libopkg/opkg_conf.c (revision 518)</div><div>+++ libopkg/opkg_conf.c (working copy)</div>
<div>@@ -64,6 +64,8 @@</div><div>      { &quot;offline_root&quot;, OPKG_OPT_TYPE_STRING, &amp;_conf.offline_root },</div><div>      { &quot;proxy_passwd&quot;, OPKG_OPT_TYPE_STRING, &amp;_conf.proxy_passwd },</div><div>      { &quot;proxy_user&quot;, OPKG_OPT_TYPE_STRING, &amp;_conf.proxy_user },</div>
<div>+     { &quot;http_user&quot;, OPKG_OPT_TYPE_STRING, &amp;_conf.http_user },</div><div>+     { &quot;http_passwd&quot;, OPKG_OPT_TYPE_STRING, &amp;_conf.http_passwd },</div><div>      { &quot;query-all&quot;, OPKG_OPT_TYPE_BOOL, &amp;_conf.query_all },</div>
<div>      { &quot;tmp_dir&quot;, OPKG_OPT_TYPE_STRING, &amp;_conf.tmp_dir },</div><div>      { &quot;verbosity&quot;, OPKG_OPT_TYPE_INT, &amp;_conf.verbosity },</div><div>Index: libopkg/opkg_conf.h</div><div>===================================================================</div>
<div>--- libopkg/opkg_conf.h (revision 518)</div><div>+++ libopkg/opkg_conf.h (working copy)</div><div>@@ -108,6 +108,10 @@</div><div>      char *proxy_user;</div><div>      char *proxy_passwd;</div><div><br></div><div>+     /* http auth */</div>
<div>+     char *http_user;</div><div>+     char *http_passwd;</div><div>+</div><div>      char *signature_ca_file;</div><div>      char *signature_ca_path;</div><div><br></div><div>Index: libopkg/opkg_download.c</div><div>
===================================================================</div><div>--- libopkg/opkg_download.c (revision 518)</div><div>+++ libopkg/opkg_download.c (working copy)</div><div>@@ -156,7 +156,7 @@</div><div> #else</div>
<div>     {</div><div>       int res;</div><div>-      const char *argv[8];</div><div>+      const char *argv[10];</div><div>       int i = 0;</div><div><br></div><div>       argv[i++] = &quot;wget&quot;;</div><div>@@ -165,6 +165,14 @@</div>
<div>    argv[i++] = &quot;-Y&quot;;</div><div>    argv[i++] = &quot;on&quot;;</div><div>       }</div><div>+</div><div>+      if (conf-&gt;http_user &amp;&amp; conf-&gt;http_passwd) {</div><div>+          char *str;</div>
<div>+          sprintf_alloc(&amp;str, &quot;--http-user=%s&quot;, conf-&gt;http_user);</div><div>+          argv[i++] = str;</div><div>+          sprintf_alloc(&amp;str, &quot;--http-password=%s&quot;, conf-&gt;http_passwd);</div>
<div>+          argv[i++] = str;</div><div>+      }</div><div>       argv[i++] = &quot;-O&quot;;</div><div><div>       argv[i++] = tmp_file_location;</div><div>       argv[i++] = src;</div><div>@@ -648,6 +656,14 @@</div><div>
        curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);</div><div>        free (userpwd);</div><div>    }</div><div>+   if (conf-&gt;http_user &amp;&amp; conf-&gt;http_passwd)</div><div>+   {</div><div>+       char *userpwd;</div>
<div>+       sprintf_alloc (&amp;userpwd, &quot;%s:%s&quot;, conf-&gt;http_user,</div><div>+           conf-&gt;http_passwd);</div><div>+       curl_easy_setopt(curl, CURLOPT_USERPWD, userpwd);</div><div>+       free (userpwd);</div>
<div>+   }</div><div>     }</div><div><br></div><div>     curl_easy_setopt (curl, CURLOPT_NOPROGRESS, (cb == NULL));</div><div><br></div></div></div><div><br></div><div>#example opkg.conf</div><div>option http_user XXX</div>
<div>option http_passwd XXX</div><div><br></div><div>Best regards.</div><br>-- <br>Cleiber Marques da Silva<br>MSc Student in Automation and System Engineering - UFSC<br>E3C Tecnologia<br>cleiber at <a href="http://e3c.com.br">e3c.com.br</a><br>
<br>Phone: +55 48 30240790<br>