Skip to content

Commit c823a69

Browse files
Guðmundur Heimissonuhthomas
authored andcommitted
Fix docker executable not being quoted in shell script templates
1 parent 94a7ddb commit c823a69

File tree

7 files changed

+42
-42
lines changed

7 files changed

+42
-42
lines changed

contrib/automatic_container_release/run_checker.sh.tpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if [[ -z "$DOCKER" ]]; then
4747
fi
4848

4949
# Create a new docker container that will run the checker.
50-
container_id=$($DOCKER $DOCKER_FLAGS create %{image_name} %{cmd_args})
50+
container_id=$("$DOCKER" $DOCKER_FLAGS create %{image_name} %{cmd_args})
5151

5252
specs=(%{specs})
5353
spec_container_paths=(%{spec_container_paths})
@@ -60,20 +60,20 @@ if [ ${#specs[@]} -ne ${#spec_container_paths[@]} ]; then
6060
exit 1
6161
fi
6262
for ((i=0;i<${#specs[@]};i++)); do
63-
$DOCKER $DOCKER_FLAGS cp -L ${specs[$i]} $container_id:${spec_container_paths[$i]}
63+
"$DOCKER" $DOCKER_FLAGS cp -L ${specs[$i]} $container_id:${spec_container_paths[$i]}
6464
done
6565

6666
# Start the container that will run the checker logic.
67-
$DOCKER $DOCKER_FLAGS start $container_id
67+
"$DOCKER" $DOCKER_FLAGS start $container_id
6868

6969
# Wait for the checker to finish running.
70-
retcode=$($DOCKER $DOCKER_FLAGS wait $container_id)
70+
retcode=$("$DOCKER" $DOCKER_FLAGS wait $container_id)
7171

7272
# Print all logs generated by the container.
73-
$DOCKER $DOCKER_FLAGS logs $container_id
73+
"$DOCKER" $DOCKER_FLAGS logs $container_id
7474

7575
# Delete the container.
76-
$DOCKER $DOCKER_FLAGS rm $container_id
76+
"$DOCKER" $DOCKER_FLAGS rm $container_id
7777

7878
exit $retcode
7979

docker/package_managers/run_download.sh.tpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ fi
2525

2626
# Load the image and remember its name
2727
image_id=$(%{image_id_extractor_path} %{image_tar})
28-
$DOCKER $DOCKER_FLAGS load -i %{image_tar}
28+
"$DOCKER" $DOCKER_FLAGS load -i %{image_tar}
2929

3030
# Run the builder image.
31-
cid=$($DOCKER $DOCKER_FLAGS run -w="/" -d --privileged $image_id sh -c $'%{download_commands}')
32-
$DOCKER $DOCKER_FLAGS attach $cid
33-
$DOCKER $DOCKER_FLAGS cp $cid:%{installables}_packages.tar %{output}
34-
$DOCKER $DOCKER_FLAGS cp $cid:%{installables}_metadata.csv %{output_metadata}
31+
cid=$("$DOCKER" $DOCKER_FLAGS run -w="/" -d --privileged $image_id sh -c $'%{download_commands}')
32+
"$DOCKER" $DOCKER_FLAGS attach $cid
33+
"$DOCKER" $DOCKER_FLAGS cp $cid:%{installables}_packages.tar %{output}
34+
"$DOCKER" $DOCKER_FLAGS cp $cid:%{installables}_metadata.csv %{output_metadata}
3535
# Cleanup
36-
$DOCKER $DOCKER_FLAGS rm $cid
36+
"$DOCKER" $DOCKER_FLAGS rm $cid

docker/package_managers/run_install.sh.tpl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ source %{util_script}
1616

1717
# Load the image and remember its name
1818
image_id=$(%{image_id_extractor_path} %{base_image_tar})
19-
$DOCKER $DOCKER_FLAGS load -i %{base_image_tar}
19+
"$DOCKER" $DOCKER_FLAGS load -i %{base_image_tar}
2020

2121
# Create a docker volume containing the installer script and the
2222
# installables TAR file.
@@ -44,21 +44,21 @@ cp -L $(pwd)/%{installer_script} $tmpdir/installer.sh
4444
# Temporarily create a container so we can mount the named volume
4545
# and copy files. It's okay if /bin/true doesn't exist inside the
4646
# image; we are never going to run the image anyways.
47-
vid=$($DOCKER $DOCKER_FLAGS volume create)
48-
cid=$($DOCKER $DOCKER_FLAGS create -v $vid:/tmp/pkginstall $image_id /bin/true)
47+
vid=$("$DOCKER" $DOCKER_FLAGS volume create)
48+
cid=$("$DOCKER" $DOCKER_FLAGS create -v $vid:/tmp/pkginstall $image_id /bin/true)
4949
for f in $tmpdir/*; do
50-
$DOCKER $DOCKER_FLAGS cp $f $cid:/tmp/pkginstall
50+
"$DOCKER" $DOCKER_FLAGS cp $f $cid:/tmp/pkginstall
5151
done
52-
$DOCKER $DOCKER_FLAGS rm $cid
52+
"$DOCKER" $DOCKER_FLAGS rm $cid
5353

54-
cid=$($DOCKER $DOCKER_FLAGS run -d -v $vid:/tmp/pkginstall --privileged $image_id /tmp/pkginstall/installer.sh)
54+
cid=$("$DOCKER" $DOCKER_FLAGS run -d -v $vid:/tmp/pkginstall --privileged $image_id /tmp/pkginstall/installer.sh)
5555

56-
$DOCKER $DOCKER_FLAGS attach $cid || true
56+
"$DOCKER" $DOCKER_FLAGS attach $cid || true
5757

5858
reset_cmd $image_id $cid %{output_image_name}
59-
$DOCKER $DOCKER_FLAGS save %{output_image_name} > %{output_file_name}
60-
$DOCKER $DOCKER_FLAGS rm $cid
61-
$DOCKER $DOCKER_FLAGS volume rm $vid
59+
"$DOCKER" $DOCKER_FLAGS save %{output_image_name} > %{output_file_name}
60+
"$DOCKER" $DOCKER_FLAGS rm $cid
61+
"$DOCKER" $DOCKER_FLAGS volume rm $vid
6262
) > "$log" 2>&1
6363

6464
if (( $? )); then

docker/util/commit.sh.tpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ logfile=$(output_logfile)
2020
if ! (
2121
# Load the image and remember its name
2222
image_id=$(%{image_id_extractor_path} %{image_tar})
23-
$DOCKER $DOCKER_FLAGS load -i %{image_tar}
23+
"$DOCKER" $DOCKER_FLAGS load -i %{image_tar}
2424

25-
readonly id=$($DOCKER $DOCKER_FLAGS create %{docker_run_flags} $image_id %{commands})
25+
readonly id=$("$DOCKER" $DOCKER_FLAGS create %{docker_run_flags} $image_id %{commands})
2626
retcode=0
27-
if $DOCKER $DOCKER_FLAGS start -a "${id}"; then
27+
if "$DOCKER" $DOCKER_FLAGS start -a "${id}"; then
2828
reset_cmd $image_id $id %{output_image}
29-
$DOCKER $DOCKER_FLAGS save %{output_image} -o %{output_tar}
29+
"$DOCKER" $DOCKER_FLAGS save %{output_image} -o %{output_tar}
3030
else
3131
retcode=$?
3232
fi
3333

34-
$DOCKER $DOCKER_FLAGS rm $id
34+
"$DOCKER" $DOCKER_FLAGS rm $id
3535
exit "$retcode"
3636
) > "$logfile" 2>&1; then
3737
cat $logfile

docker/util/commit_layer.sh.tpl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ logfile=$(output_logfile)
1919
if ! (
2020
# Load the image and remember its name
2121
image_id=$(%{image_id_extractor_path} %{image_tar})
22-
$DOCKER $DOCKER_FLAGS load -i %{image_tar}
22+
"$DOCKER" $DOCKER_FLAGS load -i %{image_tar}
2323

24-
readonly id=$($DOCKER $DOCKER_FLAGS create %{docker_run_flags} --env-file %{env_file_path} $image_id %{commands})
24+
readonly id=$("$DOCKER" $DOCKER_FLAGS create %{docker_run_flags} --env-file %{env_file_path} $image_id %{commands})
2525
retcode=0
26-
if $DOCKER $DOCKER_FLAGS start -a "${id}"; then
26+
if "$DOCKER" $DOCKER_FLAGS start -a "${id}"; then
2727
OUTPUT_IMAGE_TAR="%{output_layer_tar}.image.tar"
2828
reset_cmd $image_id $id %{output_image}
29-
$DOCKER $DOCKER_FLAGS save %{output_image} -o $OUTPUT_IMAGE_TAR
29+
"$DOCKER" $DOCKER_FLAGS save %{output_image} -o $OUTPUT_IMAGE_TAR
3030

31-
# Extract the last layer from the image - this will be the layer generated by $DOCKER commit
31+
# Extract the last layer from the image - this will be the layer generated by "$DOCKER" commit
3232
%{image_last_layer_extractor_path} $OUTPUT_IMAGE_TAR %{output_layer_tar} %{output_diff_id}
3333

3434
# Delete the intermediate tar
@@ -38,8 +38,8 @@ if ! (
3838
fi
3939

4040
# Delete the container and the intermediate image
41-
$DOCKER $DOCKER_FLAGS rm $id
42-
$DOCKER $DOCKER_FLAGS rmi %{output_image}
41+
"$DOCKER" $DOCKER_FLAGS rm $id
42+
"$DOCKER" $DOCKER_FLAGS rmi %{output_image}
4343

4444
exit "$retcode"
4545
) > "$logfile" 2>&1; then

docker/util/extract.sh.tpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ trap "rm $logfile" EXIT
1818
if ! (
1919
# Load the image and remember its name
2020
image_id=$(%{image_id_extractor_path} %{image_tar})
21-
$DOCKER $DOCKER_FLAGS load -i %{image_tar}
21+
"$DOCKER" $DOCKER_FLAGS load -i %{image_tar}
2222

23-
id=$($DOCKER $DOCKER_FLAGS run -d %{docker_run_flags} $image_id %{commands})
23+
id=$("$DOCKER" $DOCKER_FLAGS run -d %{docker_run_flags} $image_id %{commands})
2424

25-
retcode=$($DOCKER $DOCKER_FLAGS wait $id)
25+
retcode=$("$DOCKER" $DOCKER_FLAGS wait $id)
2626

2727
# Print any error that occurred in the container.
2828
if [ $retcode != 0 ]; then
29-
$DOCKER $DOCKER_FLAGS logs $id && false
29+
"$DOCKER" $DOCKER_FLAGS logs $id && false
3030
exit $retcode
3131
fi
3232

33-
$DOCKER $DOCKER_FLAGS cp $id:%{extract_file} %{output}
34-
$DOCKER $DOCKER_FLAGS rm $id
33+
"$DOCKER" $DOCKER_FLAGS cp $id:%{extract_file} %{output}
34+
"$DOCKER" $DOCKER_FLAGS rm $id
3535
) > "$logfile" 2>&1; then
3636
cat "$logfile"
3737
exit 1

docker/util/image_util.sh.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ reset_cmd() {
1010
DOCKER_FLAGS="%{docker_flags}"
1111
local old_cmd
1212
# docker inspect input cannot be piped into docker commit directly, we need to JSON format it.
13-
old_cmd=$($DOCKER $DOCKER_FLAGS inspect -f "{{range .Config.Cmd}}{{.}} {{end}}" "${original_image_name}")
13+
old_cmd=$("$DOCKER" $DOCKER_FLAGS inspect -f "{{range .Config.Cmd}}{{.}} {{end}}" "${original_image_name}")
1414
fmt_cmd=$(echo "$old_cmd" | ${TO_JSON_TOOL})
1515
# If CMD wasn't set, set it to a sane default.
1616
if [ "$fmt_cmd" == "" ] || [ "$fmt_cmd" == "[]" ];
1717
then
1818
fmt_cmd='["/bin/sh", "-c"]'
1919
fi
2020

21-
$DOCKER $DOCKER_FLAGS commit -c "CMD $fmt_cmd" "${container_id}" "${output_image_name}"
21+
"$DOCKER" $DOCKER_FLAGS commit -c "CMD $fmt_cmd" "${container_id}" "${output_image_name}"
2222
}
2323

2424
function output_logfile {

0 commit comments

Comments
 (0)