diff options
author | André Draszik <adraszik@tycoint.com> | 2016-03-23 10:47:05 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-28 15:55:49 +0100 |
commit | 9ac1b6fc399b28093b213959a568210e4037886f (patch) | |
tree | 2db144a8312da3baec2696c8d2d6f8cbb0337a81 /scripts | |
parent | a15541dc2771b949aead0a97463ddbfe19deea23 (diff) | |
download | poky-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')
-rwxr-xr-x | scripts/oe-git-proxy | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/scripts/oe-git-proxy b/scripts/oe-git-proxy index 38ce7b66fd..1247902406 100755 --- a/scripts/oe-git-proxy +++ b/scripts/oe-git-proxy | |||
@@ -116,14 +116,27 @@ for H in ${NO_PROXY//,/ }; do | |||
116 | done | 116 | done |
117 | 117 | ||
118 | # Proxy is necessary, determine protocol, server, and port | 118 | # Proxy is necessary, determine protocol, server, and port |
119 | PROTO=$(echo $ALL_PROXY | sed -e 's/\([^:]*\):\/\/.*/\1/') | 119 | # extract protocol |
120 | PROXY=$(echo $ALL_PROXY | sed -e 's/.*:\/\/\([^:]*\).*/\1/') | 120 | PROTO=${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 / | 122 | ALL_PROXY=${ALL_PROXY#*://} |
123 | PORT=$(echo $ALL_PROXY | sed -e 's/.*:\([0-9]*\)\(\/?\?\)\?$/\1/') | 123 | # extract host & port parts: |
124 | if [ "$PORT" = "$ALL_PROXY" ]; then | 124 | # 1) drop username/password |
125 | PROXY=${ALL_PROXY##*@} | ||
126 | # 2) remove optional trailing /? | ||
127 | PROXY=${PROXY%%/*} | ||
128 | # 3) extract optional port | ||
129 | PORT=${PROXY##*:} | ||
130 | if [ "$PORT" = "$PROXY" ]; then | ||
125 | PORT="" | 131 | PORT="" |
126 | fi | 132 | fi |
133 | # 4) remove port | ||
134 | PROXY=${PROXY%%:*} | ||
135 | |||
136 | # extract username & password | ||
137 | PROXYAUTH="${ALL_PROXY%@*}" | ||
138 | [ "$PROXYAUTH" = "$ALL_PROXY" ] && PROXYAUTH= | ||
139 | [ -n "${PROXYAUTH}" ] && PROXYAUTH=",proxyauth=${PROXYAUTH}" | ||
127 | 140 | ||
128 | if [ "$PROTO" = "socks" ] || [ "$PROTO" = "socks4a" ]; then | 141 | if [ "$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}" |
144 | fi | 157 | fi |
145 | 158 | ||
146 | exec $SOCAT STDIO $METHOD | 159 | exec $SOCAT STDIO "$METHOD" |