From 51970b4934c713003c95a115847081b9711841db Mon Sep 17 00:00:00 2001 From: kx1t Date: Wed, 8 May 2024 10:00:36 -0400 Subject: [PATCH] hardened LOGLEVEL param handling --- rootfs/etc/s6-overlay/scripts/readsb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/readsb b/rootfs/etc/s6-overlay/scripts/readsb index a8880ce..f10636e 100755 --- a/rootfs/etc/s6-overlay/scripts/readsb +++ b/rootfs/etc/s6-overlay/scripts/readsb @@ -17,11 +17,9 @@ # If not, see . #--------------------------------------------------------------------------------------------- -APPNAME="readsb" - source /scripts/common source /scripts/interpret_ultrafeeder_config -s6wrap=(s6wrap --quiet --timestamps --prepend="${APPNAME}") +s6wrap=(s6wrap --quiet --timestamps --prepend="${SCRIPT_NAME}") mkdir -p /run/readsb @@ -342,8 +340,11 @@ if chk_enabled "$PROMETHEUS_ENABLE"; then READSB_CMD+=("--write-prom=/run/readsb-prometheus.prom") fi -LOGLEVEL="${LOGLEVEL:-verbose}" -# shellcheck disable=SC2086,SC2069 +if ! [[ "${LOGLEVEL,,}" =~ ^(verbose|error|none)$ ]]; then + [[ -n "$LOGLEVEL" ]] && "${s6wrap[@]}" --args echo "[WARNING] LOGLEVEL set to an unknown value. Defaulting to \"verbose\"" || true + LOGLEVEL="verbose" +fi +# shellcheck disable=SC2086 if [[ "${LOGLEVEL,,}" == "verbose" ]]; then exec "${s6wrap[@]}" --args "${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS elif [[ "${LOGLEVEL,,}" == "error" ]]; then