Skip to content
Merged
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
22 changes: 11 additions & 11 deletions coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ async def _async_fetch_data(self) -> None:
_LOGGER.debug("Fetching data for container %s", service)

info_cmd = (
f"{docker_cmd} inspect {service}"
f"{docker_cmd} inspect {shlex.quote(service)}"
f" --format '{{{{.State.Status}}}};{{{{.Created}}}};{{{{.Config.Image}}}};{{{{.Image}}}}'"
)
Comment on lines 278 to 281
try:
Expand Down Expand Up @@ -344,8 +344,8 @@ async def _async_fetch_data(self) -> None:
if options.get(CONF_CHECK_FOR_UPDATES, False):
self.set_pending_state("pulling")
pull_cmd = (
f"{docker_cmd} pull {image_name} > /dev/null 2>&1;"
f" {docker_cmd} image inspect {image_name} --format '{{{{.Id}}}}'"
f"{docker_cmd} pull {shlex.quote(image_name)} > /dev/null 2>&1;"
f" {docker_cmd} image inspect {shlex.quote(image_name)} --format '{{{{.Id}}}}'"
)
try:
new_image_id, _ = await _ssh_run(
Expand Down Expand Up @@ -408,7 +408,7 @@ async def get_logs(self) -> str:
output, exit_status = await _ssh_run(
self.hass,
options,
f"{docker_cmd} logs {name} 2>&1 | tail -200",
f"{docker_cmd} logs {shlex.quote(name)} 2>&1 | tail -200",
)
if exit_status != 0:
_LOGGER.warning(
Expand Down Expand Up @@ -443,7 +443,7 @@ async def restart(self) -> None:
docker_cmd = options.get(CONF_DOCKER_COMMAND, DEFAULT_DOCKER_COMMAND)
name = self._service
_, exit_status = await _ssh_run(
self.hass, options, f"{docker_cmd} restart {name}"
self.hass, options, f"{docker_cmd} restart {shlex.quote(name)}"
)
if exit_status != 0:
_LOGGER.error(
Expand All @@ -464,7 +464,7 @@ async def stop(self) -> None:
docker_cmd = options.get(CONF_DOCKER_COMMAND, DEFAULT_DOCKER_COMMAND)
name = self._service
_, exit_status = await _ssh_run(
self.hass, options, f"{docker_cmd} stop {name}"
self.hass, options, f"{docker_cmd} stop {shlex.quote(name)}"
)
if exit_status != 0:
_LOGGER.error(
Expand All @@ -487,7 +487,7 @@ async def remove(self) -> None:
_, exit_status = await _ssh_run(
self.hass,
options,
f"{docker_cmd} stop {name}; {docker_cmd} rm {name}",
f"{docker_cmd} stop {shlex.quote(name)}; {docker_cmd} rm {shlex.quote(name)}",
)
if exit_status != 0:
_LOGGER.error(
Expand Down Expand Up @@ -527,8 +527,8 @@ async def create(self) -> None:
# Use if/then/else to run docker_create exactly once and preserve its exit code.
create_cmd = (
f"if command -v {DOCKER_CREATE_EXECUTABLE} >/dev/null 2>&1;"
f" then {DOCKER_CREATE_EXECUTABLE} {name};"
f" else /usr/bin/{DOCKER_CREATE_EXECUTABLE} {name}; fi"
f" then {DOCKER_CREATE_EXECUTABLE} {shlex.quote(name)};"
f" else /usr/bin/{DOCKER_CREATE_EXECUTABLE} {shlex.quote(name)}; fi"
)
_, exit_status = await _ssh_run(
self.hass, options, create_cmd, timeout=DOCKER_CREATE_TIMEOUT
Expand Down Expand Up @@ -594,8 +594,8 @@ async def _auto_recreate(
return
create_cmd = (
f"if command -v {DOCKER_CREATE_EXECUTABLE} >/dev/null 2>&1;"
f" then {DOCKER_CREATE_EXECUTABLE} {name};"
f" else /usr/bin/{DOCKER_CREATE_EXECUTABLE} {name}; fi"
f" then {DOCKER_CREATE_EXECUTABLE} {shlex.quote(name)};"
f" else /usr/bin/{DOCKER_CREATE_EXECUTABLE} {shlex.quote(name)}; fi"
)
try:
_, exit_status = await _ssh_run(self.hass, options, create_cmd)
Expand Down
Loading