Skip to content

Commit fbe8cb8

Browse files
committed
Fix CMD healthchecks running with /bin/sh
1 parent 84f1fbd commit fbe8cb8

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

podman_compose.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828
from asyncio import Task
2929
from enum import Enum
3030

31-
try:
32-
from shlex import quote as cmd_quote
33-
except ImportError:
34-
from pipes import quote as cmd_quote # pylint: disable=deprecated-module
35-
3631
# import fnmatch
3732
# fnmatch.fnmatchcase(env, "*_HOST")
3833

@@ -1193,7 +1188,7 @@ async def container_to_args(compose, cnt, detached=True):
11931188
# podman does not add shell to handle command with whitespace
11941189
podman_args.extend([
11951190
"--healthcheck-command",
1196-
"/bin/sh -c " + cmd_quote(healthcheck_test),
1191+
json.dumps(["CMD-SHELL", healthcheck_test]),
11971192
])
11981193
elif is_list(healthcheck_test):
11991194
healthcheck_test = healthcheck_test.copy()
@@ -1202,13 +1197,11 @@ async def container_to_args(compose, cnt, detached=True):
12021197
if healthcheck_type == "NONE":
12031198
podman_args.append("--no-healthcheck")
12041199
elif healthcheck_type == "CMD":
1205-
cmd_q = "' '".join([cmd_quote(i) for i in healthcheck_test])
1206-
podman_args.extend(["--healthcheck-command", "/bin/sh -c " + cmd_q])
1200+
podman_args.extend(["--healthcheck-command", json.dumps(healthcheck_test)])
12071201
elif healthcheck_type == "CMD-SHELL":
12081202
if len(healthcheck_test) != 1:
12091203
raise ValueError("'CMD_SHELL' takes a single string after it")
1210-
cmd_q = cmd_quote(healthcheck_test[0])
1211-
podman_args.extend(["--healthcheck-command", "/bin/sh -c " + cmd_q])
1204+
podman_args.extend(["--healthcheck-command", json.dumps(healthcheck_test)])
12121205
else:
12131206
raise ValueError(
12141207
f"unknown healthcheck test type [{healthcheck_type}],\

0 commit comments

Comments
 (0)