Skip to content

fix: quote environment and Postgres paths in Docker init - #1486

Open
lbellows wants to merge 1 commit into
roflcoopter:devfrom
lbellows:fix/env-quoting-and-postgres-paths
Open

fix: quote environment and Postgres paths in Docker init#1486
lbellows wants to merge 1 commit into
roflcoopter:devfrom
lbellows:fix/env-quoting-and-postgres-paths

Conversation

@lbellows

Copy link
Copy Markdown

Summary

  • Exporting /var/run/environment via unquoted export $(basename $file)=$(cat $file) broke values with spaces (database URLs, passwords) and could mis-parse filenames.
  • printf $PATH treated % in config paths as a format string.
  • Quote Postgres data paths throughout init/upgrade, and identifier-quote the superuser rename during pg_upgrade.

Test plan

  • bash -n on set_env.sh, 40-set-env-vars, 80-postgres, and postgres/run
  • Replayed the new export loop with values containing spaces and |
  • Confirmed printf '%s' preserves a path containing %s; unquoted printf does not
  • Confirmed "$ in a role name is doubled for a Postgres identifier
  • Container-level Postgres upgrade was not run here

Exporting /var/run/environment via unquoted command substitution
broke values with spaces (database URLs, passwords) and could
mis-parse filenames. printf without %s treated config paths as
format strings. Quote Postgres data paths throughout init/upgrade
and identifier-quote the superuser rename during pg_upgrade.
@netlify

netlify Bot commented Aug 27, 2026

Copy link
Copy Markdown

Deploy Preview for viseron canceled.

Name Link
🔨 Latest commit f013b3c
🔍 Latest deploy log https://app.netlify.com/projects/viseron/deploys/6a905404174df6000868d9f8

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes database upgrade/role-renaming logic in the pg_upgrade path without an end-to-end container upgrade run to validate behavior.

Pull request overview

This PR hardens the container init and Postgres startup/upgrade scripts against shell parsing pitfalls by correctly quoting environment exports and filesystem paths, preventing breakage when values contain spaces, glob characters, or % sequences.

Changes:

  • Export /var/run/environment/* variables safely by quoting filenames and assignment values.
  • Use printf '%s' when writing environment values to avoid unintended format-string expansion.
  • Quote Postgres binary/data paths throughout init/upgrade, and identifier-quote the superuser rename during pg_upgrade.
File summaries
File Description
rootfs/helpers/set_env.sh Makes env-file export robust to spaces/globs and skips non-files.
rootfs/etc/services.d/postgres/run Quotes config/log paths and Postgres command/data dir invocation.
rootfs/etc/cont-init.d/80-postgres Quotes Postgres paths across init/upgrade and safely identifier-quotes role rename for pg_upgrade.
rootfs/etc/cont-init.d/40-set-env-vars Writes env values with printf '%s' to avoid % being treated as a format string.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants