Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix argument escaping in Scope #1950

Merged
merged 1 commit into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ for arg in $@; do
esac
done

echo "$@" >/var/run/weave/scope-app.args
echo "$@" >/var/run/weave/scope-probe.args
ARGS=("$@")

typeset -p ARGS >/var/run/weave/scope-app.args
typeset -p ARGS >/var/run/weave/scope-probe.args

exec /home/weave/runsvinit
4 changes: 3 additions & 1 deletion docker/run-app
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

exec -a scope-app /home/weave/scope --mode app $(cat /var/run/weave/scope-app.args)
source /var/run/weave/scope-app.args

exec -a scope-app /home/weave/scope --mode app "${ARGS[@]}"
4 changes: 3 additions & 1 deletion docker/run-probe
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

exec -a scope-probe /home/weave/scope --mode probe $(cat /var/run/weave/scope-probe.args)
source /var/run/weave/scope-probe.args

exec -a scope-probe /home/weave/scope --mode probe "${ARGS[@]}"
11 changes: 6 additions & 5 deletions scope
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,20 @@ launch_command() {
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/run/scope/plugins:/var/run/scope/plugins \
-e CHECKPOINT_DISABLE \
$WEAVESCOPE_DOCKER_ARGS $SCOPE_IMAGE --probe.docker=true "$@"
$WEAVESCOPE_DOCKER_ARGS $SCOPE_IMAGE --probe.docker=true
}

launch_docker4mac_app_command() {
echo docker run -d --name=$SCOPE_APP_CONTAINER_NAME \
-e CHECKPOINT_DISABLE \
-p 0.0.0.0:4040:4040 \
$WEAVESCOPE_DOCKER_ARGS $SCOPE_IMAGE --no-probe "$@"
$WEAVESCOPE_DOCKER_ARGS $SCOPE_IMAGE --no-probe
}

launch() {
check_not_running $SCOPE_CONTAINER_NAME $SCOPE_IMAGE_NAME
docker rm -f $SCOPE_CONTAINER_NAME >/dev/null 2>&1 || true
CONTAINER=$($(launch_command "$@"))
CONTAINER=$($(launch_command) "$@")
echo $CONTAINER
}

Expand All @@ -172,7 +172,8 @@ check_docker_version

case "$COMMAND" in
command)
launch_command "$@"
# TODO: properly escape/quote the output of "$@"
echo $(launch_command) "$@"
;;

version)
Expand Down Expand Up @@ -220,7 +221,7 @@ EOF
check_not_running $SCOPE_APP_CONTAINER_NAME $SCOPE_IMAGE_NAME
check_not_running $SCOPE_CONTAINER_NAME $SCOPE_IMAGE_NAME
docker rm -f $SCOPE_APP_CONTAINER_NAME >/dev/null 2>&1 || true
CONTAINER=$($(launch_docker4mac_app_command "$@"))
CONTAINER=$($(launch_docker4mac_app_command) "$@")
echo $CONTAINER
app_ip=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' "${CONTAINER}")
docker rm -f $SCOPE_CONTAINER_NAME >/dev/null 2>&1 || true
Expand Down