Let a password containing a $ actually save, and say why when a save is refused

The value was written as typed, bash expanded it when the read-back sourced the file, and
the guard rolled the whole write back with nothing on screen but "save failed" — which is
also what an empty value, a trailing space, and a stale API-key check had been doing.
This commit is contained in:
Gmer4Lfe
2026-08-14 23:39:12 -04:00
parent 9eef5b50e6
commit 0101aef51a
3 changed files with 167 additions and 27 deletions
@@ -135,7 +135,14 @@ if [[ -n "$KEY" ]]; then
PREVIEW="${KEY:0:8}...${KEY: -4}"
# Always sync registry key → conf, even if the key was already there.
# Conf gets wiped on git pull / conf regeneration without touching the registry.
CONF_HAS_KEY=$(grep -oP "(?<=^\s*${VAR_NAME}=\")[^\"]*" "$CONF_FILE" 2>/dev/null || true)
# Sourced, not pattern-matched. This was a grep -oP with a variable-length lookbehind, which
# Unraid's grep is ugrep and rejects outright — "length of lookbehind assertion is not
# limited", rc 2, swallowed by the || true. CONF_HAS_KEY was therefore always empty, the
# comparison below never matched, and this script logged "conf is stale — syncing" and
# rewrote the same key into the conf every fifteen minutes since it was written.
# Sourcing also means the value is read the way bash reads it, escapes and all.
CONF_HAS_KEY=$(bash -c 'source "$1" >/dev/null 2>&1 || exit 0; printf "%s" "${!2-}"' \
_ "$CONF_FILE" "$VAR_NAME" 2>/dev/null || true)
if [[ "$CONF_HAS_KEY" == "$KEY" ]]; then
echo "API key valid ✅ — $VAR_NAME = $PREVIEW"
log "Key in registry and conf — no action needed"