Skip to content

Commit

Permalink
Merge pull request #29 from linuxserver/master-secrets
Browse files Browse the repository at this point in the history
Warn about newlines in secrets (39)
  • Loading branch information
thespad authored Nov 11, 2023
2 parents c4d4487 + f1bbb37 commit 8c2d820
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions root/etc/s6-overlay/s6-rc.d/init-envfile/run
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

if find /run/s6/container_environment/*"FILE__"* -maxdepth 1 > /dev/null 2>&1; then
for FILENAME in /run/s6/container_environment/*; do
if [[ "${FILENAME##*/}" == "FILE__"* ]]; then
if find /run/s6/container_environment/FILE__* -maxdepth 1 > /dev/null 2>&1; then
for FILENAME in /run/s6/container_environment/FILE__*; do
SECRETFILE=$(cat "${FILENAME}")
if [[ -f ${SECRETFILE} ]]; then
FILESTRIP=${FILENAME//FILE__/}
if [[ $(tail -n1 "${SECRETFILE}" | wc -l) != 0 ]]; then
echo "[env-init] Your secret: ${FILENAME##*/}"
echo " contains a trailing newline and may not work as expected"
fi
cat "${SECRETFILE}" >"${FILESTRIP}"
echo "[env-init] ${FILESTRIP##*/} set from ${FILENAME##*/}"
else
echo "[env-init] cannot find secret in ${FILENAME##*/}"
fi
fi
done
fi

0 comments on commit 8c2d820

Please sign in to comment.