Skip to content

Commit c7907f7

Browse files
committed
Default to sanitizing newlines in secrets
1 parent 811e9eb commit c7907f7

File tree

1 file changed

+7
-5
lines changed
  • root/etc/s6-overlay/s6-rc.d/init-envfile

1 file changed

+7
-5
lines changed
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
if find /run/s6/container_environment/*"FILE__"* -maxdepth 1 > /dev/null 2>&1; then
5-
for FILENAME in /run/s6/container_environment/*; do
6-
if [[ "${FILENAME##*/}" == "FILE__"* ]]; then
4+
if find /run/s6/container_environment/FILE__* -maxdepth 1 > /dev/null 2>&1; then
5+
for FILENAME in /run/s6/container_environment/FILE__*; do
76
SECRETFILE=$(cat "${FILENAME}")
87
if [[ -f ${SECRETFILE} ]]; then
98
FILESTRIP=${FILENAME//FILE__/}
10-
cat "${SECRETFILE}" >"${FILESTRIP}"
9+
if [[ ${SECRET_NO_SANITIZE,,} = "true" ]]; then
10+
cat "${SECRETFILE}" >"${FILESTRIP}"
11+
else
12+
tr -d '\n' < "${SECRETFILE}" >"${FILESTRIP}"
13+
fi
1114
echo "[env-init] ${FILESTRIP##*/} set from ${FILENAME##*/}"
1215
else
1316
echo "[env-init] cannot find secret in ${FILENAME##*/}"
1417
fi
15-
fi
1618
done
1719
fi

0 commit comments

Comments
 (0)