[PATCH] kas-container: Refactor docker rootless check

1 view
Skip to first unread message

Jan Kiszka

unread,
1:34 AM (7 hours ago) 1:34 AM
to kas-devel, Felix Moessbauer
From: Jan Kiszka <jan.k...@siemens.com>

This ensures that the internal variable KAS_DOCKER_ROOTLESS is always
initialized because it is tested also in podman code paths.

As this leaves check_docker_rootless even smaller behind, and it only
has one caller, fold it in.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
kas-container | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/kas-container b/kas-container
index e47db45..28f094a 100755
--- a/kas-container
+++ b/kas-container
@@ -295,14 +295,6 @@ forward_dir()
fi
}

-check_docker_rootless()
-{
- KAS_DOCKER_ROOTLESS=0
- if [ "$(docker context show)" = "rootless" ]; then
- KAS_DOCKER_ROOTLESS=1
- fi
-}
-
enable_docker_rootless()
{
warning "Rootless docker used, only limited functionality available."
@@ -565,11 +557,14 @@ if [ -z "${KAS_CONTAINER_ENGINE}" ]; then
fi
fi

+KAS_DOCKER_ROOTLESS=0
case "${KAS_CONTAINER_ENGINE}" in
docker)
KAS_CONTAINER_COMMAND="docker"
enable_unpriv_userns_docker
- check_docker_rootless
+ if [ "$(docker context show)" = "rootless" ]; then
+ KAS_DOCKER_ROOTLESS=1
+ fi
;;
podman)
KAS_CONTAINER_COMMAND="podman"
--
2.47.3
Reply all
Reply to author
Forward
0 new messages