From: "André Draszik" <git@andred.net>
To: openembedded-core@lists.openembedded.org
Cc: "André Draszik" <adraszik@tycoint.com>
Subject: [PATCH 2/2] oe-git-proxy: support username / password in http proxy
Date: Wed, 23 Mar 2016 10:47:05 +0100 [thread overview]
Message-ID: <1458726425-24672-3-git-send-email-git@andred.net> (raw)
In-Reply-To: <1458726425-24672-1-git-send-email-git@andred.net>
From: André Draszik <adraszik@tycoint.com>
We also make sure to correctly support usernames that contain spaces.
For simplicity sed + regex has been replaced with shell parameter expansion,
which works in both, bash and dash.
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
scripts/oe-git-proxy | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/scripts/oe-git-proxy b/scripts/oe-git-proxy
index 38ce7b6..1247902 100755
--- a/scripts/oe-git-proxy
+++ b/scripts/oe-git-proxy
@@ -116,14 +116,27 @@ for H in ${NO_PROXY//,/ }; do
done
# Proxy is necessary, determine protocol, server, and port
-PROTO=$(echo $ALL_PROXY | sed -e 's/\([^:]*\):\/\/.*/\1/')
-PROXY=$(echo $ALL_PROXY | sed -e 's/.*:\/\/\([^:]*\).*/\1/')
-# For backwards compatibility, this allows the port number to be followed by /?
-# in addition to the customary optional /
-PORT=$(echo $ALL_PROXY | sed -e 's/.*:\([0-9]*\)\(\/?\?\)\?$/\1/')
-if [ "$PORT" = "$ALL_PROXY" ]; then
+# extract protocol
+PROTO=${ALL_PROXY%://*}
+# strip protocol:// from string
+ALL_PROXY=${ALL_PROXY#*://}
+# extract host & port parts:
+# 1) drop username/password
+PROXY=${ALL_PROXY##*@}
+# 2) remove optional trailing /?
+PROXY=${PROXY%%/*}
+# 3) extract optional port
+PORT=${PROXY##*:}
+if [ "$PORT" = "$PROXY" ]; then
PORT=""
fi
+# 4) remove port
+PROXY=${PROXY%%:*}
+
+# extract username & password
+PROXYAUTH="${ALL_PROXY%@*}"
+[ "$PROXYAUTH" = "$ALL_PROXY" ] && PROXYAUTH=
+[ -n "${PROXYAUTH}" ] && PROXYAUTH=",proxyauth=${PROXYAUTH}"
if [ "$PROTO" = "socks" ] || [ "$PROTO" = "socks4a" ]; then
if [ -z "$PORT" ]; then
@@ -140,7 +153,7 @@ else
if [ -z "$PORT" ]; then
PORT="8080"
fi
- METHOD="PROXY:$PROXY:$1:$2,proxyport=$PORT"
+ METHOD="PROXY:$PROXY:$1:$2,proxyport=${PORT}${PROXYAUTH}"
fi
-exec $SOCAT STDIO $METHOD
+exec $SOCAT STDIO "$METHOD"
--
2.8.0.rc3
prev parent reply other threads:[~2016-03-23 9:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-23 9:47 [PATCH 0/2] oe-git-proxy updates André Draszik
2016-03-23 9:47 ` [PATCH 1/2] oe-git-proxy: also check all_proxy and http_proxy env variables André Draszik
2016-03-23 9:47 ` André Draszik [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458726425-24672-3-git-send-email-git@andred.net \
--to=git@andred.net \
--cc=adraszik@tycoint.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox