* [ptxdist] [RFC] ptxd_make_get_http: Specify the username and password
@ 2017-01-07 21:58 Ladislav Michl
2017-01-08 0:10 ` Roland Hieber
0 siblings, 1 reply; 3+ messages in thread
From: Ladislav Michl @ 2017-01-07 21:58 UTC (permalink / raw)
To: ptxdist
Hi there,
I need to pass username and password to download mercurial snapshot from
server, so something like this now works:
package_URL := https://mercurial.site.com/hg/package/archive/$(package_VERSION).$(package_SUFFIX);user=<username>:<password>
Is it acceptable to support it in upstream PTXdist?
(it could be probably rewritten some nicer way, but I'm not too good at shell scripting)
ladis
diff --git a/scripts/lib/ptxd_make_get.sh b/scripts/lib/ptxd_make_get.sh
index 2bac97817..e392e8b0c 100644
--- a/scripts/lib/ptxd_make_get.sh
+++ b/scripts/lib/ptxd_make_get.sh
@@ -25,6 +25,7 @@ ptxd_make_get_http() {
# scan for valid options
#
while [ ${#} -ne 0 ]; do
+ local cred
local opt="${1}"
shift
@@ -45,6 +46,13 @@ ptxd_make_get_http() {
curl_opts[${#curl_opts[@]}]="--cookie"
curl_opts[${#curl_opts[@]}]="${opt#cookie:}"
;;
+ user=*)
+ cred="${opt#user=}"
+ cred=(${cred//:/ })
+ opts[${#opts[@]}]="--user=${cred[0]}"
+ opts[${#opts[@]}]="--password=${cred[1]}"
+ curl_opts[${#curl_opts[@]}]="${opt#user=}"
+ ;;
*)
ptxd_bailout "invalid option '${opt}' to ${FUNCNAME}"
;;
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ptxdist] [RFC] ptxd_make_get_http: Specify the username and password
2017-01-07 21:58 [ptxdist] [RFC] ptxd_make_get_http: Specify the username and password Ladislav Michl
@ 2017-01-08 0:10 ` Roland Hieber
2017-01-08 19:55 ` Ladislav Michl
0 siblings, 1 reply; 3+ messages in thread
From: Roland Hieber @ 2017-01-08 0:10 UTC (permalink / raw)
To: ptxdist
Hm, curl loads URLs in the form http://user:password@server/path just
fine for me (and ptxd_make_get() doesn't seem to strip that part, so I
guess it should also be usable in the Makefiles). The only disadvantage
in that case is that the username cannot contain a colon, but neither
can it in your implementation :) So I would change it to take a separate
"user" and "password" parameter in order to enhance the usefullness of
this option.
- Roland
On 07.01.2017 22:58, Ladislav Michl wrote:
> Hi there,
>
> I need to pass username and password to download mercurial snapshot from
> server, so something like this now works:
> package_URL := https://mercurial.site.com/hg/package/archive/$(package_VERSION).$(package_SUFFIX);user=<username>:<password>
>
> Is it acceptable to support it in upstream PTXdist?
> (it could be probably rewritten some nicer way, but I'm not too good at shell scripting)
>
> ladis
>
> diff --git a/scripts/lib/ptxd_make_get.sh b/scripts/lib/ptxd_make_get.sh
> index 2bac97817..e392e8b0c 100644
> --- a/scripts/lib/ptxd_make_get.sh
> +++ b/scripts/lib/ptxd_make_get.sh
> @@ -25,6 +25,7 @@ ptxd_make_get_http() {
> # scan for valid options
> #
> while [ ${#} -ne 0 ]; do
> + local cred
> local opt="${1}"
> shift
>
> @@ -45,6 +46,13 @@ ptxd_make_get_http() {
> curl_opts[${#curl_opts[@]}]="--cookie"
> curl_opts[${#curl_opts[@]}]="${opt#cookie:}"
> ;;
> + user=*)
> + cred="${opt#user=}"
> + cred=(${cred//:/ })
> + opts[${#opts[@]}]="--user=${cred[0]}"
> + opts[${#opts[@]}]="--password=${cred[1]}"
> + curl_opts[${#curl_opts[@]}]="${opt#user=}"
> + ;;
> *)
> ptxd_bailout "invalid option '${opt}' to ${FUNCNAME}"
> ;;
>
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de
>
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ptxdist] [RFC] ptxd_make_get_http: Specify the username and password
2017-01-08 0:10 ` Roland Hieber
@ 2017-01-08 19:55 ` Ladislav Michl
0 siblings, 0 replies; 3+ messages in thread
From: Ladislav Michl @ 2017-01-08 19:55 UTC (permalink / raw)
To: ptxdist
On Sun, Jan 08, 2017 at 01:10:14AM +0100, Roland Hieber wrote:
> Hm, curl loads URLs in the form http://user:password@server/path just
> fine for me (and ptxd_make_get() doesn't seem to strip that part, so I
> guess it should also be usable in the Makefiles). The only disadvantage
> in that case is that the username cannot contain a colon, but neither
> can it in your implementation :) So I would change it to take a separate
> "user" and "password" parameter in order to enhance the usefullness of
> this option.
Well, that doesn't improve anything as curl parameter is:
--user=<username>:<password>
so this problem remains, it does only improve situation for wget.
But as wget also accepts credentials in url, I'll forget this
until someone needs colon in username.
ladis
> - Roland
>
> On 07.01.2017 22:58, Ladislav Michl wrote:
> > Hi there,
> >
> > I need to pass username and password to download mercurial snapshot from
> > server, so something like this now works:
> > package_URL := https://mercurial.site.com/hg/package/archive/$(package_VERSION).$(package_SUFFIX);user=<username>:<password>
> >
> > Is it acceptable to support it in upstream PTXdist?
> > (it could be probably rewritten some nicer way, but I'm not too good at shell scripting)
> >
> > ladis
> >
> > diff --git a/scripts/lib/ptxd_make_get.sh b/scripts/lib/ptxd_make_get.sh
> > index 2bac97817..e392e8b0c 100644
> > --- a/scripts/lib/ptxd_make_get.sh
> > +++ b/scripts/lib/ptxd_make_get.sh
> > @@ -25,6 +25,7 @@ ptxd_make_get_http() {
> > # scan for valid options
> > #
> > while [ ${#} -ne 0 ]; do
> > + local cred
> > local opt="${1}"
> > shift
> >
> > @@ -45,6 +46,13 @@ ptxd_make_get_http() {
> > curl_opts[${#curl_opts[@]}]="--cookie"
> > curl_opts[${#curl_opts[@]}]="${opt#cookie:}"
> > ;;
> > + user=*)
> > + cred="${opt#user=}"
> > + cred=(${cred//:/ })
> > + opts[${#opts[@]}]="--user=${cred[0]}"
> > + opts[${#opts[@]}]="--password=${cred[1]}"
> > + curl_opts[${#curl_opts[@]}]="${opt#user=}"
> > + ;;
> > *)
> > ptxd_bailout "invalid option '${opt}' to ${FUNCNAME}"
> > ;;
> >
> > _______________________________________________
> > ptxdist mailing list
> > ptxdist@pengutronix.de
> >
>
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-08 19:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-07 21:58 [ptxdist] [RFC] ptxd_make_get_http: Specify the username and password Ladislav Michl
2017-01-08 0:10 ` Roland Hieber
2017-01-08 19:55 ` Ladislav Michl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox