From 9e52dc01cd8be5ed92c7aacea3854f3a7038d6c4 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 7 Dec 2024 14:48:45 +0100 Subject: [PATCH] bin/docker: fix broken escaping and variable substitution In #24034 more variables were added to the envsubst input, but there is no escaping with envsubst, so the resulting bash script never used XDG_CONFIG_HOME. Also it replaced HOME with the build time HOME env var breaking the runtime subsitution, resulting in something bogus like: [ -e "\${XDG_CONFIG_HOME-\/home/user/.config}/containers/nodocker" ] Fix by telling envsubst to just replace BINDIR and ETCDIR and remove the broken escaping in the envsubst input. Signed-off-by: Christoph Reiter --- Makefile | 2 +- docker/docker.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a17270fe78..2b1a5e515d 100644 --- a/Makefile +++ b/Makefile @@ -964,7 +964,7 @@ install.completions: install.docker: install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR) $(eval INTERPOLATED_DOCKER_SCRIPT := $(shell mktemp)) - env BINDIR=${BINDIR} ETCDIR=${ETCDIR} envsubst < docker/docker.in > ${INTERPOLATED_DOCKER_SCRIPT} + env BINDIR=${BINDIR} ETCDIR=${ETCDIR} envsubst '$BINDIR;$ETCDIR' < docker/docker.in > ${INTERPOLATED_DOCKER_SCRIPT} install ${SELINUXOPT} -m 755 ${INTERPOLATED_DOCKER_SCRIPT} $(DESTDIR)$(BINDIR)/docker rm ${INTERPOLATED_DOCKER_SCRIPT} install ${SELINUXOPT} -m 755 -d $(DESTDIR)${SYSTEMDDIR} $(DESTDIR)${USERSYSTEMDDIR} $(DESTDIR)${TMPFILESDIR} $(DESTDIR)${USERTMPFILESDIR} diff --git a/docker/docker.in b/docker/docker.in index 0b4aa838c2..c23db62bce 100755 --- a/docker/docker.in +++ b/docker/docker.in @@ -1,4 +1,4 @@ #!/bin/sh -[ -e ${ETCDIR}/containers/nodocker ] || [ -e "\${XDG_CONFIG_HOME-\$HOME/.config}/containers/nodocker" ] || \ +[ -e ${ETCDIR}/containers/nodocker ] || [ -e "${XDG_CONFIG_HOME-$HOME/.config}/containers/nodocker" ] || \ echo "Emulate Docker CLI using podman. Create ${ETCDIR}/containers/nodocker to quiet msg." >&2 exec ${BINDIR}/podman "$@"