Fix Nix string escaping in PostgreSQL password setup
Some checks are pending
nix-bitcoin tests / build_test_drivers (push) Waiting to run
nix-bitcoin tests / test_scenario (default) (push) Blocked by required conditions
nix-bitcoin tests / test_scenario (joinmarket-bitcoind-29) (push) Blocked by required conditions
nix-bitcoin tests / test_scenario (netns) (push) Blocked by required conditions
nix-bitcoin tests / test_scenario (netnsRegtest) (push) Blocked by required conditions
nix-bitcoin tests / check_flake (push) Waiting to run

In Nix '' strings, '''' produces a literal ''. The sed pattern
to double single quotes needs this escaping.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-01-11 20:13:55 +01:00
parent 047191835c
commit 231046cbc0

View file

@ -254,7 +254,7 @@ in
if ${pkgs.postgresql}/bin/psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='${cfg.database.user}'" | grep -q 1; then if ${pkgs.postgresql}/bin/psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='${cfg.database.user}'" | grep -q 1; then
password=$(cat ${secretsDir}/lamassu-db-password) password=$(cat ${secretsDir}/lamassu-db-password)
# Escape single quotes by doubling them (SQL standard) # Escape single quotes by doubling them (SQL standard)
escaped_password=$(printf '%s' "$password" | sed "s/'/''/g") escaped_password=$(printf '%s' "$password" | sed "s/'/''''/g")
${pkgs.postgresql}/bin/psql -c "ALTER USER \"${cfg.database.user}\" WITH PASSWORD '$escaped_password';" ${pkgs.postgresql}/bin/psql -c "ALTER USER \"${cfg.database.user}\" WITH PASSWORD '$escaped_password';"
exit 0 exit 0
fi fi