summaryrefslogtreecommitdiffstats
path: root/scripts/oe-git-proxy
diff options
context:
space:
mode:
authorAndré Draszik <adraszik@tycoint.com>2016-03-23 09:47:05 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-28 14:55:49 (GMT)
commit9ac1b6fc399b28093b213959a568210e4037886f (patch)
tree2db144a8312da3baec2696c8d2d6f8cbb0337a81 /scripts/oe-git-proxy
parenta15541dc2771b949aead0a97463ddbfe19deea23 (diff)
downloadpoky-9ac1b6fc399b28093b213959a568210e4037886f.tar.gz
oe-git-proxy: support username / password in http proxy
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. (From OE-Core rev: ce4ff3dd80379e1bf71a967e0512591aaa046308) Signed-off-by: André Draszik <adraszik@tycoint.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/oe-git-proxy')
-rwxr-xr-xscripts/oe-git-proxy29
1 files 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
116done 116done
117 117
118# Proxy is necessary, determine protocol, server, and port 118# Proxy is necessary, determine protocol, server, and port
119PROTO=$(echo $ALL_PROXY | sed -e 's/\([^:]*\):\/\/.*/\1/') 119# extract protocol
120PROXY=$(echo $ALL_PROXY | sed -e 's/.*:\/\/\([^:]*\).*/\1/') 120PROTO=${ALL_PROXY%://*}
121# For backwards compatibility, this allows the port number to be followed by /? 121# strip protocol:// from string
122# in addition to the customary optional / 122ALL_PROXY=${ALL_PROXY#*://}
123PORT=$(echo $ALL_PROXY | sed -e 's/.*:\([0-9]*\)\(\/?\?\)\?$/\1/') 123# extract host & port parts:
124if [ "$PORT" = "$ALL_PROXY" ]; then 124# 1) drop username/password
125PROXY=${ALL_PROXY##*@}
126# 2) remove optional trailing /?
127PROXY=${PROXY%%/*}
128# 3) extract optional port
129PORT=${PROXY##*:}
130if [ "$PORT" = "$PROXY" ]; then
125 PORT="" 131 PORT=""
126fi 132fi
133# 4) remove port
134PROXY=${PROXY%%:*}
135
136# extract username & password
137PROXYAUTH="${ALL_PROXY%@*}"
138[ "$PROXYAUTH" = "$ALL_PROXY" ] && PROXYAUTH=
139[ -n "${PROXYAUTH}" ] && PROXYAUTH=",proxyauth=${PROXYAUTH}"
127 140
128if [ "$PROTO" = "socks" ] || [ "$PROTO" = "socks4a" ]; then 141if [ "$PROTO" = "socks" ] || [ "$PROTO" = "socks4a" ]; then
129 if [ -z "$PORT" ]; then 142 if [ -z "$PORT" ]; then
@@ -140,7 +153,7 @@ else
140 if [ -z "$PORT" ]; then 153 if [ -z "$PORT" ]; then
141 PORT="8080" 154 PORT="8080"
142 fi 155 fi
143 METHOD="PROXY:$PROXY:$1:$2,proxyport=$PORT" 156 METHOD="PROXY:$PROXY:$1:$2,proxyport=${PORT}${PROXYAUTH}"
144fi 157fi
145 158
146exec $SOCAT STDIO $METHOD 159exec $SOCAT STDIO "$METHOD"