Hello guys, 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.
Diff: Index: libopkg/opkg_conf.c =================================================================== --- libopkg/opkg_conf.c (revision 518) +++ libopkg/opkg_conf.c (working copy) @@ -64,6 +64,8 @@ { "offline_root", OPKG_OPT_TYPE_STRING, &_conf.offline_root }, { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd }, { "proxy_user", OPKG_OPT_TYPE_STRING, &_conf.proxy_user }, + { "http_user", OPKG_OPT_TYPE_STRING, &_conf.http_user }, + { "http_passwd", OPKG_OPT_TYPE_STRING, &_conf.http_passwd }, { "query-all", OPKG_OPT_TYPE_BOOL, &_conf.query_all }, { "tmp_dir", OPKG_OPT_TYPE_STRING, &_conf.tmp_dir }, { "verbosity", OPKG_OPT_TYPE_INT, &_conf.verbosity }, Index: libopkg/opkg_conf.h =================================================================== --- libopkg/opkg_conf.h (revision 518) +++ libopkg/opkg_conf.h (working copy) @@ -108,6 +108,10 @@ char *proxy_user; char *proxy_passwd; + /* http auth */ + char *http_user; + char *http_passwd; + char *signature_ca_file; char *signature_ca_path; Index: libopkg/opkg_download.c =================================================================== --- libopkg/opkg_download.c (revision 518) +++ libopkg/opkg_download.c (working copy) @@ -156,7 +156,7 @@ #else { int res; - const char *argv[8]; + const char *argv[10]; int i = 0; argv[i++] = "wget"; @@ -165,6 +165,14 @@ argv[i++] = "-Y"; argv[i++] = "on"; } + + if (conf->http_user && conf->http_passwd) { + char *str; + sprintf_alloc(&str, "--http-user=%s", conf->http_user); + argv[i++] = str; + sprintf_alloc(&str, "--http-password=%s", conf->http_passwd); + argv[i++] = str; + } argv[i++] = "-O"; argv[i++] = tmp_file_location; argv[i++] = src; @@ -648,6 +656,14 @@ curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd); free (userpwd); } + if (conf->http_user && conf->http_passwd) + { + char *userpwd; + sprintf_alloc (&userpwd, "%s:%s", conf->http_user, + conf->http_passwd); + curl_easy_setopt(curl, CURLOPT_USERPWD, userpwd); + free (userpwd); + } } curl_easy_setopt (curl, CURLOPT_NOPROGRESS, (cb == NULL)); #example opkg.conf option http_user XXX option http_passwd XXX Best regards. -- Cleiber Marques da Silva MSc Student in Automation and System Engineering - UFSC E3C Tecnologia cleiber at e3c.com.br Phone: +55 48 30240790
_______________________________________________ devel mailing list devel@lists.openmoko.org https://lists.openmoko.org/mailman/listinfo/devel